Move v2.1 code to the main compute directory - remove v3 step3
Move all the plugins/v3 code to the main compute directory. Partial-Bug: #1462901 Change-Id: I7df413b76ff0a6610ccd3cb90137ec99b372d5ab
This commit is contained in:
parent
fc10768319
commit
003c868da7
|
@ -21,6 +21,7 @@ WSGI middleware for OpenStack Compute API.
|
|||
from oslo_config import cfg
|
||||
|
||||
import nova.api.openstack
|
||||
from nova.api.openstack.compute import extension_info
|
||||
from nova.api.openstack.compute.legacy_v2 import consoles as v2_consoles
|
||||
from nova.api.openstack.compute.legacy_v2 import extensions as v2_extensions
|
||||
from nova.api.openstack.compute.legacy_v2 import flavors as v2_flavors
|
||||
|
@ -32,9 +33,8 @@ from nova.api.openstack.compute.legacy_v2 import limits as v2_limits
|
|||
from nova.api.openstack.compute.legacy_v2 import server_metadata \
|
||||
as v2_server_metadata
|
||||
from nova.api.openstack.compute.legacy_v2 import servers as v2_servers
|
||||
from nova.api.openstack.compute.legacy_v2 import versions as \
|
||||
legacy_v2_versions
|
||||
from nova.api.openstack.compute import plugins
|
||||
from nova.api.openstack.compute.legacy_v2 import versions \
|
||||
as legacy_v2_versions
|
||||
|
||||
allow_instance_snapshots_opt = cfg.BoolOpt('allow_instance_snapshots',
|
||||
default=True,
|
||||
|
@ -137,7 +137,7 @@ class APIRouterV21(nova.api.openstack.APIRouterV21):
|
|||
and method.
|
||||
"""
|
||||
def __init__(self, init_only=None):
|
||||
self._loaded_extension_info = plugins.LoadedExtensionInfo()
|
||||
self._loaded_extension_info = extension_info.LoadedExtensionInfo()
|
||||
super(APIRouterV21, self).__init__(init_only)
|
||||
|
||||
def _register_extension(self, ext):
|
||||
|
@ -155,7 +155,7 @@ class APIRouterV3(nova.api.openstack.APIRouterV21):
|
|||
and method.
|
||||
"""
|
||||
def __init__(self, init_only=None):
|
||||
self._loaded_extension_info = plugins.LoadedExtensionInfo()
|
||||
self._loaded_extension_info = extension_info.LoadedExtensionInfo()
|
||||
super(APIRouterV3, self).__init__(init_only, v3mode=True)
|
||||
|
||||
def _register_extension(self, ext):
|
||||
|
|
|
@ -20,6 +20,8 @@ import webob.exc
|
|||
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import exception
|
||||
from nova.i18n import _LE
|
||||
|
||||
ALIAS = 'extensions'
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -213,3 +215,35 @@ class ExtensionInfo(extensions.V3APIExtensionBase):
|
|||
|
||||
def get_controller_extensions(self):
|
||||
return []
|
||||
|
||||
|
||||
class LoadedExtensionInfo(object):
|
||||
"""Keep track of all loaded API extensions."""
|
||||
|
||||
def __init__(self):
|
||||
self.extensions = {}
|
||||
|
||||
def register_extension(self, ext):
|
||||
if not self._check_extension(ext):
|
||||
return False
|
||||
|
||||
alias = ext.alias
|
||||
|
||||
if alias in self.extensions:
|
||||
raise exception.NovaException("Found duplicate extension: %s"
|
||||
% alias)
|
||||
self.extensions[alias] = ext
|
||||
return True
|
||||
|
||||
def _check_extension(self, extension):
|
||||
"""Checks for required methods in extension objects."""
|
||||
try:
|
||||
extension.is_valid()
|
||||
except AttributeError:
|
||||
LOG.exception(_LE("Exception loading extension"))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def get_extensions(self):
|
||||
return self.extensions
|
|
@ -24,7 +24,7 @@ from nova.compute import vm_states
|
|||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('osapi_hide_server_address_states',
|
||||
'nova.api.openstack.compute.plugins.v3.hide_server_addresses')
|
||||
'nova.api.openstack.compute.hide_server_addresses')
|
||||
|
||||
authorize = extensions.soft_extension_authorizer('compute',
|
||||
'hide_server_addresses')
|
||||
|
|
|
@ -14,9 +14,54 @@
|
|||
# under the License.
|
||||
|
||||
from nova.api.openstack.compute.legacy_v2 import limits
|
||||
from nova.api.openstack.compute.views import limits as limits_views
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import quota
|
||||
|
||||
|
||||
# NOTE(alex_xu): This is just for keeping backward compatible with v2 endpoint
|
||||
# in api-paste.ini. This will be removed after v2 API code deprecated in the
|
||||
# future.
|
||||
RateLimitingMiddleware = limits.RateLimitingMiddleware
|
||||
|
||||
QUOTAS = quota.QUOTAS
|
||||
ALIAS = 'limits'
|
||||
authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
|
||||
|
||||
class LimitsController(wsgi.Controller):
|
||||
"""Controller for accessing limits in the OpenStack API."""
|
||||
|
||||
@extensions.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Return all global and rate limit information."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
project_id = req.params.get('tenant_id', context.project_id)
|
||||
quotas = QUOTAS.get_project_quotas(context, project_id,
|
||||
usages=False)
|
||||
abs_limits = {k: v['limit'] for k, v in quotas.items()}
|
||||
rate_limits = req.environ.get("nova.limits", [])
|
||||
|
||||
builder = self._get_view_builder(req)
|
||||
return builder.build(rate_limits, abs_limits)
|
||||
|
||||
def _get_view_builder(self, req):
|
||||
return limits_views.ViewBuilderV3()
|
||||
|
||||
|
||||
class Limits(extensions.V3APIExtensionBase):
|
||||
"""Limits support."""
|
||||
|
||||
name = "Limits"
|
||||
alias = ALIAS
|
||||
version = 1
|
||||
|
||||
def get_resources(self):
|
||||
resource = [extensions.ResourceExtension(ALIAS,
|
||||
LimitsController())]
|
||||
return resource
|
||||
|
||||
def get_controller_extensions(self):
|
||||
return []
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
# Copyright 2013 IBM Corp.
|
||||
#
|
||||
# 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_log import log as logging
|
||||
|
||||
from nova import exception
|
||||
from nova.i18n import _LE
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LoadedExtensionInfo(object):
|
||||
"""Keep track of all loaded API extensions."""
|
||||
|
||||
def __init__(self):
|
||||
self.extensions = {}
|
||||
|
||||
def register_extension(self, ext):
|
||||
if not self._check_extension(ext):
|
||||
return False
|
||||
|
||||
alias = ext.alias
|
||||
|
||||
if alias in self.extensions:
|
||||
raise exception.NovaException("Found duplicate extension: %s"
|
||||
% alias)
|
||||
self.extensions[alias] = ext
|
||||
return True
|
||||
|
||||
def _check_extension(self, extension):
|
||||
"""Checks for required methods in extension objects."""
|
||||
try:
|
||||
extension.is_valid()
|
||||
except AttributeError:
|
||||
LOG.exception(_LE("Exception loading extension"))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def get_extensions(self):
|
||||
return self.extensions
|
|
@ -1,62 +0,0 @@
|
|||
# Copyright 2011 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 nova.api.openstack.compute.views import limits as limits_views
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import quota
|
||||
|
||||
|
||||
QUOTAS = quota.QUOTAS
|
||||
ALIAS = 'limits'
|
||||
authorize = extensions.os_compute_authorizer(ALIAS)
|
||||
|
||||
|
||||
class LimitsController(wsgi.Controller):
|
||||
"""Controller for accessing limits in the OpenStack API."""
|
||||
|
||||
@extensions.expected_errors(())
|
||||
def index(self, req):
|
||||
"""Return all global and rate limit information."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
project_id = req.params.get('tenant_id', context.project_id)
|
||||
quotas = QUOTAS.get_project_quotas(context, project_id,
|
||||
usages=False)
|
||||
abs_limits = {k: v['limit'] for k, v in quotas.items()}
|
||||
rate_limits = req.environ.get("nova.limits", [])
|
||||
|
||||
builder = self._get_view_builder(req)
|
||||
return builder.build(rate_limits, abs_limits)
|
||||
|
||||
def _get_view_builder(self, req):
|
||||
return limits_views.ViewBuilderV3()
|
||||
|
||||
|
||||
class Limits(extensions.V3APIExtensionBase):
|
||||
"""Limits support."""
|
||||
|
||||
name = "Limits"
|
||||
alias = ALIAS
|
||||
version = 1
|
||||
|
||||
def get_resources(self):
|
||||
resource = [extensions.ResourceExtension(ALIAS,
|
||||
LimitsController())]
|
||||
return resource
|
||||
|
||||
def get_controller_extensions(self):
|
||||
return []
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute.plugins.v3 import security_groups as sg
|
||||
from nova.api.openstack.compute import security_groups as sg
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import exception
|
|
@ -21,12 +21,12 @@ import nova.api.metadata.vendordata_json
|
|||
import nova.api.openstack
|
||||
import nova.api.openstack.common
|
||||
import nova.api.openstack.compute
|
||||
import nova.api.openstack.compute.hide_server_addresses
|
||||
import nova.api.openstack.compute.legacy_v2.contrib
|
||||
import nova.api.openstack.compute.legacy_v2.contrib.fping
|
||||
import nova.api.openstack.compute.legacy_v2.contrib.os_tenant_networks
|
||||
import nova.api.openstack.compute.legacy_v2.extensions
|
||||
import nova.api.openstack.compute.legacy_v2.servers
|
||||
import nova.api.openstack.compute.plugins.v3.hide_server_addresses
|
||||
import nova.availability_zones
|
||||
import nova.baserpc
|
||||
import nova.cells.manager
|
||||
|
@ -139,7 +139,7 @@ def list_opts():
|
|||
nova.api.openstack.compute.legacy_v2.contrib.os_tenant_networks.
|
||||
os_network_opts,
|
||||
nova.api.openstack.compute.legacy_v2.extensions.ext_opts,
|
||||
nova.api.openstack.compute.plugins.v3.hide_server_addresses.opts,
|
||||
nova.api.openstack.compute.hide_server_addresses.opts,
|
||||
nova.api.openstack.compute.legacy_v2.servers.server_opts,
|
||||
)),
|
||||
('neutron', nova.api.metadata.handler.metadata_proxy_opts),
|
||||
|
|
|
@ -513,7 +513,8 @@ def check_http_not_implemented(logical_line, physical_line, filename):
|
|||
" common raise_feature_not_supported().")
|
||||
if pep8.noqa(physical_line):
|
||||
return
|
||||
if "nova/api/openstack/compute/plugins/v3" not in filename:
|
||||
if ("nova/api/openstack/compute/legacy_v2" in filename or
|
||||
"nova/api/openstack/compute" not in filename):
|
||||
return
|
||||
if re.match(http_not_implemented_re, logical_line):
|
||||
yield(0, msg)
|
||||
|
|
|
@ -63,7 +63,7 @@ class BareMetalNodesSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
|||
'contrib.baremetal_nodes.Baremetal_nodes')
|
||||
return f
|
||||
|
||||
@mock.patch("nova.api.openstack.compute.plugins.v3.baremetal_nodes"
|
||||
@mock.patch("nova.api.openstack.compute.baremetal_nodes"
|
||||
"._get_ironic_client")
|
||||
@mock.patch("nova.api.openstack.compute.legacy_v2.contrib.baremetal_nodes"
|
||||
"._get_ironic_client")
|
||||
|
@ -75,7 +75,7 @@ class BareMetalNodesSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
|||
subs = self._get_regexes()
|
||||
self._verify_response('baremetal-node-list-resp', subs, response, 200)
|
||||
|
||||
@mock.patch("nova.api.openstack.compute.plugins.v3.baremetal_nodes"
|
||||
@mock.patch("nova.api.openstack.compute.baremetal_nodes"
|
||||
"._get_ironic_client")
|
||||
@mock.patch("nova.api.openstack.compute.legacy_v2.contrib.baremetal_nodes"
|
||||
"._get_ironic_client")
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova.api.openstack.compute import fping
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import fping as fping_v2
|
||||
from nova.api.openstack.compute.plugins.v3 import fping
|
||||
from nova.tests.functional.v3 import test_servers
|
||||
from nova.tests.unit.api.openstack.compute.contrib import test_fping
|
||||
from nova import utils
|
||||
|
|
|
@ -20,7 +20,7 @@ from nova.tests.functional.v3 import test_servers
|
|||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('osapi_hide_server_address_states',
|
||||
'nova.api.openstack.compute.plugins.v3.hide_server_addresses')
|
||||
'nova.api.openstack.compute.hide_server_addresses')
|
||||
CONF.import_opt('osapi_compute_extension',
|
||||
'nova.api.openstack.compute.legacy_v2.extensions')
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import access_ips
|
||||
from nova.api.openstack.compute import extension_info
|
||||
from nova.api.openstack.compute.legacy_v2 import servers as servers_v20
|
||||
from nova.api.openstack.compute import plugins
|
||||
from nova.api.openstack.compute.plugins.v3 import access_ips
|
||||
from nova.api.openstack.compute.plugins.v3 import servers as servers_v21
|
||||
from nova.api.openstack.compute import servers as servers_v21
|
||||
from nova.api.openstack import extensions as extensions_v20
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.compute import api as compute_api
|
||||
|
@ -178,7 +178,7 @@ class AccessIPsExtAPIValidationTestV21(test.TestCase):
|
|||
self.req = fakes.HTTPRequest.blank('')
|
||||
|
||||
def _set_up_controller(self):
|
||||
ext_info = plugins.LoadedExtensionInfo()
|
||||
ext_info = extension_info.LoadedExtensionInfo()
|
||||
self.controller = servers_v21.ServersController(
|
||||
extension_info=ext_info)
|
||||
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import admin_actions as \
|
||||
admin_actions_v2
|
||||
from nova.api.openstack.compute.plugins.v3 import admin_actions as \
|
||||
admin_actions_v21
|
||||
from nova.api.openstack.compute import admin_actions as admin_actions_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import admin_actions \
|
||||
as admin_actions_v2
|
||||
from nova import exception
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack.compute import admin_only_action_common
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
import mock
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import admin_password as admin_password_v21
|
||||
from nova.api.openstack.compute.legacy_v2 import servers
|
||||
from nova.api.openstack.compute.plugins.v3 import admin_password \
|
||||
as admin_password_v21
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
from nova import test
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
import mock
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack.compute import agents as agents_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import agents as agents_v2
|
||||
from nova.api.openstack.compute.plugins.v3 import agents as agents_v21
|
||||
from nova import db
|
||||
from nova.db.sqlalchemy import models
|
||||
from nova import exception
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
import mock
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute import aggregates as aggregates_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import aggregates \
|
||||
as aggregates_v2
|
||||
from nova.api.openstack.compute.plugins.v3 import aggregates as aggregates_v21
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import test
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova.api.openstack.compute import attach_interfaces \
|
||||
as attach_interfaces_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import attach_interfaces \
|
||||
as attach_interfaces_v2
|
||||
from nova.api.openstack.compute.plugins.v3 import attach_interfaces \
|
||||
as attach_interfaces_v21
|
||||
as attach_interfaces_v2
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
from nova.network import api as network_api
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue