Merge "Zun execute without command returned 500"
This commit is contained in:
commit
c11caef091
@ -414,6 +414,8 @@ class ContainersController(base.Controller):
|
||||
|
||||
@pecan.expose('json')
|
||||
@exception.wrap_pecan_controller_exception
|
||||
@validation.validate_query_param(pecan.request,
|
||||
schema.query_param_execute_command)
|
||||
def execute(self, container_id, run=True, interactive=False, **kw):
|
||||
container = _get_container(container_id)
|
||||
check_policy_on_container(container.as_dict(), "container:execute")
|
||||
|
@ -126,3 +126,13 @@ query_param_signal = {
|
||||
},
|
||||
'additionalProperties': False
|
||||
}
|
||||
|
||||
query_param_execute_command = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'run': parameter_types.boolean,
|
||||
'interactive': parameter_types.boolean,
|
||||
'command': parameter_types.exec_command,
|
||||
},
|
||||
'additionalProperties': False
|
||||
}
|
||||
|
@ -184,3 +184,8 @@ signal = {
|
||||
'type': ['string', 'null'],
|
||||
'enum': SIGNALS
|
||||
}
|
||||
|
||||
exec_command = {
|
||||
'type': ['string'],
|
||||
'minLength': 1,
|
||||
}
|
||||
|
@ -862,6 +862,23 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
self.app.post('/v1/containers/%s/%s/' % (test_object.uuid,
|
||||
'execute'), cmd)
|
||||
|
||||
@patch('zun.common.utils.validate_container_state')
|
||||
@patch('zun.compute.api.API.container_exec')
|
||||
@patch('zun.objects.Container.get_by_uuid')
|
||||
def test_execute_without_command_by_uuid(self, mock_get_by_uuid,
|
||||
mock_container_exec,
|
||||
mock_validate):
|
||||
test_container = utils.get_test_container()
|
||||
test_container_obj = objects.Container(self.context, **test_container)
|
||||
mock_get_by_uuid.return_value = test_container_obj
|
||||
|
||||
container_uuid = test_container.get('uuid')
|
||||
cmd = {'command': ''}
|
||||
self.assertRaises(AppError, self.app.post,
|
||||
'/v1/containers/%s/execute' %
|
||||
container_uuid, cmd)
|
||||
self.assertFalse(mock_container_exec.called)
|
||||
|
||||
@patch('zun.common.utils.validate_container_state')
|
||||
@patch('zun.compute.api.API.container_delete')
|
||||
@patch('zun.objects.Container.get_by_uuid')
|
||||
|
Loading…
x
Reference in New Issue
Block a user