Commit 8e552137 authored by Łukasz Nowak's avatar Łukasz Nowak

XXX EXP slapos/slap: Normalise connection_dict for hash calculation

connection_dict comes with unicodes and other types (int), so its str looks
like:

"{u'key': u'value', 'int': 1}"

But on the server the str of dict is alaways:

"{'key': 'value', 'int': '1'}"

So before calculating hash on such dict "normalise" it by converting
key and values to strings.
parent 1b68f7d4
......@@ -608,7 +608,10 @@ class ComputerPartition(SlapRequester):
return self._software_release_document
def setConnectionDict(self, connection_dict, slave_reference=None):
if self.getConnectionParameterDict() == connection_dict:
normalised_connection_dict = {}
for k,v in connection_dict.items():
normalised_connection_dict[str(k)] = str(v)
if self.getConnectionParameterDict() == normalised_connection_dict:
return
if slave_reference is not None:
......@@ -625,7 +628,7 @@ class ComputerPartition(SlapRequester):
# Skip as nothing changed for the slave
if connection_parameter_hash is not None and \
connection_parameter_hash == hashlib.sha256(str(connection_dict)).hexdigest():
connection_parameter_hash == hashlib.sha256(str(normalised_connection_dict)).hexdigest():
return
self._connection_helper.POST('setComputerPartitionConnectionXml', data={
......
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