Display more flavor information in trove flavor-list command

This commit adds disk_space colmn to flavor-list

Change-Id: I71ca7ddbb6b835b5250bd2c4a0cb7ef4d72c9826
Closes-Bug:#1617987
This commit is contained in:
jiansong 2016-08-09 01:44:21 -07:00
parent 7ec71aa015
commit 6f6293f90d
9 changed files with 43 additions and 22 deletions

View File

@ -1,5 +1,5 @@
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Content-Length: 227 Content-Length: 238
Date: Mon, 18 Mar 2013 19:09:17 GMT Date: Mon, 18 Mar 2013 19:09:17 GMT

View File

@ -14,6 +14,7 @@
"name": "m1.tiny", "name": "m1.tiny",
"ram": 512, "ram": 512,
"str_id": "1", "str_id": "1",
"disk":0,
"vcpus": 10 "vcpus": 10
} }
} }

View File

@ -1,5 +1,5 @@
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Content-Length: 2899 Content-Length: 3050
Date: Mon, 18 Mar 2013 19:09:17 GMT Date: Mon, 18 Mar 2013 19:09:17 GMT

View File

@ -15,7 +15,8 @@
"name": "m1.tiny", "name": "m1.tiny",
"ram": 512, "ram": 512,
"str_id": "1", "str_id": "1",
"vcpus": 10 "vcpus": 10,
"disk":0
}, },
{ {
"id": 2, "id": 2,
@ -32,7 +33,8 @@
"name": "m1.small", "name": "m1.small",
"ram": 2048, "ram": 2048,
"str_id": "2", "str_id": "2",
"vcpus": 10 "vcpus": 10,
"disk":20
}, },
{ {
"id": 3, "id": 3,
@ -49,7 +51,8 @@
"name": "m1.medium", "name": "m1.medium",
"ram": 4096, "ram": 4096,
"str_id": "3", "str_id": "3",
"vcpus": 10 "vcpus": 10,
"disk":40
}, },
{ {
"id": 4, "id": 4,
@ -66,7 +69,8 @@
"name": "m1.large", "name": "m1.large",
"ram": 8192, "ram": 8192,
"str_id": "4", "str_id": "4",
"vcpus": 10 "vcpus": 10,
"disk":80
}, },
{ {
"id": 5, "id": 5,
@ -83,7 +87,8 @@
"name": "m1.xlarge", "name": "m1.xlarge",
"ram": 16384, "ram": 16384,
"str_id": "5", "str_id": "5",
"vcpus": 10 "vcpus": 10,
"disk":160
}, },
{ {
"id": 6, "id": 6,
@ -100,7 +105,8 @@
"name": "m1.nano", "name": "m1.nano",
"ram": 64, "ram": 64,
"str_id": "6", "str_id": "6",
"vcpus": 10 "vcpus": 10,
"disk":0
}, },
{ {
"id": 7, "id": 7,
@ -117,7 +123,8 @@
"name": "m1.micro", "name": "m1.micro",
"ram": 128, "ram": 128,
"str_id": "7", "str_id": "7",
"vcpus": 10 "vcpus": 10,
"disk":0
}, },
{ {
"id": 8, "id": 8,
@ -134,7 +141,8 @@
"name": "m1.rd-smaller", "name": "m1.rd-smaller",
"ram": 768, "ram": 768,
"str_id": "8", "str_id": "8",
"vcpus": 10 "vcpus": 10,
"disk":2
}, },
{ {
"id": 9, "id": 9,
@ -151,7 +159,8 @@
"name": "tinier", "name": "tinier",
"ram": 506, "ram": 506,
"str_id": "9", "str_id": "9",
"vcpus": 10 "vcpus": 10,
"disk":10
}, },
{ {
"id": 10, "id": 10,
@ -168,7 +177,8 @@
"name": "m1.rd-tiny", "name": "m1.rd-tiny",
"ram": 512, "ram": 512,
"str_id": "10", "str_id": "10",
"vcpus": 10 "vcpus": 10,
"disk":2
}, },
{ {
"id": 11, "id": 11,
@ -185,7 +195,8 @@
"name": "eph.rd-tiny", "name": "eph.rd-tiny",
"ram": 512, "ram": 512,
"str_id": "11", "str_id": "11",
"vcpus": 10 "vcpus": 10,
"disk":0
}, },
{ {
"id": 12, "id": 12,
@ -202,7 +213,8 @@
"name": "eph.rd-smaller", "name": "eph.rd-smaller",
"ram": 768, "ram": 768,
"str_id": "12", "str_id": "12",
"vcpus": 10 "vcpus": 10,
"disk":20
}, },
{ {
"id": null, "id": null,
@ -219,7 +231,8 @@
"name": "custom.small", "name": "custom.small",
"ram": 512, "ram": 512,
"str_id": "custom", "str_id": "custom",
"vcpus": 10 "vcpus": 10,
"disk":25
} }
] ]
} }

