Change default netpartition behavior in nuage plugin
Allows the nuage plugin handle the case where default netpartition already exists on the VSD (back-end controller) Change-Id: Ia5785c1c313cf30b8bad6cda1d0e9819784e06d8 Closes-Bug: #1319892
This commit is contained in:
parent
01c45aecfb
commit
3190e5b672
@ -806,14 +806,23 @@ class NuagePlugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return self._make_net_partition_dict(net_partitioninst)
|
return self._make_net_partition_dict(net_partitioninst)
|
||||||
|
|
||||||
def _create_default_net_partition(self, default_net_part):
|
def _create_default_net_partition(self, default_net_part):
|
||||||
self.nuageclient.check_del_def_net_partition(default_net_part)
|
def_netpart = self.nuageclient.get_def_netpartition_data(
|
||||||
|
default_net_part)
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
net_partition = nuagedb.get_net_partition_by_name(session,
|
if def_netpart:
|
||||||
default_net_part)
|
net_partition = nuagedb.get_net_partition_by_name(
|
||||||
if net_partition:
|
session, default_net_part)
|
||||||
with session.begin(subtransactions=True):
|
with session.begin(subtransactions=True):
|
||||||
nuagedb.delete_net_partition(session, net_partition)
|
if net_partition:
|
||||||
self._create_net_partition(session, default_net_part)
|
nuagedb.delete_net_partition(session, net_partition)
|
||||||
|
net_part = nuagedb.add_net_partition(session,
|
||||||
|
def_netpart['np_id'],
|
||||||
|
def_netpart['l3dom_tid'],
|
||||||
|
def_netpart['l2dom_tid'],
|
||||||
|
default_net_part)
|
||||||
|
return self._make_net_partition_dict(net_part)
|
||||||
|
else:
|
||||||
|
return self._create_net_partition(session, default_net_part)
|
||||||
|
|
||||||
def create_net_partition(self, context, net_partition):
|
def create_net_partition(self, context, net_partition):
|
||||||
ent = net_partition['net_partition']
|
ent = net_partition['net_partition']
|
||||||
|
@ -72,6 +72,15 @@ class FakeNuageClient(object):
|
|||||||
}
|
}
|
||||||
return fake_net_partition
|
return fake_net_partition
|
||||||
|
|
||||||
|
def get_def_netpartition_data(self, default_net_part):
|
||||||
|
if default_net_part == 'default_test_np':
|
||||||
|
fake_defnetpart_data = {
|
||||||
|
'np_id': uuidutils.generate_uuid(),
|
||||||
|
'l3dom_tid': uuidutils.generate_uuid(),
|
||||||
|
'l2dom_tid': uuidutils.generate_uuid(),
|
||||||
|
}
|
||||||
|
return fake_defnetpart_data
|
||||||
|
|
||||||
def delete_net_partition(self, id, l3dom_id=None, l2dom_id=None):
|
def delete_net_partition(self, id, l3dom_id=None, l2dom_id=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import contextlib
|
|||||||
import uuid
|
import uuid
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
|
from neutron import manager
|
||||||
from neutron.plugins.nuage.extensions import netpartition as netpart_ext
|
from neutron.plugins.nuage.extensions import netpartition as netpart_ext
|
||||||
from neutron.tests.unit.nuage import test_nuage_plugin
|
from neutron.tests.unit.nuage import test_nuage_plugin
|
||||||
from neutron.tests.unit import test_extensions
|
from neutron.tests.unit import test_extensions
|
||||||
@ -89,3 +90,11 @@ class NetPartitionTestCase(test_nuage_plugin.NuagePluginV2TestCase):
|
|||||||
res = self.deserialize(self.fmt, req.get_response(self.ext_api))
|
res = self.deserialize(self.fmt, req.get_response(self.ext_api))
|
||||||
self.assertEqual(res['net_partition']['name'],
|
self.assertEqual(res['net_partition']['name'],
|
||||||
npart['net_partition']['name'])
|
npart['net_partition']['name'])
|
||||||
|
|
||||||
|
def test_create_existing_default_netpartition(self):
|
||||||
|
name = 'default_test_np'
|
||||||
|
netpart1 = self._make_netpartition(self.fmt, name)
|
||||||
|
nuage_plugin = manager.NeutronManager.get_plugin()
|
||||||
|
netpart2 = nuage_plugin._create_default_net_partition(name)
|
||||||
|
self.assertEqual(netpart1['net_partition']['name'],
|
||||||
|
netpart2['name'])
|
||||||
|
Loading…
Reference in New Issue
Block a user