Implements provider network support in PLUMgrid plugin

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
This commit is contained in:
Edgar Magana 2013-12-05 15:42:04 -08:00
parent 7fb2d579ae
commit 9d226b09c2
4 changed files with 33 additions and 7 deletions

View 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

View 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)

View 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)

View 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')