Trees | Indices | Help |
---|
|
1 # 2 # Copyright (c) 2008--2016 Red Hat, Inc. 3 # 4 # This software is licensed to you under the GNU General Public License, 5 # version 2 (GPLv2). There is NO WARRANTY for this software, express or 6 # implied, including the implied warranties of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 8 # along with this software; if not, see 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 10 # 11 # Red Hat trademarks are not licensed under GPLv2. No permission is 12 # granted to use or replicate Red Hat trademarks that are incorporated 13 # in this software or its documentation. 14 # 15 import sys 16 from spacewalk.common.usix import raise_with_tb 17 from spacewalk.common.rhnLog import log_debug 18 from spacewalk.server import rhnSQL 19 from spacewalk.server.rhnLib import InvalidAction, ShadowAction 20 from spacewalk.server.action.utils import SubscribedChannel, \ 21 ChannelPackage, \ 22 PackageInstallScheduler, \ 23 NoActionInfo, \ 24 PackageNotFound 25 from spacewalk.server.rhnChannel import subscribe_to_tools_channel 26 27 28 __rhnexport__ = ['initiate', 'schedule_virt_guest_pkg_install', 'add_tools_channel'] 29 30 _query_initiate_guest = rhnSQL.Statement(""" 31 select ksd.label as profile_name, akg.kickstart_host, kvt.label as virt_type, 32 akg.mem_kb, akg.vcpus, akg.disk_path, akg.virt_bridge, akg.cobbler_system_name, 33 akg.disk_gb, akg.append_string, 34 akg.guest_name, akg.ks_session_id from rhnActionKickstartGuest akg, 35 rhnKSData ksd, rhnKickstartSession ksess, 36 rhnKickstartDefaults ksdef, rhnKickstartVirtualizationType kvt 37 where akg.action_id = :action_id 38 and ksess.kickstart_id = ksd.id 39 and ksess.id = akg.ks_session_id 40 and ksdef.kickstart_id = ksd.id 41 and ksdef.virtualization_type = kvt.id 42 """) 43 4446 """ 47 ShadowAction that schedules a package installation action for the 48 rhn-virtualization-guest package. 49 """ 50 log_debug(3) 51 52 virt_host_package_name = "rhn-virtualization-guest" 53 tools_channel = SubscribedChannel(server_id, "rhn-tools") 54 found_tools_channel = tools_channel.is_subscribed_to_channel() 55 56 if not found_tools_channel: 57 raise InvalidAction("System not subscribed to the RHN Tools channel.") 58 59 rhn_v12n_package = ChannelPackage(server_id, virt_host_package_name) 60 61 if not rhn_v12n_package.exists(): 62 raise InvalidAction("Could not find the rhn-virtualization-guest package.") 63 64 try: 65 install_scheduler = PackageInstallScheduler(server_id, action_id, rhn_v12n_package) 66 if (not dry_run): 67 install_scheduler.schedule_package_install() 68 else: 69 log_debug(4, "dry run requested") 70 except NoActionInfo: 71 nai = sys.exc_info()[1] 72 raise_with_tb(InvalidAction(str(nai)), sys.exc_info()[2]) 73 except PackageNotFound: 74 pnf = sys.exc_info()[1] 75 raise_with_tb(InvalidAction(str(pnf)), sys.exc_info()[2]) 76 except Exception: 77 e = sys.exc_info()[1] 78 raise_with_tb(InvalidAction(str(e)), sys.exc_info()[2]) 79 80 log_debug(3, "Completed scheduling install of rhn-virtualization-guest!") 81 raise ShadowAction("Scheduled installation of RHN Virtualization Guest packages.")82 8385 log_debug(3) 86 h = rhnSQL.prepare(_query_initiate_guest) 87 h.execute(action_id=action_id) 88 row = h.fetchone_dict() 89 90 if not row: 91 raise InvalidAction("Kickstart action without an associated kickstart") 92 93 kickstart_host = row['kickstart_host'] 94 virt_type = row['virt_type'] 95 name = row['guest_name'] 96 boot_image = "spacewalk-koan" 97 append_string = row['append_string'] 98 vcpus = row['vcpus'] 99 disk_gb = row['disk_gb'] 100 mem_kb = row['mem_kb'] 101 ks_session_id = row['ks_session_id'] 102 virt_bridge = row['virt_bridge'] 103 disk_path = row['disk_path'] 104 cobbler_system_name = row['cobbler_system_name'] 105 106 if not boot_image: 107 raise InvalidAction("Boot image missing") 108 109 return (kickstart_host, cobbler_system_name, virt_type, ks_session_id, name, 110 mem_kb, vcpus, disk_gb, virt_bridge, disk_path, append_string)111 112114 log_debug(3) 115 if (not dry_run): 116 subscribe_to_tools_channel(server_id) 117 else: 118 log_debug(4, "dry run requested") 119 raise ShadowAction("Subscribed guest to tools channel.")120
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Wed Mar 4 07:37:50 2020 | http://epydoc.sourceforge.net |