Merge "Support for reporting backend state in service list"
This commit is contained in:
commit
0a323eaf94
cinderclient
@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__)
|
||||
# key is a deprecated version and value is an alternative version.
|
||||
DEPRECATED_VERSIONS = {"1": "2"}
|
||||
DEPRECATED_VERSION = "2.0"
|
||||
MAX_VERSION = "3.48"
|
||||
MAX_VERSION = "3.49"
|
||||
MIN_VERSION = "3.0"
|
||||
|
||||
_SUBSTITUTIONS = {}
|
||||
|
@ -145,6 +145,7 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
||||
'state': 'up',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 2),
|
||||
'cluster': 'cluster1',
|
||||
'backend_state': 'up',
|
||||
},
|
||||
{
|
||||
'id': 2,
|
||||
@ -155,6 +156,7 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
||||
'state': 'down',
|
||||
'updated_at': datetime(2012, 9, 18, 8, 3, 38),
|
||||
'cluster': 'cluster1',
|
||||
'backend_state': 'down',
|
||||
},
|
||||
{
|
||||
'id': 3,
|
||||
@ -174,6 +176,11 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
||||
if not self.api_version.matches('3.7'):
|
||||
for svc in services:
|
||||
del svc['cluster']
|
||||
|
||||
if not self.api_version.matches('3.49'):
|
||||
for svc in services:
|
||||
if svc['binary'] == 'cinder-volume':
|
||||
del svc['backend_state']
|
||||
return (200, {}, {'services': services})
|
||||
|
||||
#
|
||||
|
@ -79,3 +79,17 @@ class ServicesTest(utils.TestCase):
|
||||
loaded=True)]
|
||||
# Since it will be sorted by the prefix we can compare them directly
|
||||
self.assertListEqual(expected, result)
|
||||
|
||||
def test_list_services_with_backend_state(self):
|
||||
cs = fakes.FakeClient(api_version=api_versions.APIVersion('3.49'))
|
||||
services_list = cs.services.list()
|
||||
cs.assert_called('GET', '/os-services')
|
||||
self.assertEqual(3, len(services_list))
|
||||
for service in services_list:
|
||||
self.assertIsInstance(service, services.Service)
|
||||
# Make sure backend_state fields from v3.49 is present and not
|
||||
# None
|
||||
if service.binary == 'cinder-volume':
|
||||
self.assertIsNotNone(getattr(service, 'backend_state',
|
||||
None))
|
||||
self._assert_request_id(services_list)
|
||||
|
@ -1655,6 +1655,8 @@ def do_service_list(cs, args):
|
||||
# so as not to add the column when the extended ext is not enabled.
|
||||
if result and hasattr(result[0], 'disabled_reason'):
|
||||
columns.append("Disabled Reason")
|
||||
if cs.api_version.matches('3.49'):
|
||||
columns.extend(["Backend State"])
|
||||
utils.print_list(result, columns)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user