Commit 3c4e7c61 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: archive Compute Node, Project open order and hosting subscription

parent 493e95b4
...@@ -14,26 +14,16 @@ for open_order_line in open_sale_order.contentValues( ...@@ -14,26 +14,16 @@ for open_order_line in open_sale_order.contentValues(
content_list = [open_order_line] content_list = [open_order_line]
for open_order_cell in content_list: for open_order_cell in content_list:
item = open_order_cell.getAggregateValue(portal_type=['Instance Tree', 'Compute Node', 'Project']) item = open_order_cell.getAggregateValue(portal_type=['Instance Tree', 'Compute Node', 'Project'])
hosting_subscription = open_order_cell.getAggregateValue(portal_type='Hosting Subscription')
if item is None: if item is None:
raise AssertionError('No matching item on: %s' % open_order_cell.getRelativeUrl()) raise AssertionError('No matching item on: %s' % open_order_cell.getRelativeUrl())
elif item.getPortalType() == 'Instance Tree': if item.getValidationState() not in ['invalidated', 'archived']:
if item.getSlapState() != 'destroy_requested': # Do not touch if the item is not clean yet
# Do not touch if the instance is still started/stopped
return return
elif item.getPortalType() == 'Compute Node': hosting_subscription.archive(comment='No item in used anymore')
# XXX TODO how to officially close a Compute Node
#raise NotImplementedError('what is the finished state for Compute Node')
return
elif item.getPortalType() == 'Project':
# Do not close project for now
return
else:
raise KeyError('Unexpected portal type: %s on %s' % (item.getPortalType(), open_order_cell.getRelativeUrl()))
# if the script didn't return before, we can archive the open sale order # if the script didn't return before, we can archive the open sale order
now = DateTime() now = DateTime()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment