Commit 15d6f6cf authored by Nicolas Wavrant's avatar Nicolas Wavrant Committed by Thomas Gambier

proxy: do not delete all partitions on each call to loadComputerConfigurationFromXML

loadComputerConfigurationFromXML must be idempotent : if partitions are requested the
same, then nothing should be done.
With this commit, we make sure we only delete partitions that don't exist anymore,
create new ones, and update the remaining ones
parent e1a81425
......@@ -316,7 +316,14 @@ def loadComputerConfigurationFromXML():
computer_dict)
# remove references to old partitions.
execute_db('partition', 'DELETE FROM %s WHERE computer_reference = :reference', computer_dict)
execute_db(
'partition',
'DELETE FROM %s WHERE computer_reference = ? and reference not in ({})'.format(
','.join('?' * len(computer_dict['partition_list'])) # Create as many placeholder as partitions requested
),
# Prepare arguments : first is for computer_reference, followed by the same of the partitions
[computer_dict['reference']] + [x['reference'] for x in computer_dict['partition_list']]
)
execute_db('partition_network', 'DELETE FROM %s WHERE computer_reference = :reference', computer_dict)
for partition in computer_dict['partition_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