#
# @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__)
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
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)
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"
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)
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
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')