Public bug reported:

The Aggregate object has an availability_zone property that, when
accessed, gets the availability zone as a key/value stored in the
metadata field. The problem is, the metadata field is nullable, so if an
Aggregate object is created with no metadata, calling the
availability_zone property will explode because it is trying to get the
'availability_zone' key on the metadata field.

Here is a simple test that fails to show the problem (put in
nova/tests/unit/objects/test_aggregate.py):

def test_get_availability_zone_with_null_metadata(self):
        agg = aggregate.Aggregate()
        self.assertIsNone(agg.availability_zone)

Here's the result of the test:

nova.tests.unit.objects.test_aggregate.TestAggregateObject.test_get_availability_zone_with_null_metadata
--------------------------------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/unit/objects/test_aggregate.py", line 192, in 
test_get_availability_zone_with_null_metadata
        self.assertIsNone(agg.availability_zone)
      File "nova/objects/aggregate.py", line 151, in availability_zone
        return self.metadata.get('availability_zone', None)
      File 
"/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py",
 line 67, in getter
        self.obj_load_attr(name)
      File 
"/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py",
 line 578, in obj_load_attr
        _("Cannot load '%s' in the base class") % attrname)
    NotImplementedError: Cannot load 'metadata' in the base class

** Affects: nova
     Importance: Undecided
     Assignee: Ryan Rossiter (rlrossit)
         Status: New

** Changed in: nova
     Assignee: (unassigned) => Ryan Rossiter (rlrossit)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1532078

Title:
  Aggregate availability_zone access throws NotImplementedError when
  metadata is null

Status in OpenStack Compute (nova):
  New

Bug description:
  The Aggregate object has an availability_zone property that, when
  accessed, gets the availability zone as a key/value stored in the
  metadata field. The problem is, the metadata field is nullable, so if
  an Aggregate object is created with no metadata, calling the
  availability_zone property will explode because it is trying to get
  the 'availability_zone' key on the metadata field.

  Here is a simple test that fails to show the problem (put in
  nova/tests/unit/objects/test_aggregate.py):

  def test_get_availability_zone_with_null_metadata(self):
          agg = aggregate.Aggregate()
          self.assertIsNone(agg.availability_zone)

  Here's the result of the test:

  
nova.tests.unit.objects.test_aggregate.TestAggregateObject.test_get_availability_zone_with_null_metadata
  
--------------------------------------------------------------------------------------------------------

  Captured traceback:
  ~~~~~~~~~~~~~~~~~~~
      Traceback (most recent call last):
        File "nova/tests/unit/objects/test_aggregate.py", line 192, in 
test_get_availability_zone_with_null_metadata
          self.assertIsNone(agg.availability_zone)
        File "nova/objects/aggregate.py", line 151, in availability_zone
          return self.metadata.get('availability_zone', None)
        File 
"/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py",
 line 67, in getter
          self.obj_load_attr(name)
        File 
"/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py",
 line 578, in obj_load_attr
          _("Cannot load '%s' in the base class") % attrname)
      NotImplementedError: Cannot load 'metadata' in the base class

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1532078/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to