Commit a5d6bd11 authored by Jérome Perrin's avatar Jérome Perrin Committed by Thomas Gambier

slapos/proxy: use slapos API when forwarding request

Eventhough implementation might be a bit more efficient is we use the
low level API, we probably don't need performance here and it's easier
to use the request API
parent 9ce3df86
...@@ -570,14 +570,21 @@ def forwardRequestToExternalMaster(master_url, request_form): ...@@ -570,14 +570,21 @@ def forwardRequestToExternalMaster(master_url, request_form):
new_request_form = request_form.copy() new_request_form = request_form.copy()
filter_kw = loads(new_request_form['filter_xml'].encode('utf-8')) filter_kw = loads(new_request_form['filter_xml'].encode('utf-8'))
filter_kw['source_instance_id'] = partition_reference filter_kw['source_instance_id'] = partition_reference
new_request_form['filter_xml'] = dumps(filter_kw)
xml = slap._connection_helper.POST('/requestComputerPartition', data=new_request_form) partition = slap.registerOpenOrder().request(
partition = loads(xml) software_release=request_form['software_release'],
partition_reference=request_form['partition_reference'],
partition_parameter_kw=loads(request_form['partition_parameter_xml'].encode('utf-8')),
software_type=request_form.get('software_type', ''),
filter_kw=filter_kw,
state=loads(request_form['state'].encode('utf-8')),
shared=loads(request_form['shared_xml'].encode('utf-8')),
)
# XXX move to other end # XXX move to other end
partition._master_url = master_url partition._master_url = master_url # type: ignore
partition._connection_helper = None
partition._software_release_document = request_form['software_release'] # type: ignore
return dumps(partition) return dumps(partition)
def getAllocatedInstance(partition_reference): def getAllocatedInstance(partition_reference):
......
...@@ -1574,6 +1574,12 @@ database_uri = %(tempdir)s/lib/external_proxy.db ...@@ -1574,6 +1574,12 @@ database_uri = %(tempdir)s/lib/external_proxy.db
self._checkInstanceIsFowarded(instance_reference, dummy_parameter_dict, self.external_software_release) self._checkInstanceIsFowarded(instance_reference, dummy_parameter_dict, self.external_software_release)
instance_parameter_dict = partition.getInstanceParameterDict()
instance_parameter_dict.pop('timestamp')
self.assertEqual(dummy_parameter_dict, instance_parameter_dict)
self.assertEqual(self.external_software_release, partition.getSoftwareRelease())
self.assertEqual({}, partition.getConnectionParameterDict())
def testRequestToCurrentMaster(self): def testRequestToCurrentMaster(self):
""" """
Explicitely ask deployment of an instance to current master Explicitely ask deployment of an instance to current master
......
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