]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Nuage core plugin decomposition
authorronak <ronak.malav.shah@gmail.com>
Sat, 14 Feb 2015 00:11:02 +0000 (16:11 -0800)
committerronak <ronak.malav.shah@gmail.com>
Mon, 23 Feb 2015 19:25:54 +0000 (11:25 -0800)
Taking out Nuage's core plugin out of tree and putting
it at nuage's github repository.
https://github.com/nuage-networks/nuage-openstack-neutron

Change-Id: I6d02df85c7a2c307ad11442d0afdd50c64210af4
Partially-implements: blueprint core-vendor-decomposition
Closes-bug: #1422930

18 files changed:
neutron/plugins/ml2/drivers/mech_nuage/driver.py
neutron/plugins/nuage/common/__init__.py [deleted file]
neutron/plugins/nuage/common/config.py [deleted file]
neutron/plugins/nuage/common/constants.py [deleted file]
neutron/plugins/nuage/common/exceptions.py [deleted file]
neutron/plugins/nuage/extensions/__init__.py [deleted file]
neutron/plugins/nuage/extensions/netpartition.py [deleted file]
neutron/plugins/nuage/extensions/nuage_router.py [deleted file]
neutron/plugins/nuage/extensions/nuage_subnet.py [deleted file]
neutron/plugins/nuage/nuagedb.py [deleted file]
neutron/plugins/nuage/plugin.py
neutron/plugins/nuage/syncmanager.py [deleted file]
neutron/tests/unit/ml2/drivers/nuage/__init__.py [deleted file]
neutron/tests/unit/ml2/drivers/nuage/test_nuage_mechanism_driver.py [deleted file]
neutron/tests/unit/nuage/__init__.py [deleted file]
neutron/tests/unit/nuage/fake_nuageclient.py [deleted file]
neutron/tests/unit/nuage/test_nuage_plugin.py [deleted file]
neutron/tests/unit/nuage/test_syncmanager.py [deleted file]

index 0b9ddefdca2b8aa8432b882cd40aa7b60bfdb488..d09ba83943c08998a954b24bf006caeea23dcd5d 100644 (file)
@@ -21,9 +21,9 @@ from neutron.i18n import _LE
 from neutron.openstack.common import log
 from neutron.plugins.common import constants
 from neutron.plugins.ml2 import driver_api as api
-from neutron.plugins.nuage.common import config
-from neutron.plugins.nuage.common import constants as nuage_const
-from neutron.plugins.nuage import plugin
+from nuage_neutron.plugins.nuage.common import config
+from nuage_neutron.plugins.nuage.common import constants as nuage_const
+from nuage_neutron.plugins.nuage import plugin
 
 LOG = log.getLogger(__name__)
 
diff --git a/neutron/plugins/nuage/common/__init__.py b/neutron/plugins/nuage/common/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/neutron/plugins/nuage/common/config.py b/neutron/plugins/nuage/common/config.py
deleted file mode 100644 (file)
index cfd2fb9..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from oslo_config import cfg
-
-
-restproxy_opts = [
-    cfg.StrOpt('server', default='localhost:8800',
-               help=_("IP Address and Port of Nuage's VSD server")),
-    cfg.StrOpt('serverauth', default='username:password',
-               secret=True,
-               help=_("Username and password for authentication")),
-    cfg.BoolOpt('serverssl', default=False,
-                help=_("Boolean for SSL connection with VSD server")),
-    cfg.StrOpt('base_uri', default='/',
-               help=_("Nuage provided base uri to reach out to VSD")),
-    cfg.StrOpt('organization', default='system',
-               help=_("Organization name in which VSD will orchestrate "
-                      "network resources using openstack")),
-    cfg.StrOpt('auth_resource', default='',
-               help=_("Nuage provided uri for initial authorization to "
-                      "access VSD")),
-    cfg.StrOpt('default_net_partition_name',
-               default='OpenStackDefaultNetPartition',
-               help=_("Default Network partition in which VSD will "
-                      "orchestrate network resources using openstack")),
-    cfg.IntOpt('default_floatingip_quota',
-               default=254,
-               help=_("Per Net Partition quota of floating ips")),
-]
-
-syncmanager_opts = [
-    cfg.BoolOpt('enable_sync', default=False,
-                help=_("Nuage plugin will sync resources between openstack "
-                       "and VSD")),
-    cfg.IntOpt('sync_interval', default=0,
-               help=_("Sync interval in seconds between openstack and VSD. "
-                      "It defines how often the synchronization is done. "
-                      "If not set, value of 0 is assumed and sync will be "
-                      "performed only once, at the Neutron startup time.")),
-]
-
-
-def nuage_register_cfg_opts():
-    cfg.CONF.register_opts(restproxy_opts, "RESTPROXY")
-    cfg.CONF.register_opts(syncmanager_opts, "SYNCMANAGER")
diff --git a/neutron/plugins/nuage/common/constants.py b/neutron/plugins/nuage/common/constants.py
deleted file mode 100644 (file)
index a996b7e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from neutron.common import constants
-
-AUTO_CREATE_PORT_OWNERS = [
-    constants.DEVICE_OWNER_DHCP,
-    constants.DEVICE_OWNER_ROUTER_INTF,
-    constants.DEVICE_OWNER_ROUTER_GW,
-    constants.DEVICE_OWNER_FLOATINGIP
-]
-
-NOVA_PORT_OWNER_PREF = 'compute:'
-
-SR_TYPE_FLOATING = "FLOATING"
diff --git a/neutron/plugins/nuage/common/exceptions.py b/neutron/plugins/nuage/common/exceptions.py
deleted file mode 100644 (file)
index a93e252..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-''' Nuage specific exceptions '''
-
-from neutron.common import exceptions as n_exc
-
-
-class OperationNotSupported(n_exc.InvalidConfigurationOption):
-    message = _("Nuage Plugin does not support this operation: %(msg)s")
-
-
-class NuageBadRequest(n_exc.BadRequest):
-    message = _("Bad request: %(msg)s")
diff --git a/neutron/plugins/nuage/extensions/__init__.py b/neutron/plugins/nuage/extensions/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/neutron/plugins/nuage/extensions/netpartition.py b/neutron/plugins/nuage/extensions/netpartition.py
deleted file mode 100644 (file)
index 2249a5e..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import abc
-
-from neutron.api import extensions
-from neutron.api.v2 import base
-from neutron import manager
-from neutron import quota
-
-
-# Attribute Map
-RESOURCE_ATTRIBUTE_MAP = {
-    'net_partitions': {
-        'id': {'allow_post': False, 'allow_put': False,
-               'validate': {'type:uuid': None},
-               'is_visible': True},
-        'name': {'allow_post': True, 'allow_put': False,
-                 'is_visible': True, 'default': '',
-                 'validate': {'type:name_not_default': None}},
-        'description': {'allow_post': True, 'allow_put': False,
-                        'is_visible': True, 'default': '',
-                        'validate': {'type:string_or_none': None}},
-        'tenant_id': {'allow_post': True, 'allow_put': False,
-                      'required_by_policy': True,
-                      'is_visible': True},
-    },
-}
-
-
-class Netpartition(object):
-    """Extension class supporting net_partition.
-    """
-
-    @classmethod
-    def get_name(cls):
-        return "NetPartition"
-
-    @classmethod
-    def get_alias(cls):
-        return "net-partition"
-
-    @classmethod
-    def get_description(cls):
-        return "NetPartition"
-
-    @classmethod
-    def get_namespace(cls):
-        return "http://nuagenetworks.net/ext/net_partition/api/v1.0"
-
-    @classmethod
-    def get_updated(cls):
-        return "2014-01-01T10:00:00-00:00"
-
-    @classmethod
-    def get_resources(cls):
-        """Returns Ext Resources."""
-        exts = []
-        plugin = manager.NeutronManager.get_plugin()
-        resource_name = 'net_partition'
-        collection_name = resource_name.replace('_', '-') + "s"
-        params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
-        quota.QUOTAS.register_resource_by_name(resource_name)
-        controller = base.create_resource(collection_name,
-                                          resource_name,
-                                          plugin, params, allow_bulk=True)
-        ex = extensions.ResourceExtension(collection_name,
-                                          controller)
-        exts.append(ex)
-
-        return exts
-
-
-class NetPartitionPluginBase(object):
-
-    @abc.abstractmethod
-    def create_net_partition(self, context, router):
-        pass
-
-    @abc.abstractmethod
-    def update_net_partition(self, context, id, router):
-        pass
-
-    @abc.abstractmethod
-    def get_net_partition(self, context, id, fields=None):
-        pass
-
-    @abc.abstractmethod
-    def delete_net_partition(self, context, id):
-        pass
-
-    @abc.abstractmethod
-    def get_net_partitions(self, context, filters=None, fields=None):
-        pass
diff --git a/neutron/plugins/nuage/extensions/nuage_router.py b/neutron/plugins/nuage/extensions/nuage_router.py
deleted file mode 100644 (file)
index 651d4a9..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-
-EXTENDED_ATTRIBUTES_2_0 = {
-    'routers': {
-        'net_partition': {
-            'allow_post': True,
-            'allow_put': True,
-            'is_visible': True,
-            'default': None,
-            'validate': {'type:string_or_none': None}
-        },
-        'rd': {
-            'allow_post': True,
-            'allow_put': True,
-            'is_visible': True,
-            'default': None,
-            'validate': {'type:string_or_none': None}
-        },
-        'rt': {
-            'allow_post': True,
-            'allow_put': True,
-            'is_visible': True,
-            'default': None,
-            'validate': {'type:string_or_none': None}
-        },
-        'nuage_router_template': {
-            'allow_post': True,
-            'allow_put': False,
-            'is_visible': True,
-            'default': None,
-            'validate': {'type:uuid_or_none': None}
-        },
-    },
-}
-
-
-class Nuage_router(object):
-    """Extension class supporting nuage router.
-    """
-
-    @classmethod
-    def get_name(cls):
-        return "Nuage router"
-
-    @classmethod
-    def get_alias(cls):
-        return "nuage-router"
-
-    @classmethod
-    def get_description(cls):
-        return "Nuage Router"
-
-    @classmethod
-    def get_namespace(cls):
-        return "http://nuagenetworks.net/ext/routers/api/v1.0"
-
-    @classmethod
-    def get_updated(cls):
-        return "2014-01-01T10:00:00-00:00"
-
-    def get_extended_resources(self, version):
-        if version == "2.0":
-            return EXTENDED_ATTRIBUTES_2_0
-        else:
-            return {}
diff --git a/neutron/plugins/nuage/extensions/nuage_subnet.py b/neutron/plugins/nuage/extensions/nuage_subnet.py
deleted file mode 100644 (file)
index 02cd201..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-
-EXTENDED_ATTRIBUTES_2_0 = {
-    'subnets': {
-        'net_partition': {
-            'allow_post': True,
-            'allow_put': True,
-            'is_visible': True,
-            'default': None,
-            'validate': {'type:string_or_none': None}
-        },
-        'nuage_subnet_template': {
-            'allow_post': True,
-            'allow_put': False,
-            'is_visible': True,
-            'default': None,
-            'validate': {'type:uuid_or_none': None}
-        },
-    },
-}
-
-
-class Nuage_subnet(object):
-    """Extension class supporting Nuage subnet.
-    """
-
-    @classmethod
-    def get_name(cls):
-        return "Nuage subnet"
-
-    @classmethod
-    def get_alias(cls):
-        return "nuage-subnet"
-
-    @classmethod
-    def get_description(cls):
-        return "Nuage subnet"
-
-    @classmethod
-    def get_namespace(cls):
-        return "http://nuagenetworks.net/ext/subnets/api/v1.0"
-
-    @classmethod
-    def get_updated(cls):
-        return "2014-01-01T10:00:00-00:00"
-
-    def get_extended_resources(self, version):
-        if version == "2.0":
-            return EXTENDED_ATTRIBUTES_2_0
-        else:
-            return {}
diff --git a/neutron/plugins/nuage/nuagedb.py b/neutron/plugins/nuage/nuagedb.py
deleted file mode 100644 (file)
index 1a3210b..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from neutron.db import common_db_mixin
-from neutron.db import extraroute_db
-from neutron.db import l3_db
-from neutron.db import models_v2
-from neutron.db import securitygroups_db
-from neutron.plugins.nuage import nuage_models
-
-
-def add_net_partition(session, netpart_id,
-                      l3dom_id, l2dom_id,
-                      ent_name):
-    net_partitioninst = nuage_models.NetPartition(id=netpart_id,
-                                                  name=ent_name,
-                                                  l3dom_tmplt_id=l3dom_id,
-                                                  l2dom_tmplt_id=l2dom_id)
-    session.add(net_partitioninst)
-    return net_partitioninst
-
-
-def delete_net_partition(session, net_partition):
-    session.delete(net_partition)
-
-
-def delete_net_partition_by_id(session, netpart_id):
-    query = session.query(nuage_models.NetPartition)
-    query.filter_by(id=netpart_id).delete()
-
-
-def get_net_partition_by_name(session, name):
-    query = session.query(nuage_models.NetPartition)
-    return query.filter_by(name=name).first()
-
-
-def get_net_partition_by_id(session, id):
-    query = session.query(nuage_models.NetPartition)
-    return query.filter_by(id=id).first()
-
-
-def get_net_partitions(session, filters=None, fields=None):
-    query = session.query(nuage_models.NetPartition)
-    common_db = common_db_mixin.CommonDbMixin()
-    query = common_db._apply_filters_to_query(query,
-                                              nuage_models.NetPartition,
-                                              filters)
-    return query
-
-
-def get_net_partition_ids(session):
-    query = session.query(nuage_models.NetPartition.id)
-    return [netpart[0] for netpart in query]
-
-
-def get_net_partition_with_lock(session, netpart_id):
-    query = session.query(nuage_models.NetPartition)
-    netpart_db = query.filter_by(id=netpart_id).with_lockmode('update').one()
-    return make_net_partition_dict(netpart_db)
-
-
-def get_subnet_ids(session):
-    query = session.query(models_v2.Subnet.id)
-    return [subn[0] for subn in query]
-
-
-def get_subnet_with_lock(session, sub_id):
-    query = session.query(models_v2.Subnet)
-    subnet_db = query.filter_by(id=sub_id).with_lockmode('update').one()
-    return subnet_db
-
-
-def get_router_ids(session):
-    query = session.query(l3_db.Router.id)
-    return [router[0] for router in query]
-
-
-def get_router_with_lock(session, router_id):
-    query = session.query(l3_db.Router)
-    router_db = query.filter_by(id=router_id).with_lockmode('update').one()
-    return router_db
-
-
-def get_secgrp_ids(session):
-    query = session.query(securitygroups_db.SecurityGroup.id)
-    return [secgrp[0] for secgrp in query]
-
-
-def get_secgrp_with_lock(session, secgrp_id):
-    query = session.query(securitygroups_db.SecurityGroup)
-    secgrp_db = query.filter_by(id=secgrp_id).with_lockmode('update').one()
-    return secgrp_db
-
-
-def get_secgrprule_ids(session):
-    query = session.query(securitygroups_db.SecurityGroupRule.id)
-    return [secgrprule[0] for secgrprule in query]
-
-
-def get_secgrprule_with_lock(session, secgrprule_id):
-    query = session.query(securitygroups_db.SecurityGroupRule)
-    secgrprule_db = (query.filter_by(id=secgrprule_id).with_lockmode(
-        'update').one())
-    return secgrprule_db
-
-
-def get_port_with_lock(session, port_id):
-    query = session.query(models_v2.Port)
-    port_db = query.filter_by(id=port_id).with_lockmode('update').one()
-    return port_db
-
-
-def get_fip_with_lock(session, fip_id):
-    query = session.query(l3_db.FloatingIP)
-    fip_db = query.filter_by(id=fip_id).with_lockmode('update').one()
-    return fip_db
-
-
-def add_entrouter_mapping(session, np_id,
-                          router_id,
-                          n_l3id):
-    ent_rtr_mapping = nuage_models.NetPartitionRouter(net_partition_id=np_id,
-                                                      router_id=router_id,
-                                                      nuage_router_id=n_l3id)
-    session.add(ent_rtr_mapping)
-
-
-def add_subnetl2dom_mapping(session, neutron_subnet_id,
-                            nuage_sub_id,
-                            np_id,
-                            l2dom_id=None,
-                            nuage_user_id=None,
-                            nuage_group_id=None):
-    subnet_l2dom = nuage_models.SubnetL2Domain(subnet_id=neutron_subnet_id,
-                                               nuage_subnet_id=nuage_sub_id,
-                                               net_partition_id=np_id,
-                                               nuage_l2dom_tmplt_id=l2dom_id,
-                                               nuage_user_id=nuage_user_id,
-                                               nuage_group_id=nuage_group_id)
-    session.add(subnet_l2dom)
-
-
-def update_subnetl2dom_mapping(subnet_l2dom,
-                               new_dict):
-    subnet_l2dom.update(new_dict)
-
-
-def get_update_subnetl2dom_mapping(session, new_dict):
-    subnet_l2dom = get_subnet_l2dom_with_lock(session, new_dict['subnet_id'])
-    subnet_l2dom.update(new_dict)
-
-
-def update_entrtr_mapping(ent_rtr, new_dict):
-    ent_rtr.update(new_dict)
-
-
-def get_update_entrtr_mapping(session, new_dict):
-    ent_rtr = get_ent_rtr_mapping_with_lock(session, new_dict['router_id'])
-    ent_rtr.update(new_dict)
-
-
-def delete_subnetl2dom_mapping(session, subnet_l2dom):
-    session.delete(subnet_l2dom)
-
-
-def get_subnet_l2dom_by_id(session, id):
-    query = session.query(nuage_models.SubnetL2Domain)
-    return query.filter_by(subnet_id=id).first()
-
-
-def get_subnet_l2dom_with_lock(session, id):
-    query = session.query(nuage_models.SubnetL2Domain)
-    subl2dom = query.filter_by(subnet_id=id).with_lockmode('update').one()
-    return subl2dom
-
-
-def get_ent_rtr_mapping_by_entid(session, entid):
-    query = session.query(nuage_models.NetPartitionRouter)
-    return query.filter_by(net_partition_id=entid).all()
-
-
-def get_ent_rtr_mapping_by_rtrid(session, rtrid):
-    query = session.query(nuage_models.NetPartitionRouter)
-    return query.filter_by(router_id=rtrid).first()
-
-
-def add_network_binding(session, network_id, network_type, physical_network,
-                        vlan_id):
-    binding = nuage_models.ProviderNetBinding(
-                            network_id=network_id,
-                            network_type=network_type,
-                            physical_network=physical_network,
-                            vlan_id=vlan_id)
-    session.add(binding)
-    return binding
-
-
-def get_network_binding(session, network_id):
-    return (session.query(nuage_models.ProviderNetBinding).
-            filter_by(network_id=network_id).
-            first())
-
-
-def get_ent_rtr_mapping_with_lock(session, rtrid):
-    query = session.query(nuage_models.NetPartitionRouter)
-    entrtr = query.filter_by(router_id=rtrid).with_lockmode('update').one()
-    return entrtr
-
-
-def get_ipalloc_for_fip(session, network_id, ip, lock=False):
-    query = session.query(models_v2.IPAllocation)
-    if lock:
-        # Lock is required when the resource is synced
-        ipalloc_db = (query.filter_by(network_id=network_id).filter_by(
-            ip_address=ip).with_lockmode('update').one())
-    else:
-        ipalloc_db = (query.filter_by(network_id=network_id).filter_by(
-            ip_address=ip).one())
-    return make_ipalloc_dict(ipalloc_db)
-
-
-def get_all_net_partitions(session):
-    net_partitions = get_net_partitions(session)
-    return make_net_partition_list(net_partitions)
-
-
-def get_all_routes(session):
-    routes = session.query(extraroute_db.RouterRoute)
-    return make_route_list(routes)
-
-
-def get_route_with_lock(session, dest, nhop):
-    query = session.query(extraroute_db.RouterRoute)
-    route_db = (query.filter_by(destination=dest).filter_by(nexthop=nhop)
-                .with_lockmode('update').one())
-    return make_route_dict(route_db)
-
-
-def make_ipalloc_dict(subnet_db):
-    return {'port_id': subnet_db['port_id'],
-            'subnet_id': subnet_db['subnet_id'],
-            'network_id': subnet_db['network_id'],
-            'ip_address': subnet_db['ip_address']}
-
-
-def make_net_partition_dict(net_partition):
-    return {'id': net_partition['id'],
-            'name': net_partition['name'],
-            'l3dom_tmplt_id': net_partition['l3dom_tmplt_id'],
-            'l2dom_tmplt_id': net_partition['l2dom_tmplt_id']}
-
-
-def make_net_partition_list(net_partitions):
-    return [make_net_partition_dict(net_partition) for net_partition in
-            net_partitions]
-
-
-def make_route_dict(route):
-    return {'destination': route['destination'],
-            'nexthop': route['nexthop'],
-            'router_id': route['router_id']}
-
-
-def make_route_list(routes):
-    return [make_route_dict(route) for route in routes]
-
-
-def make_subnl2dom_dict(subl2dom):
-    return {'subnet_id': subl2dom['subnet_id'],
-            'net_partition_id': subl2dom['net_partition_id'],
-            'nuage_subnet_id': subl2dom['nuage_subnet_id'],
-            'nuage_l2dom_tmplt_id': subl2dom['nuage_l2dom_tmplt_id'],
-            'nuage_user_id': subl2dom['nuage_user_id'],
-            'nuage_group_id': subl2dom['nuage_group_id']}
-
-
-def make_entrtr_dict(entrtr):
-    return {'net_partition_id': entrtr['net_partition_id'],
-            'router_id': entrtr['router_id'],
-            'nuage_router_id': entrtr['nuage_router_id']}
index d47a54d8a615a3bc6b6cc4f4f64c2de7238d9989..082d949b41db523696473005609a01fa9b3eafeb 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import copy
-import re
+from nuage_neutron.plugins.nuage import plugin
 
