Update GBP to work with Neutron Master (Post Juno)
Change-Id: I0262d4736e1deb990058cd7256a86badc0b9d9fd Closes-bug: 1433530
This commit is contained in:
parent
275dab7eec
commit
bab6b4a82d
11
HACKING.rst
11
HACKING.rst
@ -2,3 +2,14 @@ Group Based Policy Style Commandments
|
|||||||
===============================================
|
===============================================
|
||||||
|
|
||||||
Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/
|
Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/
|
||||||
|
|
||||||
|
|
||||||
|
Group Based Policy Specific Commandments
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
- [N319] Validate that debug level logs are not translated
|
||||||
|
- [N320] Validate that LOG messages, except debug ones, have translations
|
||||||
|
- [N321] Validate that jsonutils module is used instead of json
|
||||||
|
- [N322] Detect common errors with assert_called_once_with
|
||||||
|
- [N323] Enforce namespace-less imports for oslo libraries
|
||||||
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"context_is_admin": "role:admin",
|
|
||||||
"admin_or_owner": "rule:context_is_admin or tenant_id:%(tenant_id)s",
|
|
||||||
"admin_only": "rule:context_is_admin",
|
|
||||||
"regular_user": "",
|
|
||||||
"default": "rule:admin_or_owner",
|
|
||||||
"gbp_shared": "field:policy_target_groups:shared=True",
|
|
||||||
|
|
||||||
"create_policy_target_group": "",
|
|
||||||
"get_policy_target_group": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_l2_policy": "",
|
|
||||||
"get_l2_policy": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_l3_policy": "",
|
|
||||||
"get_l3_policy": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_policy_classifier": "",
|
|
||||||
"get_policy_classifier": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_policy_action": "",
|
|
||||||
"get_policy_action": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_policy_rule": "",
|
|
||||||
"get_policy_rule": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_policy_rule_set": "",
|
|
||||||
"get_policy_rule_set": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_network_service_policy": "",
|
|
||||||
"get_network_service_policy": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_external_segment": "",
|
|
||||||
"get_external_segment": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_external_policy": "",
|
|
||||||
"get_external_policy": "rule:admin_or_owner or rule:gbp_shared",
|
|
||||||
|
|
||||||
"create_nat_pool": "",
|
|
||||||
"get_nat_pool": "rule:admin_or_owner or rule:gbp_shared"
|
|
||||||
}
|
|
@ -11,10 +11,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from neutron.openstack.common import lockutils
|
|
||||||
from neutronclient.common import exceptions as neutron_client_exc
|
from neutronclient.common import exceptions as neutron_client_exc
|
||||||
from neutronclient.v2_0 import client as clientv20
|
from neutronclient.v2_0 import client as clientv20
|
||||||
from oslo.config import cfg
|
from oslo_concurrency import lockutils
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
neutron_opts = [
|
neutron_opts = [
|
||||||
|
@ -11,20 +11,18 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
|
|
||||||
import sqlalchemy as sa
|
|
||||||
from sqlalchemy import orm
|
|
||||||
from sqlalchemy.orm import exc
|
|
||||||
|
|
||||||
from neutron.api.v2 import attributes as attr
|
from neutron.api.v2 import attributes as attr
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.db import common_db_mixin
|
from neutron.db import common_db_mixin
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
|
from oslo_log import log as logging
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy import orm
|
||||||
|
from sqlalchemy.orm import exc
|
||||||
|
|
||||||
from gbpservice.neutron.extensions import group_policy as gpolicy
|
from gbpservice.neutron.extensions import group_policy as gpolicy
|
||||||
from gbpservice.neutron.services.grouppolicy.common import (
|
from gbpservice.neutron.services.grouppolicy.common import (
|
||||||
|
@ -10,13 +10,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sqlalchemy as sa
|
|
||||||
from sqlalchemy import orm
|
|
||||||
|
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
|
from oslo_log import log as logging
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy import orm
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ from logging import config as logging_config
|
|||||||
|
|
||||||
from alembic import context
|
from alembic import context
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
from oslo.db.sqlalchemy import session
|
from oslo_db.sqlalchemy import session
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
|
|
||||||
|
@ -13,9 +13,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_db # noqa
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db # noqa
|
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,24 +11,25 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import sqlalchemy as sa
|
|
||||||
from sqlalchemy.ext.orderinglist import ordering_list
|
|
||||||
from sqlalchemy import orm
|
|
||||||
from sqlalchemy.orm import exc
|
|
||||||
|
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.db import common_db_mixin
|
from neutron.db import common_db_mixin
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import jsonutils
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants as pconst
|
from neutron.plugins.common import constants as pconst
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.ext.orderinglist import ordering_list
|
||||||
|
from sqlalchemy import orm
|
||||||
|
from sqlalchemy.orm import exc
|
||||||
|
|
||||||
from gbpservice.neutron.extensions import servicechain as schain
|
from gbpservice.neutron.extensions import servicechain as schain
|
||||||
from gbpservice.neutron.services.servicechain.common import exceptions as s_exc
|
from gbpservice.neutron.services.servicechain.common import exceptions as s_exc
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
MAX_IPV4_SUBNET_PREFIX_LENGTH = 31
|
MAX_IPV4_SUBNET_PREFIX_LENGTH = 31
|
||||||
MAX_IPV6_SUBNET_PREFIX_LENGTH = 127
|
MAX_IPV6_SUBNET_PREFIX_LENGTH = 127
|
||||||
|
@ -12,21 +12,21 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from neutron.api import extensions
|
from neutron.api import extensions
|
||||||
from neutron.api.v2 import attributes as attr
|
from neutron.api.v2 import attributes as attr
|
||||||
from neutron.api.v2 import resource_helper
|
from neutron.api.v2 import resource_helper
|
||||||
from neutron.common import exceptions as nexc
|
from neutron.common import exceptions as nexc
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.services import service_base
|
from neutron.services import service_base
|
||||||
|
from oslo_log import log as logging
|
||||||
|
import six
|
||||||
|
|
||||||
import gbpservice.neutron.extensions
|
import gbpservice.neutron.extensions
|
||||||
from gbpservice.neutron.services.grouppolicy.common import (
|
from gbpservice.neutron.services.grouppolicy.common import (
|
||||||
constants as gp_constants)
|
constants as gp_constants)
|
||||||
|
|
||||||
|
|
||||||
# The code below is a monkey patch of key Neutron's modules. This is needed for
|
# The code below is a monkey patch of key Neutron's modules. This is needed for
|
||||||
# the GBP service to be loaded correctly. GBP extensions' path is added
|
# the GBP service to be loaded correctly. GBP extensions' path is added
|
||||||
# to Neutron's so that it's found at extension scanning time.
|
# to Neutron's so that it's found at extension scanning time.
|
||||||
@ -37,7 +37,6 @@ constants.COMMON_PREFIXES["GROUP_POLICY"] = "/grouppolicy"
|
|||||||
constants.EXT_TO_SERVICE_MAPPING['gp'] = constants.GROUP_POLICY
|
constants.EXT_TO_SERVICE_MAPPING['gp'] = constants.GROUP_POLICY
|
||||||
constants.ALLOWED_SERVICES.append(constants.GROUP_POLICY)
|
constants.ALLOWED_SERVICES.append(constants.GROUP_POLICY)
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,19 +12,19 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from neutron.api import extensions
|
from neutron.api import extensions
|
||||||
from neutron.api.v2 import attributes as attr
|
from neutron.api.v2 import attributes as attr
|
||||||
from neutron.api.v2 import resource_helper
|
from neutron.api.v2 import resource_helper
|
||||||
from neutron.common import exceptions as nexc
|
from neutron.common import exceptions as nexc
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.services import service_base
|
from neutron.services import service_base
|
||||||
|
from oslo_log import log as logging
|
||||||
|
import six
|
||||||
|
|
||||||
import gbpservice.neutron.extensions
|
import gbpservice.neutron.extensions
|
||||||
|
|
||||||
|
|
||||||
# The code below is a monkey patch of key Neutron's modules. This is needed for
|
# The code below is a monkey patch of key Neutron's modules. This is needed for
|
||||||
# the GBP service to be loaded correctly. GBP extensions' path is added
|
# the GBP service to be loaded correctly. GBP extensions' path is added
|
||||||
# to Neutron's so that it's found at extension scanning time.
|
# to Neutron's so that it's found at extension scanning time.
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron.common import constants as n_constants
|
from neutron.common import constants as n_constants
|
||||||
from neutron.openstack.common import log
|
from neutron import manager
|
||||||
from neutron.plugins.ml2 import driver_api as api
|
from neutron.plugins.ml2 import driver_api as api
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.cisco.apic import (
|
|
||||||
apic_mapping as amap)
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -31,8 +30,9 @@ class APICMechanismGBPDriver(api.MechanismDriver):
|
|||||||
@property
|
@property
|
||||||
def apic_gbp(self):
|
def apic_gbp(self):
|
||||||
if not self._apic_gbp:
|
if not self._apic_gbp:
|
||||||
self._apic_gbp = (amap.ApicMappingDriver.
|
self._apic_gbp = manager.NeutronManager.get_service_plugins()[
|
||||||
get_initialized_instance())
|
'GROUP_POLICY'].policy_driver_manager.policy_drivers[
|
||||||
|
'apic'].obj
|
||||||
return self._apic_gbp
|
return self._apic_gbp
|
||||||
|
|
||||||
def create_port_postcommit(self, context):
|
def create_port_postcommit(self, context):
|
||||||
|
@ -14,11 +14,13 @@
|
|||||||
|
|
||||||
|
|
||||||
from neutron.plugins.ml2 import driver_api as api
|
from neutron.plugins.ml2 import driver_api as api
|
||||||
from neutron.plugins.nuage.common import constants as nuage_const
|
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.nuage import driver
|
from gbpservice.neutron.services.grouppolicy.drivers.nuage import driver
|
||||||
|
|
||||||
|
|
||||||
|
NOVA_PORT_OWNER_PREF = 'compute:'
|
||||||
|
|
||||||
|
|
||||||
class NuageMechanismGBPDriver(api.MechanismDriver):
|
class NuageMechanismGBPDriver(api.MechanismDriver):
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
@ -33,7 +35,7 @@ class NuageMechanismGBPDriver(api.MechanismDriver):
|
|||||||
|
|
||||||
def update_port_postcommit(self, context):
|
def update_port_postcommit(self, context):
|
||||||
port = context.current
|
port = context.current
|
||||||
port_prefix = nuage_const.NOVA_PORT_OWNER_PREF
|
port_prefix = NOVA_PORT_OWNER_PREF
|
||||||
# Check two things prior to proceeding with
|
# Check two things prior to proceeding with
|
||||||
# talking to backend.
|
# talking to backend.
|
||||||
# 1) binding has happened successfully.
|
# 1) binding has happened successfully.
|
||||||
|
@ -10,12 +10,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.odl import odl_mapping
|
|
||||||
from neutron.common import constants as n_constants
|
from neutron.common import constants as n_constants
|
||||||
from neutron.extensions import portbindings
|
from neutron.extensions import portbindings
|
||||||
from neutron.openstack.common import log
|
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.plugins.ml2 import driver_api as api
|
from neutron.plugins.ml2 import driver_api as api
|
||||||
|
from oslo_log import log as log
|
||||||
|
|
||||||
|
from gbpservice.neutron.services.grouppolicy.drivers.odl import odl_mapping
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
group_policy_opts = [
|
group_policy_opts = [
|
||||||
|
@ -18,12 +18,12 @@ from neutron.common import exceptions as n_exc
|
|||||||
from neutron.extensions import providernet as pn
|
from neutron.extensions import providernet as pn
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import lockutils
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.plugins.ml2.drivers.cisco.apic import apic_model
|
from neutron.plugins.ml2.drivers.cisco.apic import apic_model
|
||||||
from neutron.plugins.ml2.drivers.cisco.apic import config
|
from neutron.plugins.ml2.drivers.cisco.apic import config
|
||||||
from neutron.plugins.ml2 import models
|
from neutron.plugins.ml2 import models
|
||||||
from oslo.config import cfg
|
from oslo_concurrency import lockutils
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db as gpdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db as gpdb
|
||||||
from gbpservice.neutron.services.grouppolicy.common import constants as g_const
|
from gbpservice.neutron.services.grouppolicy.common import constants as g_const
|
||||||
@ -31,6 +31,7 @@ from gbpservice.neutron.services.grouppolicy.common import exceptions as gpexc
|
|||||||
from gbpservice.neutron.services.grouppolicy.drivers import (
|
from gbpservice.neutron.services.grouppolicy.drivers import (
|
||||||
resource_mapping as api)
|
resource_mapping as api)
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +117,6 @@ class ApicMappingDriver(api.ResourceMappingDriver):
|
|||||||
self.apic_manager = ApicMappingDriver.get_apic_manager()
|
self.apic_manager = ApicMappingDriver.get_apic_manager()
|
||||||
self.name_mapper = self.apic_manager.apic_mapper
|
self.name_mapper = self.apic_manager.apic_mapper
|
||||||
self._gbp_plugin = None
|
self._gbp_plugin = None
|
||||||
ApicMappingDriver.me = self
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gbp_plugin(self):
|
def gbp_plugin(self):
|
||||||
@ -125,10 +125,6 @@ class ApicMappingDriver(api.ResourceMappingDriver):
|
|||||||
.get("GROUP_POLICY"))
|
.get("GROUP_POLICY"))
|
||||||
return self._gbp_plugin
|
return self._gbp_plugin
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_initialized_instance():
|
|
||||||
return ApicMappingDriver.me
|
|
||||||
|
|
||||||
def get_gbp_details(self, context, **kwargs):
|
def get_gbp_details(self, context, **kwargs):
|
||||||
port_id = (kwargs.get('port_id') or
|
port_id = (kwargs.get('port_id') or
|
||||||
self._core_plugin._device_to_port_id(kwargs['device']))
|
self._core_plugin._device_to_port_id(kwargs['device']))
|
||||||
@ -788,11 +784,13 @@ class ApicMappingDriver(api.ResourceMappingDriver):
|
|||||||
transaction=trs)
|
transaction=trs)
|
||||||
|
|
||||||
def _get_active_path_count(self, plugin_context, port_info):
|
def _get_active_path_count(self, plugin_context, port_info):
|
||||||
return plugin_context.session.query(
|
return (plugin_context.session.query(models.PortBindingLevel).
|
||||||
models.PortBinding).filter_by(
|
join(models.NetworkSegment).
|
||||||
host=port_info['host'],
|
filter(models.PortBindingLevel.host == port_info['host']).
|
||||||
segment=port_info['segmentation_id']).filter(
|
filter(models.NetworkSegment.segmentation_id == port_info[
|
||||||
models.PortBinding.port_id != port_info['port_id']).count()
|
'segmentation_id']).
|
||||||
|
filter(models.PortBindingLevel.port_id != port_info['port_id']).
|
||||||
|
count())
|
||||||
|
|
||||||
@lockutils.synchronized('apic-portlock')
|
@lockutils.synchronized('apic-portlock')
|
||||||
def _delete_port_path(self, context, atenant_id, ptg, port_info):
|
def _delete_port_path(self, context, atenant_id, ptg, port_info):
|
||||||
|
@ -10,12 +10,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from neutron.openstack.common import log as logging
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy import (
|
from gbpservice.neutron.services.grouppolicy import (
|
||||||
group_policy_driver_api as api)
|
group_policy_driver_api as api)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
restproxy_opts = [
|
restproxy_opts = [
|
||||||
|
@ -12,14 +12,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron.openstack.common import importutils
|
from oslo_config import cfg
|
||||||
from neutron.openstack.common import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo.config import cfg
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers import (
|
from gbpservice.neutron.services.grouppolicy.drivers import (
|
||||||
resource_mapping as api)
|
resource_mapping as api)
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.nuage.common import config
|
from gbpservice.neutron.services.grouppolicy.drivers.nuage.common import config
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
od_driver_opts = [
|
od_driver_opts = [
|
||||||
|
@ -11,13 +11,15 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from oslo.config import cfg
|
|
||||||
from oslo.serialization import jsonutils
|
|
||||||
from requests import auth
|
from requests import auth
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
cfg.CONF.import_opt(
|
cfg.CONF.import_opt(
|
||||||
'odl_username',
|
'odl_username',
|
||||||
'gbpservice.neutron.services.grouppolicy.drivers.odl.config',
|
'gbpservice.neutron.services.grouppolicy.drivers.odl.config',
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import lockutils # noqa
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
|
from oslo_concurrency import lockutils # noqa
|
||||||
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db as gpdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db as gpdb
|
||||||
from gbpservice.neutron.services.grouppolicy.common import constants as g_const
|
from gbpservice.neutron.services.grouppolicy.common import constants as g_const
|
||||||
|
@ -17,13 +17,12 @@ import httplib
|
|||||||
import requests
|
import requests
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.common import exceptions
|
from gbpservice.neutron.services.grouppolicy.common import exceptions
|
||||||
|
|
||||||
from neutron.openstack.common import jsonutils
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
|
|
||||||
|
|
||||||
SERVICE_CONTROLLER_OPTIONS = [
|
SERVICE_CONTROLLER_OPTIONS = [
|
||||||
cfg.StrOpt('service_controller_ip',
|
cfg.StrOpt('service_controller_ip',
|
||||||
|
@ -12,15 +12,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from neutron.common import exceptions as n_exc
|
||||||
|
from neutron.common import log
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from oslo_utils import excutils
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers import (
|
from gbpservice.neutron.services.grouppolicy.drivers import (
|
||||||
resource_mapping as res_map)
|
resource_mapping as res_map)
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.oneconvergence import (
|
from gbpservice.neutron.services.grouppolicy.drivers.oneconvergence import (
|
||||||
nvsd_gbp_api as api)
|
nvsd_gbp_api as api)
|
||||||
|
|
||||||
from neutron.common import exceptions as n_exc
|
|
||||||
from neutron.common import log
|
|
||||||
from neutron.openstack.common import excutils
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ from neutron.db import models_v2
|
|||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.notifiers import nova
|
from neutron.notifiers import nova
|
||||||
from neutron.openstack.common import jsonutils
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.plugins.common import constants as pconst
|
from neutron.plugins.common import constants as pconst
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
||||||
@ -1055,14 +1055,17 @@ class ResourceMappingDriver(api.PolicyDriver):
|
|||||||
for es in es_list:
|
for es in es_list:
|
||||||
subnet = self._core_plugin.get_subnet(context._plugin_context,
|
subnet = self._core_plugin.get_subnet(context._plugin_context,
|
||||||
es['subnet_id'])
|
es['subnet_id'])
|
||||||
|
external_fixed_ips = [
|
||||||
|
{'subnet_id': es['subnet_id'],
|
||||||
|
'ip_address': x} for x in es_dict[es['id']]
|
||||||
|
] if es_dict[es['id']] else None
|
||||||
|
for ip in external_fixed_ips or []:
|
||||||
|
if not ip['ip_address']:
|
||||||
|
del ip['ip_address']
|
||||||
interface_info = {
|
interface_info = {
|
||||||
'network_id': subnet['network_id'],
|
'network_id': subnet['network_id'],
|
||||||
'enable_snat': es['port_address_translation'],
|
'enable_snat': es['port_address_translation'],
|
||||||
'external_fixed_ips': [
|
'external_fixed_ips': external_fixed_ips}
|
||||||
{'subnet_id': es['subnet_id'],
|
|
||||||
'ip_address': x} for x in es_dict[es['id']]]
|
|
||||||
if es_dict[es['id']] else
|
|
||||||
attributes.ATTR_NOT_SPECIFIED}
|
|
||||||
router = self._add_router_gw_interface(
|
router = self._add_router_gw_interface(
|
||||||
context._plugin_context, router_id, interface_info)
|
context._plugin_context, router_id, interface_info)
|
||||||
if not es_dict[es['id']] or not es_dict[es['id']][0]:
|
if not es_dict[es['id']] or not es_dict[es['id']][0]:
|
||||||
|
@ -11,10 +11,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from neutron.openstack.common import log
|
from oslo_config import cfg
|
||||||
from oslo.config import cfg
|
from oslo_log import log
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -251,4 +252,4 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
|
|||||||
def extend_nat_pool_dict(self, session, result):
|
def extend_nat_pool_dict(self, session, result):
|
||||||
"""Call all extension drivers to extend NP dictionary."""
|
"""Call all extension drivers to extend NP dictionary."""
|
||||||
for driver in self.ordered_ext_drivers:
|
for driver in self.ordered_ext_drivers:
|
||||||
driver.obj.extend_nat_pool_dict(session, result)
|
driver.obj.extend_nat_pool_dict(session, result)
|
||||||
|
@ -14,8 +14,8 @@ import netaddr
|
|||||||
|
|
||||||
from neutron.api.v2 import attributes as nattr
|
from neutron.api.v2 import attributes as nattr
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.openstack.common import excutils
|
from oslo_log import log as logging
|
||||||
from neutron.openstack.common import log as logging
|
from oslo_utils import excutils
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db
|
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db
|
||||||
|
@ -10,11 +10,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron.openstack.common import log
|
from oslo_config import cfg
|
||||||
from oslo.config import cfg
|
from oslo_log import log
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.common import exceptions as gp_exc
|
from gbpservice.neutron.services.grouppolicy.common import exceptions as gp_exc
|
||||||
|
|
||||||
|
|
||||||
@ -376,4 +375,4 @@ class PolicyDriverManager(stevedore.named.NamedExtensionManager):
|
|||||||
|
|
||||||
def delete_nat_pool_postcommit(self, context):
|
def delete_nat_pool_postcommit(self, context):
|
||||||
self._call_on_drivers("delete_nat_pool_postcommit", context,
|
self._call_on_drivers("delete_nat_pool_postcommit", context,
|
||||||
continue_on_failure=True)
|
continue_on_failure=True)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
service_chain_opts = [
|
service_chain_opts = [
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron.openstack.common import log
|
from oslo_config import cfg
|
||||||
from oslo.config import cfg
|
from oslo_log import log
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
from gbpservice.neutron.services.servicechain.common import (
|
from gbpservice.neutron.services.servicechain.common import (
|
||||||
|
@ -18,9 +18,9 @@ from heatclient import client as heat_client
|
|||||||
from neutron.api.v2 import attributes
|
from neutron.api.v2 import attributes
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from neutron.openstack.common import jsonutils
|
from oslo_config import cfg
|
||||||
from neutron.openstack.common import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo.config import cfg
|
from oslo_serialization import jsonutils
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.oneconvergence import (
|
from gbpservice.neutron.services.grouppolicy.drivers.oneconvergence import (
|
||||||
|
@ -18,13 +18,12 @@ from heatclient import exc as heatException
|
|||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import jsonutils
|
|
||||||
from neutron.openstack.common import log as logging
|
|
||||||
from neutron.plugins.common import constants as pconst
|
from neutron.plugins.common import constants as pconst
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
from gbpservice.neutron.services.servicechain.common import exceptions as exc
|
from gbpservice.neutron.services.servicechain.common import exceptions as exc
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.openstack.common import excutils
|
from oslo_log import log as logging
|
||||||
from neutron.openstack.common import log as logging
|
from oslo_utils import excutils
|
||||||
|
|
||||||
import gbpservice.neutron.db.servicechain_db as servicechain_db
|
import gbpservice.neutron.db.servicechain_db as servicechain_db
|
||||||
from gbpservice.neutron.services.servicechain import (
|
from gbpservice.neutron.services.servicechain import (
|
||||||
@ -20,6 +20,7 @@ from gbpservice.neutron.services.servicechain import (
|
|||||||
from gbpservice.neutron.services.servicechain import (
|
from gbpservice.neutron.services.servicechain import (
|
||||||
servicechain_context as servicechain_context)
|
servicechain_context as servicechain_context)
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
52
gbpservice/neutron/tests/etc/test-policy.json
Normal file
52
gbpservice/neutron/tests/etc/test-policy.json
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"context_is_admin": "role:admin or user_name:neutron",
|
||||||
|
"admin_or_owner": "rule:context_is_admin or tenant_id:%(tenant_id)s",
|
||||||
|
"context_is_advsvc": "role:advsvc",
|
||||||
|
"admin_only": "rule:context_is_admin",
|
||||||
|
"regular_user": "",
|
||||||
|
"default": "rule:admin_or_owner",
|
||||||
|
"gbp_shared": "field:policy_target_groups:shared=True",
|
||||||
|
|
||||||
|
"create_policy_target_group": "",
|
||||||
|
"get_policy_target_group": "rule:admin_or_owner or rule:gbp_shared",
|
||||||
|
|
||||||
|
"gbp_l2p_shared": "field:l2_policies:shared=True",
|
||||||
|
"create_l2_policy": "",
|
||||||
|
"get_l2_policy": "rule:admin_or_owner or rule:gbp_l2p_shared",
|
||||||
|
|
||||||
|
"gbp_l3p_shared": "field:l3_policies:shared=True",
|
||||||
|
"create_l3_policy": "",
|
||||||
|
"get_l3_policy": "rule:admin_or_owner or rule:gbp_l3p_shared",
|
||||||
|
|
||||||
|
"gbp_policy_classifier_shared": "field:policy_classifiers:shared=True",
|
||||||
|
"create_policy_classifier": "",
|
||||||
|
"get_policy_classifier": "rule:admin_or_owner or rule:gbp_policy_classifier_shared",
|
||||||
|
|
||||||
|
"gbp_policy_action_shared": "field:policy_actions:shared=True",
|
||||||
|
"create_policy_action": "",
|
||||||
|
"get_policy_action": "rule:admin_or_owner or rule:gbp_policy_action_shared",
|
||||||
|
|
||||||
|
"gbp_policy_rule_shared": "field:policy_rules:shared=True",
|
||||||
|
"create_policy_rule": "",
|
||||||
|
"get_policy_rule": "rule:admin_or_owner or rule:gbp_policy_rule_shared",
|
||||||
|
|
||||||
|
"gbp_policy_rule_set_shared": "field:policy_rule_sets:shared=True",
|
||||||
|
"create_policy_rule_set": "",
|
||||||
|
"get_policy_rule_set": "rule:admin_or_owner or rule:gbp_policy_rule_set_shared",
|
||||||
|
|
||||||
|
"gbp_nsp_shared": "field:network_service_policies:shared=True",
|
||||||
|
"create_network_service_policy": "",
|
||||||
|
"get_network_service_policy": "rule:admin_or_owner or rule:gbp_nsp_shared",
|
||||||
|
|
||||||
|
"gbp_external_segment_shared": "field:external_segments:shared=True",
|
||||||
|
"create_external_segment": "",
|
||||||
|
"get_external_segment": "rule:admin_or_owner or rule:gbp_external_segment_shared",
|
||||||
|
|
||||||
|
"gbp_external_policy_shared": "field:external_policies:shared=True",
|
||||||
|
"create_external_policy": "",
|
||||||
|
"get_external_policy": "rule:admin_or_owner or rule:gbp_external_policy_shared",
|
||||||
|
|
||||||
|
"gbp_nat_pool_shared": "field:nat_pools:shared=True",
|
||||||
|
"create_nat_pool": "",
|
||||||
|
"get_nat_pool": "rule:admin_or_owner or rule:gbp_nat_pool_shared"
|
||||||
|
}
|
@ -12,26 +12,29 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import os
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from neutron.api import extensions
|
from neutron.api import extensions
|
||||||
from neutron.api.v2 import attributes as nattr
|
from neutron.api.v2 import attributes as nattr
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.openstack.common import importutils
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.tests.unit import test_db_plugin
|
from neutron.tests.unit.api import test_extensions
|
||||||
from neutron.tests.unit import test_extensions
|
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
||||||
import gbpservice.neutron.extensions
|
|
||||||
from gbpservice.neutron.extensions import group_policy as gpolicy
|
from gbpservice.neutron.extensions import group_policy as gpolicy
|
||||||
|
import gbpservice.neutron.tests
|
||||||
from gbpservice.neutron.tests.unit import common as cm
|
from gbpservice.neutron.tests.unit import common as cm
|
||||||
|
|
||||||
|
|
||||||
JSON_FORMAT = 'json'
|
JSON_FORMAT = 'json'
|
||||||
_uuid = uuidutils.generate_uuid
|
_uuid = uuidutils.generate_uuid
|
||||||
|
TESTDIR = os.path.dirname(os.path.abspath(gbpservice.neutron.tests.__file__))
|
||||||
|
ETCDIR = os.path.join(TESTDIR, 'etc')
|
||||||
|
|
||||||
|
|
||||||
class GroupPolicyDBTestBase(object):
|
class GroupPolicyDBTestBase(object):
|
||||||
@ -170,15 +173,12 @@ DB_GP_PLUGIN_KLASS = (GroupPolicyDBTestPlugin.__module__ + '.' +
|
|||||||
|
|
||||||
|
|
||||||
class GroupPolicyDbTestCase(GroupPolicyDBTestBase,
|
class GroupPolicyDbTestCase(GroupPolicyDBTestBase,
|
||||||
test_db_plugin.NeutronDbPluginV2TestCase):
|
test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||||
|
|
||||||
def setUp(self, core_plugin=None, gp_plugin=None, service_plugins=None,
|
def setUp(self, core_plugin=None, gp_plugin=None, service_plugins=None,
|
||||||
ext_mgr=None):
|
ext_mgr=None):
|
||||||
extensions.append_api_extensions_path(
|
|
||||||
gbpservice.neutron.extensions.__path__)
|
|
||||||
if not gp_plugin:
|
if not gp_plugin:
|
||||||
gp_plugin = DB_GP_PLUGIN_KLASS
|
gp_plugin = DB_GP_PLUGIN_KLASS
|
||||||
self.plugin = importutils.import_object(gp_plugin)
|
|
||||||
if not service_plugins:
|
if not service_plugins:
|
||||||
service_plugins = {'gp_plugin_name': gp_plugin}
|
service_plugins = {'gp_plugin_name': gp_plugin}
|
||||||
nattr.PLURALS['nat_pools'] = 'nat_pool'
|
nattr.PLURALS['nat_pools'] = 'nat_pool'
|
||||||
@ -186,11 +186,12 @@ class GroupPolicyDbTestCase(GroupPolicyDBTestBase,
|
|||||||
plugin=core_plugin, ext_mgr=ext_mgr,
|
plugin=core_plugin, ext_mgr=ext_mgr,
|
||||||
service_plugins=service_plugins
|
service_plugins=service_plugins
|
||||||
)
|
)
|
||||||
|
self.plugin = importutils.import_object(gp_plugin)
|
||||||
if not ext_mgr:
|
if not ext_mgr:
|
||||||
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
|
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
|
||||||
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
|
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||||
cfg.CONF.set_override('policy_file', 'test-policy.json')
|
test_policy_file = ETCDIR + "/test-policy.json"
|
||||||
|
cfg.CONF.set_override('policy_file', test_policy_file)
|
||||||
|
|
||||||
|
|
||||||
class TestGroupResources(GroupPolicyDbTestCase):
|
class TestGroupResources(GroupPolicyDbTestCase):
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from neutron.tests.unit import test_l3_plugin
|
from neutron.tests.unit.extensions import test_l3
|
||||||
from neutron.tests.unit import testlib_api
|
from neutron.tests.unit import testlib_api
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db as gpmdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_mapping_db as gpmdb
|
||||||
@ -37,7 +37,7 @@ SC_PLUGIN_KLASS = (
|
|||||||
|
|
||||||
|
|
||||||
class GroupPolicyMappingDbTestCase(tgpdb.GroupPolicyDbTestCase,
|
class GroupPolicyMappingDbTestCase(tgpdb.GroupPolicyDbTestCase,
|
||||||
test_l3_plugin.L3NatTestCaseMixin):
|
test_l3.L3NatTestCaseMixin):
|
||||||
|
|
||||||
def setUp(self, core_plugin=None, gp_plugin=None, service_plugins=None):
|
def setUp(self, core_plugin=None, gp_plugin=None, service_plugins=None):
|
||||||
testlib_api.SqlTestCase._TABLES_ESTABLISHED = False
|
testlib_api.SqlTestCase._TABLES_ESTABLISHED = False
|
||||||
|
@ -15,14 +15,13 @@ import webob.exc
|
|||||||
|
|
||||||
from neutron.api import extensions
|
from neutron.api import extensions
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.openstack.common import importutils
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.tests.unit import test_db_plugin
|
from neutron.tests.unit.api import test_extensions
|
||||||
from neutron.tests.unit import test_extensions
|
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||||
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from gbpservice.neutron.db import servicechain_db as svcchain_db
|
from gbpservice.neutron.db import servicechain_db as svcchain_db
|
||||||
import gbpservice.neutron.extensions
|
|
||||||
from gbpservice.neutron.extensions import servicechain as service_chain
|
from gbpservice.neutron.extensions import servicechain as service_chain
|
||||||
|
|
||||||
JSON_FORMAT = 'json'
|
JSON_FORMAT = 'json'
|
||||||
@ -211,15 +210,12 @@ GP_PLUGIN_KLASS = (
|
|||||||
|
|
||||||
|
|
||||||
class ServiceChainDbTestCase(ServiceChainDBTestBase,
|
class ServiceChainDbTestCase(ServiceChainDBTestBase,
|
||||||
test_db_plugin.NeutronDbPluginV2TestCase):
|
test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||||
|
|
||||||
def setUp(self, core_plugin=None, sc_plugin=None, service_plugins=None,
|
def setUp(self, core_plugin=None, sc_plugin=None, service_plugins=None,
|
||||||
ext_mgr=None):
|
ext_mgr=None):
|
||||||
extensions.append_api_extensions_path(
|
|
||||||
gbpservice.neutron.extensions.__path__)
|
|
||||||
if not sc_plugin:
|
if not sc_plugin:
|
||||||
sc_plugin = DB_GP_PLUGIN_KLASS
|
sc_plugin = DB_GP_PLUGIN_KLASS
|
||||||
self.plugin = importutils.import_object(sc_plugin)
|
|
||||||
if not service_plugins:
|
if not service_plugins:
|
||||||
service_plugins = {'gp_plugin_name': GP_PLUGIN_KLASS,
|
service_plugins = {'gp_plugin_name': GP_PLUGIN_KLASS,
|
||||||
'sc_plugin_name': sc_plugin}
|
'sc_plugin_name': sc_plugin}
|
||||||
@ -228,7 +224,7 @@ class ServiceChainDbTestCase(ServiceChainDBTestBase,
|
|||||||
plugin=core_plugin, ext_mgr=ext_mgr,
|
plugin=core_plugin, ext_mgr=ext_mgr,
|
||||||
service_plugins=service_plugins
|
service_plugins=service_plugins
|
||||||
)
|
)
|
||||||
|
self.plugin = importutils.import_object(sc_plugin)
|
||||||
if not ext_mgr:
|
if not ext_mgr:
|
||||||
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
|
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
|
||||||
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
|
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||||
|
@ -20,10 +20,13 @@ import webob.exc
|
|||||||
|
|
||||||
from neutron.common import rpc as n_rpc
|
from neutron.common import rpc as n_rpc
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.tests.unit.ml2.drivers.cisco.apic import (
|
from neutron.db import api as db_api
|
||||||
test_cisco_apic_common as mocked)
|
from neutron.db import model_base
|
||||||
from neutron.tests.unit.ml2 import test_ml2_plugin
|
from neutron import manager
|
||||||
from oslo.config import cfg
|
from neutron.tests.unit.plugins.ml2.drivers.cisco.apic import (
|
||||||
|
base as mocked)
|
||||||
|
from neutron.tests.unit.plugins.ml2 import test_plugin
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
sys.modules["apicapi"] = mock.Mock()
|
sys.modules["apicapi"] = mock.Mock()
|
||||||
|
|
||||||
@ -31,7 +34,8 @@ from gbpservice.neutron.services.grouppolicy import config
|
|||||||
from gbpservice.neutron.services.grouppolicy.drivers.cisco.apic import (
|
from gbpservice.neutron.services.grouppolicy.drivers.cisco.apic import (
|
||||||
apic_mapping as amap)
|
apic_mapping as amap)
|
||||||
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
||||||
test_grouppolicy_plugin as test_plugin)
|
test_grouppolicy_plugin as test_gp_plugin)
|
||||||
|
|
||||||
|
|
||||||
APIC_L2_POLICY = 'l2_policy'
|
APIC_L2_POLICY = 'l2_policy'
|
||||||
APIC_L3_POLICY = 'l3_policy'
|
APIC_L3_POLICY = 'l3_policy'
|
||||||
@ -41,6 +45,10 @@ APIC_POLICY_RULE = 'policy_rule'
|
|||||||
|
|
||||||
APIC_EXTERNAL_RID = '1.0.0.1'
|
APIC_EXTERNAL_RID = '1.0.0.1'
|
||||||
|
|
||||||
|
AGENT_TYPE = 'Open vSwitch agent'
|
||||||
|
AGENT_CONF = {'alive': True, 'binary': 'somebinary',
|
||||||
|
'topic': 'sometopic', 'agent_type': AGENT_TYPE}
|
||||||
|
|
||||||
|
|
||||||
def echo(context, string):
|
def echo(context, string):
|
||||||
return string
|
return string
|
||||||
@ -61,7 +69,7 @@ class MockCallRecorder(mock.Mock):
|
|||||||
|
|
||||||
|
|
||||||
class ApicMappingTestCase(
|
class ApicMappingTestCase(
|
||||||
test_plugin.GroupPolicyPluginTestCase,
|
test_gp_plugin.GroupPolicyPluginTestCase,
|
||||||
mocked.ControllerMixin, mocked.ConfigMixin):
|
mocked.ControllerMixin, mocked.ConfigMixin):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -77,9 +85,14 @@ class ApicMappingTestCase(
|
|||||||
for opt, val in ml2_opts.items():
|
for opt, val in ml2_opts.items():
|
||||||
cfg.CONF.set_override(opt, val, 'ml2')
|
cfg.CONF.set_override(opt, val, 'ml2')
|
||||||
super(ApicMappingTestCase, self).setUp(
|
super(ApicMappingTestCase, self).setUp(
|
||||||
core_plugin=test_ml2_plugin.PLUGIN_NAME)
|
core_plugin=test_plugin.PLUGIN_NAME)
|
||||||
|
engine = db_api.get_engine()
|
||||||
self.driver = amap.ApicMappingDriver.get_initialized_instance()
|
model_base.BASEV2.metadata.create_all(engine)
|
||||||
|
plugin = manager.NeutronManager.get_plugin()
|
||||||
|
plugin.remove_networks_from_down_agents = mock.Mock()
|
||||||
|
plugin.is_agent_down = mock.Mock(return_value=False)
|
||||||
|
self.driver = manager.NeutronManager.get_service_plugins()[
|
||||||
|
'GROUP_POLICY'].policy_driver_manager.policy_drivers['apic'].obj
|
||||||
amap.ApicMappingDriver.get_base_synchronizer = mock.Mock()
|
amap.ApicMappingDriver.get_base_synchronizer = mock.Mock()
|
||||||
self.driver.name_mapper = mock.Mock()
|
self.driver.name_mapper = mock.Mock()
|
||||||
self.driver.name_mapper.tenant = echo
|
self.driver.name_mapper.tenant = echo
|
||||||
@ -216,6 +229,11 @@ class TestPolicyTarget(ApicMappingTestCase):
|
|||||||
self.assertEqual(mgr.ensure_path_deleted_for_port.call_count, 0)
|
self.assertEqual(mgr.ensure_path_deleted_for_port.call_count, 0)
|
||||||
|
|
||||||
def _bind_port_to_host(self, port_id, host):
|
def _bind_port_to_host(self, port_id, host):
|
||||||
|
plugin = manager.NeutronManager.get_plugin()
|
||||||
|
ctx = context.get_admin_context()
|
||||||
|
agent = {'host': host}
|
||||||
|
agent.update(AGENT_CONF)
|
||||||
|
plugin.create_or_update_agent(ctx, agent)
|
||||||
data = {'port': {'binding:host_id': host}}
|
data = {'port': {'binding:host_id': host}}
|
||||||
# Create EP with bound port
|
# Create EP with bound port
|
||||||
req = self.new_update_request('ports', data, port_id,
|
req = self.new_update_request('ports', data, port_id,
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import os
|
||||||
|
|
||||||
from neutron.api import extensions
|
|
||||||
from neutron.api.v2 import attributes
|
from neutron.api.v2 import attributes
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy import (
|
from gbpservice.neutron.services.grouppolicy import (
|
||||||
group_policy_driver_api as api)
|
group_policy_driver_api as api)
|
||||||
@ -35,6 +35,9 @@ class ExtensionDriverTestCase(
|
|||||||
config.cfg.CONF.set_override('extension_drivers',
|
config.cfg.CONF.set_override('extension_drivers',
|
||||||
self._extension_drivers,
|
self._extension_drivers,
|
||||||
group='group_policy')
|
group='group_policy')
|
||||||
|
config.cfg.CONF.set_override(
|
||||||
|
'api_extensions_path',
|
||||||
|
os.path.dirname(os.path.abspath(test_ext.__file__)))
|
||||||
super(ExtensionDriverTestCase, self).setUp()
|
super(ExtensionDriverTestCase, self).setUp()
|
||||||
|
|
||||||
def test_pt_attr(self):
|
def test_pt_attr(self):
|
||||||
@ -539,10 +542,7 @@ class TestExtensionDriver(api.ExtensionDriver):
|
|||||||
_supported_extension_alias = 'test_extension'
|
_supported_extension_alias = 'test_extension'
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
# self.network_extension = 'Test_Network_Extension'
|
pass
|
||||||
# self.subnet_extension = 'Test_Subnet_Extension'
|
|
||||||
# self.port_extension = 'Test_Port_Extension'
|
|
||||||
extensions.append_api_extensions_path(test_ext.__path__)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extension_alias(self):
|
def extension_alias(self):
|
||||||
|
@ -12,10 +12,9 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import webob.exc
|
|
||||||
|
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
import webob.exc
|
||||||
|
|
||||||
from gbpservice.neutron.extensions import group_policy as gpolicy
|
from gbpservice.neutron.extensions import group_policy as gpolicy
|
||||||
from gbpservice.neutron.tests.unit.db.grouppolicy import (
|
from gbpservice.neutron.tests.unit.db.grouppolicy import (
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from neutron.db import api as db_api
|
||||||
|
from neutron.db import model_base
|
||||||
|
from oslo_config import cfg
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
||||||
@ -25,6 +27,8 @@ class ImplicitPolicyTestCase(
|
|||||||
cfg.CONF.set_override('policy_drivers', ['implicit_policy'],
|
cfg.CONF.set_override('policy_drivers', ['implicit_policy'],
|
||||||
group='group_policy')
|
group='group_policy')
|
||||||
super(ImplicitPolicyTestCase, self).setUp()
|
super(ImplicitPolicyTestCase, self).setUp()
|
||||||
|
engine = db_api.get_engine()
|
||||||
|
model_base.BASEV2.metadata.create_all(engine)
|
||||||
|
|
||||||
|
|
||||||
class TestImplicitL2Policy(ImplicitPolicyTestCase):
|
class TestImplicitL2Policy(ImplicitPolicyTestCase):
|
||||||
@ -310,10 +314,10 @@ class TestImplicitExternalSegment(ImplicitPolicyTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._default_es_name = 'default'
|
self._default_es_name = 'default'
|
||||||
|
super(TestImplicitExternalSegment, self).setUp()
|
||||||
cfg.CONF.set_override(
|
cfg.CONF.set_override(
|
||||||
'default_external_segment_name', self._default_es_name,
|
'default_external_segment_name', self._default_es_name,
|
||||||
group='group_policy_implicit_policy')
|
group='group_policy_implicit_policy')
|
||||||
super(TestImplicitExternalSegment, self).setUp()
|
|
||||||
|
|
||||||
def _create_default_es(self, **kwargs):
|
def _create_default_es(self, **kwargs):
|
||||||
return self.create_external_segment(name=self._default_es_name,
|
return self.create_external_segment(name=self._default_es_name,
|
||||||
|
@ -12,15 +12,16 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import mock
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from gbpservice.network.neutronv2 import client as neutronclient
|
import mock
|
||||||
|
from neutron import context
|
||||||
|
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||||
from neutronclient.common import exceptions
|
from neutronclient.common import exceptions
|
||||||
from neutronclient.v2_0 import client
|
from neutronclient.v2_0 import client
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from gbpservice.network.neutronv2 import client as neutronclient
|
||||||
|
|
||||||
from neutron import context
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ CONF = cfg.CONF
|
|||||||
NEUTRON_CLIENT_EXCEPTION = Exception
|
NEUTRON_CLIENT_EXCEPTION = Exception
|
||||||
|
|
||||||
|
|
||||||
class TestNeutronClient(unittest.TestCase):
|
class TestNeutronClient(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestNeutronClient, self).setUp()
|
super(TestNeutronClient, self).setUp()
|
||||||
|
@ -13,15 +13,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from neutron.tests.unit.ml2 import test_ml2_plugin
|
from neutron.tests.unit.plugins.ml2 import test_plugin
|
||||||
from neutron.tests.unit.nuage import fake_nuageclient
|
from oslo_config import cfg
|
||||||
from oslo.config import cfg
|
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy import config
|
from gbpservice.neutron.services.grouppolicy import config
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.nuage import (
|
from gbpservice.neutron.services.grouppolicy.drivers.nuage import (
|
||||||
driver as nuage_driver)
|
driver as nuage_driver)
|
||||||
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
||||||
test_grouppolicy_plugin as test_plugin)
|
test_grouppolicy_plugin as test_gp_plugin)
|
||||||
|
|
||||||
FAKE_GBP_APP = 'ut_gbp_app'
|
FAKE_GBP_APP = 'ut_gbp_app'
|
||||||
FAKE_DEFAULT_ENT = 'default'
|
FAKE_DEFAULT_ENT = 'default'
|
||||||
@ -34,7 +33,11 @@ FAKE_AUTH_RESOURCE = '/auth'
|
|||||||
FAKE_ORGANIZATION = 'fake_org'
|
FAKE_ORGANIZATION = 'fake_org'
|
||||||
|
|
||||||
|
|
||||||
class FakeNuageGBPClient(fake_nuageclient.FakeNuageClient):
|
class FakeNuageGBPClient(object):
|
||||||
|
|
||||||
|
def __init__(self, server, base_uri, serverssl,
|
||||||
|
serverauth, auth_resource, organization):
|
||||||
|
pass
|
||||||
|
|
||||||
def create_ptg_postcommit(self, context, application):
|
def create_ptg_postcommit(self, context, application):
|
||||||
pass
|
pass
|
||||||
@ -57,7 +60,7 @@ class FakeNuageGBPClient(fake_nuageclient.FakeNuageClient):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NuageGBPDriverTestCase(test_plugin.GroupPolicyPluginTestCase):
|
class NuageGBPDriverTestCase(test_gp_plugin.GroupPolicyPluginTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
config.cfg.CONF.set_override('policy_drivers',
|
config.cfg.CONF.set_override('policy_drivers',
|
||||||
@ -88,7 +91,7 @@ class NuageGBPDriverTestCase(test_plugin.GroupPolicyPluginTestCase):
|
|||||||
with mock.patch.object(nuage_driver.NuageGBPDriver,
|
with mock.patch.object(nuage_driver.NuageGBPDriver,
|
||||||
'nuageclient_init', new=mock_nuageclient_init):
|
'nuageclient_init', new=mock_nuageclient_init):
|
||||||
super(NuageGBPDriverTestCase, self).setUp(
|
super(NuageGBPDriverTestCase, self).setUp(
|
||||||
core_plugin=test_ml2_plugin.PLUGIN_NAME)
|
core_plugin=test_plugin.PLUGIN_NAME)
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyTargetGroup(NuageGBPDriverTestCase):
|
class TestPolicyTargetGroup(NuageGBPDriverTestCase):
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import requests
|
import requests
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import mock
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from gbpservice.neutron.services.grouppolicy import config
|
from gbpservice.neutron.services.grouppolicy import config
|
||||||
from gbpservice.neutron.services.grouppolicy.drivers.odl import odl_manager
|
from gbpservice.neutron.services.grouppolicy.drivers.odl import odl_manager
|
||||||
from oslo.serialization import jsonutils
|
|
||||||
|
|
||||||
|
|
||||||
HOST = 'fake_host'
|
HOST = 'fake_host'
|
||||||
|
@ -21,9 +21,9 @@ from gbpservice.neutron.services.grouppolicy.drivers.odl import odl_mapping
|
|||||||
from gbpservice.neutron.services.grouppolicy.drivers import resource_mapping
|
from gbpservice.neutron.services.grouppolicy.drivers import resource_mapping
|
||||||
from gbpservice.neutron.services.grouppolicy import plugin as g_plugin
|
from gbpservice.neutron.services.grouppolicy import plugin as g_plugin
|
||||||
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
from gbpservice.neutron.tests.unit.services.grouppolicy import (
|
||||||
test_grouppolicy_plugin as test_plugin)
|
test_grouppolicy_plugin as test_gp_plugin)
|
||||||
from neutron.plugins.ml2 import plugin as ml2_plugin
|
from neutron.plugins.ml2 import plugin as ml2_plugin
|
||||||
from neutron.tests.unit.ml2 import test_ml2_plugin
|
from neutron.tests.unit.plugins.ml2 import test_plugin
|
||||||
|
|
||||||
TENANT_ID = 'aaaabbbbccccaaaabbbbccccaaaabbbb'
|
TENANT_ID = 'aaaabbbbccccaaaabbbbccccaaaabbbb'
|
||||||
TENANT_UUID = 'aaaabbbb-cccc-aaaa-bbbb-ccccaaaabbbb'
|
TENANT_UUID = 'aaaabbbb-cccc-aaaa-bbbb-ccccaaaabbbb'
|
||||||
@ -218,7 +218,7 @@ class FakeGBPPlugin(object):
|
|||||||
|
|
||||||
|
|
||||||
class OdlMappingTestCase(
|
class OdlMappingTestCase(
|
||||||
test_plugin.GroupPolicyPluginTestCase):
|
test_gp_plugin.GroupPolicyPluginTestCase):
|
||||||
""" Base test case for ODL mapping driver testing
|
""" Base test case for ODL mapping driver testing
|
||||||
|
|
||||||
Set up the common testing environment
|
Set up the common testing environment
|
||||||
@ -229,7 +229,7 @@ class OdlMappingTestCase(
|
|||||||
['implicit_policy', 'odl'],
|
['implicit_policy', 'odl'],
|
||||||
group='group_policy')
|
group='group_policy')
|
||||||
super(OdlMappingTestCase, self).setUp(
|
super(OdlMappingTestCase, self).setUp(
|
||||||
core_plugin=test_ml2_plugin.PLUGIN_NAME)
|
core_plugin=test_plugin.PLUGIN_NAME)
|
||||||
|
|
||||||
self.fake_core_plugin = FakeCorePlugin()
|
self.fake_core_plugin = FakeCorePlugin()
|
||||||
self.fake_gbp_plugin = FakeGBPPlugin()
|
self.fake_gbp_plugin = FakeGBPPlugin()
|
||||||
|
@ -77,14 +77,14 @@ class TestPolicyTarget(OneConvergenceGBPDriverTestCase,
|
|||||||
ptg_id = ptg['policy_target_group']['id']
|
ptg_id = ptg['policy_target_group']['id']
|
||||||
|
|
||||||
# Create policy_target with implicit port.
|
# Create policy_target with implicit port.
|
||||||
pt = self.create_policy_target(name="pt1",
|
pt = self.create_policy_target(
|
||||||
policy_target_group_id=ptg_id)
|
name="pt1", policy_target_group_id=ptg_id)['policy_target']
|
||||||
pt_id = pt['policy_target']['id']
|
create_ep.assert_called_once_with(mock.ANY, pt)
|
||||||
create_ep.assertCalledOnceWith(mock.ANY, pt)
|
pt = self.update_policy_target(
|
||||||
pt = self.update_policy_target(pt_id, name="new_pt")
|
pt['id'], name="new_pt")['policy_target']
|
||||||
update_ep.assertCalledOnceWith(mock.ANY, pt)
|
update_ep.assert_called_once_with(mock.ANY, pt)
|
||||||
self.delete_policy_target(pt_id)
|
self.delete_policy_target(pt['id'])
|
||||||
delete_ep.assertCalledOnceWith(mock.ANY, pt_id)
|
delete_ep.assert_called_once_with(mock.ANY, pt['id'])
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyTargetGroup(OneConvergenceGBPDriverTestCase,
|
class TestPolicyTargetGroup(OneConvergenceGBPDriverTestCase,
|
||||||
@ -115,13 +115,14 @@ class TestPolicyTargetGroup(OneConvergenceGBPDriverTestCase,
|
|||||||
mock.patch.object(MockNVSDApiClient, 'update_endpointgroup'),
|
mock.patch.object(MockNVSDApiClient, 'update_endpointgroup'),
|
||||||
mock.patch.object(MockNVSDApiClient, 'delete_endpointgroup')
|
mock.patch.object(MockNVSDApiClient, 'delete_endpointgroup')
|
||||||
) as (create_epg, update_epg, delete_epg):
|
) as (create_epg, update_epg, delete_epg):
|
||||||
ptg = self.create_policy_target_group(name="ptg1")
|
ptg = self.create_policy_target_group(
|
||||||
ptg_id = ptg['policy_target_group']['id']
|
name="ptg1")['policy_target_group']
|
||||||
create_epg.assertCalledOnceWith(mock.ANY, ptg)
|
create_epg.assert_called_once_with(mock.ANY, ptg)
|
||||||
ptg = self.update_policy_target_group(ptg_id, name="new_ptg")
|
ptg = self.update_policy_target_group(
|
||||||
update_epg.assertCalledOnceWith(mock.ANY, ptg)
|
ptg['id'], name="new_ptg")['policy_target_group']
|
||||||
self.delete_policy_target_group(ptg_id)
|
update_epg.assert_called_once_with(mock.ANY, ptg)
|
||||||
delete_epg.assertCalledOnceWith(mock.ANY, ptg_id)
|
self.delete_policy_target_group(ptg['id'])
|
||||||
|
delete_epg.assert_called_once_with(mock.ANY, ptg['id'])
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyClassifier(OneConvergenceGBPDriverTestCase):
|
class TestPolicyClassifier(OneConvergenceGBPDriverTestCase):
|
||||||
@ -136,13 +137,16 @@ class TestPolicyClassifier(OneConvergenceGBPDriverTestCase):
|
|||||||
MockNVSDApiClient, 'delete_policy_classifier')
|
MockNVSDApiClient, 'delete_policy_classifier')
|
||||||
) as (create_classifier, update_classifier, delete_classifier):
|
) as (create_classifier, update_classifier, delete_classifier):
|
||||||
classifier = self.create_policy_classifier(name="classifier1")
|
classifier = self.create_policy_classifier(name="classifier1")
|
||||||
classifier_id = classifier['policy_classifier']['id']
|
classifier = classifier['policy_classifier']
|
||||||
create_classifier.assertCalledOnceWith(mock.ANY, classifier)
|
classifier.update({"policy_rules": []})
|
||||||
|
create_classifier.assert_called_once_with(mock.ANY, classifier)
|
||||||
classifier = self.update_policy_classifier(
|
classifier = self.update_policy_classifier(
|
||||||
classifier_id, name="new_classifier")
|
classifier['id'], name="new_classifier")['policy_classifier']
|
||||||
update_classifier.assertCalledOnceWith(mock.ANY, classifier)
|
classifier.update({"policy_rules": []})
|
||||||
self.delete_policy_classifier(classifier_id)
|
update_classifier.assert_called_once_with(mock.ANY, classifier)
|
||||||
delete_classifier.assertCalledOnceWith(mock.ANY, classifier_id)
|
self.delete_policy_classifier(classifier['id'])
|
||||||
|
delete_classifier.assert_called_once_with(
|
||||||
|
mock.ANY, classifier['id'])
|
||||||
|
|
||||||
|
|
||||||
class TestL2Policy(OneConvergenceGBPDriverTestCase,
|
class TestL2Policy(OneConvergenceGBPDriverTestCase,
|
||||||
|
@ -19,14 +19,16 @@ import mock
|
|||||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||||
from neutron.common import constants as cst
|
from neutron.common import constants as cst
|
||||||
from neutron import context as nctx
|
from neutron import context as nctx
|
||||||
|
from neutron.db import api as db_api
|
||||||
|
from neutron.db import model_base
|
||||||
from neutron.extensions import external_net as external_net
|
from neutron.extensions import external_net as external_net
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.notifiers import nova
|
from neutron.notifiers import nova
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants as pconst
|
from neutron.plugins.common import constants as pconst
|
||||||
from neutron.tests.unit import test_extension_security_group
|
from neutron.tests.unit.extensions import test_l3
|
||||||
from neutron.tests.unit import test_l3_plugin
|
from neutron.tests.unit.extensions import test_securitygroup
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
from gbpservice.neutron.db.grouppolicy import group_policy_db as gpdb
|
||||||
@ -44,8 +46,8 @@ SERVICECHAIN_INSTANCES = 'servicechain/servicechain_instances'
|
|||||||
|
|
||||||
|
|
||||||
class NoL3NatSGTestPlugin(
|
class NoL3NatSGTestPlugin(
|
||||||
test_l3_plugin.TestNoL3NatPlugin,
|
test_l3.TestNoL3NatPlugin,
|
||||||
test_extension_security_group.SecurityGroupTestPlugin):
|
test_securitygroup.SecurityGroupTestPlugin):
|
||||||
|
|
||||||
supported_extension_aliases = ["external-net", "security-group"]
|
supported_extension_aliases = ["external-net", "security-group"]
|
||||||
|
|
||||||
@ -67,6 +69,8 @@ class ResourceMappingTestCase(test_plugin.GroupPolicyPluginTestCase):
|
|||||||
group='servicechain')
|
group='servicechain')
|
||||||
config.cfg.CONF.set_override('allow_overlapping_ips', True)
|
config.cfg.CONF.set_override('allow_overlapping_ips', True)
|
||||||
super(ResourceMappingTestCase, self).setUp(core_plugin=CORE_PLUGIN)
|
super(ResourceMappingTestCase, self).setUp(core_plugin=CORE_PLUGIN)
|
||||||
|
engine = db_api.get_engine()
|
||||||
|
model_base.BASEV2.metadata.create_all(engine)
|
||||||
res = mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.'
|
res = mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.'
|
||||||
'_check_router_needs_rescheduling').start()
|
'_check_router_needs_rescheduling').start()
|
||||||
res.return_value = None
|
res.return_value = None
|
||||||
@ -2285,7 +2289,8 @@ class TestPolicyRuleSet(ResourceMappingTestCase):
|
|||||||
with self.subnet(cidr='192.168.0.0/24', network=net) as sub:
|
with self.subnet(cidr='192.168.0.0/24', network=net) as sub:
|
||||||
self.create_external_segment(
|
self.create_external_segment(
|
||||||
shared=True,
|
shared=True,
|
||||||
tenant_id='admin', name="default",
|
tenant_id='admin',
|
||||||
|
name="default",
|
||||||
subnet_id=sub['subnet']['id'])['external_segment']
|
subnet_id=sub['subnet']['id'])['external_segment']
|
||||||
|
|
||||||
ep = self.create_external_policy(
|
ep = self.create_external_policy(
|
||||||
@ -2331,7 +2336,8 @@ class TestPolicyRuleSet(ResourceMappingTestCase):
|
|||||||
with self.subnet(cidr='192.168.0.0/24', network=net) as sub:
|
with self.subnet(cidr='192.168.0.0/24', network=net) as sub:
|
||||||
self.create_external_segment(
|
self.create_external_segment(
|
||||||
shared=True,
|
shared=True,
|
||||||
tenant_id='admin', name="default",
|
tenant_id='admin',
|
||||||
|
name="default",
|
||||||
subnet_id=sub['subnet']['id'])['external_segment']
|
subnet_id=sub['subnet']['id'])['external_segment']
|
||||||
|
|
||||||
ep = self.create_external_policy()
|
ep = self.create_external_policy()
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from gbpservice.neutron.tests.unit.db.grouppolicy import (
|
from gbpservice.neutron.tests.unit.db.grouppolicy import (
|
||||||
test_servicechain_db as test_servicechain_db)
|
test_servicechain_db as test_servicechain_db)
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
import heatclient
|
import heatclient
|
||||||
import mock
|
import mock
|
||||||
from neutron.openstack.common import jsonutils
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from gbpservice.neutron.services.servicechain import config
|
from gbpservice.neutron.services.servicechain import config
|
||||||
|
@ -17,15 +17,15 @@ import mock
|
|||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit.api.v2 import test_base
|
||||||
from neutron.tests.unit import test_api_v2_extension
|
from neutron.tests.unit.extensions import base as test_extensions_base
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
from gbpservice.neutron.extensions import group_policy as gp
|
from gbpservice.neutron.extensions import group_policy as gp
|
||||||
from gbpservice.neutron.tests.unit import common as cm
|
from gbpservice.neutron.tests.unit import common as cm
|
||||||
|
|
||||||
_uuid = uuidutils.generate_uuid
|
_uuid = uuidutils.generate_uuid
|
||||||
_get_path = test_api_v2._get_path
|
_get_path = test_base._get_path
|
||||||
GP_PLUGIN_BASE_NAME = (
|
GP_PLUGIN_BASE_NAME = (
|
||||||
gp.GroupPolicyPluginBase.__module__ + '.' +
|
gp.GroupPolicyPluginBase.__module__ + '.' +
|
||||||
gp.GroupPolicyPluginBase.__name__)
|
gp.GroupPolicyPluginBase.__name__)
|
||||||
@ -48,7 +48,7 @@ RES_TO_URI = {'external_policy': EP_POLICIES_URI,
|
|||||||
'nat_pool': NP_POLICIES_URI}
|
'nat_pool': NP_POLICIES_URI}
|
||||||
|
|
||||||
|
|
||||||
class GroupPolicyExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
|
class GroupPolicyExtensionTestCase(test_extensions_base.ExtensionTestCase):
|
||||||
fmt = 'json'
|
fmt = 'json'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -13,17 +13,17 @@
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from webob import exc
|
|
||||||
|
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit.api.v2 import test_base
|
||||||
from neutron.tests.unit import test_api_v2_extension
|
from neutron.tests.unit.extensions import base as test_extensions_base
|
||||||
|
from webob import exc
|
||||||
|
|
||||||
from gbpservice.neutron.extensions import servicechain
|
from gbpservice.neutron.extensions import servicechain
|
||||||
|
|
||||||
|
|
||||||
_uuid = uuidutils.generate_uuid
|
_uuid = uuidutils.generate_uuid
|
||||||
_get_path = test_api_v2._get_path
|
_get_path = test_base._get_path
|
||||||
SERVICE_CHAIN_PLUGIN_BASE_NAME = (
|
SERVICE_CHAIN_PLUGIN_BASE_NAME = (
|
||||||
servicechain.ServiceChainPluginBase.__module__ + '.' +
|
servicechain.ServiceChainPluginBase.__module__ + '.' +
|
||||||
servicechain.ServiceChainPluginBase.__name__)
|
servicechain.ServiceChainPluginBase.__name__)
|
||||||
@ -33,7 +33,7 @@ SERVICECHAIN_SPECS_URI = SERVICECHAIN_URI + '/' + 'servicechain_specs'
|
|||||||
SERVICECHAIN_INSTANCES_URI = SERVICECHAIN_URI + '/' + 'servicechain_instances'
|
SERVICECHAIN_INSTANCES_URI = SERVICECHAIN_URI + '/' + 'servicechain_instances'
|
||||||
|
|
||||||
|
|
||||||
class ServiceChainExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
|
class ServiceChainExtensionTestCase(test_extensions_base.ExtensionTestCase):
|
||||||
fmt = 'json'
|
fmt = 'json'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -6,7 +6,7 @@ TOP_DIR=$BASE/new/devstack
|
|||||||
cd $TOP_DIR
|
cd $TOP_DIR
|
||||||
sudo git remote add group-policy http://github.com/group-policy/devstack
|
sudo git remote add group-policy http://github.com/group-policy/devstack
|
||||||
sudo git fetch group-policy
|
sudo git fetch group-policy
|
||||||
sudo git checkout -t group-policy/kilo-gate
|
sudo git checkout -t group-policy/kilo-gbp-openstack-master-gate
|
||||||
#sudo cp devstack-vm-gate.sh $BASE/new/devstack-gate/devstack-vm-gate.sh
|
#sudo cp devstack-vm-gate.sh $BASE/new/devstack-gate/devstack-vm-gate.sh
|
||||||
|
|
||||||
CONTRIB_DIR="$BASE/new/group-based-policy/gbpservice/tests/contrib"
|
CONTRIB_DIR="$BASE/new/group-based-policy/gbpservice/tests/contrib"
|
||||||
@ -27,7 +27,6 @@ sed -e "s+\$BASE_PATH+$BASE/new/group-based-policy/.tox/dsvm-functional+" \
|
|||||||
$FUNC_FILTER | sudo tee /etc/neutron/rootwrap.d/functional.filters > /dev/null
|
$FUNC_FILTER | sudo tee /etc/neutron/rootwrap.d/functional.filters > /dev/null
|
||||||
|
|
||||||
# Use devstack functions to install mysql and psql servers
|
# Use devstack functions to install mysql and psql servers
|
||||||
source $TOP_DIR/lib/config
|
|
||||||
source $TOP_DIR/stackrc
|
source $TOP_DIR/stackrc
|
||||||
source $TOP_DIR/lib/database
|
source $TOP_DIR/lib/database
|
||||||
disable_service postgresql
|
disable_service postgresql
|
||||||
|
@ -37,6 +37,8 @@ $prep_func
|
|||||||
# Run tests
|
# Run tests
|
||||||
echo "Running group-based-policy dsvm-functional test suite"
|
echo "Running group-based-policy dsvm-functional test suite"
|
||||||
set +e
|
set +e
|
||||||
|
# Temporary workaround for subunit not getting installed in tox environment
|
||||||
|
sudo pip uninstall python-subunit -y
|
||||||
sudo -H -u $owner tox -e dsvm-functional
|
sudo -H -u $owner tox -e dsvm-functional
|
||||||
testr_exit_code=$?
|
testr_exit_code=$?
|
||||||
set -e
|
set -e
|
||||||
|
@ -167,7 +167,7 @@ function run_pep8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TESTRTESTS="python -m neutron.openstack.common.lockutils python setup.py testr"
|
TESTRTESTS="python setup.py testr"
|
||||||
|
|
||||||
if [ $never_venv -eq 0 ]
|
if [ $never_venv -eq 0 ]
|
||||||
then
|
then
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# of appearance. Changing the order has an impact on the overall integration
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
|
|
||||||
-e git+https://github.com/openstack/neutron.git@stable/juno#egg=neutron
|
-e git+https://github.com/openstack/neutron.git#egg=neutron
|
||||||
prettytable>=0.7
|
prettytable>=0.7
|
||||||
|
|
||||||
cliff>=1.7.0 # Apache-2.0
|
cliff>=1.7.0 # Apache-2.0
|
||||||
|
8
tox.ini
8
tox.ini
@ -13,7 +13,7 @@ install_command = pip install -U {opts} {packages}
|
|||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands =
|
commands =
|
||||||
python -m neutron.openstack.common.lockutils python setup.py testr --slowest --testr-args='{posargs}'
|
python setup.py testr --slowest --testr-args='{posargs}'
|
||||||
|
|
||||||
[testenv:hashtest]
|
[testenv:hashtest]
|
||||||
# This is the same as default environment, but with a random PYTHONHASHSEED.
|
# This is the same as default environment, but with a random PYTHONHASHSEED.
|
||||||
@ -24,7 +24,7 @@ setenv = VIRTUAL_ENV={envdir}
|
|||||||
[testenv:functional]
|
[testenv:functional]
|
||||||
setenv = OS_TEST_PATH=./gbpservice/tests/functional
|
setenv = OS_TEST_PATH=./gbpservice/tests/functional
|
||||||
commands =
|
commands =
|
||||||
python -m neutron.openstack.common.lockutils python setup.py testr --slowest --testr-args='{posargs}'
|
python setup.py testr --slowest --testr-args='{posargs}'
|
||||||
|
|
||||||
[testenv:dsvm-functional]
|
[testenv:dsvm-functional]
|
||||||
setenv = OS_TEST_PATH=./gbpservice/tests/functional
|
setenv = OS_TEST_PATH=./gbpservice/tests/functional
|
||||||
@ -33,7 +33,7 @@ setenv = OS_TEST_PATH=./gbpservice/tests/functional
|
|||||||
OS_FAIL_ON_MISSING_DEPS=1
|
OS_FAIL_ON_MISSING_DEPS=1
|
||||||
sitepackages=True
|
sitepackages=True
|
||||||
commands =
|
commands =
|
||||||
python -m neutron.openstack.common.lockutils python setup.py testr --slowest --testr-args='{posargs}'
|
python setup.py testr --slowest --testr-args='{posargs}'
|
||||||
|
|
||||||
[tox:jenkins]
|
[tox:jenkins]
|
||||||
sitepackages = True
|
sitepackages = True
|
||||||
@ -49,7 +49,7 @@ commands = python ./tools/check_i18n.py ./neutron ./tools/i18n_cfg.py
|
|||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
commands =
|
commands =
|
||||||
python -m neutron.openstack.common.lockutils python setup.py testr --coverage --testr-args='{posargs}'
|
python setup.py testr --coverage --testr-args='{posargs}'
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
Loading…
Reference in New Issue
Block a user