Implement "docker execute" for magnum
"docker execute" need command as a parameter Change-Id: I31e83ff56efc3e900a716f9f84b5d593415993e0
This commit is contained in:
parent
a947c3f0f9
commit
716d7ce2c7
|
@ -212,10 +212,11 @@ class LogsController(object):
|
|||
|
||||
|
||||
class ExecuteController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, name, *remainder):
|
||||
LOG.debug('Calling backend_api.container_execute with %s' % name)
|
||||
backend_api.container_execute(name)
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text, wtypes.text)
|
||||
def _default(self, name, command, *remainder):
|
||||
LOG.debug('Calling backend_api.container_execute with %s command %s'
|
||||
% (name, command))
|
||||
backend_api.container_execute(name, command)
|
||||
|
||||
|
||||
class ContainersController(rest.RestController):
|
||||
|
|
|
@ -120,5 +120,5 @@ class API(rpc_service.API):
|
|||
def container_logs(self, name):
|
||||
return self._call('container_logs', name=name)
|
||||
|
||||
def container_execute(self, name):
|
||||
return self._call('container_execute', name=name)
|
||||
def container_execute(self, name, command):
|
||||
return self._call('container_execute', name=name, command=command)
|
||||
|
|
|
@ -186,7 +186,7 @@ class Handler(object):
|
|||
container_id = self._find_container_by_name(name)
|
||||
return self.docker.get_container_logs(container_id)
|
||||
|
||||
def container_execute(self, ctxt, name):
|
||||
LOG.debug("container_execute %s" % name)
|
||||
def container_execute(self, ctxt, name, command):
|
||||
LOG.debug("container_execute %s command %s" % (name, command))
|
||||
container_id = self._find_container_by_name(name)
|
||||
return self.docker.execute(container_id, "ls")
|
||||
return self.docker.execute(container_id, command)
|
||||
|
|
|
@ -307,12 +307,17 @@ class TestContainerController(db_base.DbTestCase):
|
|||
|
||||
# Execute some actions
|
||||
actions = ['start', 'stop', 'pause', 'unpause',
|
||||
'reboot', 'logs', 'execute']
|
||||
'reboot', 'logs']
|
||||
for action in actions:
|
||||
response = self.app.put('/v1/containers/%s/%s' % (c.get('uuid'),
|
||||
action))
|
||||
self.assertEqual(response.status_int, 200)
|
||||
|
||||
# Execute command in docker container
|
||||
response = self.app.put('/v1/containers/%s/%s' % (c.get('uuid'),
|
||||
'execute'), {'command': 'ls'})
|
||||
self.assertEqual(response.status_int, 200)
|
||||
|
||||
# Delete the bay we created
|
||||
response = self.app.delete('/v1/containers/%s' % c.get('uuid'))
|
||||
self.assertEqual(response.status_int, 204)
|
||||
|
|
Loading…
Reference in New Issue