Network configuration update should return 400
In case of raising exception 'OutOfIPs' Nailgun should return 400 error. * Add exception catching for 'errors.OutOfIPs' in 'ProviderHandler.PUT'. * Add corresponding unit test. Change-Id: I7018621350651a351c164fe45a72001874b11e57 Partial-bug: #1513774
This commit is contained in:
parent
fe7fe7d082
commit
1d70ec7df5
|
@ -134,6 +134,12 @@ class ProviderHandler(BaseHandler):
|
|||
nm = objects.Cluster.get_network_manager(cluster)
|
||||
admin_nets = nm.get_admin_networks()
|
||||
nm.update(cluster, data)
|
||||
|
||||
try:
|
||||
network_config = self.serializer.serialize_for_cluster(cluster)
|
||||
except errors.OutOfIPs as exc:
|
||||
raise self.http(400, six.text_type(exc))
|
||||
|
||||
if admin_nets != nm.get_admin_networks():
|
||||
try:
|
||||
task = UpdateDnsmasqTaskManager().execute()
|
||||
|
@ -142,7 +148,7 @@ class ProviderHandler(BaseHandler):
|
|||
if task.status == consts.TASK_STATUSES.error:
|
||||
raise self.http(400, task.message)
|
||||
|
||||
return self.serializer.serialize_for_cluster(cluster)
|
||||
return network_config
|
||||
|
||||
|
||||
class NovaNetworkConfigurationHandler(ProviderHandler):
|
||||
|
|
|
@ -560,7 +560,7 @@ class TestNeutronNetworkConfigurationHandler(BaseIntegrationTest):
|
|||
nm.assign_vip(nodegroup, consts.NETWORKS.fuelweb_admin, 'my-vip'),
|
||||
resp.json_body['vips']['my-vip']['ipaddr'])
|
||||
|
||||
def test_not_enough_ip_addresses_return_400(self):
|
||||
def test_not_enough_ip_addresses_return_400_on_get(self):
|
||||
# restrict public network to have only 2 ip addresses
|
||||
netconfig = self.env.neutron_networks_get(self.cluster.id).json_body
|
||||
public = next((
|
||||
|
@ -597,6 +597,20 @@ class TestNeutronNetworkConfigurationHandler(BaseIntegrationTest):
|
|||
"of 'public' network",
|
||||
resp.json_body['message'])
|
||||
|
||||
def test_not_enough_ip_addresses_return_400_on_put(self):
|
||||
netconfig = self.env.neutron_networks_get(self.cluster.id).json_body
|
||||
public = next((
|
||||
net for net in netconfig['networks']
|
||||
if net['name'] == consts.NETWORKS.public))
|
||||
public['ip_ranges'] = [["172.16.0.19", "172.16.0.19"]]
|
||||
resp = self.env.neutron_networks_put(
|
||||
self.cluster.id, netconfig, expect_errors=True)
|
||||
self.assertEqual(400, resp.status_code)
|
||||
self.assertEqual(
|
||||
"Not enough free IP addresses in ranges [172.16.0.19-172.16.0.19] "
|
||||
"of 'public' network",
|
||||
resp.json_body['message'])
|
||||
|
||||
def test_assign_vip_in_correct_node_group(self):
|
||||
# prepare two nodes that are in different node groups
|
||||
self.env.create_node(
|
||||
|
|
Loading…
Reference in New Issue