Commit 56100a1b authored by Romain Courteaud's avatar Romain Courteaud

slapos_upgrader: do not fixup instance tree virtual master if one software...

slapos_upgrader: do not fixup instance tree virtual master if one software instance is in the same virtual master
parent bb6439e5
...@@ -30,7 +30,7 @@ if aggregate_uid is None: ...@@ -30,7 +30,7 @@ if aggregate_uid is None:
allocation_predicate_list[0].getVariationCategoryList(), allocation_predicate_list[0].getVariationCategoryList(),
project, project,
temp_object=True temp_object=True
) )
except AssertionError: except AssertionError:
price = 0.0 price = 0.0
else: else:
...@@ -46,13 +46,12 @@ if aggregate_uid is None: ...@@ -46,13 +46,12 @@ if aggregate_uid is None:
assert subscription_request.getDestinationDecision() == destination_value.getRelativeUrl() assert subscription_request.getDestinationDecision() == destination_value.getRelativeUrl()
assert subscription_request.getLedger() == "automated" assert subscription_request.getLedger() == "automated"
balance = destination_value.Entity_getDepositBalanceAmount( balance = destination_value.Entity_getDepositBalanceAmount(
[subscription_request] [subscription_request]
) )
if balance - price < 0: if balance - price < 0:
is_future_balance_negative = 1 is_future_balance_negative = 1
return price_information, is_future_balance_negative return price_information, is_future_balance_negative
price_information, is_future_balance_negative = destination_value.Person_restrictMethodAsShadowUser( price_information, is_future_balance_negative = destination_value.Person_restrictMethodAsShadowUser(
shadow_document=destination_value, shadow_document=destination_value,
......
...@@ -30,18 +30,34 @@ if root_software_instance is not None: ...@@ -30,18 +30,34 @@ if root_software_instance is not None:
(root_instance_virtual_master_relative_url != instance_tree_virtual_master_relative_url) and (root_instance_virtual_master_relative_url != instance_tree_virtual_master_relative_url) and
(not sla_xml_dict)): (not sla_xml_dict)):
edit_kw ={'follow_up_value': None} instance_tree_migration_needed = True
activate_kw = {'tag': tag}
instance_tree.edit(**edit_kw) # ensure no software instance is not on the instance tree
instance_tree.reindexObject(activate_kw=activate_kw) # virtual master. If so, keep the instance tree virtual master
for sql_result in portal.portal_catalog( for sql_result in portal.portal_catalog(
specialise__uid=instance_tree.getUid(), specialise__uid=instance_tree.getUid(),
portal_type=['Software Instance', 'Slave Instance'] portal_type='Software Instance'
): ):
instance = sql_result.getObject() instance = sql_result.getObject()
instance.edit(**edit_kw) instance_partition = instance.getAggregateValue()
instance.reindexObject(activate_kw=activate_kw) if instance_partition is not None:
return instance_virtual_master_relative_url = instance_partition.getParentValue().getFollowUp(None)
if (instance_virtual_master_relative_url == instance_tree_virtual_master_relative_url):
instance_tree_migration_needed = False
if instance_tree_migration_needed:
edit_kw ={'follow_up_value': None}
activate_kw = {'tag': tag}
instance_tree.edit(**edit_kw)
instance_tree.reindexObject(activate_kw=activate_kw)
for sql_result in portal.portal_catalog(
specialise__uid=instance_tree.getUid(),
portal_type=['Software Instance', 'Slave Instance']
):
instance = sql_result.getObject()
instance.edit(**edit_kw)
instance.reindexObject(activate_kw=activate_kw)
return
####################################################################### #######################################################################
# If instance is not allocated on the same virtual master than instance tree # If instance is not allocated on the same virtual master than instance tree
......
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