Add flavor API support for ephemeral

blueprint ephemeral-storage-volume

Change-Id: I5525a9ce2c856b9233db55ecf75af8b08f40afe0
This commit is contained in:
Anna Shen 2013-05-09 11:05:37 -07:00
parent b3c32e3f87
commit 9e24e8e61e
4 changed files with 22 additions and 10 deletions

View File

@ -28,7 +28,7 @@ from reddwarf.common.remote import create_nova_client
class Flavor(object):
_data_fields = ['id', 'links', 'name', 'ram', 'vcpus']
_data_fields = ['id', 'links', 'name', 'ram', 'vcpus', 'ephemeral']
def __init__(self, flavor=None, context=None, flavor_id=None):
if flavor:
@ -67,6 +67,10 @@ class Flavor(object):
def links(self):
return self.flavor.links
@property
def ephemeral(self):
return self.flavor.ephemeral
class Flavors(NovaRemoteModelBase):

View File

@ -17,6 +17,9 @@
from reddwarf.common.views import create_links
from reddwarf.common import cfg
CONF = cfg.CONF
class FlavorView(object):
@ -26,15 +29,19 @@ class FlavorView(object):
self.req = req
def data(self):
return {
"flavor": {
'id': int(self.flavor.id),
'links': self._build_links(),
'name': self.flavor.name,
'ram': self.flavor.ram,
}
flavor = {
'id': int(self.flavor.id),
'links': self._build_links(),
'name': self.flavor.name,
'ram': self.flavor.ram,
}
if not CONF.reddwarf_volume_support and CONF.device_path is not None:
flavor['local_storage'] = self.flavor.ephemeral
return {"flavor": flavor}
def _build_links(self):
return create_links("flavors", self.req, self.flavor.id)

View File

@ -140,7 +140,7 @@ class Flavors(object):
@test
def test_flavor_list_attrs(self):
expected_attrs = ['id', 'name', 'ram', 'links']
expected_attrs = ['id', 'name', 'ram', 'links', 'local_storage']
flavors = self.rd_client.flavors.list()
attrcheck = AttrCheck()
for flavor in flavors:
@ -151,7 +151,7 @@ class Flavors(object):
@test
def test_flavor_get_attrs(self):
expected_attrs = ['id', 'name', 'ram', 'links']
expected_attrs = ['id', 'name', 'ram', 'links', 'local_storage']
flavor = self.rd_client.flavors.get(1)
attrcheck = AttrCheck()
flavor_dict = flavor._info

View File

@ -38,6 +38,7 @@ class FakeFlavor(object):
self.name = name
self.ram = ram
self.vcpus = 10
self.ephemeral = 0
@property
def links(self):