Commit 743b4fd9 authored by Christos Stavrakakis's avatar Christos Stavrakakis

Do not allow creation of more than one pools

Do not allow creation of more than one Bridge or MacPrefix pool, since
we can not handle them yet.
parent 5b7e28a1
......@@ -682,7 +682,7 @@ class PoolTable(models.Model):
@classmethod
def get_pool(cls):
try:
pool_row = cls.objects.select_for_update().all()[0]
pool_row = cls.objects.select_for_update().get()
return pool_row.pool
except IndexError:
raise pools.EmptyPool
......
......@@ -71,6 +71,9 @@ class Command(BaseCommand):
pool_table = pool_table_from_type(type_)
if pool_table.objects.exists():
raise CommandError("Pool of type %s already exists" % type_)
pool_table.objects.create(available_map="",
reserved_map="",
size=size,
......
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