Commit 47cf2052 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Fix HTTP code when adding NIC to inactive network

parent 8d4176e5
...@@ -41,7 +41,8 @@ from django.template.loader import render_to_string ...@@ -41,7 +41,8 @@ from django.template.loader import render_to_string
from django.utils import simplejson as json from django.utils import simplejson as json
from synnefo.api.faults import (BadRequest, ServiceUnavailable, from synnefo.api.faults import (BadRequest, ServiceUnavailable,
ItemNotFound, BuildInProgress) ItemNotFound, BuildInProgress,
OverLimit)
from synnefo.api.util import (random_password, get_vm, get_nic_from_index, from synnefo.api.util import (random_password, get_vm, get_nic_from_index,
get_network_free_address) get_network_free_address)
from synnefo.db.models import NetworkInterface, Network from synnefo.db.models import NetworkInterface, Network
...@@ -313,12 +314,13 @@ def add(request, net, args): ...@@ -313,12 +314,13 @@ def add(request, net, args):
# serviceUnavailable (503), # serviceUnavailable (503),
# unauthorized (401), # unauthorized (401),
# badRequest (400), # badRequest (400),
# buildInProgress (409),
# badMediaType(415), # badMediaType(415),
# itemNotFound (404), # itemNotFound (404),
# overLimit (413) # overLimit (413)
if net.state != 'ACTIVE': if net.state != 'ACTIVE':
raise ServiceUnavailable('Network not active yet') raise BuildInProgress('Network not active yet')
server_id = args.get('serverRef', None) server_id = args.get('serverRef', None)
if not server_id: if not server_id:
...@@ -332,7 +334,7 @@ def add(request, net, args): ...@@ -332,7 +334,7 @@ def add(request, net, args):
try: try:
address = get_network_free_address(net) address = get_network_free_address(net)
except EmptyPool: except EmptyPool:
raise ServiceUnavailable('Network is full') raise OverLimit('Network is full')
log.info("Connecting VM %s to Network %s(%s)", vm, net, address) log.info("Connecting VM %s to Network %s(%s)", vm, net, address)
......
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