Earlier, when we wanted to log a message with an object as a parameter,
obj_attr_is_set method used to check name parameter, which was a wrong
approach. The reason was, that the oslo logger, when received a
versioned object as a resource parameter, is trying to get the 'name'
parameter, which is a property, so the obj_attr_is_set method will
return False and the logger will try to get the 'type' parameter, which
does not exist in some versioned objects (please take a look at
oslo.logging code [1]).
Now, when the parameter's name is present in obj_extra_fields
dict, we avoid calling obj_attr_is_set and simply get() it.
The other cause was a difference between fields names: size (in volume
object) and volume_size (in snapshot object), and inproper condition
statement in lvm driver.
[1] goo.gl/YffLcK
Change-Id: Id92d58b4ccced907cc6e3e59d9e71650a459b4a8
Closes-Bug:
1501521
'attribute_name': key})
return None
if (value != base._NotSpecifiedSentinel and
+ key not in self.obj_extra_fields and
not self.obj_attr_is_set(key)):
return value
else:
obj.abc = 'val2'
self.assertEqual('val2', obj.get('abc', 'val'))
self.assertEqual(42, obj.get('foo'))
+ self.assertEqual(42, obj.get('foo', None))
self.assertTrue('foo' in obj)
self.assertTrue('abc' in obj)
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
- size_in_g = volume.get('volume_size') or volume.get('size')
+ size_in_g = (volume.get('volume_size') if is_snapshot
+ else volume.get('size'))
if size_in_g is None:
msg = (_("Size for volume: %s not found, cannot secure delete.")
% volume['id'])