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

cyclades: Fix default values for IP pool

Temporary commit to change default offset and size of IPPoolTable
factory.
parent 5b4d7306
......@@ -127,14 +127,15 @@ class FloatingIPAPITest(BaseAPITest):
self.assertFault(response, 503, 'serviceUnavailable')
# Full network
pool = mf.NetworkWithSubnetFactory(floating_ip_pool=True,
public=True,
subnet__cidr="192.168.2.0/31",
subnet__gateway="192.168.2.1")
net = mf.NetworkWithSubnetFactory(floating_ip_pool=True,
public=True,
subnet__cidr="192.168.2.0/31",
subnet__gateway="192.168.2.1",
subnet__pool__size=0)
response = self.post(URL, "test_user", json.dumps({}), "json")
self.assertFault(response, 503, 'serviceUnavailable')
request = {'pool': pool.id}
request = {'pool': net.id}
response = self.post(URL, "test_user", json.dumps(request), "json")
self.assertConflict(response)
......@@ -229,14 +230,16 @@ class FloatingIPPoolsAPITest(BaseAPITest):
net = mf.NetworkWithSubnetFactory(floating_ip_pool=True,
public=True,
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=False, deleted=False)
mf.NetworkWithSubnetFactory(public=True, floating_ip_pool=False)
response = self.get(POOLS_URL)
self.assertSuccess(response)
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):
......
......@@ -247,6 +247,7 @@ def get_port(port_id, user_id, for_update=False):
except (ValueError, NetworkInterface.DoesNotExist):
raise faults.ItemNotFound('Port not found.')
def get_security_group(sg_id):
try:
sg = SecurityGroup.objects.get(id=sg_id)
......@@ -254,6 +255,7 @@ def get_security_group(sg_id):
except (ValueError, SecurityGroup.DoesNotExist):
raise faults.ItemNotFound("Not valid security group")
def get_floating_ip_by_address(userid, address, for_update=False):
try:
objects = IPAddress.objects
......@@ -271,7 +273,7 @@ def get_floating_ip_by_id(userid, floating_ip_id, for_update=False):
if for_update:
objects = objects.select_for_update()
return objects.get(id=floating_ip_id, floating_ip=True,
userid=userid, deleted=False)
userid=userid, deleted=False)
except IPAddress.DoesNotExist:
raise faults.ItemNotFound("Floating IP %s does not exist." %
floating_ip_id)
......
......@@ -204,7 +204,8 @@ class IPv4SubnetFactory(SubnetFactory):
cidr = factory.Sequence(lambda n: '192.168.{0}.0/24'.format(n))
gateway = factory.LazyAttribute(lambda a: a.cidr[:-4] + '1')
pool = factory.RelatedFactory(IPPoolTableFactory, 'subnet', base=cidr,
offset=10, size=5)
offset=2,
size=253)
class IPv6SubnetFactory(SubnetFactory):
......
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