Commit 480cfb02 authored by Julien Muchembled's avatar Julien Muchembled Committed by Xavier Thompson

proxy: allow several instances with subpartitions having same reference

parent 5db9750d
...@@ -28,8 +28,7 @@ CREATE TABLE IF NOT EXISTS partition%(version)s ( ...@@ -28,8 +28,7 @@ CREATE TABLE IF NOT EXISTS partition%(version)s (
slave_instance_list TEXT, slave_instance_list TEXT,
software_type VARCHAR(255), software_type VARCHAR(255),
partition_reference VARCHAR(255), -- name of the instance partition_reference VARCHAR(255), -- name of the instance
requested_by VARCHAR(255), -- only used for debugging, requested_by VARCHAR(255),
-- slapproxy does not support proper scope
requested_state VARCHAR(255) NOT NULL DEFAULT 'started', requested_state VARCHAR(255) NOT NULL DEFAULT 'started',
timestamp REAL, timestamp REAL,
CONSTRAINT uniq PRIMARY KEY (reference, computer_reference) CONSTRAINT uniq PRIMARY KEY (reference, computer_reference)
......
...@@ -525,7 +525,9 @@ def requestComputerPartition(): ...@@ -525,7 +525,9 @@ def requestComputerPartition():
requested_computer_id = parsed_request_dict['filter_kw'].get('computer_guid', app.config['computer_id']) requested_computer_id = parsed_request_dict['filter_kw'].get('computer_guid', app.config['computer_id'])
matching_partition = getAllocatedSlaveInstance(slave_reference, requested_computer_id) matching_partition = getAllocatedSlaveInstance(slave_reference, requested_computer_id)
else: else:
matching_partition = getAllocatedInstance(parsed_request_dict['partition_reference']) matching_partition = getAllocatedInstance(
parsed_request_dict['partition_reference'],
parsed_request_dict['partition_id'])
if matching_partition: if matching_partition:
# Then the instance is already allocated, just update it # Then the instance is already allocated, just update it
...@@ -716,17 +718,14 @@ def forwardRequestToExternalMaster(master_url, request_form): ...@@ -716,17 +718,14 @@ def forwardRequestToExternalMaster(master_url, request_form):
partition._software_release_document = request_form['software_release'] # type: ignore partition._software_release_document = request_form['software_release'] # type: ignore
return dumps(partition) return dumps(partition)
def getAllocatedInstance(partition_reference): def getAllocatedInstance(partition_reference, requested_by):
""" """
Look for existence of instance, if so return the Look for existence of instance, if so return the
corresponding partition dict, else return None corresponding partition dict, else return None
""" """
args = [] return execute_db('partition',
a = args.append 'SELECT * FROM %s WHERE partition_reference is ? AND requested_by is ?',
table = 'partition' (partition_reference, requested_by or None), one=True)
q = 'SELECT * FROM %s WHERE partition_reference=?'
a(partition_reference)
return execute_db(table, q, args, one=True)
def getAllocatedSlaveInstance(slave_reference, requested_computer_id): def getAllocatedSlaveInstance(slave_reference, requested_computer_id):
""" """
...@@ -768,9 +767,7 @@ def requestNotSlave(software_release, software_type, partition_reference, partit ...@@ -768,9 +767,7 @@ def requestNotSlave(software_release, software_type, partition_reference, partit
instance_xml = dict2xml(partition_parameter_kw) instance_xml = dict2xml(partition_parameter_kw)
requested_computer_id = filter_kw['computer_guid'] requested_computer_id = filter_kw['computer_guid']
partition = execute_db('partition', partition = getAllocatedInstance(partition_reference, partition_id)
'SELECT * FROM %s WHERE partition_reference=?',
(partition_reference,), one=True)
args = [] args = []
a = args.append a = args.append
......
...@@ -31,8 +31,7 @@ CREATE TABLE partition16 ( ...@@ -31,8 +31,7 @@ CREATE TABLE partition16 (
slave_instance_list TEXT, slave_instance_list TEXT,
software_type VARCHAR(255), software_type VARCHAR(255),
partition_reference VARCHAR(255), -- name of the instance partition_reference VARCHAR(255), -- name of the instance
requested_by VARCHAR(255), -- only used for debugging, requested_by VARCHAR(255),
-- slapproxy does not support proper scope
requested_state VARCHAR(255) NOT NULL DEFAULT 'started', requested_state VARCHAR(255) NOT NULL DEFAULT 'started',
timestamp REAL, timestamp REAL,
CONSTRAINT uniq PRIMARY KEY (reference, computer_reference) CONSTRAINT uniq PRIMARY KEY (reference, computer_reference)
......
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