Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
[1254818] Neutron IP ranges check error
Browse files Browse the repository at this point in the history
"CIDR size for network 'public' is less than required". Fixed.
Now public network_size is calculated in Nailgun.

Closes-Bug: #1254818

Change-Id: Ic70eaeccdcf314b2823622b8d6b28ea409e93f0b
  • Loading branch information
AlexeyKasatkin committed Dec 5, 2013
1 parent 71bb3cb commit 91630e8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions nailgun/nailgun/api/models/neutron.py
Expand Up @@ -75,6 +75,7 @@ def update_cidr_from_gw_mask(cls, ng_db, ng):
'netmask': ng['netmask']})
if cidr:
ng_db.cidr = str(cidr)
ng_db.network_size = cidr.size


class NeutronConfig(Base):
Expand Down
3 changes: 2 additions & 1 deletion nailgun/nailgun/network/checker.py
Expand Up @@ -254,7 +254,8 @@ def neutron_check_segmentation_ids(self):
def neutron_check_network_group_sizes(self):
# check network groups sizes
for ng in self.networks:
if ng['name'] != 'private':
# network_size is calculated in case of public
if ng['name'] not in ('private', 'public'):
# ng['amount'] is always equal 1 for Neutron
if netaddr.IPNetwork(ng['cidr']).size < ng['network_size']:
self.err_msgs.append(
Expand Down
26 changes: 26 additions & 0 deletions nailgun/nailgun/test/integration/test_network_validation.py
Expand Up @@ -182,6 +182,11 @@ def setUp(self):
resp = self.env.neutron_networks_get(self.cluster.id)
self.nets = json.loads(resp.body)

def find_net_by_name(self, name):
for net in self.nets['networks']:
if net['name'] == name:
return net

def test_network_checking(self):
resp = self.env.neutron_networks_put(self.cluster.id, self.nets)
self.assertEquals(resp.status, 202)
Expand Down Expand Up @@ -390,6 +395,27 @@ def test_network_checking_fails_if_network_cidr_too_small(self):
"is less than required"
)

def test_network_checking_public_network_cidr_became_smaller(self):
self.assertEquals(self.find_net_by_name('public')['network_size'], 256)

self.find_net_by_name('public')['netmask'] = '255.255.255.128'
self.find_net_by_name('public')['gateway'] = '172.16.0.1'
self.find_net_by_name('public')['ip_ranges'] = [['172.16.0.2',
'172.16.0.77']]
virt_nets = self.nets['neutron_parameters']['predefined_networks']
virt_nets['net04_ext']['L3']['floating'] = ['172.16.0.99',
'172.16.0.111']

resp = self.env.neutron_networks_put(self.cluster.id, self.nets)
self.assertEquals(resp.status, 202)
task = json.loads(resp.body)
self.assertEquals(task['status'], 'ready')
resp = self.env.neutron_networks_get(self.cluster.id)
self.nets = json.loads(resp.body)
self.assertEquals(self.find_net_by_name('public')['cidr'],
'172.16.0.0/25')
self.assertEquals(self.find_net_by_name('public')['network_size'], 128)

def test_network_checking_fails_on_network_vlan_match(self):
for n in self.nets['networks']:
if n['name'] in ('management', 'storage'):
Expand Down

0 comments on commit 91630e8

Please sign in to comment.