Skip to content

Commit

Permalink
Move v2.1 code to the main compute directory - remove v3 step3
Browse files Browse the repository at this point in the history
Move all the plugins/v3 code to the main compute directory.

Partial-Bug: #1462901
Change-Id: I7df413b76ff0a6610ccd3cb90137ec99b372d5ab
  • Loading branch information
EdLeafe authored and soulxu committed Aug 13, 2015
1 parent fc10768 commit 003c868
Show file tree
Hide file tree
Showing 176 changed files with 381 additions and 426 deletions.
10 changes: 5 additions & 5 deletions nova/api/openstack/compute/__init__.py
Expand Up @@ -21,6 +21,7 @@
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
Expand All @@ -32,9 +33,8 @@
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,
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -20,6 +20,8 @@

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__)
Expand Down Expand Up @@ -213,3 +215,35 @@ def get_resources(self):

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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -24,7 +24,7 @@

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')
Expand Down
45 changes: 45 additions & 0 deletions nova/api/openstack/compute/limits.py
Expand Up @@ -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 []
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 0 additions & 52 deletions nova/api/openstack/compute/plugins/__init__.py

This file was deleted.

Empty file.
62 changes: 0 additions & 62 deletions nova/api/openstack/compute/plugins/v3/limits.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions nova/api/opts.py
Expand Up @@ -21,12 +21,12 @@
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
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion nova/hacking/checks.py
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions nova/tests/functional/v3/test_baremetal_nodes.py
Expand Up @@ -63,7 +63,7 @@ def _get_flags(self):
'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")
Expand All @@ -75,7 +75,7 @@ def test_baremetal_nodes_list(self, mock_get_irc, v2_1_mock_get_irc):
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")
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/functional/v3/test_fping.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/functional/v3/test_hide_server_addresses.py
Expand Up @@ -20,7 +20,7 @@

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')

Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -178,7 +178,7 @@ def fake_rebuild(*args, **kwargs):
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)

Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 003c868

Please sign in to comment.