Ejemplo n.º 1
0
    def do(self):
        usageMessage = containerizer_pb2.Usage()
        usageMessage.ParseFromString(ComminicationUtils.receive(self.log))
        containerId = usageMessage.container_id.value

        resourceStatisticsMessage = mesos_pb2.ResourceStatistics()
        resourceStatisticsMessage.timestamp = time.time()

        ComminicationUtils.send(resourceStatisticsMessage.SerializeToString())
        return
Ejemplo n.º 2
0
 def do(self):
     containersCommand = ['lxc-ls', '--active', '-1']
     containersMessage = containerizer_pb2.Containers()
     self.log.debug(containersCommand)
     output = subprocess.check_output(containersCommand)
     self.log.debug("Running containers: %s" % output)
     for line in output.splitlines():
         if len(line) > 0:
             container = containersMessage.containers.add()
             container.value = line
     ComminicationUtils.send(containersMessage.SerializeToString())
Ejemplo n.º 3
0
 def do(self):
     waitMessage = containerizer_pb2.Wait()
     waitMessage.ParseFromString(ComminicationUtils.receive(self.log))
     containerId = waitMessage.container_id.value
     self.log.debug("Waiting for EOL of container with ID: %s" % containerId)
     pidFilePath = "%s%s.pid" % (self.config['tmp_path'], containerId)
     self.log.debug("EX PID file: %s" % pidFilePath)
     self.waitPID(int(PIDLockFile(pidFilePath).read_pid()))
     DestroyArgument.destroy_container(containerId)
     terminationMessage = containerizer_pb2.Termination()
     terminationMessage.killed = False
     terminationMessage.message = ""
     terminationMessage.status = 0
     ComminicationUtils.send(terminationMessage.SerializeToString())
Ejemplo n.º 4
0
    def do(self):
        launchMessage = containerizer_pb2.Launch()
        launchMessage.ParseFromString(ComminicationUtils.receive(self.log))
        containerId = launchMessage.container_id.value
        self.log.debug(
            "Launching container with ID: %s (Task ID: %s)" % (containerId, launchMessage.task_info.task_id.value))
        if launchMessage.task_info.container.docker.image == '':
            self.log.error("You need to specify image")
            return
        self.log.debug("lxc-clone")
        cloneCommand = ['lxc-clone', '-s', launchMessage.task_info.container.docker.image, containerId]
        self.log.debug(cloneCommand)
        subprocess.check_call(cloneCommand)
        self.log.debug("Preparing LXC config")
        self.prepareLxcConfig(launchMessage)
        self.log.debug("lxc-start")
        startCommand = ['lxc-start', '-d', '-n', containerId, '--logfile', '/dev/stderr']
        self.log.debug(startCommand)
        subprocess.check_call(startCommand)
        self.log.debug("lxc-wait")
        waitCommand = ['lxc-wait', '-n', containerId, '--state', 'RUNNING']
        self.log.debug(waitCommand)
        subprocess.check_call(waitCommand)
        self.log.debug("lxc-attach")
        self.log.debug(os.environ)
        if not os.path.exists(self.config['tmp_path']):
            os.mkdir(self.config['tmp_path'])
        context = daemon.DaemonContext(pidfile=PIDLockFile(self.config['tmp_path'] + containerId + ".pid"))

        with context:
            self.launchExecutor(containerId, self.config['executor'], launchMessage.directory)
        return
Ejemplo n.º 5
0
 def do(self):
     destroyMessage = containerizer_pb2.Destroy()
     destroyMessage.ParseFromString(ComminicationUtils.receive(self.log))
     self.destroy_container(destroyMessage.container_id.value)