Fixing bug where original and new dicts would always be the same

* Calling Resource.to_dict() does not make a deep copy of the
dict.  Because of this, modifications to values in the 'new' dict would
also modify the original dict, thus defeating the purpose of the
jsonpatch comparison.

Change-Id: I1b72775b729e040d1b44658d50dcd93768f07a6e
This commit is contained in:
Matt Smith 2018-05-07 12:01:36 -05:00
parent 677d4751ef
commit ebdb9b3e90

@ -12,6 +12,7 @@
import hashlib
import copy
import jsonpatch
from openstack import _log
@ -296,7 +297,7 @@ class Image(resource.Resource):
original = self.to_dict()
# Update values from **attrs so they can be passed to jsonpatch
new = self.to_dict()
new = copy.deepcopy(self.to_dict())
new.update(**attrs)
patch_string = jsonpatch.make_patch(original, new).to_string()