From 4b81bbecc2f40c295076f52ce428839c64f5a54f Mon Sep 17 00:00:00 2001 From: Dhanashree Gosavi Date: Tue, 4 Feb 2014 10:07:39 -0800 Subject: [PATCH] Add and update subnet properties in Cisco N1kv plugin Add dns nameservers and dhcp info in subnet create. Update subnet properties. Change-Id: I70e3f0261f6ba5433bbf08d33e2a34cdbb20fed2 Closes-Bug: #1276876 --- neutron/plugins/cisco/n1kv/n1kv_client.py | 14 ++++++++++++++ neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py | 13 +++++++++++-- neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py | 6 ++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/neutron/plugins/cisco/n1kv/n1kv_client.py b/neutron/plugins/cisco/n1kv/n1kv_client.py index 77ecc1e1a..7d38d5862 100644 --- a/neutron/plugins/cisco/n1kv/n1kv_client.py +++ b/neutron/plugins/cisco/n1kv/n1kv_client.py @@ -339,11 +339,25 @@ class Client(object): 'ipAddressSubnet': netmask, 'description': subnet['name'], 'gateway': subnet['gateway_ip'], + 'dhcp': subnet['enable_dhcp'], + 'dnsServersList': subnet['dns_nameservers'], 'networkAddress': network_address, 'tenantId': subnet['tenant_id']} return self._post(self.ip_pool_path % subnet['id'], body=body) + def update_ip_pool(self, subnet): + """ + Update an ip-pool on the VSM. + + :param subnet: subnet dictionary + """ + body = {'description': subnet['name'], + 'dhcp': subnet['enable_dhcp'], + 'dnsServersList': subnet['dns_nameservers']} + return self._post(self.ip_pool_path % subnet['id'], + body=body) + def delete_ip_pool(self, subnet_id): """ Delete an ip-pool on the VSM. diff --git a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py index 6c5cf9554..3c7acb822 100644 --- a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py +++ b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py @@ -818,8 +818,16 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2, LOG.debug(_('_send_create_subnet_request: %s'), subnet['id']) n1kvclient = n1kv_client.Client() n1kvclient.create_ip_pool(subnet) - body = {'ipPool': subnet['id']} - n1kvclient.update_network_segment(subnet['network_id'], body=body) + + def _send_update_subnet_request(self, subnet): + """ + Send update subnet request to VSM. + + :param subnet: subnet dictionary + """ + LOG.debug(_('_send_update_subnet_request: %s'), subnet['name']) + n1kvclient = n1kv_client.Client() + n1kvclient.update_ip_pool(subnet) def _send_delete_subnet_request(self, context, subnet): """ @@ -1298,6 +1306,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2, sub = super(N1kvNeutronPluginV2, self).update_subnet(context, id, subnet) + self._send_update_subnet_request(sub) return sub def delete_subnet(self, context, id): diff --git a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py index 125638019..b698e09d8 100644 --- a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py +++ b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py @@ -379,6 +379,12 @@ class TestN1kvNetworks(test_plugin.TestNetworksV2, self.assertEqual(res.status_int, 400) +class TestN1kvSubnets(test_plugin.TestSubnetsV2, + N1kvPluginTestCase): + + pass + + class TestN1kvNonDbTest(base.BaseTestCase): """ -- 2.45.2