Package backend :: Package server :: Package action :: Module kickstart_host
[hide private]
[frames] | no frames]

Source Code for Module backend.server.action.kickstart_host

 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   
16  import sys 
17  from spacewalk.common.rhnLog import log_debug 
18  from spacewalk.common.usix import raise_with_tb 
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  __rhnexport__ = ['schedule_virt_host_pkg_install', 'add_tools_channel'] 
28   
29   
30 -def add_tools_channel(server_id, action_id, dry_run=0):
31 if (not dry_run): 32 subscribe_to_tools_channel(server_id) 33 else: 34 log_debug(4, "dry run requested") 35 raise ShadowAction("Subscribed server to tools channel.")
36 37
38 -def schedule_virt_host_pkg_install(server_id, action_id, dry_run=0):
39 """ 40 ShadowAction that schedules a package installation action for the 41 rhn-virtualization-host and osad packages. 42 """ 43 log_debug(3) 44 45 virt_host_package_name = "rhn-virtualization-host" 46 messaging_package_name = "osad" 47 48 tools_channel = SubscribedChannel(server_id, "rhn-tools") 49 found_tools_channel = tools_channel.is_subscribed_to_channel() 50 51 if not found_tools_channel: 52 raise InvalidAction("System not subscribed to the RHN Tools channel.") 53 54 rhn_v12n_package = ChannelPackage(server_id, virt_host_package_name) 55 56 if not rhn_v12n_package.exists(): 57 raise InvalidAction("Could not find the rhn-virtualization-host package.") 58 59 messaging_package = ChannelPackage(server_id, messaging_package_name) 60 61 if not messaging_package.exists(): 62 raise InvalidAction("Could not find the osad package.") 63 64 try: 65 rhn_v12n_install_scheduler = PackageInstallScheduler(server_id, action_id, rhn_v12n_package) 66 messaging_package = PackageInstallScheduler(server_id, action_id, messaging_package) 67 if (not dry_run): 68 rhn_v12n_install_scheduler.schedule_package_install() 69 messaging_package.schedule_package_install() 70 else: 71 log_debug(4, "dry run requested") 72 except NoActionInfo: 73 nai = sys.exc_info()[1] 74 raise_with_tb(InvalidAction(str(nai)), sys.exc_info()[2]) 75 except PackageNotFound: 76 pnf = sys.exc_info()[1] 77 raise_with_tb(InvalidAction(str(pnf)), sys.exc_info()[2]) 78 except Exception: 79 e = sys.exc_info()[1] 80 raise_with_tb(InvalidAction(str(e)), sys.exc_info()[2]) 81 82 log_debug(3, "Completed scheduling install of rhn-virtualization-host and osad!") 83 raise ShadowAction("Scheduled installation of RHN Virtualization Host packages.")
84