From 38cbb60d0fb24c2bc92b6dc7aabba8d5795279f9 Mon Sep 17 00:00:00 2001 From: Boden R Date: Tue, 14 Nov 2017 11:10:51 -0700 Subject: [PATCH] use flavors api def from neutron-lib The flavors extension's API definition was rehomed into neutron-lib with commit I0229a80bb168bac8dc0fa17fb2b06f1b140d27b4 and will be consumed in neutron with I265ac1c0596d0fb0acaf99eeb7cfe9501732476f This patch follows suit, consuming the rehomed code from neutron-lib. Change-Id: I5d239cd3530f3139ab6ded646a499f1b8da90a37 --- neutron_vpnaas/services/vpn/plugin.py | 7 ++++--- neutron_vpnaas/tests/unit/services/vpn/test_plugin.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/neutron_vpnaas/services/vpn/plugin.py b/neutron_vpnaas/services/vpn/plugin.py index c70c2c790..38b8d6792 100644 --- a/neutron_vpnaas/services/vpn/plugin.py +++ b/neutron_vpnaas/services/vpn/plugin.py @@ -15,11 +15,12 @@ # under the License. from neutron.db import servicetype_db as st_db -from neutron.extensions import flavors from neutron.services.flavors import flavors_plugin from neutron.services import provider_configuration as pconf from neutron.services import service_base from neutron_lib import context as ncontext +from neutron_lib import exceptions as lib_exc +from neutron_lib.exceptions import flavors as flav_exc from neutron_lib.plugins import constants from neutron_lib.plugins import directory from oslo_log import log as logging @@ -124,10 +125,10 @@ class VPNDriverPlugin(VPNPlugin, vpn_db.VPNPluginRpcDbMixin): fl_db = flavors_plugin.FlavorsPlugin.get_flavor( self._flavors_plugin, context, flavor_id) if fl_db['service_type'] != constants.VPN: - raise flavors.InvalidFlavorServiceType( + raise lib_exc.InvalidServiceType( service_type=fl_db['service_type']) if not fl_db['enabled']: - raise flavors.FlavorDisabled() + raise flav_exc.FlavorDisabled() providers = flavors_plugin.FlavorsPlugin.get_flavor_next_provider( self._flavors_plugin, context, fl_db['id']) provider = providers[0].get('provider') diff --git a/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py b/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py index 7ff3aabd4..ce7c847c1 100644 --- a/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py +++ b/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py @@ -16,13 +16,14 @@ import contextlib import mock from neutron.db import servicetype_db as st_db -from neutron.extensions import flavors from neutron.services.flavors.flavors_plugin import FlavorsPlugin from neutron.tests.unit.db import test_agentschedulers_db from neutron.tests.unit.extensions import test_agent as test_agent_ext_plugin from neutron_lib import constants as lib_constants from neutron_lib import context +from neutron_lib import exceptions as lib_exc +from neutron_lib.exceptions import flavors as flav_exc from neutron_lib.plugins import constants as p_constants from neutron_lib.plugins import directory from oslo_utils import uuidutils @@ -288,7 +289,7 @@ class TestVPNDriverPluginMultipleDrivers(base.BaseTestCase): with self.vpnservices_providers_set(): driver_plugin = vpn_plugin.VPNDriverPlugin() self.assertRaises( - flavors.InvalidFlavorServiceType, + lib_exc.InvalidServiceType, driver_plugin._get_provider_for_flavor, self.adminContext, _uuid()) @@ -303,7 +304,7 @@ class TestVPNDriverPluginMultipleDrivers(base.BaseTestCase): with self.vpnservices_providers_set(): driver_plugin = vpn_plugin.VPNDriverPlugin() self.assertRaises( - flavors.FlavorDisabled, + flav_exc.FlavorDisabled, driver_plugin._get_provider_for_flavor, self.adminContext, _uuid())