From: peusterm Date: Wed, 13 Jan 2016 12:50:39 +0000 (+0100) Subject: improved API input validation X-Git-Tag: v3.1~185^2~17 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=9165ef919cc37356094c9c139ae8a3d981eadb9b;p=osm%2Fvim-emu.git improved API input validation --- 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))