Merge "Fix for backward compatibility with stable/diablo flavors"

This commit is contained in:
Jenkins 2012-02-27 18:17:32 +00:00 committed by Gerrit Code Review
commit 6d8e445b79
3 changed files with 15 additions and 1 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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)