From 9165ef919cc37356094c9c139ae8a3d981eadb9b Mon Sep 17 00:00:00 2001 From: peusterm Date: Wed, 13 Jan 2016 13:50:39 +0100 Subject: [PATCH] improved API input validation --- emuvim/dcemulator/node.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/emuvim/dcemulator/node.py b/emuvim/dcemulator/node.py index def1e2d..0d96033 100644 --- a/emuvim/dcemulator/node.py +++ b/emuvim/dcemulator/node.py @@ -99,6 +99,9 @@ class Datacenter(object): a single container can be connected. """ assert name is not None + # no duplications + if name in self.containers: + raise Exception("Container with name %s already exists." % name) # set default parameter if image is None: image = "ubuntu" @@ -116,7 +119,9 @@ class Datacenter(object): """ Stop and remove a container from this data center. """ - assert name in self.containers + assert name is not None + if name not in self.containers: + raise Exception("Container with name %s not found." % name) self.net.removeLink( link=None, node1=self.containers[name], node2=self.switch) self.net.removeDocker("%s" % (name)) -- 2.25.1