Commit 38730188 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Setting for max NICs per Ganeti instance

Add new 'GANETI_MAX_NICS_PER_INSTANCE' setting which represents the
maximum number of NICs that is allowed for each Ganeti instance. The
value of this setting must be less than 'max:nic-count` option of
Ganeti's ipolicy.
parent 4595cd72
......@@ -41,3 +41,7 @@
#BACKEND_ALLOCATOR_MODULE = "synnefo.logic.allocators.default_allocator"
## Refresh backend statistics timeout, in minutes, used in backend allocation
#BACKEND_REFRESH_MIN = 15
#
## Maximum number of NICs per Ganeti instance. This value must be less or equal
## than 'max:nic-count' option of Ganeti's ipolicy.
#GANETI_MAX_NICS_PER_INSTANCE = 8
......@@ -41,3 +41,7 @@ GANETI_USE_OPPORTUNISTIC_LOCKING = True
BACKEND_ALLOCATOR_MODULE = "synnefo.logic.allocators.default_allocator"
# Refresh backend statistics timeout, in minutes, used in backend allocation
BACKEND_REFRESH_MIN = 15
# Maximum number of NICs per Ganeti instance. This value must be less or equal
# than 'max:nic-count' option of Ganeti's ipolicy.
GANETI_MAX_NICS_PER_INSTANCE = 8
......@@ -422,6 +422,12 @@ def rename(server, new_name):
@transaction.commit_on_success
def create_port(*args, **kwargs):
vm = kwargs.get("machine", None)
if vm is None and len(args) >= 3:
vm = args[2]
if vm is not None:
if vm.nics.count() == settings.GANETI_MAX_NICS_PER_INSTANCE:
raise faults.BadRequest("Maximum ports per server limit reached")
return _create_port(*args, **kwargs)
......@@ -551,7 +557,10 @@ def create_instance_ports(user_id, networks=None):
else:
# Else just connect to the networks that the user defined
ports = create_ports_for_request(user_id, networks)
return forced_ports + ports
total_ports = forced_ports + ports
if len(total_ports) > settings.GANETI_MAX_NICS_PER_INSTANCE:
raise faults.BadRequest("Maximum ports per server limit reached")
return total_ports
def create_ports_for_setting(user_id, category):
......
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