diff --git a/releasenotes/notes/create_service_norm-319a97433d68fa6a.yaml b/releasenotes/notes/create_service_norm-319a97433d68fa6a.yaml new file mode 100644 index 000000000..2f6d018a6 --- /dev/null +++ b/releasenotes/notes/create_service_norm-319a97433d68fa6a.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - The returned data from a create_service() call was not being normalized. diff --git a/shade/operatorcloud.py b/shade/operatorcloud.py index d83430837..269bce942 100644 --- a/shade/operatorcloud.py +++ b/shade/operatorcloud.py @@ -779,7 +779,7 @@ class OperatorCloud(openstackcloud.OpenStackCloud): service = self.manager.submitTask(_tasks.ServiceCreate( name=name, description=description, **service_kwargs)) - return service + return _utils.normalize_keystone_services([service])[0] def list_services(self): """List all Keystone services. diff --git a/shade/tests/unit/test_services.py b/shade/tests/unit/test_services.py index ed5014fc2..5ac8b5a44 100644 --- a/shade/tests/unit/test_services.py +++ b/shade/tests/unit/test_services.py @@ -21,6 +21,7 @@ Tests Keystone services commands. from mock import patch import os_client_config +from shade import _utils from shade import OpenStackCloudException from shade import OperatorCloud from shade.tests.fakes import FakeService @@ -47,8 +48,9 @@ class CloudServices(base.TestCase): self.mock_ks_services = [FakeService(**kwa) for kwa in self.mock_services] + @patch.object(_utils, 'normalize_keystone_services') @patch.object(OperatorCloud, 'keystone_client') - def test_create_service(self, mock_keystone_client): + def test_create_service(self, mock_keystone_client, mock_norm): kwargs = { 'name': 'a service', 'type': 'network', @@ -58,15 +60,14 @@ class CloudServices(base.TestCase): self.client.create_service(**kwargs) kwargs['service_type'] = kwargs.pop('type') mock_keystone_client.services.create.assert_called_with(**kwargs) + self.assertTrue(mock_norm.called) @patch.object(OperatorCloud, 'keystone_client') def test_list_services(self, mock_keystone_client): mock_keystone_client.services.list.return_value = \ self.mock_ks_services - services = self.client.list_services() mock_keystone_client.services.list.assert_called_with() - self.assertItemsEqual(self.mock_services, services) @patch.object(OperatorCloud, 'keystone_client')