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