Refactor extensions to align with upstream

Upstream moved ExtensionDescriptor into neutron-lib as well as some
functionality revolved around retrieving the plugin from NeutronManager.
This refactor moves libraries around in order to align quark with
upstream neutron's expectations.

JIRA:NCP2115
Change-Id: Ie922d7778d370491166a00952bec7cea7f7b5a84
This commit is contained in:
Kyle Haley 2017-02-17 11:47:32 -08:00
parent c12330227a
commit 0c9b306104
15 changed files with 43 additions and 34 deletions

View File

@ -16,8 +16,9 @@
import functools import functools
from neutron.api import extensions from neutron.api import extensions
from neutron import manager from neutron_lib.api import extensions as nl_extensions
from neutron_lib import exceptions as n_exc from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -39,7 +40,7 @@ class Diagnostician(object):
req.context, id, input['diag']) req.context, id, input['diag'])
class Diagnostics(extensions.ExtensionDescriptor): class Diagnostics(nl_extensions.ExtensionDescriptor):
def get_name(self): def get_name(self):
return "Diagnostics" return "Diagnostics"
@ -56,7 +57,7 @@ class Diagnostics(extensions.ExtensionDescriptor):
return "never" return "never"
def get_actions(self): def get_actions(self):
diagnose = Diagnostician(manager.NeutronManager.get_plugin()).diagnose diagnose = Diagnostician(directory.get_plugin()).diagnose
resources = ['port', 'subnet', 'network'] resources = ['port', 'subnet', 'network']
return (extensions.ActionExtension('%ss' % res, 'diag', return (extensions.ActionExtension('%ss' % res, 'diag',
functools.partial(diagnose, res)) for res in resources) functools.partial(diagnose, res)) for res in resources)

View File

@ -13,7 +13,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 neutron.api import extensions from neutron_lib.api import extensions
RESOURCE_NAME = "floatingip" RESOURCE_NAME = "floatingip"
RESOURCE_COLLECTION = RESOURCE_NAME + "s" RESOURCE_COLLECTION = RESOURCE_NAME + "s"

View File