View File

@ -0,0 +1,3 @@
---
other:
- Add disk column in flavor-list Bug 1617987.

View File

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

View File

@ -43,6 +43,7 @@ class FlavorView(object):
'name': self.flavor.name, 'name': self.flavor.name,
'ram': self.flavor.ram, 'ram': self.flavor.ram,
'vcpus': self.flavor.vcpus, 'vcpus': self.flavor.vcpus,
'disk': self.flavor.disk,
'str_id': str(self.flavor.id), 'str_id': str(self.flavor.id),
} }

View File

@ -59,8 +59,6 @@ def assert_attributes_equal(name, os_flavor, dbaas_flavor):
def assert_flavors_roughly_equivalent(os_flavor, dbaas_flavor): def assert_flavors_roughly_equivalent(os_flavor, dbaas_flavor):
assert_attributes_equal('name', os_flavor, dbaas_flavor) assert_attributes_equal('name', os_flavor, dbaas_flavor)
assert_attributes_equal('ram', os_flavor, dbaas_flavor) assert_attributes_equal('ram', os_flavor, dbaas_flavor)
assert_false(hasattr(dbaas_flavor, 'disk'),
"The attribute 'disk' s/b absent from the dbaas API.")
def assert_link_list_is_equal(flavor): def assert_link_list_is_equal(flavor):
@ -146,7 +144,7 @@ class Flavors(object):
@test @test
def test_flavor_list_attrs(self): def test_flavor_list_attrs(self):
allowed_attrs = ['id', 'name', 'ram', 'vcpus', 'links', allowed_attrs = ['id', 'name', 'ram', 'vcpus', 'disk', 'links',
'local_storage', 'str_id'] 'local_storage', 'str_id']
flavors = self.rd_client.flavors.list() flavors = self.rd_client.flavors.list()
attrcheck = AttrCheck() attrcheck = AttrCheck()
@ -159,7 +157,7 @@ class Flavors(object):
@test @test
def test_flavor_get_attrs(self): def test_flavor_get_attrs(self):
allowed_attrs = ['id', 'name', 'ram', 'vcpus', 'links', allowed_attrs = ['id', 'name', 'ram', 'vcpus', 'disk', 'links',
'local_storage', 'str_id'] 'local_storage', 'str_id']
flavor = self.rd_client.flavors.get(1) flavor = self.rd_client.flavors.get(1)
attrcheck = AttrCheck() attrcheck = AttrCheck()

View File

@ -82,6 +82,7 @@ class DatabaseFlavorsTest(base.BaseDatabaseTest):
"DB flavor id differs from OS flavor id value" "DB flavor id differs from OS flavor id value"
) )
self._check_values(['name', 'ram', 'vcpus'], db_flavor, os_flavor) self._check_values(['name', 'ram', 'vcpus',
self._check_values(['disk', 'swap'], db_flavor, os_flavor, 'disk'], db_flavor, os_flavor)
self._check_values(['swap'], db_flavor, os_flavor,
in_db=False) in_db=False)