-import netaddr
-from oslo_concurrency import lockutils
-from oslo_config import cfg
-from oslo_utils import excutils
-from oslo_utils import importutils
-from sqlalchemy.orm import exc
 
-from neutron.api import extensions as neutron_extensions
-from neutron.api.v2 import attributes
-from neutron.common import constants as os_constants
-from neutron.common import exceptions as n_exc
-from neutron.common import utils
-from neutron.db import api as db
-from neutron.db import db_base_plugin_v2
-from neutron.db import external_net_db
-from neutron.db import extraroute_db
-from neutron.db import l3_db
-from neutron.db import quota_db  # noqa
-from neutron.db import securitygroups_db as sg_db
-from neutron.extensions import external_net
-from neutron.extensions import l3
-from neutron.extensions import portbindings
-from neutron.extensions import providernet as pnet
-from neutron.extensions import securitygroup as ext_sg
-from neutron.openstack.common import log as logging
-from neutron.openstack.common import loopingcall
-from neutron.plugins.nuage.common import config
-from neutron.plugins.nuage.common import constants
-from neutron.plugins.nuage.common import exceptions as nuage_exc
-from neutron.plugins.nuage import extensions
-from neutron.plugins.nuage.extensions import netpartition
-from neutron.plugins.nuage import nuagedb
-from neutron.plugins.nuage import syncmanager
-from neutron import policy
+class NuagePlugin(plugin.NuagePlugin):
 
-LOG = logging.getLogger(__name__)
-
-
-class NuagePlugin(db_base_plugin_v2.NeutronDbPluginV2,
-                  external_net_db.External_net_db_mixin,
-                  extraroute_db.ExtraRoute_db_mixin,
-                  l3_db.L3_NAT_db_mixin,
-                  netpartition.NetPartitionPluginBase,
-                  sg_db.SecurityGroupDbMixin):
-    """Class that implements Nuage Networks' plugin functionality."""
+    vendor_extensions = plugin.NuagePlugin.vendor_extensions
     supported_extension_aliases = ["router", "binding", "external-net",
-                                   "net-partition", "nuage-router",
-                                   "nuage-subnet", "quotas", "provider",
-                                   "extraroute", "security-group"]
-
-    binding_view = "extension:port_binding:view"
+                                   "quotas", "provider", "extraroute",
+                                   "security-group"] + vendor_extensions
 
     def __init__(self):
         super(NuagePlugin, self).__init__()
