Commit 28e87d74 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Fix bug in network link validation

parent e069a2b1
......@@ -91,6 +91,12 @@ def create(userid, name, flavor, link=None, mac_prefix=None, mode=None,
validate_mac(mac_prefix + "0:00:00:00")
# Check that given link is unique!
if (link is not None and flavor == "IP_LESS_ROUTED" and
Network.objects.filter(deleted=False, mode=mode, link=link).exists()):
msg = "Link '%s' is already used." % link
raise faults.BadRequest(msg)
network = Network.objects.create(
name=name,
userid=userid,
......@@ -110,11 +116,6 @@ def create(userid, name, flavor, link=None, mac_prefix=None, mode=None,
network.link = "%slink-%d" % (settings.BACKEND_PREFIX_ID, network.id)
network.save()
if (flavor == "IP_LESS_ROUTED" and
Network.objects.filter(deleted=False, mode=mode, link=link).exists()):
msg = "Link '%s' is already used." % link
raise faults.BadRequest(msg)
# Issue commission to Quotaholder and accept it since at the end of
# this transaction the Network object will be created in the DB.
# Note: the following call does a commit!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment