Merge "Implements provider network support in PLUMgrid plugin"

This commit is contained in:
Jenkins 2014-02-27 05:48:51 +00:00 committed by Gerrit Code Review
commit c624dc3230
4 changed files with 33 additions and 7 deletions

View File

@ -15,7 +15,7 @@
# #
# @author: Edgar Magana, emagana@plumgrid.com, PLUMgrid, Inc. # @author: Edgar Magana, emagana@plumgrid.com, PLUMgrid, Inc.
from neutron.extensions import providernet as provider
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -38,8 +38,13 @@ class Plumlib():
director_plumgrid + ':' + director_port) director_plumgrid + ':' + director_port)
pass pass
def create_network(self, tenant_id, net_db): def create_network(self, tenant_id, net_db, network):
pass 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): def update_network(self, tenant_id, net_id):
pass pass

View File

@ -45,8 +45,8 @@ class Plumlib(object):
director_admin, director_admin,
director_password) director_password)
def create_network(self, tenant_id, net_db): def create_network(self, tenant_id, net_db, network):
self.plumlib.create_network(tenant_id, net_db) self.plumlib.create_network(tenant_id, net_db, network)
def update_network(self, tenant_id, net_id): def update_network(self, tenant_id, net_id):
self.plumlib.update_network(tenant_id, net_id) self.plumlib.update_network(tenant_id, net_id)

View File

@ -60,7 +60,7 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
l3_db.L3_NAT_db_mixin): l3_db.L3_NAT_db_mixin):
supported_extension_aliases = ["external-net", "router", "binding", supported_extension_aliases = ["external-net", "router", "binding",
"quotas"] "quotas", "provider"]
binding_view = "extension:port_binding:view" binding_view = "extension:port_binding:view"
binding_set = "extension:port_binding:set" binding_set = "extension:port_binding:set"
@ -109,7 +109,7 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
LOG.debug(_('PLUMgrid Library: create_network() called')) 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: except Exception as err_message:
raise plum_excep.PLUMgridException(err_msg=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 import mock
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.extensions import providernet as provider
from neutron.manager import NeutronManager from neutron.manager import NeutronManager
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutron.plugins.plumgrid.plumgrid_plugin import plumgrid_plugin from neutron.plugins.plumgrid.plumgrid_plugin import plumgrid_plugin
@ -127,3 +128,23 @@ class TestPlumgridAllocationPool(PLUMgridPluginV2TestCase):
plugin = NeutronManager.get_plugin() plugin = NeutronManager.get_plugin()
pool = plugin._allocate_pools_for_subnet(context, subnet) pool = plugin._allocate_pools_for_subnet(context, subnet)
self.assertEqual(allocation_pool, pool) 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')