Fixes Resource object refresh to use db object
Fix Resource object _refresh method to actually pass a database object to _from_db_object, instead of wrapped one. This fixes properties encryption. Change-Id: I3d8d54fa7441c95fc3de5354f80ce2e7e2ba7054 Closes-Bug: #1481644
This commit is contained in:
parent
606d3c019a
commit
f3101bf9e4
@ -159,7 +159,7 @@ class Resource(
|
||||
def update_and_save(self, values):
|
||||
resource_db = db_api.resource_get(self._context, self.id)
|
||||
resource_db.update_and_save(values)
|
||||
return self._refresh()
|
||||
return self.refresh()
|
||||
|
||||
def select_and_update(self, values, expected_engine_id=None,
|
||||
atomic_key=0):
|
||||
@ -167,16 +167,13 @@ class Resource(
|
||||
atomic_key=atomic_key,
|
||||
expected_engine_id=expected_engine_id)
|
||||
|
||||
def _refresh(self):
|
||||
return self.__class__._from_db_object(
|
||||
self,
|
||||
self._context,
|
||||
self.__class__.get_obj(self._context, self.id))
|
||||
|
||||
def refresh(self, attrs=None):
|
||||
resource_db = db_api.resource_get(self._context, self.id)
|
||||
resource_db.refresh(attrs=attrs)
|
||||
return self._refresh()
|
||||
return self.__class__._from_db_object(
|
||||
self,
|
||||
self._context,
|
||||
resource_db)
|
||||
|
||||
@staticmethod
|
||||
def encrypt_properties_data(data):
|
||||
|
@ -1418,6 +1418,12 @@ class ResourceTest(common.HeatTestCase):
|
||||
res_obj = res_objs['test_res_enc']
|
||||
self.assertEqual('string', res_obj.properties_data['prop1'])
|
||||
|
||||
# The properties data should be decrypted when the object is
|
||||
# refreshed
|
||||
res_obj = resource_objects.Resource.get_obj(res.context, res.id)
|
||||
res_obj.refresh()
|
||||
self.assertEqual('string', res_obj.properties_data['prop1'])
|
||||
|
||||
def test_properties_data_no_encryption(self):
|
||||
cfg.CONF.set_override('encrypt_parameters_and_properties', False)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user