From 8cb0eb37721985a58665c6e3e1b63b17c23c4cee Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Fri, 29 Jan 2016 10:28:41 -0500 Subject: [PATCH] Add enabled flag to keystone service data Services can be enabled or disabled. Add this flag to the service data structure. Change-Id: I879811e95829176a64dc34cf7bef09c25421c062 --- .../notes/service_enabled_flag-c917b305d3f2e8fd.yaml | 5 +++++ shade/_utils.py | 1 + shade/tests/fakes.py | 4 +++- shade/tests/unit/test_services.py | 8 ++++---- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/service_enabled_flag-c917b305d3f2e8fd.yaml diff --git a/releasenotes/notes/service_enabled_flag-c917b305d3f2e8fd.yaml b/releasenotes/notes/service_enabled_flag-c917b305d3f2e8fd.yaml new file mode 100644 index 000000000..089d297c9 --- /dev/null +++ b/releasenotes/notes/service_enabled_flag-c917b305d3f2e8fd.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Keystone service descriptions were missing an attribute describing whether + or not the service was enabled. A new 'enabled' boolean attribute has been + added to the service data. diff --git a/shade/_utils.py b/shade/_utils.py index 7424862e9..f846f9179 100644 --- a/shade/_utils.py +++ b/shade/_utils.py @@ -193,6 +193,7 @@ def normalize_keystone_services(services): 'description': service.get('description', None), 'type': service_type, 'service_type': service_type, + 'enabled': service['enabled'] } ret.append(new_service) return meta.obj_list_to_dict(ret) diff --git a/shade/tests/fakes.py b/shade/tests/fakes.py index 45229d962..f3c07224c 100644 --- a/shade/tests/fakes.py +++ b/shade/tests/fakes.py @@ -85,12 +85,14 @@ class FakeServer(object): class FakeService(object): - def __init__(self, id, name, type, service_type, description=''): + def __init__(self, id, name, type, service_type, description='', + enabled=True): self.id = id self.name = name self.type = type self.service_type = service_type self.description = description + self.enabled = enabled class FakeUser(object): diff --git a/shade/tests/unit/test_services.py b/shade/tests/unit/test_services.py index 5ac8b5a44..f5fd9d965 100644 --- a/shade/tests/unit/test_services.py +++ b/shade/tests/unit/test_services.py @@ -31,13 +31,13 @@ from shade.tests.unit import base class CloudServices(base.TestCase): mock_services = [ {'id': 'id1', 'name': 'service1', 'type': 'type1', - 'service_type': 'type1', 'description': 'desc1'}, + 'service_type': 'type1', 'description': 'desc1', 'enabled': True}, {'id': 'id2', 'name': 'service2', 'type': 'type2', - 'service_type': 'type2', 'description': 'desc2'}, + 'service_type': 'type2', 'description': 'desc2', 'enabled': True}, {'id': 'id3', 'name': 'service3', 'type': 'type2', - 'service_type': 'type2', 'description': 'desc3'}, + 'service_type': 'type2', 'description': 'desc3', 'enabled': True}, {'id': 'id4', 'name': 'service4', 'type': 'type3', - 'service_type': 'type3', 'description': 'desc4'} + 'service_type': 'type3', 'description': 'desc4', 'enabled': True} ] def setUp(self):