Commit 360adef0 authored by Marco Mariani's avatar Marco Mariani

filter by instance_guid; removed redundant syntax

parent 457dbb94
...@@ -331,7 +331,9 @@ def request_not_shared(): ...@@ -331,7 +331,9 @@ def request_not_shared():
address_list = [] address_list = []
for address in execute_db('partition_network', 'SELECT * FROM %s WHERE partition_reference=?', [partition['reference']]): for address in execute_db('partition_network', 'SELECT * FROM %s WHERE partition_reference=?', [partition['reference']]):
address_list.append((address['reference'], address['address'])) address_list.append((address['reference'], address['address']))
return xml_marshaller.xml_marshaller.dumps(SoftwareInstance(**dict(
# XXX it should be ComputerPartition, not a SoftwareInstance
return xml_marshaller.xml_marshaller.dumps(SoftwareInstance(
xml=partition['xml'], xml=partition['xml'],
connection_xml=partition['connection_xml'], connection_xml=partition['connection_xml'],
slap_computer_id=app.config['computer_id'], slap_computer_id=app.config['computer_id'],
...@@ -340,8 +342,9 @@ def request_not_shared(): ...@@ -340,8 +342,9 @@ def request_not_shared():
slap_server_url='slap_server_url', slap_server_url='slap_server_url',
slap_software_type=partition['software_type'], slap_software_type=partition['software_type'],
slave_instance_list=partition['slave_instance_list'], slave_instance_list=partition['slave_instance_list'],
instance_guid=partition['reference'],
ip_list=address_list ip_list=address_list
))) ))
abort(408) abort(408)
raise NotImplementedError raise NotImplementedError
...@@ -369,6 +372,9 @@ def request_slave(): ...@@ -369,6 +372,9 @@ def request_slave():
partition_parameter_kw.encode()) partition_parameter_kw.encode())
else: else:
partition_parameter_kw = {} partition_parameter_kw = {}
filter_kw = xml_marshaller.xml_marshaller.loads(request.form.get('filter_xml').encode())
instance_xml = dict2xml(partition_parameter_kw) instance_xml = dict2xml(partition_parameter_kw)
# We will search for a master corresponding to request # We will search for a master corresponding to request
args = [] args = []
...@@ -378,6 +384,10 @@ def request_slave(): ...@@ -378,6 +384,10 @@ def request_slave():
if software_type: if software_type:
q += ' AND software_type=?' q += ' AND software_type=?'
a(software_type) a(software_type)
if 'instance_guid' in filter_kw:
q += ' AND reference=?'
a(filter_kw['instance_guid'])
partition = execute_db('partition', q, args, one=True) partition = execute_db('partition', q, args, one=True)
if partition is None: if partition is None:
app.logger.warning('No partition corresponding to slave request: %s' % \ app.logger.warning('No partition corresponding to slave request: %s' % \
...@@ -434,7 +444,9 @@ def request_slave(): ...@@ -434,7 +444,9 @@ def request_slave():
'SELECT * FROM %s WHERE partition_reference=?', 'SELECT * FROM %s WHERE partition_reference=?',
[partition['reference']]): [partition['reference']]):
address_list.append((address['reference'], address['address'])) address_list.append((address['reference'], address['address']))
return xml_marshaller.xml_marshaller.dumps(SoftwareInstance(**dict(
# XXX it should be ComputerPartition, not a SoftwareInstance
return xml_marshaller.xml_marshaller.dumps(SoftwareInstance(
_connection_dict=xml2dict(slave['connection_xml']), _connection_dict=xml2dict(slave['connection_xml']),
xml = instance_xml, xml = instance_xml,
slap_computer_id=app.config['computer_id'], slap_computer_id=app.config['computer_id'],
...@@ -443,4 +455,4 @@ def request_slave(): ...@@ -443,4 +455,4 @@ def request_slave():
slap_server_url='slap_server_url', slap_server_url='slap_server_url',
slap_software_type=partition['software_type'], slap_software_type=partition['software_type'],
ip_list=address_list ip_list=address_list
))) ))
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