Commit 1697c162 authored by Marco Mariani's avatar Marco Mariani

filter by instance_guid; removed redundant syntax

parent 5240e59a
...@@ -331,17 +331,20 @@ def request_not_shared(): ...@@ -331,17 +331,20 @@ 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(
xml=partition['xml'], # XXX it should be ComputerPartition, not a SoftwareInstance
connection_xml=partition['connection_xml'], return xml_marshaller.xml_marshaller.dumps(SoftwareInstance(
slap_computer_id=app.config['computer_id'], xml=partition['xml'],
slap_computer_partition_id=partition['reference'], connection_xml=partition['connection_xml'],
slap_software_release_url=partition['software_release'], slap_computer_id=app.config['computer_id'],
slap_server_url='slap_server_url', slap_computer_partition_id=partition['reference'],
slap_software_type=partition['software_type'], slap_software_release_url=partition['software_release'],
slave_instance_list=partition['slave_instance_list'], slap_server_url='slap_server_url',
ip_list=address_list slap_software_type=partition['software_type'],
))) slave_instance_list=partition['slave_instance_list'],
instance_guid=partition['reference'],
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,13 +444,15 @@ def request_slave(): ...@@ -434,13 +444,15 @@ 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(
_connection_dict=xml2dict(slave['connection_xml']), # XXX it should be ComputerPartition, not a SoftwareInstance
xml = instance_xml, return xml_marshaller.xml_marshaller.dumps(SoftwareInstance(
slap_computer_id=app.config['computer_id'], _connection_dict=xml2dict(slave['connection_xml']),
slap_computer_partition_id=slave['hosted_by'], xml = instance_xml,
slap_software_release_url=partition['software_release'], slap_computer_id=app.config['computer_id'],
slap_server_url='slap_server_url', slap_computer_partition_id=slave['hosted_by'],
slap_software_type=partition['software_type'], slap_software_release_url=partition['software_release'],
ip_list=address_list slap_server_url='slap_server_url',
))) slap_software_type=partition['software_type'],
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