Commit 903099c9 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: stop using shadow to allocate instance

Use project only
parent 398ed4d0
......@@ -2,10 +2,12 @@ import random
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
person = context
assert project_uid
compute_partition = None
filter_kw_copy = filter_kw.copy()
query_kw = {
'follow_up__uid': project_uid,
'software_release_url': software_release_url,
'portal_type': 'Compute Partition',
}
......@@ -30,6 +32,7 @@ if 'network_guid' in filter_kw:
network_guid = filter_kw.pop('network_guid')
query_kw["default_subordination_reference"] = SimpleQuery(default_subordination_reference=network_guid)
"""
if 'project_guid' in filter_kw:
# This implementation isn't optimal, as we would prefere place a direct query rather them make an
# direct query.
......@@ -42,6 +45,7 @@ if 'project_guid' in filter_kw:
if project is not None:
query_kw["parent_reference"] = SimpleQuery(parent_reference=project.Project_getComputeNodeReferenceList())
"""
if computer_network_query:
if query_kw.get("default_subordination_reference"):
......
......@@ -50,7 +50,7 @@
</item>
<item>
<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, is_root_slave=False, test_mode=False</string> </value>
<value> <string>project_uid, 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>
<key> <string>id</string> </key>
......
......@@ -17,7 +17,8 @@ def assignComputePartition(software_instance, instance_tree):
portal_type="Compute Partition")
if compute_partition is None:
instance_tree = software_instance.getSpecialiseValue(
portal_type='Instance Tree')
portal_type='Instance Tree'
)
if instance_tree is None:
raise ValueError('%s does not have related instance tree' % software_instance.getRelativeUrl())
......@@ -109,12 +110,23 @@ def assignComputePartition(software_instance, instance_tree):
elif sla_dict.get('mode'):
computer_network_query = '-1'
"""
compute_partition_relative_url = person.Person_restrictMethodAsShadowUser(
shadow_document=person,
callable_object=person.Person_findPartition,
argument_list=[software_instance.getUrlString(), software_instance.getSourceReference(),
software_instance.getPortalType(), sla_dict, computer_network_query,
subscription_reference, instance_tree.isRootSlave()])
"""
compute_partition_relative_url = person.Person_findPartition(
software_instance.getFollowUpUid(portal_type='Project'),
software_instance.getUrlString(),
software_instance.getSourceReference(),
software_instance.getPortalType(),
sla_dict, computer_network_query,
subscription_reference,
instance_tree.isRootSlave()
)
return compute_partition_relative_url, tag
software_instance = context
......
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