@ -14,8 +14,9 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron import manager
from neutron import wsgi from neutron import wsgi
from neutron_lib.api import extensions as nl_extensions
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import quark.utils as utils import quark.utils as utils
import webob import webob
@ -119,7 +120,7 @@ class IpAddressPortController(wsgi.Controller):
raise webob.exc.HTTPNotImplemented() raise webob.exc.HTTPNotImplemented()
class Ip_addresses(extensions.ExtensionDescriptor): class Ip_addresses(nl_extensions.ExtensionDescriptor):
"""IP Addresses support.""" """IP Addresses support."""
@classmethod @classmethod
def get_name(cls): def get_name(cls):
@ -152,9 +153,9 @@ class Ip_addresses(extensions.ExtensionDescriptor):
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
ip_controller = IpAddressesController( ip_controller = IpAddressesController(
manager.NeutronManager.get_plugin()) directory.get_plugin())
ip_port_controller = IpAddressPortController( ip_port_controller = IpAddressPortController(
manager.NeutronManager.get_plugin()) directory.get_plugin())
resources = [] resources = []
resources.append(extensions.ResourceExtension( resources.append(extensions.ResourceExtension(
Ip_addresses.get_alias(), Ip_addresses.get_alias(),

View File

@ -14,9 +14,10 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron import manager
from neutron import wsgi from neutron import wsgi
from neutron_lib.api import extensions as nl_extensions
from neutron_lib import exceptions as n_exc from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
RESOURCE_NAME = "ip_availability" RESOURCE_NAME = "ip_availability"
@ -45,7 +46,7 @@ class IPAvailabilityController(wsgi.Controller):
return self._plugin.get_ip_availability(**request.GET) return self._plugin.get_ip_availability(**request.GET)
class Ip_availability(extensions.ExtensionDescriptor): class Ip_availability(nl_extensions.ExtensionDescriptor):
"""IP Availability support.""" """IP Availability support."""
@classmethod @classmethod
def get_name(cls): def get_name(cls):
@ -77,7 +78,7 @@ class Ip_availability(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plugin = manager.NeutronManager.get_plugin() plugin = directory.get_plugin()
controller = IPAvailabilityController(plugin) controller = IPAvailabilityController(plugin)
return [extensions.ResourceExtension(Ip_availability.get_alias(), return [extensions.ResourceExtension(Ip_availability.get_alias(),
controller)] controller)]

View File

@ -14,8 +14,9 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron import manager
from neutron import wsgi from neutron import wsgi
from neutron_lib.api import extensions as nl_extensions
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import quark.utils as utils import quark.utils as utils
@ -67,7 +68,7 @@ class IPPoliciesController(wsgi.Controller):
return self._plugin.delete_ip_policy(context, id) return self._plugin.delete_ip_policy(context, id)
class Ip_policies(extensions.ExtensionDescriptor): class Ip_policies(nl_extensions.ExtensionDescriptor):
"""IP Policies support.""" """IP Policies support."""
@classmethod @classmethod
def get_name(cls): def get_name(cls):
@ -100,7 +101,7 @@ class Ip_policies(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plugin = manager.NeutronManager.get_plugin() plugin = directory.get_plugin()
controller = IPPoliciesController(plugin) controller = IPPoliciesController(plugin)
return [extensions.ResourceExtension(Ip_policies.get_alias(), return [extensions.ResourceExtension(Ip_policies.get_alias(),
controller)] controller)]

View File

@ -14,8 +14,9 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron import manager
from neutron import wsgi from neutron import wsgi
from neutron_lib.api import extensions as nl_extensions
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import quark.utils as utils import quark.utils as utils
@ -69,7 +70,7 @@ class JobsController(wsgi.Controller):
return self._plugin.delete_job(context, id) return self._plugin.delete_job(context, id)
class Jobs(extensions.ExtensionDescriptor): class Jobs(nl_extensions.ExtensionDescriptor):
"""Jobs support.""" """Jobs support."""
@classmethod @classmethod
def get_name(cls): def get_name(cls):
@ -102,7 +103,7 @@ class Jobs(extensions.ExtensionDescriptor):
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
job_controller = JobsController( job_controller = JobsController(
manager.NeutronManager.get_plugin()) directory.get_plugin())
resources = [] resources = []
resources.append(extensions.ResourceExtension( resources.append(extensions.ResourceExtension(
Jobs.get_alias(), Jobs.get_alias(),

View File

@ -14,8 +14,9 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron import manager
from neutron import wsgi from neutron import wsgi
from neutron_lib.api import extensions as nl_extensions
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import quark.utils as utils import quark.utils as utils
@ -68,7 +69,7 @@ class MacAddressRangesController(wsgi.Controller):
return self._plugin.delete_mac_address_range(context, id) return self._plugin.delete_mac_address_range(context, id)
class Mac_address_ranges(extensions.ExtensionDescriptor): class Mac_address_ranges(nl_extensions.ExtensionDescriptor):
"""Mac Address Range support.""" """Mac Address Range support."""
@classmethod @classmethod
def get_name(cls): def get_name(cls):
@ -101,7 +102,7 @@ class Mac_address_ranges(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plugin = manager.NeutronManager.get_plugin() plugin = directory.get_plugin()
controller = MacAddressRangesController(plugin) controller = MacAddressRangesController(plugin)
return [extensions.ResourceExtension(Mac_address_ranges.get_alias(), return [extensions.ResourceExtension(Mac_address_ranges.get_alias(),
controller)] controller)]

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron_lib.api import extensions
RESOURCE_NAME = "network" RESOURCE_NAME = "network"
RESOURCE_COLLECTION = RESOURCE_NAME + "s" RESOURCE_COLLECTION = RESOURCE_NAME + "s"

View File

@ -13,9 +13,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 neutron.api import extensions
from neutron.extensions import securitygroup from neutron.extensions import securitygroup
from neutron_lib.api import converters as conv from neutron_lib.api import converters as conv
from neutron_lib.api import extensions
from neutron_lib import constants as const from neutron_lib import constants as const
RESOURCE_NAME = "port" RESOURCE_NAME = "port"

View File

@ -14,8 +14,9 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron import manager
from neutron import wsgi from neutron import wsgi
from neutron_lib.api import extensions as nl_extensions
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import quark.utils as utils import quark.utils as utils
@ -67,7 +68,7 @@ class RoutesController(wsgi.Controller):
self._plugin.delete_route(context, id) self._plugin.delete_route(context, id)
class Routes(extensions.ExtensionDescriptor): class Routes(nl_extensions.ExtensionDescriptor):
"""Routes support.""" """Routes support."""
@classmethod @classmethod
def get_name(cls): def get_name(cls):
@ -98,7 +99,7 @@ class Routes(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
controller = RoutesController(manager.NeutronManager.get_plugin()) controller = RoutesController(directory.get_plugin())
return [extensions.ResourceExtension( return [extensions.ResourceExtension(
Routes.get_alias(), Routes.get_alias(),
controller)] controller)]

View File

@ -13,9 +13,10 @@
# 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.api import extensions from neutron._i18n import _
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_lib.api import extensions
from neutron_lib.api import validators from neutron_lib.api import validators
from oslo_log import log as logging from oslo_log import log as logging
@ -79,7 +80,7 @@ RESOURCE_ATTRIBUTE_MAP = {
"tenant_id": { "tenant_id": {
'allow_post': True, 'allow_put': False, 'allow_post': True, 'allow_put': False,
'required_by_policy': True, 'required_by_policy': True,
'validate': {'type:string': attr.TENANT_ID_MAX_LEN}, 'validate': {'type:string': None},
'is_visible': True 'is_visible': True
}, },
"scaling_network_id": { "scaling_network_id": {
@ -127,7 +128,7 @@ class Scalingip(extensions.ExtensionDescriptor):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plural_mappings = resource_helper.build_plural_mappings( plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP) {}, RESOURCE_ATTRIBUTE_MAP)
attr.PLURALS.update(plural_mappings) # attr.PLURALS.update(plural_mappings)
return resource_helper.build_resource_info(plural_mappings, return resource_helper.build_resource_info(plural_mappings,
RESOURCE_ATTRIBUTE_MAP, RESOURCE_ATTRIBUTE_MAP,
None, None,

View File

@ -13,7 +13,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 neutron.api import extensions from neutron_lib.api import extensions
EXTENDED_ATTRIBUTES_2_0 = { EXTENDED_ATTRIBUTES_2_0 = {
"security_group_rules": { "security_group_rules": {

View File

@ -13,7 +13,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 neutron.api import extensions from neutron_lib.api import extensions
EXTENDED_ATTRIBUTES_2_0 = { EXTENDED_ATTRIBUTES_2_0 = {
"security_groups": { "security_groups": {

View File

@ -14,8 +14,9 @@
# limitations under the License. # limitations under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron import manager
from neutron import wsgi from neutron import wsgi
from neutron_lib.api import extensions as nl_extensions
from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import quark.utils as utils import quark.utils as utils
@ -65,7 +66,7 @@ class SegmentAllocationRangesController(wsgi.Controller):
return self._plugin.delete_segment_allocation_range(context, id) return self._plugin.delete_segment_allocation_range(context, id)
class Segment_allocation_ranges(extensions.ExtensionDescriptor): class Segment_allocation_ranges(nl_extensions.ExtensionDescriptor):
"""Segment Allocation Range support.""" """Segment Allocation Range support."""
@classmethod @classmethod
def get_name(cls): def get_name(cls):
@ -98,7 +99,7 @@ class Segment_allocation_ranges(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plugin = manager.NeutronManager.get_plugin() plugin = directory.get_plugin()
controller = SegmentAllocationRangesController(plugin) controller = SegmentAllocationRangesController(plugin)
return [extensions.ResourceExtension( return [extensions.ResourceExtension(
Segment_allocation_ranges.get_alias(), Segment_allocation_ranges.get_alias(),

View File

@ -13,7 +13,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 neutron.api import extensions from neutron_lib.api import extensions
EXTENDED_ATTRIBUTES_2_0 = { EXTENDED_ATTRIBUTES_2_0 = {
"subnets": { "subnets": {