]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Implements provider network support in PLUMgrid plugin
authorEdgar Magana <emagana@gmail.com>
Thu, 5 Dec 2013 23:42:04 +0000 (15:42 -0800)
committerEdgar Magana <emagana@gmail.com>
Thu, 20 Feb 2014 07:23:17 +0000 (23:23 -0800)
Includes the provider network extension in PLUMgrid plugin
PLUMgrid drivers are updated with the new extension data
Unit tests are added

Change-Id: Ia7fc011c04d143bdb7fd8f67768a2076be8c5264
Implements: blueprint provider-network-plumgrid

neutron/plugins/plumgrid/drivers/fake_plumlib.py
neutron/plugins/plumgrid/drivers/plumlib.py
neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py
neutron/tests/unit/plumgrid/test_plumgrid_plugin.py

index 28f32977c2216873f592aaf01d57401133cbefc3..a0a01023d68b4ad3b84ae2c780d006b921e0d477 100644 (file)
@@ -15,7 +15,7 @@
 #
 # @author: Edgar Magana, emagana@plumgrid.com, PLUMgrid, Inc.
 
-
+from neutron.extensions import providernet as provider
 from neutron.openstack.common import log as logging
 
 LOG = logging.getLogger(__name__)
@@ -38,8 +38,13 @@ class Plumlib():
                  director_plumgrid + ':' + director_port)
         pass
 
-    def create_network(self, tenant_id, net_db):
-        pass
+    def create_network(self, tenant_id, net_db, network):
+        net_db["network"] = {}
+        for key in (provider.NETWORK_TYPE,
+                    provider.PHYSICAL_NETWORK,
+                    provider.SEGMENTATION_ID):
+            net_db["network"][key] = network["network"][key]
+        return net_db
 
     def update_network(self, tenant_id, net_id):
         pass
index 18c8a50d5362cda80ba0722b56bf3c6f14e34f79..7a6c98c1907f0a14d49c0b97f0d6cd435571dfe3 100644 (file)
@@ -45,8 +45,8 @@ class Plumlib(object):
                                        director_admin,
                                        director_password)
 
-    def create_network(self, tenant_id, net_db):
-        self.plumlib.create_network(tenant_id, net_db)
+    def create_network(self, tenant_id, net_db, network):
+        self.plumlib.create_network(tenant_id, net_db, network)
 
     def update_network(self, tenant_id, net_id):
         self.plumlib.update_network(tenant_id, net_id)
index fb389c434b48617f7c088a4305472b6b9db5798e..70c809122aa2c07e1ebfe24976a3deb5f38560fb 100644 (file)
@@ -61,7 +61,7 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
                               l3_db.L3_NAT_db_mixin):
 
     supported_extension_aliases = ["external-net", "router", "binding",
-                                   "quotas"]
+                                   "quotas", "provider"]
 
     binding_view = "extension:port_binding:view"
     binding_set = "extension:port_binding:set"
@@ -112,7 +112,7 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
 
             try:
                 LOG.debug(_('PLUMgrid Library: create_network() called'))
-                self._plumlib.create_network(tenant_id, net_db)
+                self._plumlib.create_network(tenant_id, net_db, network)
 
             except Exception as err_message:
                 raise plum_excep.PLUMgridException(err_msg=err_message)
index 92f020b3de8684c991556cddfbe7fbe8cdc323ad..6cc39ce793e3312ca2bf7f96919db8c7c4a2ba0c 100644 (file)
@@ -22,6 +22,7 @@ Test cases for  Neutron PLUMgrid Plug-in
 import mock
 
 from neutron.extensions import portbindings
+from neutron.extensions import providernet as provider
 from neutron.manager import NeutronManager
 from neutron.openstack.common import importutils
 from neutron.plugins.plumgrid.plumgrid_plugin import plumgrid_plugin
@@ -127,3 +128,23 @@ class TestPlumgridAllocationPool(PLUMgridPluginV2TestCase):
         plugin = NeutronManager.get_plugin()
         pool = plugin._allocate_pools_for_subnet(context, subnet)
         self.assertEqual(allocation_pool, pool)
+
+
+class TestPlumgridProvidernet(PLUMgridPluginV2TestCase):
+
+    def test_create_provider_network(self):
+        tenant_id = 'admin'
+        data = {'network': {'name': 'net1',
+                            'admin_state_up': True,
+                            'tenant_id': tenant_id,
+                            provider.NETWORK_TYPE: 'vlan',
+                            provider.SEGMENTATION_ID: 3333,
+                            provider.PHYSICAL_NETWORK: 'phy3333'}}
+
+        network_req = self.new_create_request('networks', data, self.fmt)
+        net = self.deserialize(self.fmt, network_req.get_response(self.api))
+        plumlib = importutils.import_object(PLUM_DRIVER)
+        plumlib.create_network(tenant_id, net, data)
+        self.assertEqual(net['network'][provider.NETWORK_TYPE], 'vlan')
+        self.assertEqual(net['network'][provider.SEGMENTATION_ID], 3333)
+        self.assertEqual(net['network'][provider.PHYSICAL_NETWORK], 'phy3333')