Commit c47a3d80 authored by Dionysis Grigoropoulos's avatar Dionysis Grigoropoulos
Browse files

cyclades: Fix a bug in network and subnet create

* Fix a bug if the user specified no allocation pools
* Fix a wrong error message in logic/subnets.py
parent 5b64e12e
......@@ -135,7 +135,9 @@ class Command(BaseCommand):
help="IP allocation pools to be used for assigning IPs to"
" VMs. Can be used multiple times. Syntax: \n"
"192.168.42.220,192.168.42.240. Starting IP must proceed "
"ending IP."),
"ending IP. If no allocation pools are given, the whole "
"subnet range is used, excluding the gateway IP, the "
"broadcast address and the network address"),
)
@convert_api_faults
......@@ -183,12 +185,15 @@ class Command(BaseCommand):
floating_ip_pool=floating_ip_pool)
if subnet is not None:
alloc = subnets.parse_allocation_pools(allocation_pools)
alloc = None
if allocation_pools is not None:
alloc = subnets.parse_allocation_pools(allocation_pools)
alloc.sort()
name = "IPv4 Subnet of Network %s" % network.id
subnets.create_subnet(network.id, cidr=subnet, name=name,
ipversion=4, gateway=gateway, dhcp=dhcp,
user_id=userid,
allocation_pools=sorted(alloc))
allocation_pools=alloc)
if subnet6 is not None:
name = "IPv6 Subnet of Network %s" % network.id
......
......@@ -63,7 +63,10 @@ class Command(BaseCommand):
help="IP allocation pools to be used for assigning IPs to"
" VMs. Can be used multiple times. Syntax: \n"
"192.168.42.220,192.168.42.240. Starting IP must proceed "
"ending IP."),
"ending IP.20,192.168.42.240. Starting IP must proceed "
"ending IP. If no allocation pools are given, the whole "
"subnet range is used, excluding the gateway IP, the "
"broadcast address and the network address"),
make_option("--name", dest="name",
help="An arbitrary string for naming the subnet."),
make_option("--ip-version", dest="ipversion", choices=["4", "6"],
......@@ -110,12 +113,15 @@ class Command(BaseCommand):
dns = options["dns"]
host_routes = options["host_routes"]
alloc = subnets.parse_allocation_pools(allocation_pools)
alloc = None
if allocation_pools is not None:
alloc = subnets.parse_allocation_pools(allocation_pools)
alloc.sort()
sub = subnets.create_subnet(name=name,
network_id=network_id,
cidr=cidr,
allocation_pools=sorted(alloc),
allocation_pools=alloc,
gateway=gateway,
ipversion=ipversion,
dhcp=dhcp,
......
......@@ -293,6 +293,6 @@ def parse_allocation_pools(allocation_pools):
alloc.append([ipaddr.IPv4Address(start),
ipaddr.IPv4Address(end)])
except ValueError:
raise CommandError("Malformed IPv4 address")
raise faults.BadRequest("Malformed IPv4 address")
return alloc
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