Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
47cf2052
Commit
47cf2052
authored
Nov 15, 2012
by
Christos Stavrakakis
Browse files
Fix HTTP code when adding NIC to inactive network
parent
8d4176e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/actions.py
View file @
47cf2052
...
...
@@ -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
,
OverLimit
)
from
synnefo.api.util
import
(
random_password
,
get_vm
,
get_nic_from_index
,
get_network_free_address
)
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):
try
:
address
=
get_network_free_address
(
net
)
except
EmptyPool
:
raise
ServiceUnavailable
(
'Network is full'
)
raise
OverLimit
(
'Network is full'
)
log
.
info
(
"Connecting VM %s to Network %s(%s)"
,
vm
,
net
,
address
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment