| Trees | Indices | Help |
|---|
|
|
1 #
2 # Copyright (c) 2008--2015 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 # Activation key related queuing functions
16 #
17
18 from spacewalk.common.rhnLog import log_debug
19 from spacewalk.server import rhnSQL, rhnAction, rhnServer
20 from spacewalk.server.rhnLib import ShadowAction
21 from spacewalk.server.rhnServer import server_kickstart
22
23 # the "exposed" functions
24 __rhnexport__ = ['schedule_deploy', 'schedule_pkg_install', ]
25
26
27 # queries
28 _query_copy_pkgs_from_shadow_action = rhnSQL.Statement("""
29 insert into rhnActionPackage (id, action_id, name_id, parameter)
30 select sequence_nextval('rhn_act_p_id_seq'), :new_action_id, name_id, parameter
31 from rhnActionPackage
32 where action_id = :action_id
33 """)
34
35 _query_copy_revs_from_shadow_action = rhnSQL.Statement("""
36 insert into rhnActionConfigRevision (id, action_id, server_id, config_revision_id)
37 select sequence_nextval('rhn_actioncr_id_seq'), :new_action_id, server_id, config_revision_id
38 from rhnActionConfigRevision
39 where action_id = :action_id
40 and server_id = :server_id
41 """)
42
43
45 log_debug(2, server_id, action_id)
46 s = rhnServer.search(server_id)
47
48 # Schedule an rhncfg install
49 new_action_id = server_kickstart.schedule_rhncfg_install(server_id,
50 action_id, scheduler=None)
51
52 new_action_id_2 = rhnAction.schedule_server_action(
53 server_id,
54 action_type='configfiles.deploy',
55 action_name="Activation Key Config Auto-Deploy",
56 delta_time=0, scheduler=None,
57 org_id=s.server['org_id'],
58 prerequisite=new_action_id,
59 )
60
61 if (not dry_run):
62 h = rhnSQL.prepare(_query_copy_revs_from_shadow_action)
63 h.execute(action_id=action_id, new_action_id=new_action_id_2,
64 server_id=server_id)
65 else:
66 log_debug(4, "dry run requested")
67
68 log_debug(4, "scheduled config deploy for activation key")
69
70 raise ShadowAction("Config deploy scheduled")
71
72
73 # XXX this duplicates rhnAction.schedule_server_packages_update. fix that.
75 s = rhnServer.search(server_id)
76
77 new_action_id = rhnAction.schedule_server_action(
78 server_id,
79 action_type='packages.update',
80 action_name="Activation Key Package Auto-Install",
81 delta_time=0, scheduler=None,
82 org_id=s.server['org_id'],
83 )
84
85 if (not dry_run):
86 h = rhnSQL.prepare(_query_copy_pkgs_from_shadow_action)
87 h.execute(action_id=action_id, new_action_id=new_action_id)
88 else:
89 log_debug(4, "dry run requested")
90
91 log_debug(4, "scheduled pkg install for activation key")
92
93 raise ShadowAction("Package install scheduled")
94
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Wed Mar 4 07:37:50 2020 | http://epydoc.sourceforge.net |