Commit 9afe59c7 authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[refactor] Fix container namedtuple

This patch propagates the process object into the container namedtuple,
fix a couple of bad function calls and adapt the run command handler to
use that process object instead of just the pid of it.
parent edeb413b
......@@ -4,11 +4,10 @@ from aci import ImageManifest
from collections import namedtuple
import logging
import os
import signal
from subprograms import ChrtClient, NodeOSClient, resources
logger = logging.getLogger('nrm')
Container = namedtuple('Container', ['uuid', 'manifest', 'pid'])
Container = namedtuple('Container', ['uuid', 'manifest', 'process'])
class ContainerManager(object):
......@@ -72,7 +71,7 @@ class ContainerManager(object):
c = Container(container_name, manifest, process)
self.pids[] = c
self.containers[container_name] = c
return process
def delete(self, uuid):
"""Delete a container and kill all related processes."""
......@@ -80,7 +79,7 @@ class ContainerManager(object):
c = self.containers[uuid]
del self.containers[uuid]
del self.pids[]
del self.pids[]
def kill(self, uuid):
"""Kill all the processes of a container."""
......@@ -88,11 +87,11 @@ class ContainerManager(object):
c = self.containers[uuid]
logger.debug("killing %r:", c)
except OSError:
def list(self):
"""List the containers in the system."""
return [{'uuid': c.uuid, 'pid':} for c in
return [{'uuid': c.uuid, 'pid':} for c in
......@@ -119,22 +119,14 @@ class Daemon(object):"new target measure: %g",
elif command == 'run':"new container required: %r", msg)
pid = self.container_manager.create(msg)
if pid > 0:
self.containerpids[pid] = msg['uuid']
process = self.container_manager.create(msg)
self.containerpids[] = msg['uuid']
# TODO: obviously we need to send more info than that
update = {'type': 'container',
'event': 'start',
'uuid': msg['uuid'],
'errno': 0,
'pid': pid,
update = {'type': 'container',
'event': 'start',
'uuid': msg['uuid'],
'errno': pid,
elif command == 'kill':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment