[aim] Remove gbp/ml2 drivers' dependency from AIM config

Change-Id: I6fc6a1abf2ffdd91abfd8f480861b6e3a9b38d9f
This commit is contained in:
Ivar Lazzaro
2016-12-16 17:06:06 -08:00
parent dc14911b6b
commit a2c019d6d4
3 changed files with 43 additions and 16 deletions

View File

@@ -0,0 +1,30 @@
# Copyright (c) 2014 OpenStack Foundation
# All Rights Reserved.
#
# 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
# Register apic_system_id
# REVISIT(ivar): would be nice to remove dependency from apic_ml2 in GBP, and
# register option directly here.
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import config # noqa
apic_opts = [
cfg.BoolOpt('enable_optimized_dhcp', default=True),
cfg.BoolOpt('enable_optimized_metadata', default=False),
]
cfg.CONF.register_opts(apic_opts, "ml2_apic_aim")

View File

@@ -19,7 +19,6 @@ from aim.aim_lib import nat_strategy
from aim import aim_manager
from aim.api import resource as aim_resource
from aim.common import utils
from aim import config as aim_cfg
from aim import context as aim_context
from aim import utils as aim_utils
from neutron._i18n import _LI
@@ -29,7 +28,6 @@ from neutron.common import constants as n_constants
from neutron.common import exceptions
from neutron.common import topics as n_topics
from neutron.db import address_scope_db
from neutron.db import api as db_api
from neutron.db import l3_db
from neutron.db import models_v2
from neutron.extensions import portbindings
@@ -38,6 +36,7 @@ from neutron.plugins.common import constants as pconst
from neutron.plugins.ml2 import driver_api as api
from opflexagent import constants as ofcst
from opflexagent import rpc as ofrpc
from oslo_config import cfg
from oslo_log import log
from gbpservice.neutron.extensions import cisco_apic
@@ -45,11 +44,11 @@ from gbpservice.neutron.extensions import cisco_apic_l3 as a_l3
from gbpservice.neutron.plugins.ml2plus import driver_api as api_plus
from gbpservice.neutron.plugins.ml2plus.drivers.apic_aim import apic_mapper
from gbpservice.neutron.plugins.ml2plus.drivers.apic_aim import cache
from gbpservice.neutron.plugins.ml2plus.drivers.apic_aim import config # noqa
from gbpservice.neutron.plugins.ml2plus.drivers.apic_aim import extension_db
from oslo_serialization.jsonutils import netaddr
LOG = log.getLogger(__name__)
DEVICE_OWNER_SNAT_PORT = 'apic:snat-pool'
@@ -102,16 +101,13 @@ class ApicMechanismDriver(api_plus.MechanismDriver):
self.aim = aim_manager.AimManager()
self._core_plugin = None
self._l3_plugin = None
self.aim_cfg_mgr = aim_cfg.ConfigManager(
aim_context.AimContext(db_api.get_session()),
host=aim_cfg.CONF.host)
# Get APIC configuration and subscribe for changes
self.enable_metadata_opt = self.aim_cfg_mgr.get_option_and_subscribe(
self._set_enable_metadata_opt, 'enable_optimized_metadata', 'apic')
self.enable_dhcp_opt = self.aim_cfg_mgr.get_option_and_subscribe(
self._set_enable_dhcp_opt, 'enable_optimized_dhcp', 'apic')
self.ap_name = self.aim_cfg_mgr.get_option_and_subscribe(
self._set_ap_name, 'apic_app_profile_name', 'apic')
self.enable_metadata_opt = (
cfg.CONF.ml2_apic_aim.enable_optimized_metadata)
self.enable_dhcp_opt = (
cfg.CONF.ml2_apic_aim.enable_optimized_dhcp)
self.ap_name = 'OpenStack'
self.apic_system_id = cfg.CONF.apic_system_id
self.notifier = ofrpc.AgentNotifierApi(n_topics.AGENT)
def ensure_tenant(self, plugin_context, tenant_id):
@@ -1092,8 +1088,9 @@ class ApicMechanismDriver(api_plus.MechanismDriver):
return vrf
def _map_unrouted_vrf(self):
vrf = aim_resource.VRF(tenant_name=COMMON_TENANT_NAME,
name=UNROUTED_VRF_NAME)
vrf = aim_resource.VRF(
tenant_name=COMMON_TENANT_NAME,
name=self.apic_system_id + '_' + UNROUTED_VRF_NAME)
return vrf
def _get_tenant_name(self, session, project_id):

View File

@@ -26,6 +26,7 @@ from aim.db import model_base as aim_model_base
from gbpservice.neutron.plugins.ml2plus.drivers.apic_aim import (
extension_db as extn_db)
from gbpservice.neutron.plugins.ml2plus.drivers.apic_aim import config # noqa
from keystoneclient.v3 import client as ksc_client
from neutron.api import extensions
from neutron import context
@@ -93,7 +94,6 @@ class FakeKeystoneClient(object):
class ApicAimTestMixin(object):
def initialize_db_config(self, session):
aim_cfg.CONF.register_opts(aim_cfg.global_opts)
aim_cfg._get_option_subscriber_manager = mock.Mock()
self.aim_cfg_manager = aim_cfg.ConfigManager(
aim_context.AimContext(db_session=session), '')
@@ -364,7 +364,7 @@ class TestAimMapping(ApicAimTestCase):
vrf_tenant_aname = tenant_aname
vrf_tenant_dname = ''
else:
vrf_aname = 'UnroutedVRF'
vrf_aname = self.driver.apic_system_id + '_UnroutedVRF'
vrf_dname = 'Common Unrouted VRF'
vrf_tenant_aname = 'common'
vrf_tenant_dname = 'Common Tenant'