Commit a916f807 authored by Łukasz Nowak's avatar Łukasz Nowak

Initiate server-side SLA parameter.

Also as Vifib does not accept optional parameters, transmit all everytime.
parent bcdd74a8
...@@ -243,8 +243,8 @@ class SlapTool(BaseTool): ...@@ -243,8 +243,8 @@ class SlapTool(BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, 'requestComputerPartition') security.declareProtected(Permissions.AccessContentsInformation, 'requestComputerPartition')
def requestComputerPartition(self, computer_id, computer_partition_id, def requestComputerPartition(self, computer_id, computer_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml): shared_xml, partition_parameter_xml, filter_xml, sla_parameter_xml):
""" """
Asynchronously requests creation of computer partition for assigned Asynchronously requests creation of computer partition for assigned
parameters parameters
...@@ -258,7 +258,7 @@ class SlapTool(BaseTool): ...@@ -258,7 +258,7 @@ class SlapTool(BaseTool):
""" """
return self._requestComputerPartition(computer_id, computer_partition_id, return self._requestComputerPartition(computer_id, computer_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml) shared_xml, partition_parameter_xml, filter_xml, sla_parameter_xml)
security.declareProtected(Permissions.AccessContentsInformation, 'useComputer') security.declareProtected(Permissions.AccessContentsInformation, 'useComputer')
def useComputer(self, computer_id, use_string): def useComputer(self, computer_id, use_string):
...@@ -544,7 +544,7 @@ class SlapTool(BaseTool): ...@@ -544,7 +544,7 @@ class SlapTool(BaseTool):
@convertToREST @convertToREST
def _requestComputerPartition(self, computer_id, computer_partition_id, def _requestComputerPartition(self, computer_id, computer_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml): shared_xml, partition_parameter_xml, filter_xml, sla_parameter_xml):
""" """
Asynchronously requests creation of computer partition for assigned Asynchronously requests creation of computer partition for assigned
parameters parameters
...@@ -565,6 +565,11 @@ class SlapTool(BaseTool): ...@@ -565,6 +565,11 @@ class SlapTool(BaseTool):
partition_parameter_xml) partition_parameter_xml)
else: else:
partition_parameter_kw = dict() partition_parameter_kw = dict()
if sla_parameter_xml:
sla_parameter_kw = xml_marshaller.xml_marshaller.loads(
sla_parameter_xml)
else:
sla_parameter_kw = dict()
if filter_xml: if filter_xml:
filter_kw = xml_marshaller.xml_marshaller.loads(filter_xml) filter_kw = xml_marshaller.xml_marshaller.loads(filter_xml)
else: else:
...@@ -588,7 +593,8 @@ class SlapTool(BaseTool): ...@@ -588,7 +593,8 @@ class SlapTool(BaseTool):
partition_reference=partition_reference, partition_reference=partition_reference,
shared=shared, shared=shared,
instance_xml=instance_xml, instance_xml=instance_xml,
filter_kw=filter_kw) filter_kw=filter_kw,
sla_parameter_kw=sla_parameter_kw)
# Get requested software instance # Get requested software instance
requested_software_instance = software_instance_document.portal_catalog.\ requested_software_instance = software_instance_document.portal_catalog.\
......
...@@ -152,16 +152,16 @@ class OpenOrder(SlapDocument): ...@@ -152,16 +152,16 @@ class OpenOrder(SlapDocument):
partition_parameter_kw=None, software_type=None, sla_parameter_kw=None): partition_parameter_kw=None, software_type=None, sla_parameter_kw=None):
if partition_parameter_kw is None: if partition_parameter_kw is None:
partition_parameter_kw = {} partition_parameter_kw = {}
if sla_parameter_kw is None:
sla_parameter_kw = {}
request_dict = { request_dict = {
'software_release': software_release, 'software_release': software_release,
'partition_reference': partition_reference, 'partition_reference': partition_reference,
'partition_parameter_xml': xml_marshaller.dumps(partition_parameter_kw), 'partition_parameter_xml': xml_marshaller.dumps(partition_parameter_kw),
'sla_parameter_xml': xml_marshaller.dumps(sla_parameter_kw)
} }
if software_type is not None: if software_type is not None:
request_dict['software_type'] = software_type request_dict['software_type'] = software_type
if sla_parameter_kw is not None:
request_dict['sla_parameter_xml'] = xml_marshaller.dumps(
sla_parameter_kw)
self._connection_helper.POST('/requestComputerPartition', request_dict) self._connection_helper.POST('/requestComputerPartition', request_dict)
xml = self._connection_helper.response.read() xml = self._connection_helper.response.read()
software_instance = xml_marshaller.loads(xml) software_instance = xml_marshaller.loads(xml)
...@@ -286,6 +286,8 @@ class ComputerPartition(SlapDocument): ...@@ -286,6 +286,8 @@ class ComputerPartition(SlapDocument):
sla_parameter_kw=None): sla_parameter_kw=None):
if partition_parameter_kw is None: if partition_parameter_kw is None:
partition_parameter_kw = {} partition_parameter_kw = {}
if sla_parameter_kw is None:
sla_parameter_kw = {}
elif not isinstance(partition_parameter_kw, dict): elif not isinstance(partition_parameter_kw, dict):
raise ValueError("Unexpected type of partition_parameter_kw '%s'" % \ raise ValueError("Unexpected type of partition_parameter_kw '%s'" % \
partition_parameter_kw) partition_parameter_kw)
...@@ -305,10 +307,8 @@ class ComputerPartition(SlapDocument): ...@@ -305,10 +307,8 @@ class ComputerPartition(SlapDocument):
'partition_parameter_xml': xml_marshaller.dumps( 'partition_parameter_xml': xml_marshaller.dumps(
partition_parameter_kw), partition_parameter_kw),
'filter_xml': xml_marshaller.dumps(filter_kw), 'filter_xml': xml_marshaller.dumps(filter_kw),
'sla_parameter_xml': xml_marshaller.dumps(sla_parameter_kw)
} }
if sla_parameter_kw is not None:
request_dict['sla_parameter_xml'] = xml_marshaller.dumps(
sla_parameter_kw)
self._connection_helper.POST('/requestComputerPartition', request_dict) self._connection_helper.POST('/requestComputerPartition', request_dict)
xml = self._connection_helper.response.read() xml = self._connection_helper.response.read()
software_instance = xml_marshaller.loads(xml) software_instance = xml_marshaller.loads(xml)
......
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