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

Source Code for Module backend.server.taskomatic

 1   
 2  """ 
 3  Module for taskomatic related functions (inserting into queues, etc) 
 4  """ 
 5   
 6  from spacewalk.server import rhnSQL 
 7   
 8   
9 -class RepodataQueueEntry(object):
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
20 -class RepodataQueue(object):
21
22 - def _boolean_as_char(boolean):
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
47 -def add_to_repodata_queue(channel, client, reason, force=False, 48 bypass_filters=False):
49 if reason == '': 50 reason = None 51 entry = RepodataQueueEntry(channel, client, reason, force, bypass_filters) 52 queue = RepodataQueue() 53 queue.add(entry)
54 55 # XXX not the best place for this... 56 57
58 -def add_to_repodata_queue_for_channel_package_subscription(affected_channels, 59 batch, caller):
60 61 tmpreason = [] 62 for package in batch: 63 tmpreason.append(package.short_str()) 64 65 reason = " ".join(tmpreason) 66 67 for channel in affected_channels: 68 # don't want to cause an error for the db 69 add_to_repodata_queue(channel, caller, reason[:128])
70 71
72 -def add_to_erratacache_queue(channel, priority=0):
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