From 70baaf8cf227d70288c3e310f0ab6b344e66d4c0 Mon Sep 17 00:00:00 2001 From: peusterm Date: Wed, 6 Jan 2016 17:14:40 +0100 Subject: [PATCH] added basic start/stop functionality for containers. connection setup etc. still missing. --- emuvim/api/zerorpcapi.py | 6 +++++- emuvim/cli/__main__.py | 2 +- emuvim/dcemulator/node.py | 14 +++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/emuvim/api/zerorpcapi.py b/emuvim/api/zerorpcapi.py index 88d7740..7be3f60 100644 --- a/emuvim/api/zerorpcapi.py +++ b/emuvim/api/zerorpcapi.py @@ -44,10 +44,14 @@ class MultiDatacenterApi(object): def compute_action_start(self, dc_name, compute_name): # TODO return UUID / IP ? - logging.info("compute start") + logging.debug("RPC CALL: compute start") + if dc_name in self.dcs: + self.dcs[dc_name].addCompute(compute_name) def compute_action_stop(self, dc_name, compute_name): logging.info("compute stop") + if dc_name in self.dcs: + self.dcs[dc_name].removeCompute(compute_name) def compute_list(self): pass diff --git a/emuvim/cli/__main__.py b/emuvim/cli/__main__.py index 771049b..95ce01e 100644 --- a/emuvim/cli/__main__.py +++ b/emuvim/cli/__main__.py @@ -15,7 +15,7 @@ def main(): # do some API tests print c.compute_action_start("dc2", "my_new_container1") - time.sleep(5) + time.sleep(10) print c.compute_action_stop("dc2", "my_new_container1") diff --git a/emuvim/dcemulator/node.py b/emuvim/dcemulator/node.py index b095e19..3111735 100644 --- a/emuvim/dcemulator/node.py +++ b/emuvim/dcemulator/node.py @@ -39,8 +39,12 @@ class Datacenter(object): def start(self): pass - def addCompute(self): - pass - - def removeCompute(self): - pass + def addCompute(self, name): + #TODO remove mnet shortcut to have a clean API + #TODO connect container to DC's swtich + self.net.mnet.addDocker("%s.%s" % (self.name, name), dimage="ubuntu") + + def removeCompute(self, name): + #TODO remove mnet shortcut to have a clean API + #TODO disconnect container to DC's swtich + self.net.mnet.removeDocker("%s.%s" % (self.name, name)) -- 2.25.1