1
2 """
3 Module for taskomatic related functions (inserting into queues, etc)
4 """
5
6 from spacewalk.server import rhnSQL
7
8
10
11 - def __init__(self, channel, client, reason, force=False,
12 bypass_filters=False):
13 self.channel = channel
14 self.client = client
15 self.reason = reason
16 self.force = force
17 self.bypass_filters = bypass_filters
18
19
21
23 if boolean:
24 return 'Y'
25 else:
26 return 'N'
27
28 _boolean_as_char = staticmethod(_boolean_as_char)
29
30 - def add(self, entry):
31 h = rhnSQL.prepare("""
32 insert into rhnRepoRegenQueue
33 (id, channel_label, client, reason, force, bypass_filters,
34 next_action, created, modified)
35 values (
36 sequence_nextval('rhn_repo_regen_queue_id_seq'),
37 :channel, :client, :reason, :force, :bypass_filters,
38 current_timestamp, current_timestamp, current_timestamp
39 )
40 """)
41
42 h.execute(channel=entry.channel, client=entry.client,
43 reason=entry.reason, force=self._boolean_as_char(entry.force),
44 bypass_filters=self._boolean_as_char(entry.bypass_filters))
45
46
54
55
56
57
70
71
73 h = rhnSQL.prepare("""
74 insert into rhnTaskQueue
75 (org_id, task_name, task_data, priority, earliest)
76 select coalesce(c.org_id, 1),
77 'update_errata_cache_by_channel',
78 c.id,
79 :priority,
80 current_timestamp
81 from rhnChannel c
82 where c.label = :label
83 """)
84 h.execute(label=channel, priority=priority)
85 rhnSQL.commit()
86