From 6f6293f90dab3ee0362ae3d278d02da6b83fd2cf Mon Sep 17 00:00:00 2001 From: jiansong Date: Tue, 9 Aug 2016 01:44:21 -0700 Subject: [PATCH] Display more flavor information in trove flavor-list command This commit adds disk_space colmn to flavor-list Change-Id: I71ca7ddbb6b835b5250bd2c4a0cb7ef4d72c9826 Closes-Bug:#1617987 --- .../db-flavors-by-id-response-json-http.txt | 2 +- .../samples/db-flavors-by-id-response.json | 1 + .../samples/db-flavors-response-json-http.txt | 2 +- .../source/samples/db-flavors-response.json | 39 ++++++++++++------- .../flavor-list-disk-6213c3760e374441.yaml | 3 ++ trove/flavor/models.py | 6 ++- trove/flavor/views.py | 1 + trove/tests/api/flavors.py | 6 +-- .../api/database/flavors/test_flavors.py | 5 ++- 9 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 releasenotes/notes/flavor-list-disk-6213c3760e374441.yaml diff --git a/api-ref/source/samples/db-flavors-by-id-response-json-http.txt b/api-ref/source/samples/db-flavors-by-id-response-json-http.txt index 7cf3e8a711..3137516acf 100644 --- a/api-ref/source/samples/db-flavors-by-id-response-json-http.txt +++ b/api-ref/source/samples/db-flavors-by-id-response-json-http.txt @@ -1,5 +1,5 @@ HTTP/1.1 200 OK Content-Type: application/json -Content-Length: 227 +Content-Length: 238 Date: Mon, 18 Mar 2013 19:09:17 GMT diff --git a/api-ref/source/samples/db-flavors-by-id-response.json b/api-ref/source/samples/db-flavors-by-id-response.json index 931f06c914..6c17ccaea0 100644 --- a/api-ref/source/samples/db-flavors-by-id-response.json +++ b/api-ref/source/samples/db-flavors-by-id-response.json @@ -14,6 +14,7 @@ "name": "m1.tiny", "ram": 512, "str_id": "1", + "disk":0, "vcpus": 10 } } diff --git a/api-ref/source/samples/db-flavors-response-json-http.txt b/api-ref/source/samples/db-flavors-response-json-http.txt index 9026e13382..af739601b9 100644 --- a/api-ref/source/samples/db-flavors-response-json-http.txt +++ b/api-ref/source/samples/db-flavors-response-json-http.txt @@ -1,5 +1,5 @@ HTTP/1.1 200 OK Content-Type: application/json -Content-Length: 2899 +Content-Length: 3050 Date: Mon, 18 Mar 2013 19:09:17 GMT diff --git a/api-ref/source/samples/db-flavors-response.json b/api-ref/source/samples/db-flavors-response.json index 29d8516c36..623368b516 100644 --- a/api-ref/source/samples/db-flavors-response.json +++ b/api-ref/source/samples/db-flavors-response.json @@ -15,7 +15,8 @@ "name": "m1.tiny", "ram": 512, "str_id": "1", - "vcpus": 10 + "vcpus": 10, + "disk":0 }, { "id": 2, @@ -32,7 +33,8 @@ "name": "m1.small", "ram": 2048, "str_id": "2", - "vcpus": 10 + "vcpus": 10, + "disk":20 }, { "id": 3, @@ -49,7 +51,8 @@ "name": "m1.medium", "ram": 4096, "str_id": "3", - "vcpus": 10 + "vcpus": 10, + "disk":40 }, { "id": 4, @@ -66,7 +69,8 @@ "name": "m1.large", "ram": 8192, "str_id": "4", - "vcpus": 10 + "vcpus": 10, + "disk":80 }, { "id": 5, @@ -83,7 +87,8 @@ "name": "m1.xlarge", "ram": 16384, "str_id": "5", - "vcpus": 10 + "vcpus": 10, + "disk":160 }, { "id": 6, @@ -100,7 +105,8 @@ "name": "m1.nano", "ram": 64, "str_id": "6", - "vcpus": 10 + "vcpus": 10, + "disk":0 }, { "id": 7, @@ -117,7 +123,8 @@ "name": "m1.micro", "ram": 128, "str_id": "7", - "vcpus": 10 + "vcpus": 10, + "disk":0 }, { "id": 8, @@ -134,7 +141,8 @@ "name": "m1.rd-smaller", "ram": 768, "str_id": "8", - "vcpus": 10 + "vcpus": 10, + "disk":2 }, { "id": 9, @@ -151,7 +159,8 @@ "name": "tinier", "ram": 506, "str_id": "9", - "vcpus": 10 + "vcpus": 10, + "disk":10 }, { "id": 10, @@ -168,7 +177,8 @@ "name": "m1.rd-tiny", "ram": 512, "str_id": "10", - "vcpus": 10 + "vcpus": 10, + "disk":2 }, { "id": 11, @@ -185,7 +195,8 @@ "name": "eph.rd-tiny", "ram": 512, "str_id": "11", - "vcpus": 10 + "vcpus": 10, + "disk":0 }, { "id": 12, @@ -202,7 +213,8 @@ "name": "eph.rd-smaller", "ram": 768, "str_id": "12", - "vcpus": 10 + "vcpus": 10, + "disk":20 }, { "id": null, @@ -219,7 +231,8 @@ "name": "custom.small", "ram": 512, "str_id": "custom", - "vcpus": 10 + "vcpus": 10, + "disk":25 } ] } diff --git a/releasenotes/notes/flavor-list-disk-6213c3760e374441.yaml b/releasenotes/notes/flavor-list-disk-6213c3760e374441.yaml new file mode 100644 index 0000000000..c7e430e617 --- /dev/null +++ b/releasenotes/notes/flavor-list-disk-6213c3760e374441.yaml @@ -0,0 +1,3 @@ +--- +other: + - Add disk column in flavor-list Bug 1617987. diff --git a/trove/flavor/models.py b/trove/flavor/models.py index 2ea0802c50..bd8675d47b 100644 --- a/trove/flavor/models.py +++ b/trove/flavor/models.py @@ -24,7 +24,7 @@ from trove.common.remote import create_nova_client 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): if flavor: @@ -63,6 +63,10 @@ class Flavor(object): def links(self): return self.flavor.links + @property + def disk(self): + return self.flavor.disk + @property def ephemeral(self): return self.flavor.ephemeral diff --git a/trove/flavor/views.py b/trove/flavor/views.py index cf893f93a2..7f4386b172 100644 --- a/trove/flavor/views.py +++ b/trove/flavor/views.py @@ -43,6 +43,7 @@ class FlavorView(object): 'name': self.flavor.name, 'ram': self.flavor.ram, 'vcpus': self.flavor.vcpus, + 'disk': self.flavor.disk, 'str_id': str(self.flavor.id), } diff --git a/trove/tests/api/flavors.py b/trove/tests/api/flavors.py index bfeaaaa501..fa57c058f2 100644 --- a/trove/tests/api/flavors.py +++ b/trove/tests/api/flavors.py @@ -59,8 +59,6 @@ def assert_attributes_equal(name, os_flavor, dbaas_flavor): def assert_flavors_roughly_equivalent(os_flavor, dbaas_flavor): assert_attributes_equal('name', 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): @@ -146,7 +144,7 @@ class Flavors(object): @test 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'] flavors = self.rd_client.flavors.list() attrcheck = AttrCheck() @@ -159,7 +157,7 @@ class Flavors(object): @test 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'] flavor = self.rd_client.flavors.get(1) attrcheck = AttrCheck() diff --git a/trove/tests/tempest/tests/api/database/flavors/test_flavors.py b/trove/tests/tempest/tests/api/database/flavors/test_flavors.py index c91ad615bb..43e3909c36 100644 --- a/trove/tests/tempest/tests/api/database/flavors/test_flavors.py +++ b/trove/tests/tempest/tests/api/database/flavors/test_flavors.py @@ -82,6 +82,7 @@ class DatabaseFlavorsTest(base.BaseDatabaseTest): "DB flavor id differs from OS flavor id value" ) - self._check_values(['name', 'ram', 'vcpus'], db_flavor, os_flavor) - self._check_values(['disk', 'swap'], db_flavor, os_flavor, + self._check_values(['name', 'ram', 'vcpus', + 'disk'], db_flavor, os_flavor) + self._check_values(['swap'], db_flavor, os_flavor, in_db=False)