Merge pull request #108 from ramielrowe/usage_seed
Only seed deleted instance when deleted today.
This commit is contained in:
@@ -166,6 +166,9 @@ def seed(period_length):
|
|||||||
in_flight_usages = []
|
in_flight_usages = []
|
||||||
deletes = []
|
deletes = []
|
||||||
|
|
||||||
|
|
||||||
|
start, end = get_previous_period(datetime.datetime.utcnow(), period_length)
|
||||||
|
|
||||||
context = RequestContext(1, 1, is_admin=True)
|
context = RequestContext(1, 1, is_admin=True)
|
||||||
|
|
||||||
print "Selecting all active instances"
|
print "Selecting all active instances"
|
||||||
@@ -178,21 +181,30 @@ def seed(period_length):
|
|||||||
task_state = instance['task_state']
|
task_state = instance['task_state']
|
||||||
|
|
||||||
if vm_state == 'building':
|
if vm_state == 'building':
|
||||||
building_usages.append(_usage_for_instance(instance))
|
if instance['deleted'] != 0 and instance['deleted_at'] >= start:
|
||||||
if instance['deleted'] != 0:
|
building_usages.append(_usage_for_instance(instance))
|
||||||
# Just in case...
|
|
||||||
deletes.append(_delete_for_instance(instance))
|
deletes.append(_delete_for_instance(instance))
|
||||||
|
elif instance['deleted'] == 0:
|
||||||
|
building_usages.append(_usage_for_instance(instance))
|
||||||
else:
|
else:
|
||||||
if task_state in in_flight_tasks:
|
if task_state in in_flight_tasks:
|
||||||
in_flight_usages.append(_usage_for_instance(instance,
|
if (instance['deleted'] != 0 and
|
||||||
task=task_state))
|
instance['deleted_at'] >= start):
|
||||||
if instance['deleted'] != 0:
|
|
||||||
# Just in case...
|
# Just in case...
|
||||||
deletes.append(_delete_for_instance(instance))
|
deletes.append(_delete_for_instance(instance))
|
||||||
|
in_flight_usages.append(_usage_for_instance(instance,
|
||||||
|
task=task_state))
|
||||||
|
elif instance['deleted'] == 0:
|
||||||
|
in_flight_usages.append(_usage_for_instance(instance,
|
||||||
|
task=task_state))
|
||||||
else:
|
else:
|
||||||
usages.append(_usage_for_instance(instance))
|
if (instance['deleted'] != 0 and
|
||||||
if instance['deleted'] != 0:
|
instance['deleted_at'] >= start):
|
||||||
deletes.append(_delete_for_instance(instance))
|
deletes.append(_delete_for_instance(instance))
|
||||||
|
usages.append(_usage_for_instance(instance))
|
||||||
|
elif instance['deleted'] == 0:
|
||||||
|
usages.append(_usage_for_instance(instance))
|
||||||
|
|
||||||
print "Populated active instances, processing building"
|
print "Populated active instances, processing building"
|
||||||
for usage in building_usages:
|
for usage in building_usages:
|
||||||
action = get_action_for_instance(context, usage['instance'], 'create')
|
action = get_action_for_instance(context, usage['instance'], 'create')
|
||||||
|
Reference in New Issue
Block a user