1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import time
19
20 from spacewalk.common.rhnLog import log_debug
21 from spacewalk.server import rhnSQL, rhnServer
22 from spacewalk.server.configFilesHandler import format_file_results
23 from spacewalk.server.config_common.templated_document import var_interp_prep
24
25
26 __rhnexport__ = ['upload', 'deploy', 'verify', 'diff', 'mtime_upload']
27
28 _query_upload_files = rhnSQL.Statement("""
29 select cfn.path
30 from rhnActionConfigFileName acfn, rhnConfigFileName cfn
31 where acfn.server_id = :server_id
32 and acfn.action_id = :action_id
33 and acfn.config_file_name_id = cfn.id
34 """)
35
36 _query_mtime_upload_info = rhnSQL.Statement("""
37 select TO_CHAR(start_date, 'YYYY-MM-DD HH24:MI:SS') as start_date,
38 TO_CHAR(end_date, 'YYYY-MM-DD HH24:MI:SS') as end_date,
39 TO_CHAR(sysdate, 'YYYY-MM-DD HH24:MI:SS') as now,
40 import_contents
41 from rhnActionConfigDate
42 where action_id = :action_id
43 """)
44
45 _query_mtime_upload_paths = rhnSQL.Statement("""
46 select file_name,
47 file_type
48 from rhnActionConfigDateFile
49 where action_id = :action_id
50 """)
51
52
92
93
94 -def upload(server_id, action_id, dry_run=0):
101
102
103 -def deploy(server_id, action_id, dry_run=0):
106
107
108 -def verify(server_id, action_id, dry_run=0):
111
112
113 -def diff(server_id, action_id, dry_run=0):
116
117 _query_get_files = rhnSQL.Statement("""
118 select cfn.path,
119 cc.label config_channel,
120 ccont.contents file_contents,
121 ccont.is_binary is_binary,
122 c.checksum_type,
123 c.checksum,
124 ccont.delim_start,
125 ccont.delim_end,
126 cr.revision,
127 ci.username,
128 ci.groupname,
129 ci.filemode,
130 cft.label,
131 ci.selinux_ctx,
132 case
133 when cft.label='symlink' then (select path from rhnConfigFileName where id = ci.SYMLINK_TARGET_FILENAME_ID)
134 else ''
135 end as symlink
136 from
137 rhnConfigFileState cfs,
138 rhnConfigChannel cc,
139 rhnConfigFileName cfn,
140 rhnConfigInfo ci,
141 rhnConfigFile cf,
142 rhnConfigRevision cr
143 left join rhnConfigContent ccont
144 on cr.config_content_id = ccont.id
145 left join rhnChecksumView c
146 on ccont.checksum_id = c.id,
147 rhnConfigFileType cft,
148 rhnActionConfigRevision acr
149 where acr.server_id = :server_id
150 and acr.action_id = :action_id
151 and acr.config_revision_id = cr.id
152 and cr.config_file_id = cf.id
153 and cr.config_info_id = ci.id
154 and cf.config_file_name_id = cfn.id
155 and cf.config_channel_id = cc.id
156 and cf.state_id = cfs.id
157 and cfs.label = 'alive'
158 and cr.config_file_type_id = cft.id
159 """)
160
161
179