Commit 5ee0273b authored by Łukasz Nowak's avatar Łukasz Nowak

XXX EXP slapos/slap: Normalise connection_dict for hash calculation

connection_dict can come with u'', so its str(connection_dict) can be:

"{u'key': u'value'}"

But on the server the str of dict is alaways:

"{'key': 'value'}"

So before calculating hash on such dict "normalise" it by converting
unicode to strings.
parent 1b68f7d4
......@@ -608,7 +608,14 @@ 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():
if isinstance(k, unicode):
k = str(k)
if isinstance(v, unicode):
v = str(v)
normalised_connection_dict[k] = v
if self.getConnectionParameterDict() == normalised_connection_dict:
return
if slave_reference is not None:
......@@ -625,7 +632,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