-        neutron_extensions.append_api_extensions_path(extensions.__path__)
-        config.nuage_register_cfg_opts()
-        self.nuageclient_init()
-        net_partition = cfg.CONF.RESTPROXY.default_net_partition_name
-        self._create_default_net_partition(net_partition)
-        if cfg.CONF.SYNCMANAGER.enable_sync:
-            self.syncmanager = syncmanager.SyncManager(self.nuageclient)
-            self._synchronization_thread()
-
-    db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
-        attributes.NETWORKS, ['_extend_network_dict_provider_nuage'])
-
-    def nuageclient_init(self):
-        server = cfg.CONF.RESTPROXY.server
-        serverauth = cfg.CONF.RESTPROXY.serverauth
-        serverssl = cfg.CONF.RESTPROXY.serverssl
-        base_uri = cfg.CONF.RESTPROXY.base_uri
-        auth_resource = cfg.CONF.RESTPROXY.auth_resource
-        organization = cfg.CONF.RESTPROXY.organization
-        nuageclient = importutils.import_module('nuagenetlib.nuageclient')
-        self.nuageclient = nuageclient.NuageClient(server, base_uri,
-                                                   serverssl, serverauth,
-                                                   auth_resource,
-                                                   organization)
-
-    def _synchronization_thread(self):
-        sync_interval = cfg.CONF.SYNCMANAGER.sync_interval
-        fip_quota = str(cfg.CONF.RESTPROXY.default_floatingip_quota)
-        if sync_interval > 0:
-            sync_loop = loopingcall.FixedIntervalLoopingCall(
-                self.syncmanager.synchronize, fip_quota)
-            sync_loop.start(interval=sync_interval)
-        else:
-            self.syncmanager.synchronize(fip_quota)
-
-    def _resource_finder(self, context, for_resource, resource, user_req):
-        match = re.match(attributes.UUID_PATTERN, user_req[resource])
-        if match:
-            obj_lister = getattr(self, "get_%s" % resource)
-            found_resource = obj_lister(context, user_req[resource])
-            if not found_resource:
-                msg = (_("%(resource)s with id %(resource_id)s does not "
-                         "exist") % {'resource': resource,
-                                     'resource_id': user_req[resource]})
-                raise n_exc.BadRequest(resource=for_resource, msg=msg)
-        else:
-            filter = {'name': [user_req[resource]]}
-            obj_lister = getattr(self, "get_%ss" % resource)
-            found_resource = obj_lister(context, filters=filter)
-            if not found_resource:
-                msg = (_("Either %(resource)s %(req_resource)s not found "
-                         "or you dont have credential to access it")
-                       % {'resource': resource,
-                          'req_resource': user_req[resource]})
-                raise n_exc.BadRequest(resource=for_resource, msg=msg)
-            if len(found_resource) > 1:
-                msg = (_("More than one entry found for %(resource)s "
-                         "%(req_resource)s. Use id instead")
-                       % {'resource': resource,
-                          'req_resource': user_req[resource]})
-                raise n_exc.BadRequest(resource=for_resource, msg=msg)
-            found_resource = found_resource[0]
-        return found_resource
-
-    def _create_update_port(self, context, port, np_name):
-        filters = {'device_id': [port['device_id']]}
-        ports = self.get_ports(context, filters)
-        params = {
-            'port_id': port['id'],
-            'id': port['device_id'],
-            'mac': port['mac_address'],
-            'netpart_name': np_name,
-            'ip': port['fixed_ips'][0]['ip_address'],
-            'no_of_ports': len(ports),
-            'tenant': port['tenant_id'],
-            'neutron_id': port['fixed_ips'][0]['subnet_id']
-        }
-        self.nuageclient.create_vms(params)
-
-    def _get_router_by_subnet(self, context, subnet_id):
-        filters = {
-            'fixed_ips': {'subnet_id': [subnet_id]},
-            'device_owner': [os_constants.DEVICE_OWNER_ROUTER_INTF]
-        }
-        router_port = self.get_ports(context, filters=filters)
-        if not router_port:
-            msg = (_("Router for subnet %s not found ") % subnet_id)
-            raise n_exc.BadRequest(resource='port', msg=msg)
-        return router_port[0]['device_id']
-
-    def _process_port_create_security_group(self, context, port,
-                                            sec_group):
-        if not attributes.is_attr_set(sec_group):
-            port[ext_sg.SECURITYGROUPS] = []
-            return
-        port_id = port['id']
-        with context.session.begin(subtransactions=True):
-            for sg_id in sec_group:
-                super(NuagePlugin,
-                      self)._create_port_security_group_binding(context,
-                                                                port_id,
-                                                                sg_id)
-        try:
-            vptag_vport_list = []
-            for sg_id in sec_group:
-                params = {
-                    'neutron_port_id': port_id
-                }
-                nuage_port = self.nuageclient.get_nuage_port_by_id(params)
-                if nuage_port and nuage_port.get('nuage_vport_id'):
-                    nuage_vport_id = nuage_port['nuage_vport_id']
-                    sg = self._get_security_group(context, sg_id)
-                    sg_rules = self.get_security_group_rules(
-                                        context,
-                                        {'security_group_id': [sg_id]})
-                    sg_params = {
-                        'nuage_port': nuage_port,
-                        'sg': sg,
-                        'sg_rules': sg_rules
-                    }
-                    nuage_vptag_id = (
-                        self.nuageclient.process_port_create_security_group(
-                                                                    sg_params))
-                    vptag_vport = {
-                        'nuage_vporttag_id': nuage_vptag_id
-                    }
-                    vptag_vport_list.append(vptag_vport)
-
-            if vptag_vport_list:
-                params = {
-                    'vptag_vport_list': vptag_vport_list,
-                    'nuage_vport_id': nuage_vport_id
-                }
-                self.nuageclient.update_nuage_vport(params)
-        except Exception:
-            with excutils.save_and_reraise_exception():
-                for sg_id in sec_group:
-                    super(NuagePlugin,
-                          self)._delete_port_security_group_bindings(context,
-                                                                 port_id)
-        # Convert to list as a set might be passed here and
-        # this has to be serialized
-        port[ext_sg.SECURITYGROUPS] = (list(sec_group) if sec_group else [])
-
-    def _delete_port_security_group_bindings(self, context, port_id):
-        super(NuagePlugin,
-              self)._delete_port_security_group_bindings(context, port_id)
-        self.nuageclient.delete_port_security_group_bindings(port_id)
-
-    @lockutils.synchronized('create_port', 'nuage-port', external=True)
-    def create_port(self, context, port):
-        session = context.session
-        with session.begin(subtransactions=True):
-            p = port['port']
-            self._ensure_default_security_group_on_port(context, port)
-            port = super(NuagePlugin, self).create_port(context, port)
-            device_owner = port.get('device_owner', None)
-            if device_owner not in constants.AUTO_CREATE_PORT_OWNERS:
-                if 'fixed_ips' not in port or len(port['fixed_ips']) == 0:
-                    return self._extend_port_dict_binding(context, port)
-                subnet_id = port['fixed_ips'][0]['subnet_id']
-                subnet_mapping = nuagedb.get_subnet_l2dom_by_id(session,
-                                                                subnet_id)
-                if subnet_mapping:
-                    port_prefix = constants.NOVA_PORT_OWNER_PREF
-                    if port['device_owner'].startswith(port_prefix):
-                        #This request is coming from nova
-                        try:
-                            net_partition = nuagedb.get_net_partition_by_id(
-                                session,
-                                subnet_mapping['net_partition_id'])
-                            self._create_update_port(
-                                context,
-                                port,
-                                net_partition['name'])
-                        except Exception:
-                            with excutils.save_and_reraise_exception():
-                                super(NuagePlugin, self).delete_port(
-                                    context,
-                                    port['id'])
-                    if ext_sg.SECURITYGROUPS in p:
-                        self._process_port_create_security_group(
-                            context,
-                            port,
-                            p[ext_sg.SECURITYGROUPS])
-        return self._extend_port_dict_binding(context, port)
-
-    def update_port(self, context, id, port):
-        p = port['port']
-        sg_groups = None
-        if p.get('device_owner', '').startswith(
-            constants.NOVA_PORT_OWNER_PREF):
-            session = context.session
-            with session.begin(subtransactions=True):
-                port = self._get_port(context, id)
-                port.update(p)
-                if not port.get('fixed_ips'):
-                    return self._make_port_dict(port)
-                subnet_id = port['fixed_ips'][0]['subnet_id']
-
-                subnet_mapping = nuagedb.get_subnet_l2dom_by_id(session,
-                                                                subnet_id)
-                if not subnet_mapping:
-                    msg = (_("Subnet %s not found on VSD") % subnet_id)
-                    raise n_exc.BadRequest(resource='port', msg=msg)
-
-                params = {
-                    'neutron_port_id': id,
-                }
-                nuage_port = self.nuageclient.get_nuage_port_by_id(params)
-                if not nuage_port or not nuage_port.get('nuage_vport_id'):
-                    net_partition = nuagedb.get_net_partition_by_id(
-                        session, subnet_mapping['net_partition_id'])
-                    self._create_update_port(context, port,
-                                             net_partition['name'])
-                self._check_floatingip_update(context, port)
-                updated_port = self._make_port_dict(port)
-                sg_port = self._extend_port_dict_security_group(
-                    updated_port,
-                    port
-                )
-                sg_groups = sg_port[ext_sg.SECURITYGROUPS]
-        else:
-            updated_port = super(NuagePlugin, self).update_port(context, id,
-                                                                port)
-            if not updated_port.get('fixed_ips'):
-                return updated_port
-            subnet_id = updated_port['fixed_ips'][0]['subnet_id']
-            subnet_mapping = nuagedb.get_subnet_l2dom_by_id(context.session,
-                                                            subnet_id)
-        if subnet_mapping:
-            if sg_groups:
-                self._delete_port_security_group_bindings(context,
-                                                          updated_port['id'])
-                self._process_port_create_security_group(context,
-                                                         updated_port,
-                                                         sg_groups)
-            elif ext_sg.SECURITYGROUPS in p:
-                self._delete_port_security_group_bindings(context,
-                                                          updated_port['id'])
-                self._process_port_create_security_group(
-                    context,
-                    updated_port,
-                    p[ext_sg.SECURITYGROUPS]
-                )
-        return updated_port
-
-    def _delete_nuage_vport(self, context, port, np_name):
-        nuage_vif_id = None
-        params = {
-            'neutron_port_id': port['id'],
-        }
-        nuage_port = self.nuageclient.get_nuage_port_by_id(params)
-
-        if constants.NOVA_PORT_OWNER_PREF in port['device_owner']:
-            # This was a VM Port
-            if nuage_port:
-                nuage_vif_id = nuage_port['nuage_vif_id']
-            filters = {'device_id': [port['device_id']]}
-            ports = self.get_ports(context, filters)
-            params = {
-                'no_of_ports': len(ports),
-                'netpart_name': np_name,
-                'tenant': port['tenant_id'],
-                'mac': port['mac_address'],
-                'nuage_vif_id': nuage_vif_id,
-                'id': port['device_id']
-            }
-            self.nuageclient.delete_vms(params)
-
-    @lockutils.synchronized('delete-port', 'nuage-del', external=True)
-    def delete_port(self, context, id, l3_port_check=True):
-        if l3_port_check:
-            self.prevent_l3_port_deletion(context, id)
-        port = self._get_port(context, id)
-        # This is required for to pass ut test_floatingip_port_delete
-        self.disassociate_floatingips(context, id)
-        if not port['fixed_ips']:
-            return super(NuagePlugin, self).delete_port(context, id)
-
-        sub_id = port['fixed_ips'][0]['subnet_id']
-
-        subnet_mapping = nuagedb.get_subnet_l2dom_by_id(context.session,
-                                                        sub_id)
-        if not subnet_mapping:
-            return super(NuagePlugin, self).delete_port(context, id)
-
-        # Need to call this explicitly to delete vport to vporttag binding
-        if ext_sg.SECURITYGROUPS in port:
-            self.nuageclient.delete_port_security_group_bindings(id)
-
-        netpart_id = subnet_mapping['net_partition_id']
-        net_partition = nuagedb.get_net_partition_by_id(context.session,
-                                                        netpart_id)
-        self._delete_nuage_vport(context, port, net_partition['name'])
-        super(NuagePlugin, self).delete_port(context, id)
-
-    def _check_view_auth(self, context, resource, action):
-        return policy.check(context, action, resource)
-
-    def _extend_port_dict_binding(self, context, port):
-        if self._check_view_auth(context, port, self.binding_view):
-            port[portbindings.VIF_TYPE] = portbindings.VIF_TYPE_OVS
-            port[portbindings.VIF_DETAILS] = {
-                portbindings.CAP_PORT_FILTER: False
-            }
-        return port
-
-    def get_port(self, context, id, fields=None):
-        port = super(NuagePlugin, self).get_port(context, id, fields)
-        return self._fields(self._extend_port_dict_binding(context, port),
-                            fields)
-
-    def get_ports(self, context, filters=None, fields=None):
-        ports = super(NuagePlugin, self).get_ports(context, filters, fields)
-        return [self._fields(self._extend_port_dict_binding(context, port),
-                             fields) for port in ports]
-
-    def _check_router_subnet_for_tenant(self, context, tenant_id):
-        # Search router and subnet tables.
-        # If no entry left delete user and group from VSD
-        filters = {'tenant_id': [tenant_id]}
-        routers = self.get_routers(context, filters=filters)
-        subnets = self.get_subnets(context, filters=filters)
-        return bool(routers or subnets)
-
-    def _extend_network_dict_provider_nuage(self, network, net_db,
-                                            net_binding=None):
-        binding = net_db.pnetbinding if net_db else net_binding
-        if binding:
-            network[pnet.NETWORK_TYPE] = binding.network_type
-            network[pnet.PHYSICAL_NETWORK] = binding.physical_network
-            network[pnet.SEGMENTATION_ID] = binding.vlan_id
-
-    def _process_provider_create(self, context, attrs):
-        network_type = attrs.get(pnet.NETWORK_TYPE)
-        physical_network = attrs.get(pnet.PHYSICAL_NETWORK)
-        segmentation_id = attrs.get(pnet.SEGMENTATION_ID)
-
-        network_type_set = attributes.is_attr_set(network_type)
-        physical_network_set = attributes.is_attr_set(physical_network)
-        segmentation_id_set = attributes.is_attr_set(segmentation_id)
-
-        if not (network_type_set or physical_network_set or
-                segmentation_id_set):
-            return None, None, None
-        if not network_type_set:
-            msg = _("provider:network_type required")
-            raise n_exc.InvalidInput(error_message=msg)
-        elif network_type != 'vlan':
-            msg = (_("provider:network_type %s not supported in VSP")
-                   % network_type)
-            raise nuage_exc.NuageBadRequest(msg=msg)
-        if not physical_network_set:
-            msg = _("provider:physical_network required")
-            raise nuage_exc.NuageBadRequest(msg=msg)
-        if not segmentation_id_set:
-            msg = _("provider:segmentation_id required")
-            raise nuage_exc.NuageBadRequest(msg=msg)
-
-        self.nuageclient.validate_provider_network(network_type,
-                                                   physical_network,
-                                                   segmentation_id)
-
-        return network_type, physical_network, segmentation_id
-
-    def create_network(self, context, network):
-        binding = None
-        (network_type, physical_network,
-         vlan_id) = self._process_provider_create(context,
-                                                  network['network'])
-        with context.session.begin(subtransactions=True):
-            self._ensure_default_security_group(
-                context,
-                network['network']['tenant_id']
-            )
-            net = super(NuagePlugin, self).create_network(context,
-                                                          network)
-            self._process_l3_create(context, net, network['network'])
-            if network_type == 'vlan':
-                binding = nuagedb.add_network_binding(context.session,
-                                            net['id'],
-                                            network_type,
-                                            physical_network, vlan_id)
-            self._extend_network_dict_provider_nuage(net, None, binding)
-        return net
-
-    def _validate_update_network(self, context, id, network):
-        req_data = network['network']
-        is_external_set = req_data.get(external_net.EXTERNAL)
-        if not attributes.is_attr_set(is_external_set):
-            return (None, None)
-        neutron_net = self.get_network(context, id)
-        if neutron_net.get(external_net.EXTERNAL) == is_external_set:
-            return (None, None)
-        subnet = self._validate_nuage_sharedresource(context, 'network', id)
-        if subnet and not is_external_set:
-            msg = _('External network with subnets can not be '
-                    'changed to non-external network')
-            raise nuage_exc.OperationNotSupported(msg=msg)
-        if is_external_set:
-            # Check if there are vm ports attached to this network
-            # If there are, then updating the network is not allowed
-            ports = self.get_ports(context, filters={'network_id': [id]})
-            for p in ports:
-                if p['device_owner'].startswith(
-                        constants.NOVA_PORT_OWNER_PREF):
-                    raise n_exc.NetworkInUse(net_id=id)
-        return (is_external_set, subnet)
-
-    def update_network(self, context, id, network):
-        pnet._raise_if_updates_provider_attributes(network['network'])
-        with context.session.begin(subtransactions=True):
-            is_external_set, subnet = self._validate_update_network(context,
-                                                                    id,
-                                                                    network)
-            net = super(NuagePlugin, self).update_network(context, id,
-                                                          network)
-            self._process_l3_update(context, net, network['network'])
-            if subnet and is_external_set:
-                subn = subnet[0]
-                subnet_l2dom = nuagedb.get_subnet_l2dom_by_id(context.session,
-                                                              subn['id'])
-                if subnet_l2dom:
-                    user_id = subnet_l2dom['nuage_user_id']
-                    group_id = subnet_l2dom['nuage_group_id']
-                    self.nuageclient.delete_subnet(subn['id'])
-                    nuagedb.delete_subnetl2dom_mapping(context.session,
-                                                       subnet_l2dom)
-                    if not self._check_router_subnet_for_tenant(
-                            context, subn['tenant_id']):
-                        self.nuageclient.delete_user(user_id)
-                        self.nuageclient.delete_group(group_id)
-
-                    self._add_nuage_sharedresource(subnet[0],
-                                                   id,
-                                                   constants.SR_TYPE_FLOATING)
-        return net
-
-    def delete_network(self, context, id):
-        with context.session.begin(subtransactions=True):
-            self._process_l3_delete(context, id)
-            filter = {'network_id': [id]}
-            subnets = self.get_subnets(context, filters=filter)
-            for subnet in subnets:
-                self.delete_subnet(context, subnet['id'])
-            super(NuagePlugin, self).delete_network(context, id)
-
-    def _get_net_partition_for_subnet(self, context, subnet):
-        ent = subnet.get('net_partition', None)
-        if not ent:
-            def_net_part = cfg.CONF.RESTPROXY.default_net_partition_name
-            net_partition = nuagedb.get_net_partition_by_name(context.session,
-                                                              def_net_part)
-        else:
-            net_partition = self._resource_finder(context, 'subnet',
-                                                  'net_partition', subnet)
-        if not net_partition:
-            msg = _('Either net_partition is not provided with subnet OR '
-                    'default net_partition is not created at the start')
-            raise n_exc.BadRequest(resource='subnet', msg=msg)
-        return net_partition
-
-    @staticmethod
-    def _validate_create_subnet(subnet):
-        if (attributes.is_attr_set(subnet['gateway_ip'])
-            and netaddr.IPAddress(subnet['gateway_ip'])
-            not in netaddr.IPNetwork(subnet['cidr'])):
-            msg = "Gateway IP outside of the subnet CIDR "
-            raise nuage_exc.NuageBadRequest(msg=msg)
-
-    def _validate_create_provider_subnet(self, context, net_id):
-        net_filter = {'network_id': [net_id]}
-        existing_subn = self.get_subnets(context, filters=net_filter)
-        if len(existing_subn) > 0:
-            msg = _('Only one subnet is allowed per '
-                    'Provider network %s') % net_id
-            raise nuage_exc.OperationNotSupported(msg=msg)
-
-    def _delete_nuage_sharedresource(self, net_id):
-        self.nuageclient.delete_nuage_sharedresource(net_id)
-
-    def _validate_nuage_sharedresource(self, context, resource, net_id):
-        filter = {'network_id': [net_id]}
-        existing_subn = self.get_subnets(context, filters=filter)
-        if len(existing_subn) > 1:
-            msg = _('Only one subnet is allowed per '
-                    'external network %s') % net_id
-            raise nuage_exc.OperationNotSupported(msg=msg)
-        return existing_subn
-
-    def _add_nuage_sharedresource(self, subnet, net_id, type):
-        net = netaddr.IPNetwork(subnet['cidr'])
-        params = {
-            'neutron_subnet': subnet,
-            'net': net,
-            'type': type,
-            'net_id': net_id
-        }
-        self.nuageclient.create_nuage_sharedresource(params)
-
-    def _create_nuage_sharedresource(self, context, subnet, type):
-        subn = subnet['subnet']
-        net_id = subn['network_id']
-        self._validate_nuage_sharedresource(context, 'subnet', net_id)
-        with context.session.begin(subtransactions=True):
-            subn = super(NuagePlugin, self).create_subnet(context, subnet)
-            self._add_nuage_sharedresource(subn, net_id, type)
-            return subn
-
-    def _create_port_gateway(self, context, subnet, gw_ip=None):
-        if gw_ip is not None:
-            fixed_ip = [{'ip_address': gw_ip, 'subnet_id': subnet['id']}]
-        else:
-            fixed_ip = [{'subnet_id': subnet['id']}]
-
-        port_dict = dict(port=dict(
-            name='',
-            device_id='',
-            admin_state_up=True,
-            network_id=subnet['network_id'],
-            tenant_id=subnet['tenant_id'],
-            fixed_ips=fixed_ip,
-            mac_address=attributes.ATTR_NOT_SPECIFIED,
-            device_owner=os_constants.DEVICE_OWNER_DHCP))
-        port = super(NuagePlugin, self).create_port(context, port_dict)
-        return port
-
-    def _delete_port_gateway(self, context, ports):
-        for port in ports:
-            super(NuagePlugin, self).delete_port(context, port['id'])
-
-    def _create_nuage_subnet(self, context, neutron_subnet, netpart_id,
-                             l2dom_template_id, pnet_binding):
-        net = netaddr.IPNetwork(neutron_subnet['cidr'])
-        # list(net)[-1] is the broadcast
-        last_address = neutron_subnet['allocation_pools'][-1]['end']
-        gw_port = self._create_port_gateway(context, neutron_subnet,
-                                            last_address)
-        params = {
-            'netpart_id': netpart_id,
-            'tenant_id': neutron_subnet['tenant_id'],
-            'net': net,
-            'l2dom_tmplt_id': l2dom_template_id,
-            'pnet_binding': pnet_binding,
-            'dhcp_ip': gw_port['fixed_ips'][0]['ip_address']
-        }
-        try:
-            nuage_subnet = self.nuageclient.create_subnet(neutron_subnet,
-                                                          params)
-        except Exception:
-            with excutils.save_and_reraise_exception():
-                self._delete_port_gateway(context, [gw_port])
-                super(NuagePlugin, self).delete_subnet(context,
-                                                       neutron_subnet['id'])
-
-        if nuage_subnet:
-            l2dom_id = str(nuage_subnet['nuage_l2template_id'])
-            user_id = nuage_subnet['nuage_userid']
-            group_id = nuage_subnet['nuage_groupid']
-            id = nuage_subnet['nuage_l2domain_id']
-            with context.session.begin(subtransactions=True):
-                nuagedb.add_subnetl2dom_mapping(context.session,
-                                                neutron_subnet['id'],
-                                                id,
-                                                netpart_id,
-                                                l2dom_id=l2dom_id,
-                                                nuage_user_id=user_id,
-                                                nuage_group_id=group_id)
-
-    def create_subnet(self, context, subnet):
-        subn = subnet['subnet']
-        net_id = subn['network_id']
-
-        if self._network_is_external(context, net_id):
-            return self._create_nuage_sharedresource(
-                context, subnet, constants.SR_TYPE_FLOATING)
-        pnet_binding = nuagedb.get_network_binding(context.session, net_id)
-        if pnet_binding:
-            self._validate_create_provider_subnet(context, net_id)
-
-        self._validate_create_subnet(subn)
-
-        net_partition = self._get_net_partition_for_subnet(context, subn)
-        neutron_subnet = super(NuagePlugin, self).create_subnet(context,
-                                                                subnet)
-        self._create_nuage_subnet(context, neutron_subnet, net_partition['id'],
-                                  subn['nuage_subnet_template'],
-                                  pnet_binding)
-        return neutron_subnet
-
-    def update_subnet(self, context, id, subnet):
-        subn = copy.deepcopy(subnet['subnet'])
-        subnet_l2dom = nuagedb.get_subnet_l2dom_by_id(context.session,
-                                                      id)
-        params = {
-            'parent_id': subnet_l2dom['nuage_subnet_id'],
-            'type': subnet_l2dom['nuage_l2dom_tmplt_id']
-        }
-        with context.session.begin(subtransactions=True):
-            neutron_subnet = super(NuagePlugin, self).update_subnet(context,
-                                                                    id, subnet)
-            self.nuageclient.update_subnet(subn, params)
-            return neutron_subnet
-
-    def delete_subnet(self, context, id):
-        subnet = self.get_subnet(context, id)
-        if self._network_is_external(context, subnet['network_id']):
-            super(NuagePlugin, self).delete_subnet(context, id)
-            return self._delete_nuage_sharedresource(id)
-
-        filters = {'fixed_ips': {'subnet_id': [id]}}
-        ports = self.get_ports(context, filters)
-        for port in ports:
-            if port['device_owner'] != os_constants.DEVICE_OWNER_DHCP:
-                raise n_exc.SubnetInUse(subnet_id=id)
-
-        subnet_l2dom = nuagedb.get_subnet_l2dom_by_id(context.session, id)
-        if subnet_l2dom:
-            try:
-                self.nuageclient.delete_subnet(id)
-            except Exception:
-                msg = (_('Unable to complete operation on subnet %s.'
-                         'One or more ports have an IP allocation '
-                         'from this subnet.') % id)
-                raise n_exc.BadRequest(resource='subnet', msg=msg)
-        super(NuagePlugin, self).delete_subnet(context, id)
-        if subnet_l2dom and not self._check_router_subnet_for_tenant(
-                context, subnet['tenant_id']):
-            self.nuageclient.delete_user(subnet_l2dom['nuage_user_id'])
-            self.nuageclient.delete_group(subnet_l2dom['nuage_group_id'])
-
-    def add_router_interface(self, context, router_id, interface_info):
-        session = context.session
-        with session.begin(subtransactions=True):
-            rtr_if_info = super(NuagePlugin,
-                                self).add_router_interface(context,
-                                                           router_id,
-                                                           interface_info)
-            subnet_id = rtr_if_info['subnet_id']
-            subn = self.get_subnet(context, subnet_id)
-            ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(session,
-                                                                   router_id)
-            nuage_zone = self.nuageclient.get_zone_by_routerid(router_id)
-            if not nuage_zone or not ent_rtr_mapping:
-                super(NuagePlugin,
-                      self).remove_router_interface(context,
-                                                    router_id,
-                                                    interface_info)
-                msg = (_("Router %s does not hold default zone OR "
-                         "domain in VSD. Router-IF add failed")
-                       % router_id)
-                raise n_exc.BadRequest(resource='router', msg=msg)
-
-            subnet_l2dom = nuagedb.get_subnet_l2dom_by_id(session,
-                                                          subnet_id)
-            if not subnet_l2dom:
-                super(NuagePlugin,
-                      self).remove_router_interface(context,
-                                                    router_id,
-                                                    interface_info)
-                msg = (_("Subnet %s does not hold Nuage VSD reference. "
-                         "Router-IF add failed") % subnet_id)
-                raise n_exc.BadRequest(resource='subnet', msg=msg)
-
-            if (subnet_l2dom['net_partition_id'] !=
-                ent_rtr_mapping['net_partition_id']):
-                super(NuagePlugin,
-                      self).remove_router_interface(context,
-                                                    router_id,
-                                                    interface_info)
-                msg = (_("Subnet %(subnet)s and Router %(router)s belong to "
-                         "different net_partition Router-IF add "
-                         "not permitted") % {'subnet': subnet_id,
-                                             'router': router_id})
-                raise n_exc.BadRequest(resource='subnet', msg=msg)
-            nuage_subnet_id = subnet_l2dom['nuage_subnet_id']
-            if self.nuageclient.vms_on_l2domain(nuage_subnet_id):
-                super(NuagePlugin,
-                      self).remove_router_interface(context,
-                                                    router_id,
-                                                    interface_info)
-                msg = (_("Subnet %s has one or more active VMs "
-                       "Router-IF add not permitted") % subnet_id)
-                raise n_exc.BadRequest(resource='subnet', msg=msg)
-            self.nuageclient.delete_subnet(subnet_id)
-            net = netaddr.IPNetwork(subn['cidr'])
-            pnet_binding = nuagedb.get_network_binding(context.session,
-                                                       subn['network_id'])
-            params = {
-                'net': net,
-                'zone_id': nuage_zone['nuage_zone_id'],
-                'neutron_subnet_id': subnet_id,
-                'pnet_binding': pnet_binding
-            }
-            if not attributes.is_attr_set(subn['gateway_ip']):
-                subn['gateway_ip'] = str(netaddr.IPAddress(net.first + 1))
-
-            try:
-                nuage_subnet = self.nuageclient.create_domain_subnet(subn,
-                                                                   params)
-            except Exception:
-                with excutils.save_and_reraise_exception():
-                    super(NuagePlugin,
-                          self).remove_router_interface(context,
-                                                        router_id,
-                                                        interface_info)
-
-            if nuage_subnet:
-                ns_dict = {}
-                ns_dict['nuage_subnet_id'] = nuage_subnet['nuage_subnetid']
-                ns_dict['nuage_l2dom_tmplt_id'] = None
-                nuagedb.update_subnetl2dom_mapping(subnet_l2dom,
-                                                   ns_dict)
-
-        return rtr_if_info
-
-    def remove_router_interface(self, context, router_id, interface_info):
-        if 'subnet_id' in interface_info:
-            subnet_id = interface_info['subnet_id']
-            subnet = self.get_subnet(context, subnet_id)
-            found = False
-            try:
-                filters = {'device_id': [router_id],
-                           'device_owner':
-                           [os_constants.DEVICE_OWNER_ROUTER_INTF],
-                           'network_id': [subnet['network_id']]}
-                ports = self.get_ports(context, filters)
-
-                for p in ports:
-                    if p['fixed_ips'][0]['subnet_id'] == subnet_id:
-                        found = True
-                        break
-            except exc.NoResultFound:
-                msg = (_("No router interface found for Router %s. "
-                         "Router-IF delete failed") % router_id)
-                raise n_exc.BadRequest(resource='router', msg=msg)
-
-            if not found:
-                msg = (_("No router interface found for Router %s. "
-                         "Router-IF delete failed") % router_id)
-                raise n_exc.BadRequest(resource='router', msg=msg)
-        elif 'port_id' in interface_info:
-            port_db = self._get_port(context, interface_info['port_id'])
-            if not port_db:
-                msg = (_("No router interface found for Router %s. "
-                         "Router-IF delete failed") % router_id)
-                raise n_exc.BadRequest(resource='router', msg=msg)
-            subnet_id = port_db['fixed_ips'][0]['subnet_id']
-
-        session = context.session
-        with session.begin(subtransactions=True):
-            subnet_l2dom = nuagedb.get_subnet_l2dom_by_id(session,
-                                                          subnet_id)
-            if not subnet_l2dom:
-                return super(NuagePlugin,
-                             self).remove_router_interface(context,
-                                                           router_id,
-                                                           interface_info)
-            nuage_subn_id = subnet_l2dom['nuage_subnet_id']
-            if self.nuageclient.vms_on_subnet(nuage_subn_id):
-                msg = (_("Subnet %s has one or more active VMs "
-                         "Router-IF delete not permitted") % subnet_id)
-                raise n_exc.BadRequest(resource='subnet', msg=msg)
-
-            neutron_subnet = self.get_subnet(context, subnet_id)
-            ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(
-                context.session,
-                router_id)
-            if not ent_rtr_mapping:
-                msg = (_("Router %s does not hold net_partition "
-                         "assoc on Nuage VSD. Router-IF delete failed")
-                       % router_id)
-                raise n_exc.BadRequest(resource='router', msg=msg)
-
-            net = netaddr.IPNetwork(neutron_subnet['cidr'])
-            netpart_id = ent_rtr_mapping['net_partition_id']
-            pnet_binding = nuagedb.get_network_binding(
-                context.session, neutron_subnet['network_id'])
-            params = {
-                'tenant_id': neutron_subnet['tenant_id'],
-                'net': net,
-                'netpart_id': netpart_id,
-                'nuage_subn_id': nuage_subn_id,
-                'neutron_subnet': neutron_subnet,
-                'pnet_binding': pnet_binding
-            }
-            nuage_subnet = self.nuageclient.remove_router_interface(params)
-            info = super(NuagePlugin,
-                         self).remove_router_interface(context, router_id,
-                                                       interface_info)
-
-            if nuage_subnet:
-                tmplt_id = str(nuage_subnet['nuage_l2template_id'])
-                ns_dict = {}
-                ns_dict['nuage_subnet_id'] = nuage_subnet['nuage_l2domain_id']
-                ns_dict['nuage_l2dom_tmplt_id'] = tmplt_id
-                nuagedb.update_subnetl2dom_mapping(subnet_l2dom,
-                                                   ns_dict)
-        return info
-
-    def _get_net_partition_for_router(self, context, rtr):
-        ent = rtr.get('net_partition', None)
-        if not ent:
-            def_net_part = cfg.CONF.RESTPROXY.default_net_partition_name
-            net_partition = nuagedb.get_net_partition_by_name(context.session,
-                                                              def_net_part)
-        else:
-            net_partition = self._resource_finder(context, 'router',
-                                                  'net_partition', rtr)
-        if not net_partition:
-            msg = _("Either net_partition is not provided with router OR "
-                    "default net_partition is not created at the start")
-            raise n_exc.BadRequest(resource='router', msg=msg)
-        return net_partition
-
-    def create_router(self, context, router):
-        net_partition = self._get_net_partition_for_router(context, router)
-        neutron_router = super(NuagePlugin, self).create_router(context,
-                                                                router)
-        params = {
-            'net_partition': net_partition,
-            'tenant_id': neutron_router['tenant_id']
-        }
-        try:
-            nuage_router = self.nuageclient.create_router(neutron_router,
-                                                          router['router'],
-                                                          params)
-        except Exception:
-            with excutils.save_and_reraise_exception():
-                super(NuagePlugin, self).delete_router(context,
-                                                       neutron_router['id'])
-
-        if nuage_router:
-            with context.session.begin(subtransactions=True):
-                nuagedb.add_entrouter_mapping(context.session,
-                                              net_partition['id'],
-                                              neutron_router['id'],
-                                              nuage_router['nuage_domain_id'])
-
-        return neutron_router
-
-    def _validate_nuage_staticroutes(self, old_routes, added, removed):
-        cidrs = []
-        for old in old_routes:
-            if old not in removed:
-                ip = netaddr.IPNetwork(old['destination'])
-                cidrs.append(ip)
-        for route in added:
-            ip = netaddr.IPNetwork(route['destination'])
-            matching = netaddr.all_matching_cidrs(ip.ip, cidrs)
-            if matching:
-                msg = _('for same subnet, multiple static routes not allowed')
-                raise n_exc.BadRequest(resource='router', msg=msg)
-            cidrs.append(ip)
-
-    def update_router(self, context, id, router):
-        r = router['router']
-        with context.session.begin(subtransactions=True):
-            if 'routes' in r:
-                old_routes = self._get_extra_routes_by_router_id(context,
-                                                                 id)
-                added, removed = utils.diff_list_of_dict(old_routes,
-                                                         r['routes'])
-                self._validate_nuage_staticroutes(old_routes, added, removed)
-
-                ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(
-                    context.session, id)
-                if not ent_rtr_mapping:
-                    msg = (_("Router %s does not hold net-partition "
-                             "assoc on VSD. extra-route failed") % id)
-                    raise n_exc.BadRequest(resource='router', msg=msg)
-                # Let it do internal checks first and verify it.
-                router_updated = super(NuagePlugin,
-                                       self).update_router(context,
-                                                           id,
-                                                           router)
-                for route in removed:
-                    destaddr = route['destination']
-                    cidr = destaddr.split('/')
-                    params = {
-                        "address": cidr[0],
-                        "nexthop": route['nexthop'],
-                        "nuage_domain_id": ent_rtr_mapping['nuage_router_id']
-                    }
-                    self.nuageclient.delete_nuage_staticroute(params)
-
-                for route in added:
-                    params = {
-                        'parent_id': ent_rtr_mapping['nuage_router_id'],
-                        'net': netaddr.IPNetwork(route['destination']),
-                        'nexthop': route['nexthop']
-                    }
-                    self.nuageclient.create_nuage_staticroute(
-                        params)
-            else:
-                router_updated = super(NuagePlugin, self).update_router(
-                    context, id, router)
-        return router_updated
-
-    def delete_router(self, context, id):
-        neutron_router = self.get_router(context, id)
-        session = context.session
-        ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(session,
-                                                               id)
-        if ent_rtr_mapping:
-            filters = {
-                'device_id': [id],
-                'device_owner': [os_constants.DEVICE_OWNER_ROUTER_INTF]
-            }
-            ports = self.get_ports(context, filters)
-            if ports:
-                raise l3.RouterInUse(router_id=id)
-            nuage_domain_id = ent_rtr_mapping['nuage_router_id']
-            self.nuageclient.delete_router(nuage_domain_id)
-
-        super(NuagePlugin, self).delete_router(context, id)
-
-        if not self._check_router_subnet_for_tenant(
-                context, neutron_router['tenant_id']):
-            user_id, group_id = self.nuageclient.get_usergroup(
-                neutron_router['tenant_id'],
-                ent_rtr_mapping['net_partition_id'])
-            self.nuageclient.delete_user(user_id)
-            self.nuageclient.delete_group(group_id)
-
-    def _make_net_partition_dict(self, net_partition, fields=None):
-        res = {
-            'id': net_partition['id'],
-            'name': net_partition['name'],
-            'l3dom_tmplt_id': net_partition['l3dom_tmplt_id'],
-            'l2dom_tmplt_id': net_partition['l2dom_tmplt_id'],
-        }
-        return self._fields(res, fields)
-
-    def _create_net_partition(self, session, net_part_name):
-        fip_quota = cfg.CONF.RESTPROXY.default_floatingip_quota
-        params = {
-            "name": net_part_name,
-            "fp_quota": str(fip_quota)
-        }
-        nuage_net_partition = self.nuageclient.create_net_partition(params)
-        net_partitioninst = None
-        if nuage_net_partition:
-            nuage_entid = nuage_net_partition['nuage_entid']
-            l3dom_id = nuage_net_partition['l3dom_id']
-            l2dom_id = nuage_net_partition['l2dom_id']
-            with session.begin():
-                net_partitioninst = nuagedb.add_net_partition(session,
-                                                              nuage_entid,
-                                                              l3dom_id,
-                                                              l2dom_id,
-                                                              net_part_name)
-        if not net_partitioninst:
-            return {}
-        return self._make_net_partition_dict(net_partitioninst)
-
-    def _create_default_net_partition(self, default_net_part):
-        def_netpart = self.nuageclient.get_def_netpartition_data(
-            default_net_part)
-        session = db.get_session()
-        if def_netpart:
-            net_partition = nuagedb.get_net_partition_by_name(
-                session, default_net_part)
-            with session.begin(subtransactions=True):
-                if net_partition:
-                    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):
-        ent = net_partition['net_partition']
-        session = context.session
-        return self._create_net_partition(session, ent["name"])
-
-    def delete_net_partition(self, context, id):
-        ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_entid(context.session,
-                                                               id)
-        if ent_rtr_mapping:
-            msg = (_("One or more router still attached to "
-                     "net_partition %s.") % id)
-            raise n_exc.BadRequest(resource='net_partition', msg=msg)
-        net_partition = nuagedb.get_net_partition_by_id(context.session, id)
-        if not net_partition:
-            msg = (_("NetPartition with %s does not exist") % id)
-            raise n_exc.BadRequest(resource='net_partition', msg=msg)
-        l3dom_tmplt_id = net_partition['l3dom_tmplt_id']
-        l2dom_tmplt_id = net_partition['l2dom_tmplt_id']
-        self.nuageclient.delete_net_partition(net_partition['id'],
-                                              l3dom_id=l3dom_tmplt_id,
-                                              l2dom_id=l2dom_tmplt_id)
-        with context.session.begin(subtransactions=True):
-            nuagedb.delete_net_partition(context.session,
-                                         net_partition)
-
-    def get_net_partition(self, context, id, fields=None):
-        net_partition = nuagedb.get_net_partition_by_id(context.session,
-                                                        id)
-        return self._make_net_partition_dict(net_partition)
-
-    def get_net_partitions(self, context, filters=None, fields=None):
-        net_partitions = nuagedb.get_net_partitions(context.session,
-                                                    filters=filters,
-                                                    fields=fields)
-        return [self._make_net_partition_dict(net_partition, fields)
-                for net_partition in net_partitions]
-
-    def _check_floatingip_update(self, context, port):
-        filter = {'fixed_port_id': [port['id']]}
-        local_fip = self.get_floatingips(context,
-                                         filters=filter)
-        if local_fip:
-            fip = local_fip[0]
-            self._create_update_floatingip(context,
-                                           fip, port['id'])
-
-    def _create_update_floatingip(self, context,
-                                  neutron_fip, port_id):
-        rtr_id = neutron_fip['router_id']
-        net_id = neutron_fip['floating_network_id']
-        subn = nuagedb.get_ipalloc_for_fip(context.session,
-                                           net_id,
-                                           neutron_fip['floating_ip_address'])
-
-        fip_pool = self.nuageclient.get_nuage_fip_pool_by_id(subn['subnet_id'])
-        if not fip_pool:
-            msg = _('sharedresource %s not found on VSD') % subn['subnet_id']
-            raise n_exc.BadRequest(resource='floatingip',
-                                   msg=msg)
-
-        ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(context.session,
-                                                               rtr_id)
-        if not ent_rtr_mapping:
-            msg = _('router %s is not associated with '
-                    'any net-partition') % rtr_id
-            raise n_exc.BadRequest(resource='floatingip',
-                                   msg=msg)
-
-        params = {
-            'router_id': ent_rtr_mapping['nuage_router_id'],
-            'fip_id': neutron_fip['id'],
-            'neutron_fip': neutron_fip
-        }
-
-        fip = self.nuageclient.get_nuage_fip_by_id(params)
-        if not fip:
-            params = {
-                'nuage_rtr_id': ent_rtr_mapping['nuage_router_id'],
-                'nuage_fippool_id': fip_pool['nuage_fip_pool_id'],
-                'neutron_fip_ip': neutron_fip['floating_ip_address'],
-                'neutron_fip_id': neutron_fip['id']
-            }
-            nuage_fip_id = self.nuageclient.create_nuage_floatingip(params)
-        else:
-            nuage_fip_id = fip['nuage_fip_id']
-
-        # Update VM if required
-        params = {
-            'neutron_port_id': port_id,
-            'nuage_fip_id': nuage_fip_id,
-            'nuage_rtr_id': ent_rtr_mapping['nuage_router_id']
-        }
-        nuage_port = self.nuageclient.get_nuage_port_by_id(params)
-        if nuage_port:
-            if (nuage_port['nuage_domain_id']) != (
-                    ent_rtr_mapping['nuage_router_id']):
-                msg = _('Floating IP can not be associated to VM in '
-                        'different router context')
-                raise nuage_exc.OperationNotSupported(msg=msg)
-
-            params = {
-                'nuage_vport_id': nuage_port['nuage_vport_id'],
-                'nuage_fip_id': nuage_fip_id
-            }
-            self.nuageclient.update_nuage_vm_vport(params)
-
-    def create_floatingip(self, context, floatingip):
-        fip = floatingip['floatingip']
-        with context.session.begin(subtransactions=True):
-            neutron_fip = super(NuagePlugin, self).create_floatingip(
-                context, floatingip)
-            if not neutron_fip['router_id']:
-                return neutron_fip
-            try:
-                self._create_update_floatingip(context, neutron_fip,
-                                               fip['port_id'])
-            except (nuage_exc.OperationNotSupported, n_exc.BadRequest):
-                with excutils.save_and_reraise_exception():
-                    super(NuagePlugin, self).delete_floatingip(
-                        context, neutron_fip['id'])
-            return neutron_fip
-
-    def disassociate_floatingips(self, context, port_id, do_notify=True):
-        router_ids = super(NuagePlugin, self).disassociate_floatingips(
-            context, port_id, do_notify=do_notify)
-
-        params = {
-            'neutron_port_id': port_id,
-        }
-        nuage_port = self.nuageclient.get_nuage_port_by_id(params)
-        if nuage_port:
-            params = {
-                'nuage_vport_id': nuage_port['nuage_vport_id'],
-                'nuage_fip_id': None
-            }
-            self.nuageclient.update_nuage_vm_vport(params)
-
-        return router_ids
-
-    def update_floatingip(self, context, id, floatingip):
-        fip = floatingip['floatingip']
-        orig_fip = self._get_floatingip(context, id)
-        port_id = orig_fip['fixed_port_id']
-        router_ids = []
-        with context.session.begin(subtransactions=True):
-            neutron_fip = super(NuagePlugin, self).update_floatingip(
-                context, id, floatingip)
-            if fip['port_id'] is not None:
-                if not neutron_fip['router_id']:
-                    ret_msg = 'floating-ip is not associated yet'
-                    raise n_exc.BadRequest(resource='floatingip',
-                                           msg=ret_msg)
-
-                try:
-                    self._create_update_floatingip(context,
-                                                   neutron_fip,
-                                                   fip['port_id'])
-                except nuage_exc.OperationNotSupported:
-                    with excutils.save_and_reraise_exception():
-                        router_ids = super(
-                            NuagePlugin, self).disassociate_floatingips(
-                                context, fip['port_id'], do_notify=False)
-                except n_exc.BadRequest:
-                    with excutils.save_and_reraise_exception():
-                        super(NuagePlugin, self).delete_floatingip(context,
-                                                                   id)
-            else:
-                params = {
-                    'neutron_port_id': port_id,
-                }
-                nuage_port = self.nuageclient.get_nuage_port_by_id(params)
-                if nuage_port:
-                    params = {
-                        'nuage_vport_id': nuage_port['nuage_vport_id'],
-                        'nuage_fip_id': None
-                    }
-                    self.nuageclient.update_nuage_vm_vport(params)
-
-        # now that we've left db transaction, we are safe to notify
-        self.notify_routers_updated(context, router_ids)
-
-        return neutron_fip
-
-    def delete_floatingip(self, context, fip_id):
-        fip = self._get_floatingip(context, fip_id)
-        port_id = fip['fixed_port_id']
-        with context.session.begin(subtransactions=True):
-            if port_id:
-                params = {
-                    'neutron_port_id': port_id,
-                }
-                nuage_port = self.nuageclient.get_nuage_port_by_id(params)
-                if (nuage_port and
-                    nuage_port['nuage_vport_id'] is not None):
-                    params = {
-                        'nuage_vport_id': nuage_port['nuage_vport_id'],
-                        'nuage_fip_id': None
-                    }
-                    self.nuageclient.update_nuage_vm_vport(params)
-                    LOG.debug("Floating-ip %(fip)s is disassociated from "
-                              "vport %(vport)s",
-                              {'fip': fip_id,
-                               'vport': nuage_port['nuage_vport_id']})
-
-                router_id = fip['router_id']
-            else:
-                router_id = fip['last_known_router_id']
-
-            if router_id:
-                ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(
-                    context.session,
-                    router_id)
-                if not ent_rtr_mapping:
-                    msg = _('router %s is not associated with '
-                            'any net-partition') % router_id
-                    raise n_exc.BadRequest(resource='floatingip',
-                                       msg=msg)
-                params = {
-                    'router_id': ent_rtr_mapping['nuage_router_id'],
-                    'fip_id': fip_id
-                }
-                fip = self.nuageclient.get_nuage_fip_by_id(params)
-                if fip:
-                    self.nuageclient.delete_nuage_floatingip(
-                        fip['nuage_fip_id'])
-                    LOG.debug('Floating-ip %s deleted from VSD', fip_id)
-
-            super(NuagePlugin, self).delete_floatingip(context, fip_id)
-
-    def delete_security_group(self, context, id):
-        filters = {'security_group_id': [id]}
-        ports = self._get_port_security_group_bindings(context,
-                                                       filters)
-        if ports:
-            raise ext_sg.SecurityGroupInUse(id=id)
-        sg_rules = self.get_security_group_rules(context,
-                                                 {'security_group_id': [id]})
-
-        if sg_rules:
-            self.nuageclient.delete_nuage_sgrule(sg_rules)
-        self.nuageclient.delete_nuage_secgroup(id)
-
-        super(NuagePlugin, self).delete_security_group(context, id)
-
-    def create_security_group_rule(self, context, security_group_rule):
-        sg_rule = security_group_rule['security_group_rule']
-        self.nuageclient.validate_nuage_sg_rule_definition(sg_rule)
-        sg_id = sg_rule['security_group_id']
-
-        local_sg_rule = super(NuagePlugin,
-                              self).create_security_group_rule(
-                                        context, security_group_rule)
-
-        try:
-            nuage_vptag = self.nuageclient.get_sg_vptag_mapping(sg_id)
-            if nuage_vptag:
-                sg_params = {
-                    'sg_id': sg_id,
-                    'neutron_sg_rule': local_sg_rule,
-                    'vptag': nuage_vptag
-                }
-                self.nuageclient.create_nuage_sgrule(sg_params)
-        except Exception:
-            with excutils.save_and_reraise_exception():
-                super(NuagePlugin,
-                      self).delete_security_group_rule(context,
-                                                   local_sg_rule['id'])
-
-        return local_sg_rule
-
-    def delete_security_group_rule(self, context, id):
-        local_sg_rule = self.get_security_group_rule(context, id)
-        super(NuagePlugin, self).delete_security_group_rule(context, id)
-        self.nuageclient.delete_nuage_sgrule([local_sg_rule])
diff --git a/neutron/plugins/nuage/syncmanager.py b/neutron/plugins/nuage/syncmanager.py
deleted file mode 100644 (file)
index 6768fe0..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-#
-
-from oslo_concurrency import lockutils
-from oslo_config import cfg
-from oslo_utils import importutils
-import sqlalchemy.orm.exc as db_exc
-
-from neutron import context as ncontext
-from neutron.db import db_base_plugin_v2
-from neutron.db import extraroute_db
-from neutron.db import securitygroups_db
-from neutron.i18n import _LE, _LI, _LW
-from neutron.openstack.common import log
-from neutron.plugins.nuage.common import config
-from neutron.plugins.nuage import nuagedb
-
-
-LOG = log.getLogger(__name__)
-NUAGE_CONFIG_FILE = '/etc/neutron/plugins/nuage/nuage_plugin.ini'
-
-
-class SyncManager(db_base_plugin_v2.NeutronDbPluginV2,
-                  extraroute_db.ExtraRoute_db_mixin,
-                  securitygroups_db.SecurityGroupDbMixin):
-    """
-    This class provides functionality to sync data between OpenStack and VSD.
-    """
-
-    def __init__(self, nuageclient):
-        self.context = ncontext.get_admin_context()
-        self.nuageclient = nuageclient
-
-    @lockutils.synchronized('synchronize', 'nuage-sync', external=True)
-    def synchronize(self, fipquota):
-        LOG.info(_LI("Starting the sync between Neutron and VSD"))
-        try:
-            # Get all data to determine the resources to sync
-            data = self._get_all_data()
-            resources = self.nuageclient.get_resources_to_sync(data)
-
-            # Sync all resources
-            self._sync(resources, fipquota)
-        except Exception:
-            LOG.exception(_LE("Cannot complete the sync between Neutron and "
-                              "VSD because of error."))
-            return
-
-        LOG.info(_LI("Sync between Neutron and VSD completed successfully"))
-
-    def _get_all_data(self):
-        # Get all net-partitions
-        net_partition_list = nuagedb.get_all_net_partitions(
-            self.context.session)
-
-        # Get all subnet ids
-        subnet_id_list = nuagedb.get_subnet_ids(self.context.session)
-
-        # Get all router ids
-        router_id_list = nuagedb.get_router_ids(self.context.session)
-
-        # Get all ports
-        port_list = self.get_ports(self.context)
-
-        # Get all routes
-        route_list = nuagedb.get_all_routes(self.context.session)
-
-        # Get all floatingips
-        fip_list = self.get_floatingips(self.context)
-
-        # Get all securitygrp ids
-        secgrp_id_list = nuagedb.get_secgrp_ids(self.context.session)
-
-        # Get all securitygrprules
-        secgrprule_id_list = self.get_security_group_rules(self.context)
-
-        # Get all portbindings
-        portbinding_list = self._get_port_security_group_bindings(self.context)
-
-        data = {
-            'netpartition': net_partition_list,
-            'subnet': subnet_id_list,
-            'router': router_id_list,
-            'port': port_list,
-            'route': route_list,
-            'fip': fip_list,
-            'secgroup': secgrp_id_list,
-            'secgrouprule': secgrprule_id_list,
-            'portbinding': portbinding_list,
-        }
-        return data
-
-    def _sync(self, resources, fip_quota):
-        # Sync net-partitions
-        net_partition_id_dict = self.sync_net_partitions(fip_quota, resources)
-
-        # Sync sharednetworks
-        self.sync_sharednetworks(resources)
-
-        # Sync l2domains
-        self.sync_l2domains(net_partition_id_dict, resources)
-
-        # Sync domains
-        self.sync_domains(net_partition_id_dict, resources)
-
-        # Sync domainsubnets
-        self.sync_domainsubnets(resources)
-
-        # Sync routes
-        self.sync_routes(resources)
-
-        # Sync vms
-        self.sync_vms(resources)
-
-        # Sync secgrps
-        self.sync_secgrps(resources)
-
-        # Sync secgrprules
-        self.sync_secgrp_rules(resources)
-
-        # Sync fips
-        self._sync_fips(resources)
-
-        # Delete the old net-partitions
-        for net_id in net_partition_id_dict:
-            nuagedb.delete_net_partition_by_id(self.context.session,
-                                               net_id)
-
-    def sync_net_partitions(self, fip_quota, resources):
-        net_partition_id_dict = {}
-        for netpart_id in resources['netpartition']['add']:
-            with self.context.session.begin(subtransactions=True):
-                netpart = self._get_netpart_data(netpart_id)
-                if netpart:
-                    result = self.nuageclient.create_netpart(netpart,
-                                                             fip_quota)
-                    netpart = result.get(netpart_id)
-                    if netpart:
-                        net_partition_id_dict[netpart_id] = netpart['id']
-                        nuagedb.add_net_partition(
-                            self.context.session,
-                            netpart['id'],
-                            netpart['l3dom_tmplt_id'],
-                            netpart['l2dom_tmplt_id'],
-                            netpart['name'])
-
-        return net_partition_id_dict
-
-    def sync_sharednetworks(self, resources):
-        for sharednet_id in resources['sharednetwork']['add']:
-            with self.context.session.begin(subtransactions=True):
-                subnet, subl2dom = self._get_subnet_data(
-                    sharednet_id,
-                    get_mapping=False)
-                if subnet:
-                    self.nuageclient.create_sharednetwork(subnet)
-
-    def sync_l2domains(self, net_partition_id_dict, resources):
-        for l2dom_id in resources['l2domain']['add']:
-            with self.context.session.begin(subtransactions=True):
-                subnet, subl2dom = self._get_subnet_data(l2dom_id)
-                if subnet:
-                    # if subnet exists, subl2dom will exist
-                    netpart_id = subl2dom['net_partition_id']
-                    if netpart_id in net_partition_id_dict.keys():
-                        # Use the id of the newly created net_partition
-                        netpart_id = net_partition_id_dict[netpart_id]
-
-                    result = self.nuageclient.create_l2domain(netpart_id,
-                                                              subnet)
-                    if result:
-                        nuagedb.get_update_subnetl2dom_mapping(
-                            self.context.session,
-                            result)
-
-    def sync_domains(self, net_partition_id_dict, resources):
-        for domain_id in resources['domain']['add']:
-            with self.context.session.begin(subtransactions=True):
-                router, entrtr = self._get_router_data(domain_id)
-                if router:
-                    # if router exists, entrtr will exist
-                    netpart_id = entrtr['net_partition_id']
-                    if netpart_id in net_partition_id_dict.keys():
-                        # Use the id of the newly created net_partition
-                        netpart_id = net_partition_id_dict[netpart_id]
-
-                    netpart = nuagedb.get_net_partition_by_id(
-                        self.context.session,
-                        netpart_id)
-                    result = self.nuageclient.create_domain(netpart, router)
-                    if result:
-                        nuagedb.get_update_entrtr_mapping(self.context.session,
-                                                          result)
-
-    def sync_domainsubnets(self, resources):
-        for domsubn_id in resources['domainsubnet']['add']:
-            # This is a dict of subn_id and the router interface port
-            subn_rtr_intf_port_dict = (
-                resources['port']['sub_rtr_intf_port_dict'])
-            port_id = subn_rtr_intf_port_dict[domsubn_id]
-            port = self._get_port_data(port_id)
-            if port:
-                with self.context.session.begin(subtransactions=True):
-                    subnet, subl2dom = self._get_subnet_data(domsubn_id)
-                    if subnet:
-                        result = self.nuageclient.create_domainsubnet(subnet,
-                                                                      port)
-                        if result:
-                            nuagedb.get_update_subnetl2dom_mapping(
-                                self.context.session,
-                                result)
-
-    def sync_routes(self, resources):
-        for rt in resources['route']['add']:
-            with self.context.session.begin(subtransactions=True):
-                route = self._get_route_data(rt)
-                if route:
-                    self.nuageclient.create_route(route)
-
-    def sync_vms(self, resources):
-        for port_id in resources['port']['vm']:
-            port = self._get_port_data(port_id)
-            if port:
-                self.nuageclient.create_vm(port)
-
-    def sync_secgrps(self, resources):
-        secgrp_dict = resources['security']['secgroup']
-        for secgrp_id, ports in secgrp_dict['l2domain']['add'].iteritems():
-            with self.context.session.begin(subtransactions=True):
-                secgrp = self._get_sec_grp_data(secgrp_id)
-                if secgrp:
-                    self.nuageclient.create_security_group(secgrp, ports)
-
-        for secgrp_id, ports in secgrp_dict['domain']['add'].iteritems():
-            with self.context.session.begin(subtransactions=True):
-                secgrp = self._get_sec_grp_data(secgrp_id)
-                if secgrp:
-                    self.nuageclient.create_security_group(secgrp, ports)
-
-    def sync_secgrp_rules(self, resources):
-        secrule_list = resources['security']['secgrouprule']
-        for secrule_id in secrule_list['l2domain']['add']:
-            with self.context.session.begin(subtransactions=True):
-                secgrprule = self._get_sec_grp_rule_data(secrule_id)
-                if secgrprule:
-                    self.nuageclient.create_security_group_rule(secgrprule)
-
-        for secrule_id in secrule_list['domain']['add']:
-            with self.context.session.begin(subtransactions=True):
-                secgrprule = self._get_sec_grp_rule_data(secrule_id)
-                if secgrprule:
-                    self.nuageclient.create_security_group_rule(secgrprule)
-
-    def _sync_fips(self, resources):
-        for fip_id in resources['fip']['add']:
-            with self.context.session.begin(subtransactions=True):
-                fip = self._get_fip_data(fip_id)
-                if fip:
-                    ipalloc = self._get_ipalloc_for_fip(fip)
-                    self.nuageclient.create_fip(fip, ipalloc)
-
-        for fip_id in resources['fip']['disassociate']:
-            with self.context.session.begin(subtransactions=True):
-                fip = self._get_fip_data(fip_id)
-                if fip:
-                    self.nuageclient.disassociate_fip(fip)
-
-        for fip_id in resources['fip']['associate']:
-            with self.context.session.begin(subtransactions=True):
-                fip = self._get_fip_data(fip_id)
-                if fip:
-                    self.nuageclient.associate_fip(fip)
-
-    def _get_subnet_data(self, subnet_id, get_mapping=True):
-        subnet = None
-        subl2dom = None
-        try:
-            if get_mapping:
-                subl2dom_db = nuagedb.get_subnet_l2dom_with_lock(
-                    self.context.session,
-                    subnet_id)
-                subl2dom = nuagedb.make_subnl2dom_dict(subl2dom_db)
-
-            subnet_db = nuagedb.get_subnet_with_lock(self.context.session,
-                                                     subnet_id)
-            subnet = self._make_subnet_dict(subnet_db)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("Subnet %s not found in neutron for sync"),
-                        subnet_id)
-
-        return subnet, subl2dom
-
-    def _get_router_data(self, router_id):
-        router = None
-        entrtr = None
-        try:
-            entrtr_db = nuagedb.get_ent_rtr_mapping_with_lock(
-                self.context.session,
-                router_id)
-            entrtr = nuagedb.make_entrtr_dict(entrtr_db)
-
-            router_db = nuagedb.get_router_with_lock(self.context.session,
-                                                     router_id)
-            router = self._make_router_dict(router_db)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("Router %s not found in neutron for sync"),
-                        router_id)
-
-        return router, entrtr
-
-    def _get_route_data(self, rt):
-        route = None
-        try:
-            route = nuagedb.get_route_with_lock(self.context.session,
-                                                rt['destination'],
-                                                rt['nexthop'])
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("Route with destination %(dest)s and nexthop "
-                            "%(hop)s not found in neutron for sync"),
-                        {'dest': rt['destination'],
-                         'hop': rt['nexthop']})
-
-        return route
-
-    def _get_sec_grp_data(self, secgrp_id):
-        secgrp = None
-        try:
-            secgrp_db = nuagedb.get_secgrp_with_lock(self.context.session,
-                                                     secgrp_id)
-            secgrp = self._make_security_group_dict(secgrp_db)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("Security group %s not found in neutron for sync"),
-                        secgrp_id)
-        return secgrp
-
-    def _get_sec_grp_rule_data(self, secgrprule_id):
-        secgrprule = None
-        try:
-            secrule_db = nuagedb.get_secgrprule_with_lock(self.context.session,
-                                                          secgrprule_id)
-            secgrprule = self._make_security_group_rule_dict(secrule_db)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("Security group rule %s not found in neutron for "
-                            "sync"), secgrprule_id)
-        return secgrprule
-
-    def _get_fip_data(self, fip_id):
-        fip = None
-        try:
-            fip_db = nuagedb.get_fip_with_lock(self.context.session, fip_id)
-            fip = self._make_floatingip_dict(fip_db)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("Floating ip %s not found in neutron for sync"),
-                        fip_id)
-        return fip
-
-    def _get_ipalloc_for_fip(self, fip):
-        ipalloc = None
-        try:
-            ipalloc = nuagedb.get_ipalloc_for_fip(self.context.session,
-                                                  fip['floating_network_id'],
-                                                  fip['floating_ip_address'],
-                                                  lock=True)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("IP allocation for floating ip %s not found in "
-                            "neutron for sync"), fip['id'])
-        return ipalloc
-
-    def _get_netpart_data(self, netpart_id):
-        netpart = None
-        try:
-            netpart = nuagedb.get_net_partition_with_lock(
-                self.context.session,
-                netpart_id)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("Net-partition %s not found in neutron for sync"),
-                        netpart_id)
-        return netpart
-
-    def _get_port_data(self, port_id):
-        port = None
-        try:
-            port_db = nuagedb.get_port_with_lock(self.context.session, port_id)
-            port = self._make_port_dict(port_db)
-        except db_exc.NoResultFound:
-            LOG.warning(_LW("VM port %s not found in neutron for sync"),
-                        port_id)
-        return port
-
-
-def main():
-    cfg.CONF(default_config_files=(
-        [NUAGE_CONFIG_FILE]))
-    config.nuage_register_cfg_opts()
-    server = cfg.CONF.RESTPROXY.server
-    serverauth = cfg.CONF.RESTPROXY.serverauth
-    serverssl = cfg.CONF.RESTPROXY.serverssl
-    base_uri = cfg.CONF.RESTPROXY.base_uri
-    auth_resource = cfg.CONF.RESTPROXY.auth_resource
-    organization = cfg.CONF.RESTPROXY.organization
-    fipquota = str(cfg.CONF.RESTPROXY.default_floatingip_quota)
-    logging = importutils.import_module('logging')
-    nuageclientinst = importutils.import_module('nuagenetlib.nuageclient')
-    nuageclient = nuageclientinst.NuageClient(server, base_uri,
-                                              serverssl, serverauth,
-                                              auth_resource,
-                                              organization)
-    logging.basicConfig(level=logging.DEBUG)
-    SyncManager(nuageclient).synchronize(fipquota)
-
-if __name__ == '__main__':
-    main()
diff --git a/neutron/tests/unit/ml2/drivers/nuage/__init__.py b/neutron/tests/unit/ml2/drivers/nuage/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/neutron/tests/unit/ml2/drivers/nuage/test_nuage_mechanism_driver.py b/neutron/tests/unit/ml2/drivers/nuage/test_nuage_mechanism_driver.py
deleted file mode 100644 (file)
index d890270..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from neutron.plugins.ml2 import config as ml2_config
-from neutron.tests.unit.ml2 import test_ml2_plugin
-import neutron.tests.unit.nuage.test_nuage_plugin as tnp
-from neutron.tests.unit import test_db_plugin
-
-
-class TestNuageMechDriverBase(tnp.NuagePluginV2TestCase):
-    def setUp(self):
-        ml2_config.cfg.CONF.set_override('mechanism_drivers',
-                                         ['nuage'],
-                                         'ml2')
-
-        super(TestNuageMechDriverBase,
-              self).setUp(plugin=test_ml2_plugin.PLUGIN_NAME)
-
-
-class TestNuageMechDriverNetworksV2(test_db_plugin.TestNetworksV2,
-                                    TestNuageMechDriverBase):
-    pass
-
-
-class TestNuageMechDriverSubnetsV2(test_db_plugin.TestSubnetsV2,
-                                   TestNuageMechDriverBase):
-    pass
-
-
-class TestNuageMechDriverPortsV2(test_db_plugin.TestPortsV2,
-                                TestNuageMechDriverBase):
-
-    def setUp(self):
-        super(TestNuageMechDriverPortsV2, self).setUp()
-        self.port_create_status = 'DOWN'
diff --git a/neutron/tests/unit/nuage/__init__.py b/neutron/tests/unit/nuage/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/neutron/tests/unit/nuage/fake_nuageclient.py b/neutron/tests/unit/nuage/fake_nuageclient.py
deleted file mode 100644 (file)
index e8099a6..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from neutron.openstack.common import uuidutils
-
-
-class FakeNuageClient(object):
-    def __init__(self, server, base_uri, serverssl,
-                 serverauth, auth_resource, organization):
-        pass
-
-    def rest_call(self, action, resource, data, extra_headers=None):
-        pass
-
-    def vms_on_l2domain(self, l2dom_id):
-        pass
-
-    def vms_on_subnet(self, subnet_id):
-        pass
-
-    def create_subnet(self, neutron_subnet, params):
-        nuage_subnet = {
-            'nuage_l2template_id': uuidutils.generate_uuid(),
-            'nuage_userid': uuidutils.generate_uuid(),
-            'nuage_groupid': uuidutils.generate_uuid(),
-            'nuage_l2domain_id': uuidutils.generate_uuid()
-        }
-        return nuage_subnet
-
-    def update_subnet(self, neutron_subnet, params):
-        pass
-
-    def delete_subnet(self, id):
-        pass
-
-    def create_router(self, neutron_router, router, params):
-        nuage_router = {
-            'nuage_userid': uuidutils.generate_uuid(),
-            'nuage_groupid': uuidutils.generate_uuid(),
-            'nuage_domain_id': uuidutils.generate_uuid(),
-            'nuage_def_zone_id': uuidutils.generate_uuid(),
-        }
-        return nuage_router
-
-    def delete_router(self, id):
-        pass
-
-    def delete_user(self, id):
-        pass
-
-    def delete_group(self, id):
-        pass
-
-    def create_domain_subnet(self, neutron_subnet, params):
-        pass
-
-    def delete_domain_subnet(self, id):
-        pass
-
-    def create_net_partition(self, params):
-        fake_net_partition = {
-            'nuage_entid': uuidutils.generate_uuid(),
-            'l3dom_id': uuidutils.generate_uuid(),
-            'l2dom_id': uuidutils.generate_uuid(),
-        }
-        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 get_net_partition_id_by_name(self, name):
-        return uuidutils.generate_uuid()
-
-    def delete_net_partition(self, id, l3dom_id=None, l2dom_id=None):
-        pass
-
-    def check_del_def_net_partition(self, ent_name):
-        pass
-
-    def create_vms(self, params):
-        pass
-
-    def delete_vms(self, params):
-        pass
-
-    def create_nuage_staticroute(self, params):
-        return uuidutils.generate_uuid()
-
-    def delete_nuage_staticroute(self, id):
-        pass
-
-    def create_nuage_sharedresource(self, params):
-        return uuidutils.generate_uuid()
-
-    def delete_nuage_sharedresource(self, id):
-        pass
-
-    def create_nuage_floatingip(self, params):
-        return uuidutils.generate_uuid()
-
-    def delete_nuage_floatingip(self, id):
-        pass
-
-    def update_nuage_vm_vport(self, params):
-        pass
-
-    def get_nuage_fip_pool_by_id(self, net_id):
-        result = {
-            'nuage_fip_pool_id': uuidutils.generate_uuid()
-        }
-        return result
-
-    def get_nuage_fip_by_id(self, params):
-        if 'neutron_fip' in params:
-            neutron_fip = params['neutron_fip']
-            if (neutron_fip['floating_ip_address'] == '12.0.0.3' and
-                neutron_fip['fixed_ip_address'] == '10.0.1.2') or (
-                    neutron_fip['floating_ip_address'] == '12.0.0.5' and
-                    neutron_fip['fixed_ip_address'] == '10.0.1.3'):
-                result = {
-                    'nuage_fip_id': '1',
-                    'nuage_parent_id': '1'
-                }
-                return result
-
-    def get_nuage_port_by_id(self, params):
-        if params.get('nuage_fip_id') == '1':
-            domain_id = uuidutils.generate_uuid()
-        else:
-            if 'nuage_router_id' in params:
-                domain_id = params['nuage_router_id']
-            else:
-                return
-
-        result = {
-            'nuage_vif_id': uuidutils.generate_uuid(),
-            'nuage_vport_id': uuidutils.generate_uuid(),
-            'nuage_domain_id': domain_id
-        }
-
-        return result
-
-    def get_zone_by_routerid(self, neutron_router_id):
-        result = {
-            'nuage_zone_id': uuidutils.generate_uuid()
-        }
-        return result
-
-    def get_usergroup(self, tenant, net_partition_id):
-        return uuidutils.generate_uuid(), uuidutils.generate_uuid()
-
-    def get_sg_vptag_mapping(self, id):
-        pass
-
-    def validate_nuage_sg_rule_definition(self, params):
-        pass
-
-    def create_nuage_sgrule(self, params):
-        pass
-
-    def update_nuage_vport(self, params):
-        pass
-
-    def delete_nuage_sgrule(self, params):
-        pass
-
-    def delete_nuage_secgroup(self, params):
-        pass
-
-    def process_port_create_security_group(self, params):
-        pass
-
-    def delete_port_security_group_bindings(self, params):
-        pass
-
-    def validate_provider_network(self, net_type, phy_net, vlan_id):
-        pass
-
-    def remove_router_interface(self, params):
-        pass
-
-    def get_resources_to_sync(self, data):
-        netpart_id_list = []
-        for netpart in data['netpartition']:
-            netpart_id_list.append(netpart['id'])
-
-        netpart_dict = {
-            'add': netpart_id_list,
-            'sync': []
-        }
-
-        subn_id_list = []
-        if data['subnet']:
-            subn_id_list.append(data['subnet'][0])
-
-        l2domain_dict = {
-            'add': subn_id_list
-        }
-
-        rtr_id_list = []
-        if data['router']:
-            rtr_id_list.append(data['router'][0])
-
-        domain_dict = {
-            'add': rtr_id_list
-        }
-
-        domain_subn_id = uuidutils.generate_uuid()
-
-        result = {
-            'netpartition': netpart_dict,
-            'l2domain': l2domain_dict,
-            'domain': domain_dict,
-            'domainsubnet': {'add': [domain_subn_id]},
-            'sharednetwork': {'add': [uuidutils.generate_uuid()]},
-            'route': {'add': []},
-            'security': {
-                'secgroup': {
-                    'l2domain': {'add': {
-                        uuidutils.generate_uuid(): [uuidutils.generate_uuid()]
-                    }},
-                    'domain': {'add': {
-                        uuidutils.generate_uuid(): [uuidutils.generate_uuid()]
-                    }}
-                },
-                'secgrouprule': {
-                    'l2domain': {'add': [uuidutils.generate_uuid()]},
-                    'domain': {'add': [uuidutils.generate_uuid()]}
-                },
-            },
-            'port': {
-                'vm': [uuidutils.generate_uuid()],
-                'sub_rtr_intf_port_dict': {
-                    domain_subn_id: uuidutils.generate_uuid()
-                },
-                'secgroup': [uuidutils.generate_uuid()]
-            },
-            'subl2dommapping': [uuidutils.generate_uuid()],
-            'fip': {
-                'add': [uuidutils.generate_uuid()],
-                'associate': [uuidutils.generate_uuid()],
-                'disassociate': [uuidutils.generate_uuid()]
-            }
-        }
-        return result
-
-    def create_netpart(self, netpart, fip_quota):
-        if netpart['name'] == 'sync-new-netpartition':
-            oldid = netpart['id']
-            netpart['id'] = 'a917924f-3139-4bdb-a4c3-ea7c8011582f'
-            netpart = {
-                oldid: netpart
-            }
-            return netpart
-        return {}
-
-    def create_sharednetwork(self, subnet):
-        pass
-
-    def create_l2domain(self, netpart_id, subnet):
-        subl2dom = {
-            'subnet_id': subnet['id'],
-            'nuage_subnet_id': '52daa465-cf33-4efd-91d3-f5bc2aebd',
-            'net_partition_id': netpart_id,
-            'nuage_l2dom_tmplt_id': uuidutils.generate_uuid(),
-            'nuage_user_id': uuidutils.generate_uuid(),
-            'nuage_group_id': uuidutils.generate_uuid(),
-        }
-
-        return subl2dom
-
-    def create_domain(self, netpart, router):
-        entrtr = {
-            'router_id': router['id'],
-            'nuage_router_id': '2d782c02-b88e-44ad-a79b-4bdf11f7df3d',
-            'net_partition_id': netpart['id']
-        }
-
-        return entrtr
-
-    def create_domainsubnet(self, subnet, ports):
-        pass
-
-    def create_route(self, route):
-        pass
-
-    def create_vm(self, port):
-        pass
-
-    def create_security_group(self, secgrp, ports):
-        pass
-
-    def create_security_group_rule(self, secgrprule):
-        pass
-
-    def create_fip(self, fip, ipalloc):
-        pass
-
-    def associate_fip(self, fip):
-        pass
-
-    def disassociate_fip(self, fip):
-        pass
diff --git a/neutron/tests/unit/nuage/test_nuage_plugin.py b/neutron/tests/unit/nuage/test_nuage_plugin.py
deleted file mode 100644 (file)
index bc2e342..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-
-import contextlib
-import copy
-import os
-
-import mock
-import netaddr
-from oslo_config import cfg
-from webob import exc
-
-from neutron.common import constants
-from neutron import context
-from neutron.extensions import external_net
-from neutron.extensions import l3
-from neutron.extensions import portbindings
-from neutron.extensions import providernet as pnet
-from neutron.extensions import securitygroup as ext_sg
-from neutron import manager
-from neutron.openstack.common import uuidutils
-from neutron.plugins.nuage import extensions
-from neutron.plugins.nuage.extensions import nuage_router
-from neutron.plugins.nuage import plugin as nuage_plugin
-from neutron.tests.unit import _test_extension_portbindings as test_bindings
-from neutron.tests.unit.nuage import fake_nuageclient
-from neutron.tests.unit import test_db_plugin
-from neutron.tests.unit import test_extension_extraroute as extraroute_test
-from neutron.tests.unit import test_extension_security_group as test_sg
-from neutron.tests.unit import test_extensions
-
-
-API_EXT_PATH = os.path.dirname(extensions.__file__)
-FAKE_DEFAULT_ENT = 'default'
-NUAGE_PLUGIN_PATH = 'neutron.plugins.nuage.plugin'
-FAKE_SERVER = '1.1.1.1'
-FAKE_SERVER_AUTH = 'user:pass'
-FAKE_SERVER_SSL = False
-FAKE_BASE_URI = '/base/'
-FAKE_AUTH_RESOURCE = '/auth'
-FAKE_ORGANIZATION = 'fake_org'
-
-_plugin_name = ('%s.NuagePlugin' % NUAGE_PLUGIN_PATH)
-
-
-def getNuageClient():
-    server = FAKE_SERVER
-    serverauth = FAKE_SERVER_AUTH
-    serverssl = FAKE_SERVER_SSL
-    base_uri = FAKE_BASE_URI
-    auth_resource = FAKE_AUTH_RESOURCE
-    organization = FAKE_ORGANIZATION
-    nuageclient = fake_nuageclient.FakeNuageClient(server,
-                                                   base_uri,
-                                                   serverssl,
-                                                   serverauth,
-                                                   auth_resource,
-                                                   organization)
-    return nuageclient
-
-
-class NuagePluginV2TestCase(test_db_plugin.NeutronDbPluginV2TestCase):
-    def setUp(self, plugin=_plugin_name,
-              ext_mgr=None, service_plugins=None):
-
-        if 'v6' in self._testMethodName:
-            self.skipTest("Nuage Plugin does not support IPV6.")
-
-        def mock_nuageClient_init(self):
-            self.nuageclient = getNuageClient()
-
-        with mock.patch.object(nuage_plugin.NuagePlugin,
-                               'nuageclient_init', new=mock_nuageClient_init):
-            cfg.CONF.set_override('api_extensions_path',
-                                  API_EXT_PATH)
-            super(NuagePluginV2TestCase, self).setUp(plugin=plugin,
-                                                     ext_mgr=ext_mgr)
-
-    def _assert_no_assoc_fip(self, fip):
-        body = self._show('floatingips',
-                          fip['floatingip']['id'])
-        self.assertIsNone(body['floatingip']['port_id'])
-        self.assertIsNone(
-            body['floatingip']['fixed_ip_address'])
-
-    def _associate_and_assert_fip(self, fip, port, allow=True):
-        port_id = port['port']['id']
-        ip_address = (port['port']['fixed_ips']
-                      [0]['ip_address'])
-        if allow:
-            body = self._update(
-                'floatingips', fip['floatingip']['id'],
-                {'floatingip': {'port_id': port_id}})
-            self.assertEqual(
-                body['floatingip']['port_id'], port_id)
-            self.assertEqual(
-                body['floatingip']['fixed_ip_address'],
-                ip_address)
-            return body['floatingip']['router_id']
-        else:
-            code = exc.HTTPInternalServerError.code
-            self._update(
-                'floatingips', fip['floatingip']['id'],
-                {'floatingip': {'port_id': port_id}},
-                expected_code=code)
-
-    def _test_floatingip_update_different_router(self):
-        with contextlib.nested(self.subnet(cidr='10.0.0.0/24'),
-                               self.subnet(cidr='10.0.1.0/24')) as (
-                                   s1, s2):
-            with contextlib.nested(self.port(subnet=s1),
-                                   self.port(subnet=s2)) as (p1, p2):
-                private_sub1 = {'subnet':
-                                {'id':
-                                 p1['port']['fixed_ips'][0]['subnet_id']}}
-                private_sub2 = {'subnet':
-                                {'id':
-                                 p2['port']['fixed_ips'][0]['subnet_id']}}
-                with self.subnet(cidr='12.0.0.0/24') as public_sub:
-                    with contextlib.nested(
-                            self.floatingip_no_assoc_with_public_sub(
-                                private_sub1, public_sub=public_sub),
-                            self.floatingip_no_assoc_with_public_sub(
-                                private_sub2, public_sub=public_sub)) as (
-                                    (fip1, r1), (fip2, r2)):
-
-                        self._assert_no_assoc_fip(fip1)
-                        self._assert_no_assoc_fip(fip2)
-
-                        fip1_r1_res = self._associate_and_assert_fip(fip1, p1)
-                        self.assertEqual(fip1_r1_res, r1['router']['id'])
-                        # The following operation will associate the floating
-                        # ip to a different router and should fail
-                        self._associate_and_assert_fip(fip1, p2, allow=False)
-                        # disassociate fip1
-                        self._update(
-                            'floatingips', fip1['floatingip']['id'],
-                            {'floatingip': {'port_id': None}})
-                        fip2_r2_res = self._associate_and_assert_fip(fip2, p2)
-                        self.assertEqual(fip2_r2_res, r2['router']['id'])
-
-    def _test_network_update_external_failure(self):
-        with self.router() as r:
-            with self.subnet() as s1:
-                self._set_net_external(s1['subnet']['network_id'])
-                self._add_external_gateway_to_router(
-                    r['router']['id'],
-                    s1['subnet']['network_id'])
-                self._update('networks', s1['subnet']['network_id'],
-                             {'network': {external_net.EXTERNAL: False}},
-                             expected_code=exc.HTTPInternalServerError.code)
-                self._remove_external_gateway_from_router(
-                    r['router']['id'],
-                    s1['subnet']['network_id'])
-
-    def _test_floatingip_update_different_fixed_ip_same_port(self):
-        with self.subnet() as s:
-            # The plugin use the last IP as a gateway
-            ip_range = list(netaddr.IPNetwork(s['subnet']['cidr']))[:-1]
-            fixed_ips = [{'ip_address': str(ip_range[-3])},
-                         {'ip_address': str(ip_range[-2])}]
-            with self.port(subnet=s, fixed_ips=fixed_ips) as p:
-                with self.floatingip_with_assoc(
-                    port_id=p['port']['id'],
-                    fixed_ip=str(ip_range[-3])) as fip:
-                    body = self._show('floatingips', fip['floatingip']['id'])
-                    self.assertEqual(fip['floatingip']['id'],
-                                     body['floatingip']['id'])
-                    self.assertEqual(fip['floatingip']['port_id'],
-                                     body['floatingip']['port_id'])
-                    self.assertEqual(str(ip_range[-3]),
-                                     body['floatingip']['fixed_ip_address'])
-                    self.assertIsNotNone(body['floatingip']['router_id'])
-                    body_2 = self._update(
-                        'floatingips', fip['floatingip']['id'],
-                        {'floatingip': {'port_id': p['port']['id'],
-                                        'fixed_ip_address': str(ip_range[-2])}
-                         })
-                    self.assertEqual(fip['floatingip']['port_id'],
-                                     body_2['floatingip']['port_id'])
-                    self.assertEqual(str(ip_range[-2]),
-                                     body_2['floatingip']['fixed_ip_address'])
-
-    def _test_floatingip_create_different_fixed_ip_same_port(self):
-        """Test to create fixed IPs using the same port.
-
-        This tests that it is possible to delete a port that has
-        multiple floating ip addresses associated with it (each floating
-        address associated with a unique fixed address).
-        """
-
-        with self.router() as r:
-            with self.subnet(cidr='11.0.0.0/24') as public_sub:
-                self._set_net_external(public_sub['subnet']['network_id'])
-                self._add_external_gateway_to_router(
-                    r['router']['id'],
-                    public_sub['subnet']['network_id'])
-
-                with self.subnet() as private_sub:
-                    ip_range = list(netaddr.IPNetwork(
-                        private_sub['subnet']['cidr']))[:-1]
-                    fixed_ips = [{'ip_address': str(ip_range[-3])},
-                                 {'ip_address': str(ip_range[-2])}]
-
-                    self._router_interface_action(
-                        'add', r['router']['id'],
-                        private_sub['subnet']['id'], None)
-
-                    with self.port(subnet=private_sub,
-                                   fixed_ips=fixed_ips) as p:
-
-                        fip1 = self._make_floatingip(
-                            self.fmt,
-                            public_sub['subnet']['network_id'],
-                            p['port']['id'],
-                            fixed_ip=str(ip_range[-2]))
-                        fip2 = self._make_floatingip(
-                            self.fmt,
-                            public_sub['subnet']['network_id'],
-                            p['port']['id'],
-                            fixed_ip=str(ip_range[-3]))
-
-                        # Test that floating ips are assigned successfully.
-                        body = self._show('floatingips',
-                                          fip1['floatingip']['id'])
-                        self.assertEqual(
-                            fip1['floatingip']['port_id'],
-                            body['floatingip']['port_id'])
-
-                        body = self._show('floatingips',
-                                          fip2['floatingip']['id'])
-                        self.assertEqual(
-                            fip2['floatingip']['port_id'],
-                            body['floatingip']['port_id'])
-                        self._delete('ports', p['port']['id'])
-
-                    # Test that port has been successfully deleted.
-                    body = self._show('ports', p['port']['id'],
-                                      expected_code=exc.HTTPNotFound.code)
-
-                    for fip in [fip1, fip2]:
-                        self._delete('floatingips',
-                                     fip['floatingip']['id'])
-
-                    self._router_interface_action(
-                        'remove', r['router']['id'],
-                        private_sub['subnet']['id'], None)
-
-                self._remove_external_gateway_from_router(
-                    r['router']['id'],
-                    public_sub['subnet']['network_id'])
-
-    def test_router_update_gateway_with_different_external_subnet(self):
-        self.skipTest("Plugin doesn't support multiple external networks")
-
-    def test_router_create_with_gwinfo_ext_ip_subnet(self):
-        self.skipTest("Plugin doesn't support multiple external networks")
-
-
-class TestNuageBasicGet(NuagePluginV2TestCase,
-                        test_db_plugin.TestBasicGet):
-    pass
-
-
-class TestNuageV2HTTPResponse(NuagePluginV2TestCase,
-                              test_db_plugin.TestV2HTTPResponse):
-    pass
-
-
-class TestNuageNetworksV2(NuagePluginV2TestCase,
-                          test_db_plugin.TestNetworksV2):
-    pass
-
-
-class TestNuageSubnetsV2(NuagePluginV2TestCase,
-                         test_db_plugin.TestSubnetsV2):
-
-    def test_create_subnet_nonzero_cidr(self):
-        # The plugin requires 2 IP addresses available if gateway is set
-        with contextlib.nested(
-            self.subnet(cidr='10.129.122.5/8'),
-            self.subnet(cidr='11.129.122.5/15'),
-            self.subnet(cidr='12.129.122.5/16'),
-            self.subnet(cidr='13.129.122.5/18'),
-            self.subnet(cidr='14.129.122.5/22'),
-            self.subnet(cidr='15.129.122.5/24'),
-            self.subnet(cidr='16.129.122.5/28'),
-        ) as subs:
-            # the API should accept and correct these for users
-            self.assertEqual('10.0.0.0/8', subs[0]['subnet']['cidr'])
-            self.assertEqual('11.128.0.0/15', subs[1]['subnet']['cidr'])
-            self.assertEqual('12.129.0.0/16', subs[2]['subnet']['cidr'])
-            self.assertEqual('13.129.64.0/18', subs[3]['subnet']['cidr'])
-            self.assertEqual('14.129.120.0/22', subs[4]['subnet']['cidr'])
-            self.assertEqual('15.129.122.0/24', subs[5]['subnet']['cidr'])
-            self.assertEqual('16.129.122.0/28', subs[6]['subnet']['cidr'])
-
-    def test_create_subnet_gateway_outside_cidr(self):
-        with self.network() as network:
-            data = {'subnet': {'network_id': network['network']['id'],
-                    'cidr': '10.0.2.0/24',
-                    'ip_version': '4',
-                    'tenant_id': network['network']['tenant_id'],
-                    'gateway_ip': '10.0.3.1'}}
-            subnet_req = self.new_create_request('subnets', data)
-            res = subnet_req.get_response(self.api)
-            self.assertEqual(exc.HTTPClientError.code, res.status_int)
-
-    def test_create_subnet_with_dhcp_port(self):
-        nuage_dhcp_port = '10.0.0.254'
-        with self.network() as network:
-            keys = {
-                'cidr': '10.0.0.0/24',
-                'gateway_ip': '10.0.0.1'
-            }
-            with self.subnet(network=network, **keys) as subnet:
-                query_params = "fixed_ips=ip_address%%3D%s" % nuage_dhcp_port
-                ports = self._list('ports', query_params=query_params)
-                self.assertEqual(4, subnet['subnet']['ip_version'])
-                self.assertIn('name', subnet['subnet'])
-                self.assertEqual(1, len(ports['ports']))
-                self.assertEqual(nuage_dhcp_port,
-                                 ports['ports'][0]['fixed_ips']
-                                 [0]['ip_address'])
-
-    def test_create_subnet_with_nuage_subnet_template(self):
-        with self.network() as network:
-            nuage_subn_template = uuidutils.generate_uuid()
-            data = {'subnet': {'tenant_id': network['network']['tenant_id']}}
-            data['subnet']['cidr'] = '10.0.0.0/24'
-            data['subnet']['ip_version'] = 4
-            data['subnet']['network_id'] = network['network']['id']
-            data['subnet']['nuage_subnet_template'] = nuage_subn_template
-            subnet_req = self.new_create_request('subnets', data, 'json')
-            subnet_res = subnet_req.get_response(self.api)
-            self.assertEqual(exc.HTTPCreated.code, subnet_res.status_int)
-
-    def test_delete_subnet_port_exists_returns_409(self):
-        gateway_ip = '10.0.0.1'
-        cidr = '10.0.0.0/24'
-        res = self._create_network(fmt=self.fmt, name='net',
-                                   admin_state_up=True)
-        network = self.deserialize(self.fmt, res)
-        subnet = self._make_subnet(self.fmt, network, gateway_ip,
-                                   cidr, ip_version=4)
-        self._create_port(self.fmt,
-                          network['network']['id'])
-        req = self.new_delete_request('subnets', subnet['subnet']['id'])
-        res = req.get_response(self.api)
-        self.assertEqual(409, res.status_int)
-
-
-class TestNuagePluginPortBinding(NuagePluginV2TestCase,
-                                 test_bindings.PortBindingsTestCase):
-    VIF_TYPE = portbindings.VIF_TYPE_OVS
-
-    def setUp(self):
-        super(TestNuagePluginPortBinding, self).setUp()
-
-    def test_ports_vif_details(self):
-        # The Plugin will create 2 extra ports
-        plugin = manager.NeutronManager.get_plugin()
-        cfg.CONF.set_default('allow_overlapping_ips', True)
-        with contextlib.nested(self.port(), self.port()):
-            ctx = context.get_admin_context()
-            ports = plugin.get_ports(ctx)
-            self.assertEqual(4, len(ports))
-            for port in ports:
-                self._check_response_portbindings(port)
-            # By default user is admin - now test non admin user
-            ctx = self._get_non_admin_context()
-            ports = self._list('ports', neutron_context=ctx)['ports']
-            self.assertEqual(4, len(ports))
-            for non_admin_port in ports:
-                self._check_response_no_portbindings(non_admin_port)
-
-
-class TestNuageExtrarouteTestCase(NuagePluginV2TestCase,
-                                  extraroute_test.ExtraRouteDBIntTestCase):
-
-    def test_router_create_with_gwinfo_ext_ip_subnet(self):
-        self.skipTest("Nuage plugin does not support multiple subnets per "
-                      "external network.")
-
-    def test_router_update_gateway_with_different_external_subnet(self):
-        self.skipTest("Nuage plugin does not support multiple subnets per "
-                      "external networks.")
-
-    def test_router_update_with_dup_destination_address(self):
-        with self.router() as r:
-            with self.subnet(cidr='10.0.1.0/24') as s:
-                with self.port(subnet=s) as p:
-                    self._router_interface_action('add',
-                                                  r['router']['id'],
-                                                  None,
-                                                  p['port']['id'])
-
-                    routes = [{'destination': '135.207.0.0/16',
-                               'nexthop': '10.0.1.3'},
-                              {'destination': '135.207.0.0/16',
-                               'nexthop': '10.0.1.5'}]
-
-                    self._update('routers', r['router']['id'],
-                                 {'router': {'routes':
-                                             routes}},
-                                 expected_code=exc.HTTPBadRequest.code)
-
-                    # clean-up
-                    self._router_interface_action('remove',
-                                                  r['router']['id'],
-                                                  None,
-                                                  p['port']['id'])
-
-    def test_router_update_on_external_port(self):
-        with self.router() as r:
-            with self.subnet(cidr='10.0.1.0/24') as s:
-                self._set_net_external(s['subnet']['network_id'])
-                self._add_external_gateway_to_router(
-                    r['router']['id'],
-                    s['subnet']['network_id'])
-                body = self._show('routers', r['router']['id'])
-                net_id = body['router']['external_gateway_info']['network_id']
-                self.assertEqual(net_id, s['subnet']['network_id'])
-                port_res = self._list_ports(
-                    'json',
-                    200,
-                    s['subnet']['network_id'],
-                    tenant_id=r['router']['tenant_id'],
-                    device_own=constants.DEVICE_OWNER_ROUTER_GW)
-                port_list = self.deserialize('json', port_res)
-                # The plugin will create 1 port
-                self.assertEqual(2, len(port_list['ports']))
-
-                routes = [{'destination': '135.207.0.0/16',
-                           'nexthop': '10.0.1.3'}]
-
-                body = self._update('routers', r['router']['id'],
-                                    {'router': {'routes':
-                                                routes}})
-
-                body = self._show('routers', r['router']['id'])
-                self.assertEqual(routes,
-                                 body['router']['routes'])
-
-                self._remove_external_gateway_from_router(
-                    r['router']['id'],
-                    s['subnet']['network_id'])
-                body = self._show('routers', r['router']['id'])
-                gw_info = body['router']['external_gateway_info']
-                self.assertIsNone(gw_info)
-
-    def test_floatingip_create_different_fixed_ip_same_port(self):
-        self._test_floatingip_create_different_fixed_ip_same_port()
-
-    def test_floatingip_update_different_router(self):
-        self._test_floatingip_update_different_router()
-
-    def test_floatingip_update_different_fixed_ip_same_port(self):
-        self._test_floatingip_update_different_fixed_ip_same_port()
-
-    def test_network_update_external_failure(self):
-        self._test_network_update_external_failure()
-
-    def test_update_port_with_assoc_floatingip(self):
-        with self.subnet(cidr='200.0.0.0/24') as public_sub:
-            self._set_net_external(public_sub['subnet']['network_id'])
-            with self.port() as port:
-                p_id = port['port']['id']
-                with self.floatingip_with_assoc(port_id=p_id):
-                    # Update the port with dummy vm info
-                    port_dict = {
-                        'device_id': uuidutils.generate_uuid(),
-                        'device_owner': 'compute:Nova'
-                    }
-                    port = self._update('ports', port['port']['id'],
-                                        {'port': port_dict})
-                    self.assertEqual(port_dict['device_id'],
-                                     port['port']['device_id'])
-
-    def test_disassociated_floatingip_delete(self):
-        with self.subnet(cidr='200.0.0.0/24') as public_sub:
-            self._set_net_external(public_sub['subnet']['network_id'])
-            with self.port() as port:
-                p_id = port['port']['id']
-                with self.floatingip_with_assoc(port_id=p_id) as fip:
-
-                    # Disassociate fip from the port
-                    fip = self._update('floatingips', fip['floatingip']['id'],
-                                       {'floatingip': {'port_id': None}})
-                    self.assertIsNone(fip['floatingip']['router_id'])
-
-
-class NuageRouterTestExtensionManager(object):
-
-    def get_resources(self):
-        l3.RESOURCE_ATTRIBUTE_MAP['routers'].update(
-            nuage_router.EXTENDED_ATTRIBUTES_2_0['routers'])
-        return l3.L3.get_resources()
-
-    def get_actions(self):
-        return []
-
-    def get_request_extensions(self):
-        return []
-
-
-class TestNuageRouterExtTestCase(NuagePluginV2TestCase):
-
-    def setUp(self):
-        self._l3_attribute_map_bk = copy.deepcopy(l3.RESOURCE_ATTRIBUTE_MAP)
-        ext_mgr = NuageRouterTestExtensionManager()
-        super(TestNuageRouterExtTestCase, self).setUp(plugin=_plugin_name,
-                                                      ext_mgr=ext_mgr)
-        self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
-        self.addCleanup(self.restore_l3_attribute_map)
-
-    def restore_l3_attribute_map(self):
-        l3.RESOURCE_ATTRIBUTE_MAP = self._l3_attribute_map_bk
-
-    def test_router_create_with_nuage_rtr_template(self):
-        nuage_rtr_template = uuidutils.generate_uuid()
-        data = {'router': {'tenant_id': uuidutils.generate_uuid()}}
-        data['router']['name'] = 'router1'
-        data['router']['admin_state_up'] = True
-        data['router']['nuage_router_template'] = nuage_rtr_template
-        router_req = self.new_create_request('routers', data, 'json')
-        router_res = router_req.get_response(self.ext_api)
-        self.assertEqual(exc.HTTPCreated.code, router_res.status_int)
-
-
-class TestNuageProviderNetTestCase(NuagePluginV2TestCase):
-
-    def test_create_provider_network(self):
-        phys_net = uuidutils.generate_uuid()
-        data = {'network': {'name': 'pnet1',
-                            'tenant_id': 'admin',
-                            pnet.NETWORK_TYPE: 'vlan',
-                            pnet.PHYSICAL_NETWORK: phys_net,
-                            pnet.SEGMENTATION_ID: 123}}
-        network_req = self.new_create_request('networks', data, self.fmt)
-        net = self.deserialize(self.fmt, network_req.get_response(self.api))
-        self.assertEqual('vlan', net['network'][pnet.NETWORK_TYPE])
-        self.assertEqual(phys_net, net['network'][pnet.PHYSICAL_NETWORK])
-        self.assertEqual(123, net['network'][pnet.SEGMENTATION_ID])
-
-    def test_create_provider_network_no_admin(self):
-        phys_net = uuidutils.generate_uuid()
-        data = {'network': {'name': 'pnet1',
-                            'tenant_id': 'no_admin',
-                            pnet.NETWORK_TYPE: 'vlan',
-                            pnet.PHYSICAL_NETWORK: phys_net,
-                            pnet.SEGMENTATION_ID: 123}}
-        network_req = self.new_create_request('networks', data, self.fmt)
-        network_req.environ['neutron.context'] = context.Context(
-                                    '', 'no_admin', is_admin=False)
-        res = network_req.get_response(self.api)
-        self.assertEqual(exc.HTTPForbidden.code, res.status_int)
-
-    def test_get_network_for_provider_network(self):
-        phys_net = uuidutils.generate_uuid()
-        data = {'network': {'name': 'pnet1',
-                            'tenant_id': 'admin',
-                            pnet.NETWORK_TYPE: 'vlan',
-                            pnet.PHYSICAL_NETWORK: phys_net,
-                            pnet.SEGMENTATION_ID: 123}}
-        network_req = self.new_create_request('networks', data, self.fmt)
-        res = self.deserialize(self.fmt, network_req.get_response(self.api))
-
-        get_req = self.new_show_request('networks', res['network']['id'])
-        net = self.deserialize(self.fmt, get_req.get_response(self.api))
-        self.assertEqual('vlan', net['network'][pnet.NETWORK_TYPE])
-        self.assertEqual(phys_net, net['network'][pnet.PHYSICAL_NETWORK])
-        self.assertEqual(123, net['network'][pnet.SEGMENTATION_ID])
-
-    def test_list_networks_for_provider_network(self):
-        phys_net = uuidutils.generate_uuid()
-        data1 = {'network': {'name': 'pnet1',
-                            'tenant_id': 'admin',
-                            pnet.NETWORK_TYPE: 'vlan',
-                            pnet.PHYSICAL_NETWORK: phys_net,
-                            pnet.SEGMENTATION_ID: 123}}
-        network_req_1 = self.new_create_request('networks', data1, self.fmt)
-        network_req_1.get_response(self.api)
-        data2 = {'network': {'name': 'pnet2',
-                            'tenant_id': 'admin',
-                            pnet.NETWORK_TYPE: 'vlan',
-                            pnet.PHYSICAL_NETWORK: phys_net,
-                            pnet.SEGMENTATION_ID: 234}}
-        network_req_2 = self.new_create_request('networks', data2, self.fmt)
-        network_req_2.get_response(self.api)
-
-        list_req = self.new_list_request('networks')
-        pnets = self.deserialize(self.fmt, list_req.get_response(self.api))
-        self.assertEqual(2, len(pnets['networks']))
-        self.assertEqual('vlan', pnets['networks'][0][pnet.NETWORK_TYPE])
-        self.assertEqual(phys_net, pnets['networks'][0][pnet.PHYSICAL_NETWORK])
-        self.assertEqual(123, pnets['networks'][0][pnet.SEGMENTATION_ID])
-        self.assertEqual('vlan', pnets['networks'][1][pnet.NETWORK_TYPE])
-        self.assertEqual(phys_net, pnets['networks'][1][pnet.PHYSICAL_NETWORK])
-        self.assertEqual(234, pnets['networks'][1][pnet.SEGMENTATION_ID])
-
-
-class TestNuageSecurityGroupTestCase(NuagePluginV2TestCase,
-                                     test_sg.TestSecurityGroups):
-
-    def test_list_ports_security_group(self):
-        with self.network() as n:
-            with self.subnet(n):
-                self._create_port(self.fmt, n['network']['id'])
-                req = self.new_list_request('ports')
-                res = req.get_response(self.api)
-                ports = self.deserialize(self.fmt, res)
-                # The Nuage plugin reserve the first port
-                port = ports['ports'][1]
-                self.assertEqual(1, len(port[ext_sg.SECURITYGROUPS]))
-                self._delete('ports', port['id'])
diff --git a/neutron/tests/unit/nuage/test_syncmanager.py b/neutron/tests/unit/nuage/test_syncmanager.py
deleted file mode 100644 (file)
index 1bdead8..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-# Copyright 2014 Alcatel-Lucent USA Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-#
-
-import contextlib
-
-from neutron import context
-from neutron.openstack.common import uuidutils
-from neutron.plugins.nuage import nuage_models
-from neutron.plugins.nuage import syncmanager as sync
-from neutron.tests.unit.nuage import test_netpartition
-from neutron.tests.unit.nuage import test_nuage_plugin
-from neutron.tests.unit import test_extension_extraroute as extraroute_test
-from neutron.tests.unit import test_extension_security_group as test_sg
-
-_uuid = uuidutils.generate_uuid
-
-
-class TestL3Sync(test_nuage_plugin.NuagePluginV2TestCase,
-                 extraroute_test.ExtraRouteDBIntTestCase):
-
-    def setUp(self):
-        super(TestL3Sync, self).setUp()
-        self.syncmanager = sync.SyncManager(
-            test_nuage_plugin.getNuageClient())
-        self.session = context.get_admin_context().session
-
-    def _make_floatingip_for_tenant_port(self, net_id, port_id, tenant_id):
-        data = {'floatingip': {'floating_network_id': net_id,
-                               'tenant_id': tenant_id,
-                               'port_id': port_id}}
-        floatingip_req = self.new_create_request('floatingips', data, self.fmt)
-        res = floatingip_req.get_response(self.ext_api)
-        return self.deserialize(self.fmt, res)
-
-    def test_router_sync(self):
-        # If the router exists in neutron and not in VSD,
-        # sync will create it in VSD. But the nuage_router_id
-        # will now change and will be updated in neutron
-        # accordingly
-        rtr_res = self._create_router('json', 'foo', 'test-router', True)
-        router = self.deserialize('json', rtr_res)
-
-        self.syncmanager.synchronize('250')
-
-        # Check that the nuage_router_id is updated in entrtrmapping table
-        router_db = self.session.query(
-            nuage_models.NetPartitionRouter).filter_by(
-                router_id=router['router']['id']).first()
-
-        self.assertEqual('2d782c02-b88e-44ad-a79b-4bdf11f7df3d',
-                         router_db['nuage_router_id'])
-
-        self._delete('routers', router['router']['id'])
-
-    def test_router_deleted_get(self):
-        data = self.syncmanager._get_router_data(_uuid())
-        self.assertIsNone(data[0])
-        self.assertIsNone(data[1])
-
-    def test_fip_sync(self):
-        with self.subnet(cidr='200.0.0.0/24') as public_sub:
-            self._set_net_external(public_sub['subnet']['network_id'])
-            with contextlib.nested(self.port(), self.port(), self.port()) as (
-                p1, p2, p3):
-                p1_id = p1['port']['id']
-                p2_id = p2['port']['id']
-                p3_id = p3['port']['id']
-                with contextlib.nested(self.floatingip_with_assoc(
-                    port_id=p1_id), self.floatingip_with_assoc(
-                    port_id=p2_id), self.floatingip_with_assoc(
-                    port_id=p3_id)) as (fip1, fip2, fip3):
-                    fip_dict = {'fip': {
-                        'add': [fip1['floatingip']['id']],
-                        'associate': [fip2['floatingip']['id']],
-                        'disassociate': [fip3['floatingip']['id']]
-                    }}
-                    self.syncmanager._sync_fips(fip_dict)
-
-    def test_deleted_fip_sync(self):
-        fip_dict = {'fip': {
-            'add': [_uuid()],
-            'associate': [_uuid()],
-            'disassociate': [_uuid()]
-        }}
-        self.syncmanager._sync_fips(fip_dict)
-
-    def test_fip_and_ipalloc_get(self):
-        with self.subnet(cidr='200.0.0.0/24') as public_sub:
-            self._set_net_external(public_sub['subnet']['network_id'])
-            with self.port() as port:
-                p_id = port['port']['id']
-                with self.floatingip_with_assoc(port_id=p_id) as fip:
-
-                    data = self.syncmanager._get_fip_data(
-                        fip['floatingip']['id'])
-
-                    self.assertEqual(fip['floatingip']['id'], data['id'])
-
-                    data = self.syncmanager._get_ipalloc_for_fip(
-                        fip['floatingip'])
-                    self.assertEqual(fip['floatingip']['floating_ip_address'],
-                                     data['ip_address'])
-
-    def test_fip_and_ipalloc_deleted_get(self):
-        data = self.syncmanager._get_fip_data(_uuid())
-        self.assertIsNone(data)
-
-        fip = {
-            'id': _uuid(),
-            'floating_network_id': _uuid(),
-            'floating_ip_address': '176.176.10.10'
-        }
-        data = self.syncmanager._get_ipalloc_for_fip(fip)
-        self.assertIsNone(data)
-
-    def test_domainsubnet_sync(self):
-        with self.subnet() as s1:
-            with contextlib.nested(
-                    self.router(),
-                    self.port()) as (r1, p1):
-                self._router_interface_action(
-                    'add', r1['router']['id'],
-                    s1['subnet']['id'], p1['port']['id'])
-                domainsubn_dict = {
-                    'domainsubnet': {'add': [s1['subnet']['id']]},
-                    'port': {'sub_rtr_intf_port_dict': {s1['subnet']['id']:
-                                                        p1['port']['id']}}}
-                self.syncmanager.sync_domainsubnets(domainsubn_dict)
-                self._router_interface_action('remove', r1['router']['id'],
-                                              s1['subnet']['id'], None)
-
-    def test_floatingip_update_different_router(self):
-        self._test_floatingip_update_different_router()
-
-    def test_floatingip_update_different_fixed_ip_same_port(self):
-        self._test_floatingip_update_different_fixed_ip_same_port()
-
-    def test_floatingip_create_different_fixed_ip_same_port(self):
-        self._test_floatingip_create_different_fixed_ip_same_port()
-
-    def test_network_update_external_failure(self):
-        self._test_network_update_external_failure()
-
-    def test_route_sync(self):
-        route = {'destination': '135.207.0.0/16', 'nexthop': '10.0.1.3'}
-        with self.router() as r:
-            with self.subnet(cidr='10.0.1.0/24') as s:
-                net_id = s['subnet']['network_id']
-                res = self._create_port('json', net_id)
-                p = self.deserialize(self.fmt, res)
-                self._routes_update_prepare(r['router']['id'],
-                                            None, p['port']['id'], [route])
-
-                route_dict = {'route': {'add': [route]}}
-                self.syncmanager.sync_routes(route_dict)
-
-                self._routes_update_cleanup(p['port']['id'],
-                                            None, r['router']['id'], [])
-
-    def test_route_get(self):
-        routes = [{'destination': '135.207.0.0/16', 'nexthop': '10.0.1.3'}]
-        with self.router() as r:
-            with self.subnet(cidr='10.0.1.0/24') as s:
-                net_id = s['subnet']['network_id']
-                res = self._create_port('json', net_id)
-                p = self.deserialize(self.fmt, res)
-                self._routes_update_prepare(r['router']['id'],
-                                            None, p['port']['id'], routes)
-
-                data = self.syncmanager._get_route_data(routes[0])
-                self.assertEqual(routes[0]['destination'], data['destination'])
-                self.assertEqual(routes[0]['nexthop'], data['nexthop'])
-                self._routes_update_cleanup(p['port']['id'],
-                                            None, r['router']['id'], [])
-
-    def test_route_deleted_get(self):
-        route = {'destination': '135.207.0.0/16', 'nexthop': '10.0.1.3'}
-        data = self.syncmanager._get_route_data(route)
-        self.assertIsNone(data)
-
-
-class TestNetPartSync(test_netpartition.NetPartitionTestCase):
-
-    def setUp(self):
-        self.syncmanager = sync.SyncManager(
-            test_nuage_plugin.getNuageClient())
-        super(TestNetPartSync, self).setUp()
-        self.session = context.get_admin_context().session
-
-    def test_net_partition_sync(self):
-        # If the net-partition exists in neutron and not in VSD,
-        # sync will create it in VSD. But the net-partition
-        # id will now change and has to be updated in neutron
-        # accordingly
-        netpart = self._make_netpartition('json', 'sync-new-netpartition')
-
-        self.syncmanager.synchronize('250')
-
-        # Check that the net-partition id is updated in db
-        netpart_db = self.session.query(
-            nuage_models.NetPartition).filter_by(name=netpart['net_partition'][
-                'name']).first()
-
-        self.assertEqual('a917924f-3139-4bdb-a4c3-ea7c8011582f',
-                         netpart_db['id'])
-        self._del_netpartition(netpart_db['id'])
-
-    def test_net_partition_deleted_get(self):
-        data = self.syncmanager._get_netpart_data(_uuid())
-        self.assertIsNone(data)
-
-
-class TestL2Sync(test_nuage_plugin.NuagePluginV2TestCase):
-
-    def setUp(self):
-        super(TestL2Sync, self).setUp()
-        self.syncmanager = sync.SyncManager(
-            test_nuage_plugin.getNuageClient())
-        self.session = context.get_admin_context().session
-
-    def test_subnet_sync(self):
-        # If the subnet exists in neutron and not in VSD,
-        # sync will create it in VSD. But the nuage_subnet_id
-        # will now change and will be updated in neutron
-        # accordingly
-        net_res = self._create_network("json", "pub", True)
-        network = self.deserialize('json', net_res)
-
-        sub_res = self._create_subnet("json", network['network']['id'],
-                                      '10.0.0.0/24')
-        subnet = self.deserialize('json', sub_res)
-
-        self.syncmanager.synchronize('250')
-
-        # Check that the nuage_subnet_id is updated in db
-        subl2dom_db = self.session.query(
-            nuage_models.SubnetL2Domain).filter_by(subnet_id=subnet[
-                'subnet']['id']).first()
-        self.assertEqual('52daa465-cf33-4efd-91d3-f5bc2aebd',
-                         subl2dom_db['nuage_subnet_id'])
-
-        self._delete('subnets', subnet['subnet']['id'])
-        self._delete('networks', network['network']['id'])
-
-    def test_subnet_deleted_get(self):
-        data = self.syncmanager._get_subnet_data(_uuid())
-        self.assertIsNone(data[0])
-        self.assertIsNone(data[1])
-
-    def test_sharednetwork_sync(self):
-        with self.subnet(cidr='200.0.0.0/24') as public_sub:
-            sharednet_dict = {'sharednetwork': {'add': [public_sub['subnet'][
-                                                        'id']]}}
-            self.syncmanager.sync_sharednetworks(sharednet_dict)
-
-    def test_vm_sync(self):
-        with self.port() as p:
-            port_dict = {'port': {'vm': [p['port']['id']]}}
-            self.syncmanager.sync_vms(port_dict)
-
-
-class TestSecurityGroupSync(test_sg.TestSecurityGroups):
-
-    def setUp(self):
-        self.syncmanager = sync.SyncManager(
-            test_nuage_plugin.getNuageClient())
-        super(TestSecurityGroupSync, self).setUp()
-        self.session = context.get_admin_context().session
-
-    def test_sg_get(self):
-        with self.security_group() as sg:
-            data = self.syncmanager._get_sec_grp_data(
-                sg['security_group']['id'])
-            self.assertEqual(sg['security_group']['id'], data['id'])
-
-    def test_sg_deleted_get(self):
-        data = self.syncmanager._get_sec_grp_data(_uuid())
-        self.assertIsNone(data)
-
-    def test_sg_rule_get(self):
-        with self.security_group() as sg:
-            sg_rule_id = sg['security_group']['security_group_rules'][0]['id']
-            data = self.syncmanager._get_sec_grp_rule_data(sg_rule_id)
-            self.assertEqual(sg_rule_id, data['id'])
-
-    def test_sg_rule_deleted_get(self):
-        data = self.syncmanager._get_sec_grp_rule_data(_uuid())
-        self.assertIsNone(data)
-
-    def test_sg_grp_sync(self):
-        with contextlib.nested(self.security_group(),
-                               self.security_group()) as (sg1, sg2):
-            sg1_id = sg1['security_group']['id']
-            sg2_id = sg2['security_group']['id']
-            sg_dict = {'security': {'secgroup': {'l2domain': {'add': {sg1_id: [
-                _uuid()]}}, 'domain': {'add': {sg2_id: [_uuid()]}}}}}
-            self.syncmanager.sync_secgrps(sg_dict)
-
-    def test_deleted_sg_grp_sync(self):
-        sg_dict = {'security': {'secgroup': {'l2domain': {'add': {_uuid(): [
-            _uuid()]}}, 'domain': {'add': {_uuid(): [_uuid()]}}}}}
-        self.syncmanager.sync_secgrps(sg_dict)
-
-    def test_sg_rule_sync(self):
-        with contextlib.nested(self.security_group(),
-                               self.security_group()) as (sg1, sg2):
-            sg1_rule_id = (
-                sg1['security_group']['security_group_rules'][0]['id'])
-            sg2_rule_id = (
-                sg2['security_group']['security_group_rules'][0]['id'])
-
-            sg_dict = {'security': {'secgrouprule': {'l2domain': {
-                'add': [sg1_rule_id]}, 'domain': {'add': [sg2_rule_id]}}}}
-            self.syncmanager.sync_secgrp_rules(sg_dict)
-
-    def test_deleted_sg_grp_rule_sync(self):
-        sg_dict = {'security': {'secgrouprule':
-                                {'l2domain': {'add': [_uuid()]},
-                                 'domain': {'add': [_uuid()]}}}}
-        self.syncmanager.sync_secgrp_rules(sg_dict)