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

slapos_cloud: use instance/computer project in the security mapping

parent 47a85370
......@@ -47,10 +47,19 @@ def getComputeNodeSecurityCategory(self, base_category_list, user_name,
)
if len(compute_node_list) == 1:
category_dict = {}
for base_category in base_category_list:
if base_category == "role":
category_list.append(
{base_category: ['role/computer']})
elif base_category == "destination_project":
compute_node = compute_node_list[0]
project = compute_node.getFollowUpValue(portal_type='Project')
if project is not None:
category_dict.setdefault(base_category, []).append(project.getRelativeUrl())
else:
raise NotImplementedError('Not supported base category: %s' % base_category)
category_list.append(category_dict)
elif len(compute_node_list) > 1:
raise ConsistencyError("Error: There is more than one Compute Node " \
"with reference '%s'" % user_name)
......@@ -77,11 +86,18 @@ def getSoftwareInstanceSecurityCategory(self, base_category_list, user_name,
for base_category in base_category_list:
if base_category == "role":
category_dict.setdefault(base_category, []).extend(['role/instance'])
if base_category == "aggregate":
elif base_category == "destination_project":
software_instance = software_instance_list[0]
project = software_instance.getFollowUpValue(portal_type='Project')
if project is not None:
category_dict.setdefault(base_category, []).append(project.getRelativeUrl())
elif base_category == "aggregate":
software_instance = software_instance_list[0]
instance_tree = software_instance.getSpecialiseValue(portal_type='Instance Tree')
if instance_tree is not None:
category_dict.setdefault(base_category, []).append(instance_tree.getRelativeUrl())
else:
raise NotImplementedError('Not supported base category: %s' % base_category)
category_list.append(category_dict)
elif len(software_instance_list) > 1:
raise ConsistencyError("Error: There is more than one Software Instance " \
......
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