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
cd4c9c13
Commit
cd4c9c13
authored
Oct 30, 2013
by
Christos Stavrakakis
Browse files
cyclades: Fix default values for IP pool
Temporary commit to change default offset and size of IPPoolTable factory.
parent
5b4d7306
Changes
3
Show whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/tests/floating_ips.py
View file @
cd4c9c13
...
@@ -127,14 +127,15 @@ class FloatingIPAPITest(BaseAPITest):
...
@@ -127,14 +127,15 @@ class FloatingIPAPITest(BaseAPITest):
self
.
assertFault
(
response
,
503
,
'serviceUnavailable'
)
self
.
assertFault
(
response
,
503
,
'serviceUnavailable'
)
# Full network
# Full network
pool
=
mf
.
NetworkWithSubnetFactory
(
floating_ip_pool
=
True
,
net
=
mf
.
NetworkWithSubnetFactory
(
floating_ip_pool
=
True
,
public
=
True
,
public
=
True
,
subnet__cidr
=
"192.168.2.0/31"
,
subnet__cidr
=
"192.168.2.0/31"
,
subnet__gateway
=
"192.168.2.1"
)
subnet__gateway
=
"192.168.2.1"
,
subnet__pool__size
=
0
)
response
=
self
.
post
(
URL
,
"test_user"
,
json
.
dumps
({}),
"json"
)
response
=
self
.
post
(
URL
,
"test_user"
,
json
.
dumps
({}),
"json"
)
self
.
assertFault
(
response
,
503
,
'serviceUnavailable'
)
self
.
assertFault
(
response
,
503
,
'serviceUnavailable'
)
request
=
{
'pool'
:
pool
.
id
}
request
=
{
'pool'
:
net
.
id
}
response
=
self
.
post
(
URL
,
"test_user"
,
json
.
dumps
(
request
),
"json"
)
response
=
self
.
post
(
URL
,
"test_user"
,
json
.
dumps
(
request
),
"json"
)
self
.
assertConflict
(
response
)
self
.
assertConflict
(
response
)
...
@@ -229,14 +230,16 @@ class FloatingIPPoolsAPITest(BaseAPITest):
...
@@ -229,14 +230,16 @@ class FloatingIPPoolsAPITest(BaseAPITest):
net
=
mf
.
NetworkWithSubnetFactory
(
floating_ip_pool
=
True
,
net
=
mf
.
NetworkWithSubnetFactory
(
floating_ip_pool
=
True
,
public
=
True
,
public
=
True
,
subnet__cidr
=
"192.168.2.0/30"
,
subnet__cidr
=
"192.168.2.0/30"
,
subnet__gateway
=
"192.168.2.1"
)
subnet__gateway
=
"192.168.2.1"
,
subnet__pool__size
=
1
,
subnet__pool__offset
=
1
)
mf
.
NetworkWithSubnetFactory
(
public
=
True
,
deleted
=
True
)
mf
.
NetworkWithSubnetFactory
(
public
=
True
,
deleted
=
True
)
mf
.
NetworkWithSubnetFactory
(
public
=
False
,
deleted
=
False
)
mf
.
NetworkWithSubnetFactory
(
public
=
False
,
deleted
=
False
)
mf
.
NetworkWithSubnetFactory
(
public
=
True
,
floating_ip_pool
=
False
)
mf
.
NetworkWithSubnetFactory
(
public
=
True
,
floating_ip_pool
=
False
)
response
=
self
.
get
(
POOLS_URL
)
response
=
self
.
get
(
POOLS_URL
)
self
.
assertSuccess
(
response
)
self
.
assertSuccess
(
response
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
)[
"floating_ip_pools"
],
self
.
assertEqual
(
json
.
loads
(
response
.
content
)[
"floating_ip_pools"
],
[{
"name"
:
str
(
net
.
id
),
"size"
:
4
,
"free"
:
1
}])
[{
"name"
:
str
(
net
.
id
),
"size"
:
1
,
"free"
:
1
}])
class
FloatingIPActionsTest
(
BaseAPITest
):
class
FloatingIPActionsTest
(
BaseAPITest
):
...
...
snf-cyclades-app/synnefo/api/util.py
View file @
cd4c9c13
...
@@ -247,6 +247,7 @@ def get_port(port_id, user_id, for_update=False):
...
@@ -247,6 +247,7 @@ def get_port(port_id, user_id, for_update=False):
except
(
ValueError
,
NetworkInterface
.
DoesNotExist
):
except
(
ValueError
,
NetworkInterface
.
DoesNotExist
):
raise
faults
.
ItemNotFound
(
'Port not found.'
)
raise
faults
.
ItemNotFound
(
'Port not found.'
)
def
get_security_group
(
sg_id
):
def
get_security_group
(
sg_id
):
try
:
try
:
sg
=
SecurityGroup
.
objects
.
get
(
id
=
sg_id
)
sg
=
SecurityGroup
.
objects
.
get
(
id
=
sg_id
)
...
@@ -254,6 +255,7 @@ def get_security_group(sg_id):
...
@@ -254,6 +255,7 @@ def get_security_group(sg_id):
except
(
ValueError
,
SecurityGroup
.
DoesNotExist
):
except
(
ValueError
,
SecurityGroup
.
DoesNotExist
):
raise
faults
.
ItemNotFound
(
"Not valid security group"
)
raise
faults
.
ItemNotFound
(
"Not valid security group"
)
def
get_floating_ip_by_address
(
userid
,
address
,
for_update
=
False
):
def
get_floating_ip_by_address
(
userid
,
address
,
for_update
=
False
):
try
:
try
:
objects
=
IPAddress
.
objects
objects
=
IPAddress
.
objects
...
...
snf-cyclades-app/synnefo/db/models_factory.py
View file @
cd4c9c13
...
@@ -204,7 +204,8 @@ class IPv4SubnetFactory(SubnetFactory):
...
@@ -204,7 +204,8 @@ class IPv4SubnetFactory(SubnetFactory):
cidr
=
factory
.
Sequence
(
lambda
n
:
'192.168.{0}.0/24'
.
format
(
n
))
cidr
=
factory
.
Sequence
(
lambda
n
:
'192.168.{0}.0/24'
.
format
(
n
))
gateway
=
factory
.
LazyAttribute
(
lambda
a
:
a
.
cidr
[:
-
4
]
+
'1'
)
gateway
=
factory
.
LazyAttribute
(
lambda
a
:
a
.
cidr
[:
-
4
]
+
'1'
)
pool
=
factory
.
RelatedFactory
(
IPPoolTableFactory
,
'subnet'
,
base
=
cidr
,
pool
=
factory
.
RelatedFactory
(
IPPoolTableFactory
,
'subnet'
,
base
=
cidr
,
offset
=
10
,
size
=
5
)
offset
=
2
,
size
=
253
)
class
IPv6SubnetFactory
(
SubnetFactory
):
class
IPv6SubnetFactory
(
SubnetFactory
):
...
...
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