proper audit period names

This commit is contained in:
Sandy Walsh 2014-08-19 07:21:40 +00:00
parent 8c53a567b5
commit f672eea37b
2 changed files with 13 additions and 9 deletions

View File

@ -23,9 +23,14 @@ queue = driver.create_queue(queue_name, exchange, queue_name,
channel=connection.channel()) channel=connection.channel())
queue.declare() queue.declare()
print "Usage: python event_pump.py <template_dir> <operations/hour> " \
"<realtime? 1/0>"
template_dir = sys.argv[1] template_dir = sys.argv[1]
rate = int(sys.argv[2]) rate = int(sys.argv[2])
realtime = int(sys.argv[3]) == 1
print "Using template dir:", template_dir print "Using template dir:", template_dir
print "Rate:", rate
print "Real-time?", realtime
g = notigen.EventGenerator(template_dir, rate) g = notigen.EventGenerator(template_dir, rate)
now = datetime.datetime.utcnow() now = datetime.datetime.utcnow()
@ -38,6 +43,9 @@ while now < end:
nevents += len(e) nevents += len(e)
for event in e: for event in e:
driver.send_notification(event, queue_name, connection, exchange) driver.send_notification(event, queue_name, connection, exchange)
print nevents, event['timestamp'], event['event_type'] print event['timestamp'], event['event_type']
now = datetime.datetime.utcnow() if realtime:
now = datetime.datetime.utcnow()
else:
now = g.move_to_next_tick(now)

View File

@ -137,8 +137,6 @@ class EventGenerator(object):
else: else:
self.instances_in_use.add(uuid) self.instances_in_use.add(uuid)
print "%s %4s-%s %s" % (when, uuid[-4:], operation[17:],
event['event_type'])
del event['____context____'] del event['____context____']
ready.append(event) ready.append(event)
@ -156,13 +154,11 @@ class EventGenerator(object):
operation, context_hints, template) operation, context_hints, template)
for when, event in sequence: for when, event in sequence:
payload = event['payload'] payload = event['payload']
del event['____context____'] payload['audit_period_beginning'] = str(audit_period_start)
payload['audit_period_beginning'] = audit_period_start payload['audit_period_ending'] = str(audit_period_end)
payload['audit_period_ending'] = audit_period_start
payload['instance_id'] = instance payload['instance_id'] = instance
print "%s %s %s" % (now, instance, event['event_type'])
ready.append(event) ready.append(event)
self.instances_in_use = set()
return ready return ready
def _get_sequence(self, now): def _get_sequence(self, now):