Support for reporting backend state in service list
This patch will support the feature: report backend state in service list in client side. Depends-On: I561dca3ef7c1901401621bc112389dbd178a907e Change-Id: If15e1fa50b5feecd74c7394c918f4fc9d87bcf3e Implements: blueprint report-backend-state-in-service-list
This commit is contained in:
@@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
# key is a deprecated version and value is an alternative version.
|
# key is a deprecated version and value is an alternative version.
|
||||||
DEPRECATED_VERSIONS = {"1": "2"}
|
DEPRECATED_VERSIONS = {"1": "2"}
|
||||||
DEPRECATED_VERSION = "2.0"
|
DEPRECATED_VERSION = "2.0"
|
||||||
MAX_VERSION = "3.48"
|
MAX_VERSION = "3.49"
|
||||||
MIN_VERSION = "3.0"
|
MIN_VERSION = "3.0"
|
||||||
|
|
||||||
_SUBSTITUTIONS = {}
|
_SUBSTITUTIONS = {}
|
||||||
|
@@ -145,6 +145,7 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
|||||||
'state': 'up',
|
'state': 'up',
|
||||||
'updated_at': datetime(2012, 10, 29, 13, 42, 2),
|
'updated_at': datetime(2012, 10, 29, 13, 42, 2),
|
||||||
'cluster': 'cluster1',
|
'cluster': 'cluster1',
|
||||||
|
'backend_state': 'up',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 2,
|
'id': 2,
|
||||||
@@ -155,6 +156,7 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
|||||||
'state': 'down',
|
'state': 'down',
|
||||||
'updated_at': datetime(2012, 9, 18, 8, 3, 38),
|
'updated_at': datetime(2012, 9, 18, 8, 3, 38),
|
||||||
'cluster': 'cluster1',
|
'cluster': 'cluster1',
|
||||||
|
'backend_state': 'down',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 3,
|
'id': 3,
|
||||||
@@ -174,6 +176,11 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
|||||||
if not self.api_version.matches('3.7'):
|
if not self.api_version.matches('3.7'):
|
||||||
for svc in services:
|
for svc in services:
|
||||||
del svc['cluster']
|
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})
|
return (200, {}, {'services': services})
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -79,3 +79,17 @@ class ServicesTest(utils.TestCase):
|
|||||||
loaded=True)]
|
loaded=True)]
|
||||||
# Since it will be sorted by the prefix we can compare them directly
|
# Since it will be sorted by the prefix we can compare them directly
|
||||||
self.assertListEqual(expected, result)
|
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)
|
||||||
|
@@ -1597,6 +1597,8 @@ def do_service_list(cs, args):
|
|||||||
# so as not to add the column when the extended ext is not enabled.
|
# so as not to add the column when the extended ext is not enabled.
|
||||||
if result and hasattr(result[0], 'disabled_reason'):
|
if result and hasattr(result[0], 'disabled_reason'):
|
||||||
columns.append("Disabled Reason")
|
columns.append("Disabled Reason")
|
||||||
|
if cs.api_version.matches('3.49'):
|
||||||
|
columns.extend(["Backend State"])
|
||||||
utils.print_list(result, columns)
|
utils.print_list(result, columns)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user