diff --git a/novaclient/v1_1/flavors.py b/novaclient/v1_1/flavors.py index b4c71743a..6f9a24b82 100644 --- a/novaclient/v1_1/flavors.py +++ b/novaclient/v1_1/flavors.py @@ -18,7 +18,7 @@ class Flavor(base.Resource): """ Provide a user-friendly accessor to OS-FLV-EXT-DATA:ephemeral """ - return self._info["OS-FLV-EXT-DATA:ephemeral"] + return self._info.get("OS-FLV-EXT-DATA:ephemeral", 'N/A') class FlavorManager(base.ManagerWithFind): diff --git a/tests/v1_1/fakes.py b/tests/v1_1/fakes.py index c7c130105..91c54b226 100644 --- a/tests/v1_1/fakes.py +++ b/tests/v1_1/fakes.py @@ -354,6 +354,11 @@ class FakeHTTPClient(base_client.HTTPClient): def get_flavors_2(self, **kw): return (200, {'flavor': self.get_flavors_detail()[1]['flavors'][1]}) + def get_flavors_3(self, **kw): + # Diablo has no ephemeral + return (200, {'flavor': {'id': 3, 'name': '256 MB Server', + 'ram': 256, 'disk': 10}}) + def delete_flavors_flavordelete(self, **kw): return (202, None) diff --git a/tests/v1_1/test_flavors.py b/tests/v1_1/test_flavors.py index 7efa674ea..f20b2d9e8 100644 --- a/tests/v1_1/test_flavors.py +++ b/tests/v1_1/test_flavors.py @@ -25,6 +25,15 @@ class FlavorsTest(utils.TestCase): self.assertTrue(isinstance(f, flavors.Flavor)) self.assertEqual(f.ram, 256) self.assertEqual(f.disk, 10) + self.assertEqual(f.ephemeral, 10) + + def test_get_flavor_details_diablo(self): + f = cs.flavors.get(3) + cs.assert_called('GET', '/flavors/3') + self.assertTrue(isinstance(f, flavors.Flavor)) + self.assertEqual(f.ram, 256) + self.assertEqual(f.disk, 10) + self.assertEqual(f.ephemeral, 'N/A') def test_find(self): f = cs.flavors.find(ram=256)