From bd44f4aedca9d48d150939cd76d7cefe7e386aa2 Mon Sep 17 00:00:00 2001 From: peusterm Date: Wed, 13 Jan 2016 14:53:30 +0100 Subject: [PATCH] improved CLI --- emuvim/api/zerorpcapi.py | 8 ++++---- emuvim/dcemulator/net.py | 9 +++++++++ emuvim/dcemulator/node.py | 2 +- emuvim/example_topology.py | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/emuvim/api/zerorpcapi.py b/emuvim/api/zerorpcapi.py index ecf822c..c6b9c70 100644 --- a/emuvim/api/zerorpcapi.py +++ b/emuvim/api/zerorpcapi.py @@ -7,7 +7,7 @@ import logging import threading import zerorpc -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.INFO) class ZeroRpcApiEndpoint(object): @@ -66,7 +66,7 @@ class MultiDatacenterApi(object): return ex.message def compute_action_stop(self, dc_name, compute_name): - logging.info("RPC CALL: compute stop") + logging.debug("RPC CALL: compute stop") try: return self.dcs.get(dc_name).stopCompute(compute_name) except Exception as ex: @@ -74,7 +74,7 @@ class MultiDatacenterApi(object): return ex.message def compute_list(self, dc_name): - logging.info("RPC CALL: compute list") + logging.debug("RPC CALL: compute list") try: if dc_name is None: # return list with all compute nodes in all DCs @@ -92,7 +92,7 @@ class MultiDatacenterApi(object): return ex.message def compute_status(self, dc_name, compute_name): - logging.info("RPC CALL: compute status") + logging.debug("RPC CALL: compute status") try: return self.dcs.get( dc_name).containers.get(compute_name).getStatus() diff --git a/emuvim/dcemulator/net.py b/emuvim/dcemulator/net.py index 1762e0b..83ac619 100644 --- a/emuvim/dcemulator/net.py +++ b/emuvim/dcemulator/net.py @@ -114,6 +114,15 @@ class DCNetwork(object): def getNextIp(self): return self.mnet.getNextIp() + def getAllContainers(self): + """ + Returns a list with all containers within all data centers. + """ + all_containers = [] + for dc in self.dcs.itervalues(): + all_containers += dc.listCompute() + return all_containers + def start(self): # start for dc in self.dcs.itervalues(): diff --git a/emuvim/dcemulator/node.py b/emuvim/dcemulator/node.py index 0d96033..de64d69 100644 --- a/emuvim/dcemulator/node.py +++ b/emuvim/dcemulator/node.py @@ -100,7 +100,7 @@ class Datacenter(object): """ assert name is not None # no duplications - if name in self.containers: + if name in [c.name for c in self.net.getAllContainers()]: raise Exception("Container with name %s already exists." % name) # set default parameter if image is None: diff --git a/emuvim/example_topology.py b/emuvim/example_topology.py index 109808c..0117fa7 100644 --- a/emuvim/example_topology.py +++ b/emuvim/example_topology.py @@ -20,7 +20,7 @@ import logging from dcemulator.net import DCNetwork from api.zerorpcapi import ZeroRpcApiEndpoint -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.INFO) def create_topology1(): -- 2.25.1