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:
parent
c12330227a
commit
0c9b306104
@ -16,8 +16,9 @@
|
||||
import functools
|
||||
|
||||
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.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -39,7 +40,7 @@ class Diagnostician(object):
|
||||
req.context, id, input['diag'])
|
||||
|
||||
|
||||
class Diagnostics(extensions.ExtensionDescriptor):
|
||||
class Diagnostics(nl_extensions.ExtensionDescriptor):
|
||||
def get_name(self):
|
||||
return "Diagnostics"
|
||||
|
||||
@ -56,7 +57,7 @@ class Diagnostics(extensions.ExtensionDescriptor):
|
||||
return "never"
|
||||
|
||||
def get_actions(self):
|
||||
diagnose = Diagnostician(manager.NeutronManager.get_plugin()).diagnose
|
||||
diagnose = Diagnostician(directory.get_plugin()).diagnose
|
||||
resources = ['port', 'subnet', 'network']
|
||||
return (extensions.ActionExtension('%ss' % res, 'diag',
|
||||
functools.partial(diagnose, res)) for res in resources)
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron_lib.api import extensions
|
||||
|
||||
RESOURCE_NAME = "floatingip"
|
||||
RESOURCE_COLLECTION = RESOURCE_NAME + "s"
|
||||
|
@ -14,8 +14,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import manager
|
||||
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
|
||||
import quark.utils as utils
|
||||
import webob
|
||||
@ -119,7 +120,7 @@ class IpAddressPortController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotImplemented()
|
||||
|
||||
|
||||
class Ip_addresses(extensions.ExtensionDescriptor):
|
||||
class Ip_addresses(nl_extensions.ExtensionDescriptor):
|
||||
"""IP Addresses support."""
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
@ -152,9 +153,9 @@ class Ip_addresses(extensions.ExtensionDescriptor):
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
ip_controller = IpAddressesController(
|
||||
manager.NeutronManager.get_plugin())
|
||||
directory.get_plugin())
|
||||
ip_port_controller = IpAddressPortController(
|
||||
manager.NeutronManager.get_plugin())
|
||||
directory.get_plugin())
|
||||
resources = []
|
||||
resources.append(extensions.ResourceExtension(
|
||||
Ip_addresses.get_alias(),
|
||||
|
@ -14,9 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import manager
|
||||
from neutron import wsgi
|
||||
from neutron_lib.api import extensions as nl_extensions
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
|
||||
RESOURCE_NAME = "ip_availability"
|
||||
@ -45,7 +46,7 @@ class IPAvailabilityController(wsgi.Controller):
|
||||
return self._plugin.get_ip_availability(**request.GET)
|
||||
|
||||
|
||||
class Ip_availability(extensions.ExtensionDescriptor):
|
||||
class Ip_availability(nl_extensions.ExtensionDescriptor):
|
||||
"""IP Availability support."""
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
@ -77,7 +78,7 @@ class Ip_availability(extensions.ExtensionDescriptor):
|
||||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
controller = IPAvailabilityController(plugin)
|
||||
return [extensions.ResourceExtension(Ip_availability.get_alias(),
|
||||
controller)]
|
||||
|
@ -14,8 +14,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import manager
|
||||
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
|
||||
import quark.utils as utils
|
||||
|
||||
@ -67,7 +68,7 @@ class IPPoliciesController(wsgi.Controller):
|
||||
return self._plugin.delete_ip_policy(context, id)
|
||||
|
||||
|
||||
class Ip_policies(extensions.ExtensionDescriptor):
|
||||
class Ip_policies(nl_extensions.ExtensionDescriptor):
|
||||
"""IP Policies support."""
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
@ -100,7 +101,7 @@ class Ip_policies(extensions.ExtensionDescriptor):
|
||||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
controller = IPPoliciesController(plugin)
|
||||
return [extensions.ResourceExtension(Ip_policies.get_alias(),
|
||||
controller)]
|
||||
|
@ -14,8 +14,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import manager
|
||||
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
|
||||
import quark.utils as utils
|
||||
|
||||
@ -69,7 +70,7 @@ class JobsController(wsgi.Controller):
|
||||
return self._plugin.delete_job(context, id)
|
||||
|
||||
|
||||
class Jobs(extensions.ExtensionDescriptor):
|
||||
class Jobs(nl_extensions.ExtensionDescriptor):
|
||||
"""Jobs support."""
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
@ -102,7 +103,7 @@ class Jobs(extensions.ExtensionDescriptor):
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
job_controller = JobsController(
|
||||
manager.NeutronManager.get_plugin())
|
||||
directory.get_plugin())
|
||||
resources = []
|
||||
resources.append(extensions.ResourceExtension(
|
||||
Jobs.get_alias(),
|
||||
|
@ -14,8 +14,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import manager
|
||||
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
|
||||
import quark.utils as utils
|
||||
|
||||
@ -68,7 +69,7 @@ class MacAddressRangesController(wsgi.Controller):
|
||||
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."""
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
@ -101,7 +102,7 @@ class Mac_address_ranges(extensions.ExtensionDescriptor):
|
||||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
controller = MacAddressRangesController(plugin)
|
||||
return [extensions.ResourceExtension(Mac_address_ranges.get_alias(),
|
||||
controller)]
|
||||
|
@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron_lib.api import extensions
|
||||
|
||||
RESOURCE_NAME = "network"
|
||||
RESOURCE_COLLECTION = RESOURCE_NAME + "s"
|
||||
|
@ -13,9 +13,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron.extensions import securitygroup
|
||||
from neutron_lib.api import converters as conv
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import constants as const
|
||||
|
||||
RESOURCE_NAME = "port"
|
||||
|
@ -14,8 +14,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import manager
|
||||
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
|
||||
import quark.utils as utils
|
||||
|
||||
@ -67,7 +68,7 @@ class RoutesController(wsgi.Controller):
|
||||
self._plugin.delete_route(context, id)
|
||||
|
||||
|
||||
class Routes(extensions.ExtensionDescriptor):
|
||||
class Routes(nl_extensions.ExtensionDescriptor):
|
||||
"""Routes support."""
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
@ -98,7 +99,7 @@ class Routes(extensions.ExtensionDescriptor):
|
||||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
controller = RoutesController(manager.NeutronManager.get_plugin())
|
||||
controller = RoutesController(directory.get_plugin())
|
||||
return [extensions.ResourceExtension(
|
||||
Routes.get_alias(),
|
||||
controller)]
|
||||
|
@ -13,9 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# 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 resource_helper
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.api import validators
|
||||
from oslo_log import log as logging
|
||||
|
||||
@ -79,7 +80,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
"tenant_id": {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': attr.TENANT_ID_MAX_LEN},
|
||||
'validate': {'type:string': None},
|
||||
'is_visible': True
|
||||
},
|
||||
"scaling_network_id": {
|
||||
@ -127,7 +128,7 @@ class Scalingip(extensions.ExtensionDescriptor):
|
||||
"""Returns Ext Resources."""
|
||||
plural_mappings = resource_helper.build_plural_mappings(
|
||||
{}, RESOURCE_ATTRIBUTE_MAP)
|
||||
attr.PLURALS.update(plural_mappings)
|
||||
# attr.PLURALS.update(plural_mappings)
|
||||
return resource_helper.build_resource_info(plural_mappings,
|
||||
RESOURCE_ATTRIBUTE_MAP,
|
||||
None,
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron_lib.api import extensions
|
||||
|
||||
EXTENDED_ATTRIBUTES_2_0 = {
|
||||
"security_group_rules": {
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron_lib.api import extensions
|
||||
|
||||
EXTENDED_ATTRIBUTES_2_0 = {
|
||||
"security_groups": {
|
||||
|
@ -14,8 +14,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import manager
|
||||
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
|
||||
import quark.utils as utils
|
||||
|
||||
@ -65,7 +66,7 @@ class SegmentAllocationRangesController(wsgi.Controller):
|
||||
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."""
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
@ -98,7 +99,7 @@ class Segment_allocation_ranges(extensions.ExtensionDescriptor):
|
||||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin = directory.get_plugin()
|
||||
controller = SegmentAllocationRangesController(plugin)
|
||||
return [extensions.ResourceExtension(
|
||||
Segment_allocation_ranges.get_alias(),
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron_lib.api import extensions
|
||||
|
||||
EXTENDED_ATTRIBUTES_2_0 = {
|
||||
"subnets": {
|
||||
|
Loading…
Reference in New Issue
Block a user