Commit 0c0b9a6e authored by Titouan Soulard's avatar Titouan Soulard Committed by Romain Courteaud

slapos_jio_api_style: update references to project_reference

parent a944e6ab
import json
import urllib
compute_node_id = data_dict.get("compute_node_id", None)
compute_partition_id = data_dict.get("compute_partition_id", None)
......@@ -19,7 +22,6 @@ portal = context.getPortalObject()
# Loads partition parameter
partition_parameter = data_dict.get("parameters", None)
if partition_parameter:
import json
try:
partition_parameter = json.loads(partition_parameter)
except ValueError, e:
......@@ -41,7 +43,6 @@ try:
filter_kw = data_dict.get("sla_parameters", {})
partition_reference = data_dict.get("title")
import urllib
kw = dict(software_release=urllib.unquote(data_dict.get("software_release_uri")),
software_type=data_dict.get("software_type", "RootSoftwareInstance"),
software_title=partition_reference,
......@@ -49,7 +50,7 @@ try:
shared=data_dict.get("shared", False),
sla_xml=castToStr(filter_kw),
state=data_dict.get("state", "started"),
project_reference=data_dict.get("project_reference"))
project_reference=data_dict.get("project_reference", None))
if compute_node_id and compute_partition_id:
compute_partition = portal.portal_catalog.getComputePartitionObject(
......@@ -58,8 +59,13 @@ try:
)
requester = compute_partition.getSoftwareInstance()
instance_tree = requester.getSpecialiseValue()
if instance_tree is not None and instance_tree.getSlapState() == "stop_requested":
kw['state'] = 'stopped'
if instance_tree is not None:
kw["project_reference"] = instance_tree.getFollowUpReference()
if instance_tree.getSlapState() == "stop_requested":
kw['state'] = 'stopped'
key = '_'.join([instance_tree.getRelativeUrl(), partition_reference])
else:
# requested as root, so done by human
......
......@@ -975,13 +975,11 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
try:
requestInstance = instance.__class__.requestInstance
project_reference = self.project.getReference()
instance.__class__.requestInstance = calledRequestInstance
partition_id = instance.getAggregateValue(portal_type='Compute Partition').getReference()
self.login(instance.getUserId())
response_dict = self.postToApi({
"portal_type": "Software Instance",
"project_reference": project_reference,
"software_release_uri": "req_release",
"software_type": "req_type",
"title": "req_reference",
......@@ -996,7 +994,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
response.headers.get('content-type'))
self.assertEqual(self.called_instance_request, {
'instance_xml': "<?xml version='1.0' encoding='utf-8'?>\n<instance/>\n",
"project_reference": project_reference,
'project_reference': self.project.getReference(),
'software_title': 'req_reference',
'software_release': 'req_release',
'state': 'started',
......@@ -1024,13 +1022,11 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
try:
requestInstance = instance.__class__.requestInstance
project_reference = self.project.getReference()
instance.__class__.requestInstance = calledRequestInstance
partition_id = instance.getAggregateValue(portal_type='Compute Partition').getReference()
self.login(instance.getUserId())
response_dict = self.postToApi({
"portal_type": "Software Instance",
"project_reference": project_reference,
"software_release_uri": "req_release",
"software_type": "req_type",
"title": "req_reference",
......@@ -1044,7 +1040,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
response.headers.get('content-type'))
self.assertEqual(self.called_instance_request, {
'instance_xml': "<?xml version='1.0' encoding='utf-8'?>\n<instance/>\n",
"project_reference": project_reference,
'project_reference': self.project.getReference(),
'software_title': 'req_reference',
'software_release': 'req_release',
'shared': False,
......@@ -1072,13 +1068,11 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
try:
requestInstance = instance.__class__.requestInstance
project_reference = self.project.getReference()
instance.__class__.requestInstance = calledRequestInstance
partition_id = instance.getAggregateValue(portal_type='Compute Partition').getReference()
self.login(instance.getUserId())
response_dict = self.postToApi({
"portal_type": "Software Instance",
"project_reference": project_reference,
"software_release_uri": "req_release",
"software_type": "req_type",
"title": "req_reference",
......@@ -1093,7 +1087,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
response.headers.get('content-type'))
self.assertEqual(self.called_instance_request, {
'instance_xml': "<?xml version='1.0' encoding='utf-8'?>\n<instance/>\n",
"project_reference": project_reference,
'project_reference': self.project.getReference(),
'software_title': 'req_reference',
'software_release': 'req_release',
'shared': False,
......
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