Remove redundant argument in container_create api
The argument 'name' and 'container_uuid' is redundant, since it can be retrieve from container object. Change-Id: I691ba046f03ba8179903f51a602c22d4e0501178 Closes-Bug: #1479108
This commit is contained in:
parent
657136ec22
commit
c57c42a750
|
@ -358,9 +358,7 @@ class ContainersController(rest.RestController):
|
|||
container_dict['user_id'] = auth_token['user']['id']
|
||||
new_container = objects.Container(context, **container_dict)
|
||||
new_container.create()
|
||||
res_container = pecan.request.rpcapi.container_create(
|
||||
new_container.name, new_container.uuid,
|
||||
new_container)
|
||||
res_container = pecan.request.rpcapi.container_create(new_container)
|
||||
|
||||
# Set the HTTP Location Header
|
||||
pecan.response.location = link.build_url('containers',
|
||||
|
|
|
@ -117,10 +117,8 @@ class API(rpc_service.API):
|
|||
|
||||
# Container operations
|
||||
|
||||
def container_create(self, name, container_uuid, container):
|
||||
return self._call('container_create', name=name,
|
||||
container_uuid=container_uuid,
|
||||
container=container)
|
||||
def container_create(self, container):
|
||||
return self._call('container_create', container=container)
|
||||
|
||||
def container_list(self, context, limit, marker, sort_key, sort_dir):
|
||||
return objects.Container.list(context, limit, marker, sort_key,
|
||||
|
|
|
@ -116,8 +116,10 @@ class Handler(object):
|
|||
# Container operations
|
||||
|
||||
@wrap_container_exception
|
||||
def container_create(self, context, name, container_uuid, container):
|
||||
def container_create(self, context, container):
|
||||
docker = self.get_docker_client(context, container)
|
||||
name = container.name
|
||||
container_uuid = container.uuid
|
||||
image = container.image
|
||||
LOG.debug('Creating container with image %s name %s'
|
||||
% (image, name))
|
||||
|
|
|
@ -40,7 +40,7 @@ class TestContainerController(api_base.FunctionalTest):
|
|||
|
||||
@patch('magnum.conductor.api.API.container_create')
|
||||
def test_create_container(self, mock_container_create):
|
||||
mock_container_create.side_effect = lambda x, y, z: z
|
||||
mock_container_create.side_effect = lambda x: x
|
||||
|
||||
params = ('{"name": "My Docker", "image": "ubuntu",'
|
||||
'"command": "env",'
|
||||
|
@ -59,7 +59,7 @@ class TestContainerController(api_base.FunctionalTest):
|
|||
mock_container_delete,
|
||||
mock_container_create,
|
||||
mock_container_show):
|
||||
mock_container_create.side_effect = lambda x, y, z: z
|
||||
mock_container_create.side_effect = lambda x: x
|
||||
# Create a container with a command
|
||||
params = ('{"name": "My Docker", "image": "ubuntu",'
|
||||
'"command": "env",'
|
||||
|
@ -97,7 +97,7 @@ class TestContainerController(api_base.FunctionalTest):
|
|||
mock_container_delete,
|
||||
mock_container_create,
|
||||
mock_container_show):
|
||||
mock_container_create.side_effect = lambda x, y, z: z
|
||||
mock_container_create.side_effect = lambda x: x
|
||||
# Create a container with a command
|
||||
params = ('{"name": "My Docker", "image": "ubuntu",'
|
||||
'"command": "env",'
|
||||
|
|
|
@ -112,12 +112,13 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_get_docker_client.return_value = mock_docker
|
||||
|
||||
mock_container = mock.MagicMock()
|
||||
mock_container.name = 'some-name'
|
||||
mock_container.uuid = 'some-uuid'
|
||||
mock_container.image = 'test_image:some_tag'
|
||||
mock_container.command = None
|
||||
|
||||
container = self.conductor.container_create(
|
||||
None, 'some-name',
|
||||
'some-uuid', mock_container)
|
||||
None, mock_container)
|
||||
|
||||
utf8_image = self.conductor._encode_utf8(mock_container.image)
|
||||
mock_docker.pull.assert_called_once_with('test_image',
|
||||
|
@ -136,12 +137,13 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_get_docker_client.return_value = mock_docker
|
||||
|
||||
mock_container = mock.MagicMock()
|
||||
mock_container.name = 'some-name'
|
||||
mock_container.uuid = 'some-uuid'
|
||||
mock_container.image = 'test_image:some_tag'
|
||||
mock_container.command = 'env'
|
||||
|
||||
container = self.conductor.container_create(
|
||||
None, 'some-name',
|
||||
'some-uuid', mock_container)
|
||||
None, mock_container)
|
||||
|
||||
utf8_image = self.conductor._encode_utf8(mock_container.image)
|
||||
mock_docker.pull.assert_called_once_with('test_image',
|
||||
|
@ -173,7 +175,7 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_create,
|
||||
None, 'some-name', 'some-uuid', mock_container)
|
||||
None, mock_container)
|
||||
mock_docker.pull.assert_called_once_with(
|
||||
'test_image',
|
||||
tag='some_tag')
|
||||
|
|
|
@ -169,8 +169,6 @@ class RPCAPITestCase(base.DbTestCase):
|
|||
self._test_rpcapi('container_create',
|
||||
'call',
|
||||
version='1.0',
|
||||
name=self.fake_container['name'],
|
||||
container_uuid=self.fake_container['uuid'],
|
||||
container=self.fake_container)
|
||||
|
||||
def test_container_delete(self):
|
||||
|
|
Loading…
Reference in New Issue