Commit 815b3b94 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Also Migrate closed allocation scope

   Here we drop the close/* to keep simply the "close" category.
   Whenever we close/forever we consider it as invalidated computer.
parent 39e46b81
portal = context.getPortalObject()
result_list = []
category = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)
if category is None:
# Category already migrated nothing to do
return []
category_path_list = ['portal_categories/allocation_scope/open/friend',
'portal_categories/allocation_scope/close/outdated',
'portal_categories/allocation_scope/close/maintenance',
'portal_categories/allocation_scope/close/termination',
'portal_categories/allocation_scope/close/forever'
]
if category.getValidationState() != "expired":
if fixit:
category.expire(comment="Expired by Migration Constraint")
else:
result_list.append("allocation_scope/friend exists and isn't expired")
category_uid_list = []
for category_path in category_path_list:
category = portal.restrictedTraverse(category_path, None)
if category is None:
continue
category_uid_list.append(category.getUid())
if category.getValidationState() != "expired":
if fixit:
category.expire(comment="Expired by Migration Constraint")
else:
result_list.append("allocation_scope/friend exists and isn't expired")
if not category_uid_list:
# Categories were already removed so nothing to migrate
return
migration_kw = {
'portal_type': 'Compute Node',
'default_allocation_scope_uid': category.getUid()
'default_allocation_scope_uid': category_uid_list
}
non_migrated_instance = portal.portal_catalog(limit=1, **migration_kw)
......
error_list = []
if context.getAllocationScope() != "open/friend" or \
if context.getAllocationScope() not in ['open/friend', 'close/outdated',
'close/maintenance', 'close/termination',
'close/forever'] or \
context.getPortalType() != "Compute Node":
# Skip if the document isn't on
return error_list
if fixit:
owner = context.getSourceAdministrationValue()
if owner is not None and \
context.getSubjectList() == [owner.getDefaultEmailText()]:
# The user shared his computer with himself only.
context.setSubjectList([])
context.setAllocationScope("open/personal")
elif not (context.getSubjectList()):
# The user shared his computer with himself only, so just move into
# Personal
context.setAllocationScope("open/personal")
else:
# XXX here we have to finish it up
pass
if context.getAllocationScope() == 'open/friend':
owner = context.getSourceAdministrationValue()
if owner is not None and \
context.getSubjectList() == [owner.getDefaultEmailText()]:
# The user shared his computer with himself only.
context.setSubjectList([])
context.setAllocationScope("open/personal")
elif not (context.getSubjectList()):
# The user shared his computer with himself only, so just move into
# Personal
context.setAllocationScope("open/personal")
else:
# XXX here we have to finish it up
pass
elif context.getAllocationScope() in ['close/outdated',
'close/maintenance',
'close/termination']:
context.setAllocationScope("close")
elif context.getAllocationScope() in ['close/forever']:
context.setAllocationScope("close")
if context.getValidationState() != "invalidated":
context.invalidate()
else:
error_list.append('Compute Node has to migrate allocation scope from friend to personal')
......
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