REST API for container actions
* Stubs for start/stop/pause/unpause/logs/execute/reboot * Added a test case to make sure stubs work (200 OK) Change-Id: I47e3a25b7ca7802d971c3b961c9d3651c8f1060c
This commit is contained in:
parent
0a7969740a
commit
4fd406f461
|
@ -175,9 +175,59 @@ class Container(_Base):
|
|||
desc='Docker Containers')
|
||||
|
||||
|
||||
class StartController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, container_id):
|
||||
return "Start Container %s" % container_id
|
||||
|
||||
|
||||
class StopController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, container_id, *remainder):
|
||||
return "Stop Container %s" % container_id
|
||||
|
||||
|
||||
class RebootController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, container_id, *remainder):
|
||||
return "Reboot Container %s" % container_id
|
||||
|
||||
|
||||
class PauseController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, container_id, *remainder):
|
||||
return "Pause Container %s" % container_id
|
||||
|
||||
|
||||
class UnpauseController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, container_id, *remainder):
|
||||
return "Unpause Container %s" % container_id
|
||||
|
||||
|
||||
class LogsController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, container_id, *remainder):
|
||||
return "Logs Container %s" % container_id
|
||||
|
||||
|
||||
class ExecuteController(object):
|
||||
@wsme_pecan.wsexpose(wtypes.text, wtypes.text)
|
||||
def _default(self, container_id, *remainder):
|
||||
return "Execute Container %s" % container_id
|
||||
|
||||
|
||||
class ContainerController(rest.RestController):
|
||||
"""Manages Containers."""
|
||||
|
||||
start = StartController()
|
||||
stop = StopController()
|
||||
reboot = RebootController()
|
||||
pause = PauseController()
|
||||
unpause = UnpauseController()
|
||||
logs = LogsController()
|
||||
execute = ExecuteController()
|
||||
|
||||
@wsme_pecan.wsexpose(Container, wtypes.text)
|
||||
def get_one(self, container_id):
|
||||
"""Retrieve details about one container.
|
||||
|
|
|
@ -80,3 +80,10 @@ class TestContainerController(tests.FunctionalTest):
|
|||
def test_delete(self):
|
||||
response = self.app.delete('/v1/containers/xyz')
|
||||
self.assertEqual(response.status_int, 200)
|
||||
|
||||
def test_container_actions(self):
|
||||
actions = ['start', 'stop', 'pause', 'unpause',
|
||||
'reboot', 'logs', 'execute']
|
||||
for action in actions:
|
||||
response = self.app.get('/v1/containers/xyz/%s' % action)
|
||||
self.assertEqual(response.status_int, 200)
|
Loading…
Reference in New Issue