summaryrefslogtreecommitdiffstats
path: root/api/resources/v2/containers.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/resources/v2/containers.py')
-rw-r--r--api/resources/v2/containers.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/api/resources/v2/containers.py b/api/resources/v2/containers.py
index 5042e0592..556477df7 100644
--- a/api/resources/v2/containers.py
+++ b/api/resources/v2/containers.py
@@ -318,3 +318,30 @@ class V2Containers(ApiResource):
LOG.info('Starting container')
client.start(container)
return container
+
+
+class V2Container(ApiResource):
+
+ def get(self, container_id):
+ try:
+ uuid.UUID(container_id)
+ except ValueError:
+ result_handler(consts.API_ERROR, 'invalid container id')
+
+ try:
+ container = container_handler.get_by_uuid(container_id)
+ except ValueError:
+ result_handler(consts.API_ERROR, 'no such container id')
+
+ name = container.name
+ client = Client(base_url=consts.DOCKER_URL)
+ info = client.inspect_container(name)
+
+ data = {
+ 'name': name,
+ 'status': info.get('State', {}).get('Status', 'error'),
+ 'time': info.get('Created'),
+ 'port': container.port
+ }
+
+ return result_handler(consts.API_SUCCESS, {'container': data})