Commit 24162f94 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Fixup allocation when Subscription Related Slave Instance

   If the Slave Instance is root instance, we should allocated exclusivelly on Subscription defined computers/instances
parent 8452f1ef
...@@ -92,6 +92,11 @@ query_kw["capacity_scope_uid"] = portal.portal_categories.capacity_scope.open.ge ...@@ -92,6 +92,11 @@ query_kw["capacity_scope_uid"] = portal.portal_categories.capacity_scope.open.ge
if subscription_reference is not None and software_instance_portal_type != "Slave Instance": if subscription_reference is not None and software_instance_portal_type != "Slave Instance":
# Subscriptions uses a specific set of allocation scope # Subscriptions uses a specific set of allocation scope
query_kw["allocation_scope_uid"] = portal.portal_categories.allocation_scope.open.subscription.getUid() query_kw["allocation_scope_uid"] = portal.portal_categories.allocation_scope.open.subscription.getUid()
elif subscription_reference is not None and \
software_instance_portal_type == "Slave Instance" and \
is_root_slave:
# Subscriptions uses a specific set of allocation scope
query_kw["allocation_scope_uid"] = getOpenAllocationScopeUidList([])
else: else:
# else pic anything but open/subscription # else pic anything but open/subscription
query_kw["allocation_scope_uid"] = getOpenAllocationScopeUidList( query_kw["allocation_scope_uid"] = getOpenAllocationScopeUidList(
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>software_release_url, software_type, software_instance_portal_type, filter_kw, computer_network_query=None, subscription_reference=None,test_mode=False</string> </value> <value> <string>software_release_url, software_type, software_instance_portal_type, filter_kw, computer_network_query=None, subscription_reference=None, is_root_slave=False, test_mode=False</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -94,14 +94,15 @@ def assignComputerPartition(software_instance, hosting_subscription): ...@@ -94,14 +94,15 @@ def assignComputerPartition(software_instance, hosting_subscription):
shadow_document=person, shadow_document=person,
callable_object=person.Person_findPartition, callable_object=person.Person_findPartition,
argument_list=[software_instance.getUrlString(), software_instance.getSourceReference(), argument_list=[software_instance.getUrlString(), software_instance.getSourceReference(),
software_instance.getPortalType(), sla_dict, computer_network_query, subscription_reference]) software_instance.getPortalType(), sla_dict, computer_network_query,
subscription_reference, hosting_subscription.isRootSlave()])
return computer_partition_relative_url, tag return computer_partition_relative_url, tag
software_instance = context software_instance = context
if software_instance.getValidationState() != 'validated' \ if software_instance.getValidationState() != 'validated' \
or software_instance.getSlapState() not in ('start_requested', 'stop_requested') \ or software_instance.getSlapState() not in ('start_requested', 'stop_requested') \
or software_instance.getAggregateValue(portal_type='Computer Partition') is not None: or software_instance.getAggregateValue(portal_type='Computer Partition') is not None:
return return
hosting_subscription = software_instance.getSpecialiseValue() hosting_subscription = software_instance.getSpecialiseValue()
try: try:
...@@ -113,9 +114,9 @@ try: ...@@ -113,9 +114,9 @@ try:
hosting_subscription.activate(activity="SQLQueue", tag=tag, hosting_subscription.activate(activity="SQLQueue", tag=tag,
after_tag="allocate_%s" % computer_partition_url).getId() after_tag="allocate_%s" % computer_partition_url).getId()
except ValueError: except ValueError, e:
# It was not possible to find free Computer Partition # It was not possible to find free Computer Partition
markHistory(software_instance, 'Allocation failed: no free Computer Partition') markHistory(software_instance, 'Allocation failed: no free Computer Partition %s' % e)
except Unauthorized, e: except Unauthorized, e:
# user has bad balance # user has bad balance
markHistory(software_instance, 'Allocation failed: %s' % e) markHistory(software_instance, 'Allocation failed: %s' % e)
......
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