diff --git a/magnum/api/controllers/v1/container.py b/magnum/api/controllers/v1/container.py index d108fe56a8..bdae55db45 100644 --- a/magnum/api/controllers/v1/container.py +++ b/magnum/api/controllers/v1/container.py @@ -243,9 +243,9 @@ class ExecuteController(object): % pecan.request.method)) container_uuid = api_utils.get_rpc_resource('Container', container_ident).uuid - LOG.debug('Calling conductor.container_execute with %s command %s' + LOG.debug('Calling conductor.container_exec with %s command %s' % (container_uuid, command)) - return pecan.request.rpcapi.container_execute(container_uuid, command) + return pecan.request.rpcapi.container_exec(container_uuid, command) class ContainersController(rest.RestController): diff --git a/magnum/conductor/api.py b/magnum/conductor/api.py index c0b8d438e5..d50e9d16a8 100644 --- a/magnum/conductor/api.py +++ b/magnum/conductor/api.py @@ -150,8 +150,8 @@ class API(rpc_service.API): def container_logs(self, container_uuid): return self._call('container_logs', container_uuid=container_uuid) - def container_execute(self, container_uuid, command): - return self._call('container_execute', container_uuid=container_uuid, + def container_exec(self, container_uuid, command): + return self._call('container_exec', container_uuid=container_uuid, command=command) diff --git a/magnum/conductor/handlers/docker_conductor.py b/magnum/conductor/handlers/docker_conductor.py index 174868b274..06a63ce232 100644 --- a/magnum/conductor/handlers/docker_conductor.py +++ b/magnum/conductor/handlers/docker_conductor.py @@ -222,8 +222,8 @@ class Handler(object): "Docker API Error : %s" % str(api_error)) @wrap_container_exception - def container_execute(self, context, container_uuid, command): - LOG.debug("container_execute %s command %s" % + def container_exec(self, context, container_uuid, command): + LOG.debug("container_exec %s command %s" % (container_uuid, command)) docker = self.get_docker_client(context, container_uuid) try: diff --git a/magnum/tests/unit/api/controllers/v1/test_container.py b/magnum/tests/unit/api/controllers/v1/test_container.py index a340177e4d..493fcd0bda 100644 --- a/magnum/tests/unit/api/controllers/v1/test_container.py +++ b/magnum/tests/unit/api/controllers/v1/test_container.py @@ -358,10 +358,10 @@ class TestContainerController(db_base.DbTestCase): '/v1/containers/%s/logs' % container_uuid) self.assertFalse(mock_container_logs.called) - @patch('magnum.conductor.api.API.container_execute') + @patch('magnum.conductor.api.API.container_exec') @patch('magnum.objects.Container.get_by_uuid') def test_execute_command_by_uuid(self, mock_get_by_uuid, - mock_container_execute): + mock_container_exec): test_container = utils.get_test_container() test_container_obj = objects.Container(self.context, **test_container) mock_get_by_uuid.return_value = test_container_obj @@ -371,12 +371,12 @@ class TestContainerController(db_base.DbTestCase): cmd = {'command': 'ls'} response = self.app.put(url, cmd) self.assertEqual(response.status_int, 200) - mock_container_execute.assert_called_one_with(container_uuid, cmd) + mock_container_exec.assert_called_one_with(container_uuid, cmd) - @patch('magnum.conductor.api.API.container_execute') + @patch('magnum.conductor.api.API.container_exec') @patch('magnum.objects.Container.get_by_name') def test_execute_command_by_name(self, mock_get_by_name, - mock_container_execute): + mock_container_exec): test_container = utils.get_test_container() test_container_obj = objects.Container(self.context, **test_container) mock_get_by_name.return_value = test_container_obj @@ -387,7 +387,7 @@ class TestContainerController(db_base.DbTestCase): cmd = {'command': 'ls'} response = self.app.put(url, cmd) self.assertEqual(response.status_int, 200) - mock_container_execute.assert_called_one_with(container_uuid, cmd) + mock_container_exec.assert_called_one_with(container_uuid, cmd) @patch('magnum.conductor.api.API.container_delete') @patch('magnum.objects.Container.get_by_uuid') diff --git a/magnum/tests/unit/conductor/handlers/test_docker_conductor.py b/magnum/tests/unit/conductor/handlers/test_docker_conductor.py index 96f0e55d62..3014366381 100644 --- a/magnum/tests/unit/conductor/handlers/test_docker_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_docker_conductor.py @@ -610,8 +610,8 @@ class TestDockerConductor(base.BaseTestCase): @patch.object(docker_conductor.Handler, '_find_container_by_name') @mock.patch.object(docker_conductor.Handler, 'get_docker_client') - def test_container_execute(self, mock_get_docker_client, - mock_find_container): + def test_container_exec(self, mock_get_docker_client, + mock_find_container): mock_docker = mock.MagicMock() mock_get_docker_client.return_value = mock_docker mock_container_uuid = 'd545a92d-609a-428f-8edb-16b02ad20ca1' @@ -620,7 +620,7 @@ class TestDockerConductor(base.BaseTestCase): mock_find_container.return_value = mock_docker_id mock_create_res = mock.MagicMock() mock_docker.exec_create.return_value = mock_create_res - self.conductor.container_execute(None, mock_container_uuid, 'ls') + self.conductor.container_exec(None, mock_container_uuid, 'ls') mock_docker.exec_create.assert_called_once_with(mock_docker_id, 'ls', True, True, False) @@ -631,8 +631,8 @@ class TestDockerConductor(base.BaseTestCase): @patch.object(docker_conductor.Handler, '_find_container_by_name') @mock.patch.object(docker_conductor.Handler, 'get_docker_client') - def test_container_execute_deprecated(self, mock_get_docker_client, - mock_find_container): + def test_container_exec_deprecated(self, mock_get_docker_client, + mock_find_container): mock_docker = mock.MagicMock() mock_get_docker_client.return_value = mock_docker mock_container_uuid = 'd545a92d-609a-428f-8edb-16b02ad20ca1' @@ -641,16 +641,16 @@ class TestDockerConductor(base.BaseTestCase): mock_find_container.return_value = mock_docker_id mock_create_res = mock.MagicMock() mock_docker.exec_create.return_value = mock_create_res - self.conductor.container_execute(None, mock_container_uuid, 'ls') + self.conductor.container_exec(None, mock_container_uuid, 'ls') mock_docker.execute.assert_called_once_with(mock_docker_id, 'ls') mock_find_container.assert_called_once_with(mock_docker, mock_container_uuid) @patch.object(docker_conductor.Handler, '_find_container_by_name') @mock.patch.object(docker_conductor.Handler, 'get_docker_client') - def test_container_execute_with_failure(self, - mock_get_docker_client, - mock_find_container): + def test_container_exec_with_failure(self, + mock_get_docker_client, + mock_find_container): mock_docker = mock.MagicMock() mock_get_docker_client.return_value = mock_docker mock_container_uuid = 'd545a92d-609a-428f-8edb-16b02ad20ca1' @@ -662,7 +662,7 @@ class TestDockerConductor(base.BaseTestCase): mock_docker.exec_create = mock.Mock( side_effect=errors.APIError('Error', '', '')) self.assertRaises(exception.ContainerException, - self.conductor.container_execute, + self.conductor.container_exec, None, mock_container_uuid, 'ls') mock_docker.exec_create.assert_called_once_with(mock_docker_id, 'ls', True, True, @@ -673,9 +673,9 @@ class TestDockerConductor(base.BaseTestCase): @patch.object(docker_conductor.Handler, '_find_container_by_name') @mock.patch.object(docker_conductor.Handler, 'get_docker_client') - def test_container_execute_deprecated_with_failure(self, - mock_get_docker_client, - mock_find_container): + def test_container_exec_deprecated_with_failure(self, + mock_get_docker_client, + mock_find_container): mock_docker = mock.MagicMock() mock_get_docker_client.return_value = mock_docker mock_container_uuid = 'd545a92d-609a-428f-8edb-16b02ad20ca1' @@ -687,7 +687,7 @@ class TestDockerConductor(base.BaseTestCase): mock_docker.execute = mock.Mock( side_effect=errors.APIError('Error', '', '')) self.assertRaises(exception.ContainerException, - self.conductor.container_execute, + self.conductor.container_exec, None, mock_container_uuid, 'ls') mock_docker.execute.assert_called_once_with(mock_docker_id, 'ls') mock_find_container.assert_called_once_with(mock_docker, @@ -732,7 +732,7 @@ class TestDockerConductor(base.BaseTestCase): mock_init.assert_called_once_with() def test_container_common_exception(self): - for action in ('container_execute', 'container_logs', 'container_show', + for action in ('container_exec', 'container_logs', 'container_show', 'container_delete', 'container_create', '_container_action'): func = getattr(self.conductor, action)