Commit cb36a56e authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

wip only 14 tests remaining till new API

parent 4ed72fcc
......@@ -582,6 +582,7 @@ stderr_logfile_backups=1
"slap_partition": partition,
"access_status_message": partition.getAccessStatus(),
"software_release_uri": software_release_uri,
"sla_parameters": getattr(partition, '_filter_dict', {}),
})
return self.computer_partition_list
......@@ -1041,11 +1042,12 @@ stderr_logfile_backups=1
"root_instance_title": computer_partition["root_instance_title"],
}).get("result_list", [])
for instance_result in related_instance_list:
instance = self.slap.jio_api_connector.get({
"portal_type": "Software Instance",
"reference": instance_result["reference"],
})
hosting_ip_list = hosting_ip_list + instance["ip_list"]
if instance_result["reference"] != computer_partition["reference"]:
instance = self.slap.jio_api_connector.get({
"portal_type": "Software Instance",
"reference": instance_result["reference"],
})
hosting_ip_list = hosting_ip_list + instance["ip_list"]
else:
hosting_ip_list = computer_partition["slap_partition"].getFullHostingIpAddressList()
......@@ -1057,7 +1059,7 @@ stderr_logfile_backups=1
if not ip in ipv6_list:
hosting_ipv6_list.append(ip)
filter_dict = getattr(computer_partition, '_filter_dict', None)
filter_dict = computer_partition.get('sla_parameters', None)
extra_list = []
accept_ip_list = []
if filter_dict is not None:
......@@ -1152,7 +1154,7 @@ stderr_logfile_backups=1
buildout=self.buildout,
buildout_debug=self.buildout_debug,
logger=self.logger,
retention_delay=getattr(computer_partition, '_filter_dict', {}).get('retention_delay', '0'),
retention_delay=computer_partition.get('sla_parameters', {}).get('retention_delay', '0'),
instance_min_free_space=self.instance_min_free_space,
instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network,
......@@ -1202,7 +1204,6 @@ stderr_logfile_backups=1
instance_path,
COMPUTER_PARTITION_TIMESTAMP_FILENAME
)
parameter_dict = computer_partition.get("parameters", {})
timestamp = computer_partition.get("processing_timestamp")
error_output_file = os.path.join(
......@@ -1246,7 +1247,7 @@ stderr_logfile_backups=1
buildout=self.buildout,
buildout_debug=self.buildout_debug,
logger=self.logger,
retention_delay=getattr(computer_partition, '_filter_dict', {}).get('retention_delay', '0'),
retention_delay=computer_partition.get('sla_parameters', {}).get('retention_delay', '0'),
instance_min_free_space=self.instance_min_free_space,
instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network,
......@@ -1334,7 +1335,7 @@ stderr_logfile_backups=1
partition_ip_list = full_hosting_ip_list = []
if self.firewall_conf:
partition_ip_list = parameter_dict['ip_list'] + parameter_dict.get(
partition_ip_list = computer_partition['ip_list'] + computer_partition.get(
'full_ip_list', [])
if computer_partition_state == COMPUTER_PARTITION_STARTED_STATE:
......
......@@ -439,16 +439,37 @@ class ComputerForTest(object):
} for x in self.software_list]
})
if content["portal_type"] == "Software Instance":
return json.dumps({
"result_list": [{
"software_release_uri": x.software.name if x.software else None,
"reference": x.name,
"title": x.name,
"portal_type": "Software Instance",
"compute_partition_id": x.name,
"state": x.requested_state
} for x in self.instance_list]
})
if "compute_node_id" in content:
return json.dumps({
"result_list": [{
"software_release_uri": x.software.name if x.software else None,
"reference": x.name,
"title": x.name,
"portal_type": "Software Instance",
"compute_partition_id": x.name,
"state": x.requested_state
} for x in self.instance_list]
})
elif "root_instance_title" in content:
return json.dumps({
"result_list": [{
"software_release_uri": x.software.name if x.software else None,
"reference": x.name,
"title": x.name,
"portal_type": "Software Instance",
"compute_partition_id": x.name,
"state": x.requested_state
} for x in self.instance_list] + [
{
"software_release_uri": "foo.cfg",
"reference": "related_instance",
"title": "related_instance",
"portal_type": "Software Instance",
"compute_partition_id": "related_instance",
"state": "stopped"
}
]
})
elif (url.path == '/api/put/'):
if content["portal_type"] == "Software Installation":
......@@ -470,6 +491,7 @@ class ComputerForTest(object):
requested_instance.sequence.append((url.path, content))
if "reported_state" in content:
if content["reported_state"] == "error":
instance.error = True
instance.error_log = content["status_message"]
else:
requested_instance.state = content["reported_state"]
......@@ -494,6 +516,31 @@ class ComputerForTest(object):
elif (url.path == '/api/get/'):
if content["portal_type"] == "Software Instance":
reference = content["reference"]
# Treat the case of firewall
if reference == "related_instance":
return json.dumps({
"title": "related_instance",
"reference": "related_instance",
"software_release_uri": "foo.cfg",
"software_type": None,
"state": "stopped",
"connection_parameters": {
},
"parameters": {},
"shared": False,
"root_instance_title": "0",
"ip_list": self.ip_address_list,
"X509": {
"certificate": "",
"key": ""
},
"sla_parameters": {},
"compute_node_id": None,
"compute_partition_id": "requested_instance",
"processing_timestamp": 0,
"access_status_message": "",
"portal_type": "Software Instance"
})
requested_instance = None
for instance in self.instance_list:
if instance.name == reference:
......@@ -513,6 +560,7 @@ class ComputerForTest(object):
"shared": False,
"root_instance_title": requested_instance.name,
"ip_list": requested_instance.ip_list,
"full_ip_list": requested_instance.full_ip_list,
"X509": {
"certificate": requested_instance.certificate,
"key": requested_instance.key
......@@ -2574,6 +2622,8 @@ class TestSlapgridDestructionLock(MasterMixin, unittest.TestCase):
)))
instance.requested_state = 'destroyed'
# Reset Cache
self.grid.computer_partition_list = None
self.grid.agregateAndSendUsage()
self.assertTrue(os.path.exists(dummy_instance_file_path))
self.assertTrue(os.path.exists(os.path.join(
......
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