summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/nova/policy.json3
-rw-r--r--nova/api/openstack/compute/plugins/v3/cells.py28
-rw-r--r--nova/api/openstack/compute/plugins/v3/images.py36
-rw-r--r--nova/api/openstack/compute/plugins/v3/server_diagnostics.py24
-rwxr-xr-xnova/compute/manager.py7
-rw-r--r--nova/db/sqlalchemy/models.py33
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_cells.py11
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_images.py142
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py11
-rw-r--r--nova/tests/compute/test_compute.py5
-rw-r--r--nova/tests/db/test_db_api.py20
-rw-r--r--nova/tests/fake_policy.py3
-rw-r--r--setup.cfg3
13 files changed, 186 insertions, 140 deletions
diff --git a/etc/nova/policy.json b/etc/nova/policy.json
index 7c563b936..69fbbb584 100644
--- a/etc/nova/policy.json
+++ b/etc/nova/policy.json
@@ -33,6 +33,7 @@
"compute_extension:attach_interfaces": "",
"compute_extension:baremetal_nodes": "rule:admin_api",
"compute_extension:cells": "rule:admin_api",
+ "compute_extension:v3:os-cells": "rule:admin_api",
"compute_extension:certificates": "",
"compute_extension:v3:os-certificates": "",
"compute_extension:cloudpipe": "rule:admin_api",
@@ -79,6 +80,7 @@
"compute_extension:hosts": "rule:admin_api",
"compute_extension:hypervisors": "rule:admin_api",
"compute_extension:image_size": "",
+ "compute_extension:v3:os-images": "",
"compute_extension:instance_actions": "",
"compute_extension:instance_actions:events": "rule:admin_api",
"compute_extension:instance_usage_audit_log": "rule:admin_api",
@@ -102,6 +104,7 @@
"compute_extension:security_group_default_rules": "rule:admin_api",
"compute_extension:security_groups": "",
"compute_extension:server_diagnostics": "rule:admin_api",
+ "compute_extension:v3:os-server-diagnostics": "rule:admin_api",
"compute_extension:server_password": "",
"compute_extension:server_usage": "",
"compute_extension:services": "rule:admin_api",
diff --git a/nova/api/openstack/compute/plugins/v3/cells.py b/nova/api/openstack/compute/plugins/v3/cells.py
index 4e809d70e..e07792018 100644
--- a/nova/api/openstack/compute/plugins/v3/cells.py
+++ b/nova/api/openstack/compute/plugins/v3/cells.py
@@ -37,7 +37,8 @@ CONF = cfg.CONF
CONF.import_opt('name', 'nova.cells.opts', group='cells')
CONF.import_opt('capabilities', 'nova.cells.opts', group='cells')
-authorize = extensions.extension_authorizer('compute', 'cells')
+ALIAS = "os-cells"
+authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
def make_cell(elem):
@@ -145,13 +146,12 @@ def _scrub_cell(cell, detail=False):
return cell_info
-class Controller(object):
+class CellsController(object):
"""Controller for Cell resources."""
- def __init__(self, ext_mgr):
+ def __init__(self):
self.compute_api = compute.API()
self.cells_rpcapi = cells_rpcapi.CellsAPI()
- self.ext_mgr = ext_mgr
def _get_cells(self, ctxt, req, detail=False):
"""Return all cells."""
@@ -198,9 +198,6 @@ class Controller(object):
"""Return capacities for a given cell or all cells."""
# TODO(kaushikc): return capacities as a part of cell info and
# cells detail calls in v3, along with capabilities
- if not self.ext_mgr.is_loaded('os-cell-capacities'):
- raise exc.HTTPNotFound()
-
context = req.environ['nova.context']
authorize(context)
try:
@@ -320,15 +317,15 @@ class Controller(object):
updated_since=updated_since, deleted=deleted)
-class Cells(extensions.ExtensionDescriptor):
+class Cells(extensions.V3APIExtensionBase):
"""Enables cells-related functionality such as adding neighbor cells,
listing neighbor cells, and getting the capabilities of the local cell.
"""
name = "Cells"
- alias = "os-cells"
- namespace = "http://docs.openstack.org/compute/ext/cells/api/v1.1"
- updated = "2013-05-14T00:00:00+00:00"
+ alias = ALIAS
+ namespace = "http://docs.openstack.org/compute/ext/cells/api/v3"
+ version = 1
def get_resources(self):
coll_actions = {
@@ -341,7 +338,10 @@ class Cells(extensions.ExtensionDescriptor):
'capacities': 'GET',
}
- res = extensions.ResourceExtension('os-cells',
- Controller(self.ext_mgr), collection_actions=coll_actions,
- member_actions=memb_actions)
+ res = extensions.ResourceExtension(ALIAS, CellsController(),
+ collection_actions=coll_actions,
+ member_actions=memb_actions)
return [res]
+
+ def get_controller_extensions(self):
+ return []
diff --git a/nova/api/openstack/compute/plugins/v3/images.py b/nova/api/openstack/compute/plugins/v3/images.py
index e0c4f7465..dde22488d 100644
--- a/nova/api/openstack/compute/plugins/v3/images.py
+++ b/nova/api/openstack/compute/plugins/v3/images.py
@@ -17,6 +17,7 @@ import webob.exc
from nova.api.openstack import common
from nova.api.openstack.compute.views import images as views_images
+from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import exception
@@ -24,6 +25,9 @@ import nova.image.glance
import nova.utils
+ALIAS = "os-images"
+authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
+
SUPPORTED_FILTERS = {
'name': 'name',
'status': 'status',
@@ -83,7 +87,7 @@ class ImagesTemplate(xmlutil.TemplateBuilder):
return xmlutil.MasterTemplate(root, 1, nsmap=image_nsmap)
-class Controller(wsgi.Controller):
+class ImagesController(wsgi.Controller):
"""Base controller for retrieving/displaying images."""
_view_builder_class = views_images.ViewBuilder
@@ -94,7 +98,7 @@ class Controller(wsgi.Controller):
:param image_service: `nova.image.glance:GlanceImageService`
"""
- super(Controller, self).__init__(**kwargs)
+ super(ImagesController, self).__init__(**kwargs)
self._image_service = (image_service or
nova.image.glance.get_default_image_service())
@@ -134,6 +138,7 @@ class Controller(wsgi.Controller):
:param id: Image identifier
"""
context = req.environ['nova.context']
+ authorize(context)
try:
image = self._image_service.show(context, id)
@@ -151,6 +156,8 @@ class Controller(wsgi.Controller):
:param id: Image identifier (integer)
"""
context = req.environ['nova.context']
+ authorize(context)
+
try:
self._image_service.delete(context, id)
except exception.ImageNotFound:
@@ -171,6 +178,8 @@ class Controller(wsgi.Controller):
"""
context = req.environ['nova.context']
+ authorize(context)
+
filters = self._get_filters(req)
params = req.GET.copy()
page_params = common.get_pagination_params(req)
@@ -192,6 +201,8 @@ class Controller(wsgi.Controller):
"""
context = req.environ['nova.context']
+ authorize(context)
+
filters = self._get_filters(req)
params = req.GET.copy()
page_params = common.get_pagination_params(req)
@@ -210,5 +221,22 @@ class Controller(wsgi.Controller):
raise webob.exc.HTTPMethodNotAllowed()
-def create_resource():
- return wsgi.Resource(Controller())
+class Images(extensions.V3APIExtensionBase):
+ """Server addresses."""
+
+ name = "Images"
+ alias = ALIAS
+ namespace = "http://docs.openstack.org/compute/ext/images/v3"
+ version = 1
+
+ def get_resources(self):
+ collection_actions = {'detail': 'GET'}
+ resources = [
+ extensions.ResourceExtension(
+ ALIAS, ImagesController(),
+ collection_actions=collection_actions)]
+
+ return resources
+
+ def get_controller_extensions(self):
+ return []
diff --git a/nova/api/openstack/compute/plugins/v3/server_diagnostics.py b/nova/api/openstack/compute/plugins/v3/server_diagnostics.py
index 7711eb653..6a19732dc 100644
--- a/nova/api/openstack/compute/plugins/v3/server_diagnostics.py
+++ b/nova/api/openstack/compute/plugins/v3/server_diagnostics.py
@@ -22,7 +22,8 @@ from nova import compute
from nova import exception
-authorize = extensions.extension_authorizer('compute', 'server_diagnostics')
+ALIAS = "os-server-diagnostics"
+authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS)
sd_nsmap = {None: wsgi.XMLNS_V11}
@@ -49,19 +50,22 @@ class ServerDiagnosticsController(object):
return compute_api.get_diagnostics(context, instance)
-class Server_diagnostics(extensions.ExtensionDescriptor):
+class ServerDiagnostics(extensions.V3APIExtensionBase):
"""Allow Admins to view server diagnostics through server action."""
name = "ServerDiagnostics"
- alias = "os-server-diagnostics"
+ alias = ALIAS
namespace = ("http://docs.openstack.org/compute/ext/"
- "server-diagnostics/api/v1.1")
- updated = "2011-12-21T00:00:00+00:00"
+ "server-diagnostics/api/v3")
+ version = 1
def get_resources(self):
parent_def = {'member_name': 'server', 'collection_name': 'servers'}
- #NOTE(bcwaldon): This should be prefixed with 'os-'
- ext = extensions.ResourceExtension('diagnostics',
- ServerDiagnosticsController(),
- parent=parent_def)
- return [ext]
+ resources = [
+ extensions.ResourceExtension(ALIAS,
+ ServerDiagnosticsController(),
+ parent=parent_def)]
+ return resources
+
+ def get_controller_extensions(self):
+ return []
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 82a71e448..dbef94596 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -412,7 +412,8 @@ class ComputeManager(manager.SchedulerDependentManager):
'trying to set it to ERROR'),
instance_uuid=instance_uuid)
- def _get_instances_on_driver(self, context, filters=None):
+ def _get_instances_on_driver(self, context, filters=None,
+ columns_to_join=None):
"""Return a list of instance records for the instances found
on the hypervisor which satisfy the specified filters. If filters=None
return a list of instance records for all the instances found on the
@@ -424,7 +425,7 @@ class ComputeManager(manager.SchedulerDependentManager):
driver_uuids = self.driver.list_instance_uuids()
filters['uuid'] = driver_uuids
local_instances = self.conductor_api.instance_get_all_by_filters(
- context, filters, columns_to_join=[])
+ context, filters, columns_to_join=columns_to_join)
return local_instances
except NotImplementedError:
pass
@@ -433,7 +434,7 @@ class ComputeManager(manager.SchedulerDependentManager):
# to brute force.
driver_instances = self.driver.list_instances()
instances = self.conductor_api.instance_get_all_by_filters(
- context, filters, columns_to_join=[])
+ context, filters, columns_to_join=columns_to_join)
name_map = dict((instance['name'], instance) for instance in instances)
local_instances = []
for driver_instance in driver_instances:
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 183a42f60..d1be47f8c 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -760,11 +760,15 @@ class FloatingIp(BASE, NovaBase):
class DNSDomain(BASE, NovaBase):
"""Represents a DNS domain with availability zone or project info."""
__tablename__ = 'dns_domains'
+ __table_args__ = (
+ Index('project_id', 'project_id'),
+ Index('dns_domains_domain_deleted_idx', 'domain', 'deleted'),
+ )
deleted = Column(Boolean, default=False)
- domain = Column(String(512), primary_key=True)
- scope = Column(String(255))
- availability_zone = Column(String(255))
- project_id = Column(String(255))
+ domain = Column(String(255), primary_key=True)
+ scope = Column(String(255), nullable=True)
+ availability_zone = Column(String(255), nullable=True)
+ project_id = Column(String(255), nullable=True)
class ConsolePool(BASE, NovaBase):
@@ -899,6 +903,9 @@ class AggregateHost(BASE, NovaBase):
class AggregateMetadata(BASE, NovaBase):
"""Represents a metadata key/value pair for an aggregate."""
__tablename__ = 'aggregate_metadata'
+ __table_args__ = (
+ Index('aggregate_metadata_key_idx', 'key'),
+ )
id = Column(Integer, primary_key=True)
key = Column(String(255), nullable=False)
value = Column(String(255), nullable=False)
@@ -955,15 +962,19 @@ class AgentBuild(BASE, NovaBase):
class BandwidthUsage(BASE, NovaBase):
"""Cache for instance bandwidth usage data pulled from the hypervisor."""
__tablename__ = 'bw_usage_cache'
+ __table_args__ = (
+ Index('bw_usage_cache_uuid_start_period_idx', 'uuid',
+ 'start_period'),
+ )
id = Column(Integer, primary_key=True, nullable=False)
- uuid = Column(String(36), nullable=False)
- mac = Column(String(255), nullable=False)
+ uuid = Column(String(36), nullable=True)
+ mac = Column(String(255), nullable=True)
start_period = Column(DateTime, nullable=False)
- last_refreshed = Column(DateTime)
- bw_in = Column(BigInteger)
- bw_out = Column(BigInteger)
- last_ctr_in = Column(BigInteger)
- last_ctr_out = Column(BigInteger)
+ last_refreshed = Column(DateTime, nullable=True)
+ bw_in = Column(BigInteger, nullable=True)
+ bw_out = Column(BigInteger, nullable=True)
+ last_ctr_in = Column(BigInteger, nullable=True)
+ last_ctr_out = Column(BigInteger, nullable=True)
class VolumeUsage(BASE, NovaBase):
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_cells.py b/nova/tests/api/openstack/compute/plugins/v3/test_cells.py
index a9e77693e..f369c06e3 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_cells.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_cells.py
@@ -18,7 +18,7 @@ import copy
from lxml import etree
from webob import exc
-from nova.api.openstack.compute.contrib import cells as cells_ext
+from nova.api.openstack.compute.plugins.v3 import cells as cells_ext
from nova.api.openstack import extensions
from nova.api.openstack import xmlutil
from nova.cells import rpcapi as cells_rpcapi
@@ -88,12 +88,11 @@ class CellsTest(test.TestCase):
self.stubs.Set(cells_rpcapi.CellsAPI, 'get_cell_info_for_neighbors',
fake_cells_api_get_all_cell_info)
- self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager)
- self.controller = cells_ext.Controller(self.ext_mgr)
+ self.controller = cells_ext.CellsController()
self.context = context.get_admin_context()
def _get_request(self, resource):
- return fakes.HTTPRequest.blank('/v2/fake/' + resource)
+ return fakes.HTTPRequestV3.blank('/' + resource)
def test_index(self):
req = self._get_request("cells")
@@ -284,7 +283,6 @@ class CellsTest(test.TestCase):
self.assertEqual(cell_caps['cap2'], 'c;d')
def test_show_capacities(self):
- self.ext_mgr.is_loaded('os-cell-capacities').AndReturn(True)
self.mox.StubOutWithMock(self.controller.cells_rpcapi,
'get_capacities')
response = {"ram_free":
@@ -305,7 +303,6 @@ class CellsTest(test.TestCase):
self.assertEqual(response, res_dict['cell']['capacities'])
def test_show_capacity_fails_with_non_admin_context(self):
- self.ext_mgr.is_loaded('os-cell-capacities').AndReturn(True)
rules = {"compute_extension:cells": "is_admin:true"}
self.policy.set_rules(rules)
@@ -317,7 +314,6 @@ class CellsTest(test.TestCase):
self.controller.capacities, req)
def test_show_capacities_for_invalid_cell(self):
- self.ext_mgr.is_loaded('os-cell-capacities').AndReturn(True)
self.mox.StubOutWithMock(self.controller.cells_rpcapi,
'get_capacities')
self.controller.cells_rpcapi. \
@@ -330,7 +326,6 @@ class CellsTest(test.TestCase):
self.controller.capacities, req, "invalid_cell")
def test_show_capacities_for_cell(self):
- self.ext_mgr.is_loaded('os-cell-capacities').AndReturn(True)
self.mox.StubOutWithMock(self.controller.cells_rpcapi,
'get_capacities')
response = {"ram_free":
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_images.py b/nova/tests/api/openstack/compute/plugins/v3/test_images.py
index a35dc6e51..712e3c8a5 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_images.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_images.py
@@ -25,7 +25,7 @@ import urlparse
from lxml import etree
import webob
-from nova.api.openstack.compute import images
+from nova.api.openstack.compute.plugins.v3 import images
from nova.api.openstack.compute.views import images as images_view
from nova.api.openstack import xmlutil
from nova import exception
@@ -54,18 +54,18 @@ class ImagesControllerTest(test.TestCase):
fakes.stub_out_compute_api_backup(self.stubs)
fakes.stub_out_glance(self.stubs)
- self.controller = images.Controller()
+ self.controller = images.ImagesController()
def test_get_image(self):
- fake_req = fakes.HTTPRequest.blank('/v2/fake/images/123')
+ fake_req = fakes.HTTPRequestV3.blank('/os-images/123')
actual_image = self.controller.show(fake_req, '124')
- href = "http://localhost/v2/fake/images/124"
- bookmark = "http://localhost/fake/images/124"
+ href = "http://localhost/v3/images/124"
+ bookmark = "http://localhost/images/124"
alternate = "%s/fake/images/124" % glance.generate_glance_url()
server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
- server_href = "http://localhost/v2/fake/servers/" + server_uuid
- server_bookmark = "http://localhost/fake/servers/" + server_uuid
+ server_href = "http://localhost/v3/servers/" + server_uuid
+ server_bookmark = "http://localhost/servers/" + server_uuid
expected_image = {
"image": {
@@ -113,14 +113,14 @@ class ImagesControllerTest(test.TestCase):
def test_get_image_with_custom_prefix(self):
self.flags(osapi_compute_link_prefix='https://zoo.com:42',
osapi_glance_link_prefix='http://circus.com:34')
- fake_req = fakes.HTTPRequest.blank('/v2/fake/images/123')
+ fake_req = fakes.HTTPRequestV3.blank('/v3/os-images/124')
actual_image = self.controller.show(fake_req, '124')
- href = "https://zoo.com:42/v2/fake/images/124"
- bookmark = "https://zoo.com:42/fake/images/124"
+ href = "https://zoo.com:42/v3/images/124"
+ bookmark = "https://zoo.com:42/images/124"
alternate = "http://circus.com:34/fake/images/124"
server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
- server_href = "https://zoo.com:42/v2/fake/servers/" + server_uuid
- server_bookmark = "https://zoo.com:42/fake/servers/" + server_uuid
+ server_href = "https://zoo.com:42/v3/servers/" + server_uuid
+ server_bookmark = "https://zoo.com:42/servers/" + server_uuid
expected_image = {
"image": {
@@ -165,18 +165,18 @@ class ImagesControllerTest(test.TestCase):
self.assertThat(actual_image, matchers.DictMatches(expected_image))
def test_get_image_404(self):
- fake_req = fakes.HTTPRequest.blank('/v2/fake/images/unknown')
+ fake_req = fakes.HTTPRequestV3.blank('/os-images/unknown')
self.assertRaises(webob.exc.HTTPNotFound,
self.controller.show, fake_req, 'unknown')
def test_get_image_details(self):
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail')
+ request = fakes.HTTPRequestV3.blank('/os-images/detail')
response = self.controller.detail(request)
response_list = response["images"]
server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
- server_href = "http://localhost/v2/fake/servers/" + server_uuid
- server_bookmark = "http://localhost/fake/servers/" + server_uuid
+ server_href = "http://localhost/v3/servers/" + server_uuid
+ server_bookmark = "http://localhost/servers/" + server_uuid
alternate = "%s/fake/images/%s"
expected = [{
@@ -191,11 +191,11 @@ class ImagesControllerTest(test.TestCase):
'minRam': 128,
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/123",
+ "href": "http://localhost/v3/images/123",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/123",
+ "href": "http://localhost/images/123",
},
{
"rel": "alternate",
@@ -229,11 +229,11 @@ class ImagesControllerTest(test.TestCase):
},
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/124",
+ "href": "http://localhost/v3/images/124",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/124",
+ "href": "http://localhost/images/124",
},
{
"rel": "alternate",
@@ -267,11 +267,11 @@ class ImagesControllerTest(test.TestCase):
},
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/125",
+ "href": "http://localhost/v3/images/125",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/125",
+ "href": "http://localhost/images/125",
},
{
"rel": "alternate",
@@ -305,11 +305,11 @@ class ImagesControllerTest(test.TestCase):
},
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/126",
+ "href": "http://localhost/v3/images/126",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/126",
+ "href": "http://localhost/images/126",
},
{
"rel": "alternate",
@@ -343,11 +343,11 @@ class ImagesControllerTest(test.TestCase):
},
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/127",
+ "href": "http://localhost/v3/images/127",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/127",
+ "href": "http://localhost/images/127",
},
{
"rel": "alternate",
@@ -381,11 +381,11 @@ class ImagesControllerTest(test.TestCase):
},
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/128",
+ "href": "http://localhost/v3/images/128",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/128",
+ "href": "http://localhost/images/128",
},
{
"rel": "alternate",
@@ -419,11 +419,11 @@ class ImagesControllerTest(test.TestCase):
},
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/129",
+ "href": "http://localhost/v3/images/129",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/129",
+ "href": "http://localhost/images/129",
},
{
"rel": "alternate",
@@ -443,11 +443,11 @@ class ImagesControllerTest(test.TestCase):
'minRam': 0,
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/130",
+ "href": "http://localhost/v3/images/130",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/130",
+ "href": "http://localhost/images/130",
},
{
"rel": "alternate",
@@ -460,14 +460,14 @@ class ImagesControllerTest(test.TestCase):
self.assertThat(expected, matchers.DictListMatches(response_list))
def test_get_image_details_with_limit(self):
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail?limit=2')
+ request = fakes.HTTPRequestV3.blank('/os-images/detail?limit=2')
response = self.controller.detail(request)
response_list = response["images"]
response_links = response["images_links"]
server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
- server_href = "http://localhost/v2/fake/servers/" + server_uuid
- server_bookmark = "http://localhost/fake/servers/" + server_uuid
+ server_href = "http://localhost/v3/servers/" + server_uuid
+ server_bookmark = "http://localhost/servers/" + server_uuid
alternate = "%s/fake/images/%s"
expected = [{
@@ -482,11 +482,11 @@ class ImagesControllerTest(test.TestCase):
'minRam': 128,
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/123",
+ "href": "http://localhost/v3/images/123",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/123",
+ "href": "http://localhost/images/123",
},
{
"rel": "alternate",
@@ -520,11 +520,11 @@ class ImagesControllerTest(test.TestCase):
},
"links": [{
"rel": "self",
- "href": "http://localhost/v2/fake/images/124",
+ "href": "http://localhost/v3/images/124",
},
{
"rel": "bookmark",
- "href": "http://localhost/fake/images/124",
+ "href": "http://localhost/images/124",
},
{
"rel": "alternate",
@@ -536,7 +536,7 @@ class ImagesControllerTest(test.TestCase):
self.assertThat(expected, matchers.DictListMatches(response_list))
href_parts = urlparse.urlparse(response_links[0]['href'])
- self.assertEqual('/v2/fake/images', href_parts.path)
+ self.assertEqual('/v3/images', href_parts.path)
params = urlparse.parse_qs(href_parts.query)
self.assertThat({'limit': ['2'], 'marker': ['124']},
@@ -545,47 +545,47 @@ class ImagesControllerTest(test.TestCase):
def test_image_detail_filter_with_name(self):
image_service = self.mox.CreateMockAnything()
filters = {'name': 'testname'}
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail'
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/detail'
'?name=testname')
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_filter_with_status(self):
image_service = self.mox.CreateMockAnything()
filters = {'status': 'active'}
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail'
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/detail'
'?status=ACTIVE')
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_filter_with_property(self):
image_service = self.mox.CreateMockAnything()
filters = {'property-test': '3'}
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail'
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/detail'
'?property-test=3')
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_filter_server_href(self):
image_service = self.mox.CreateMockAnything()
uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
ref = 'http://localhost:8774/servers/' + uuid
- url = '/v2/fake/images/detail?server=' + ref
+ url = '/v3/os-images/detail?server=' + ref
filters = {'property-instance_uuid': uuid}
- request = fakes.HTTPRequest.blank(url)
+ request = fakes.HTTPRequestV3.blank(url)
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_filter_server_uuid(self):
@@ -593,53 +593,53 @@ class ImagesControllerTest(test.TestCase):
uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
url = '/v2/fake/images/detail?server=' + uuid
filters = {'property-instance_uuid': uuid}
- request = fakes.HTTPRequest.blank(url)
+ request = fakes.HTTPRequestV3.blank(url)
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_filter_changes_since(self):
image_service = self.mox.CreateMockAnything()
filters = {'changes-since': '2011-01-24T17:08Z'}
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail'
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/detail'
'?changes-since=2011-01-24T17:08Z')
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_filter_with_type(self):
image_service = self.mox.CreateMockAnything()
filters = {'property-image_type': 'BASE'}
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail?type=BASE')
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/detail?type=BASE')
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_filter_not_supported(self):
image_service = self.mox.CreateMockAnything()
filters = {'status': 'active'}
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail?status='
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/detail?status='
'ACTIVE&UNSUPPORTEDFILTER=testname')
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_no_filters(self):
image_service = self.mox.CreateMockAnything()
filters = {}
- request = fakes.HTTPRequest.blank('/v2/fake/images/detail')
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/detail')
context = request.environ['nova.context']
image_service.detail(context, filters=filters).AndReturn([])
self.mox.ReplayAll()
- controller = images.Controller(image_service=image_service)
+ controller = images.ImagesController(image_service=image_service)
controller.detail(request)
def test_image_detail_invalid_marker(self):
@@ -648,19 +648,19 @@ class ImagesControllerTest(test.TestCase):
def detail(self, *args, **kwargs):
raise exception.Invalid('meow')
- request = fakes.HTTPRequest.blank('/v2/images?marker=invalid')
- controller = images.Controller(image_service=InvalidImageService())
+ request = fakes.HTTPRequestV3.blank('/v3/os-images?marker=invalid')
+ controller = images.ImagesController(image_service=InvalidImageService())
self.assertRaises(webob.exc.HTTPBadRequest, controller.detail, request)
def test_generate_alternate_link(self):
view = images_view.ViewBuilder()
- request = fakes.HTTPRequest.blank('/v2/fake/images/1')
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/1')
generated_url = view._get_alternate_link(request, 1)
actual_url = "%s/fake/images/1" % glance.generate_glance_url()
self.assertEqual(generated_url, actual_url)
def test_delete_image(self):
- request = fakes.HTTPRequest.blank('/v2/fake/images/124')
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/124')
request.method = 'DELETE'
response = self.controller.delete(request, '124')
self.assertEqual(response.status_int, 204)
@@ -671,14 +671,14 @@ class ImagesControllerTest(test.TestCase):
deleted_image_id = 128
# see nova.tests.api.openstack.fakes:_make_image_fixtures
- request = fakes.HTTPRequest.blank(
- '/v2/fake/images/%s' % deleted_image_id)
+ request = fakes.HTTPRequestV3.blank(
+ '/v3/os-images/%s' % deleted_image_id)
request.method = 'DELETE'
self.assertRaises(webob.exc.HTTPForbidden, self.controller.delete,
request, '%s' % deleted_image_id)
def test_delete_image_not_found(self):
- request = fakes.HTTPRequest.blank('/v2/fake/images/300')
+ request = fakes.HTTPRequestV3.blank('/v3/os-images/300')
request.method = 'DELETE'
self.assertRaises(webob.exc.HTTPNotFound,
self.controller.delete, request, '300')
@@ -688,11 +688,11 @@ class ImageXMLSerializationTest(test.TestCase):
TIMESTAMP = "2010-10-11T10:30:22Z"
SERVER_UUID = 'aa640691-d1a7-4a67-9d3c-d35ee6b3cc74'
- SERVER_HREF = 'http://localhost/v2/fake/servers/' + SERVER_UUID
- SERVER_BOOKMARK = 'http://localhost/fake/servers/' + SERVER_UUID
- IMAGE_HREF = 'http://localhost/v2/fake/images/%s'
- IMAGE_NEXT = 'http://localhost/v2/fake/images?limit=%s&marker=%s'
- IMAGE_BOOKMARK = 'http://localhost/fake/images/%s'
+ SERVER_HREF = 'http://localhost/v3/servers/' + SERVER_UUID
+ SERVER_BOOKMARK = 'http://localhost/servers/' + SERVER_UUID
+ IMAGE_HREF = 'http://localhost/v3/os-images/%s'
+ IMAGE_NEXT = 'http://localhost/v3/os-images?limit=%s&marker=%s'
+ IMAGE_BOOKMARK = 'http://localhost/os-images/%s'
def test_xml_declaration(self):
serializer = images.ImageTemplate()
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py b/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py
index 783275ea2..61b78fea8 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py
@@ -16,7 +16,7 @@
from lxml import etree
from nova.api.openstack import compute
-from nova.api.openstack.compute.contrib import server_diagnostics
+from nova.api.openstack.compute.plugins.v3 import server_diagnostics
from nova.api.openstack import wsgi
from nova.compute import api as compute_api
from nova.openstack.common import jsonutils
@@ -41,18 +41,15 @@ class ServerDiagnosticsTest(test.TestCase):
def setUp(self):
super(ServerDiagnosticsTest, self).setUp()
- self.flags(verbose=True,
- osapi_compute_extension=[
- 'nova.api.openstack.compute.contrib.select_extensions'],
- osapi_compute_ext_list=['Server_diagnostics'])
self.stubs.Set(compute_api.API, 'get_diagnostics',
fake_get_diagnostics)
self.stubs.Set(compute_api.API, 'get', fake_instance_get)
- self.router = compute.APIRouter(init_only=('servers', 'diagnostics'))
+ self.router = compute.APIRouterV3(init_only=('servers', 'os-server-diagnostics'))
def test_get_diagnostics(self):
- req = fakes.HTTPRequest.blank('/fake/servers/%s/diagnostics' % UUID)
+ req = fakes.HTTPRequestV3.blank(
+ '/servers/%s/os-server-diagnostics' % UUID)
res = req.get_response(self.router)
output = jsonutils.loads(res.body)
self.assertEqual(output, {'data': 'Some diagnostic info'})
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 4fbf805f1..2ac8b22b8 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -5221,7 +5221,8 @@ class ComputeTestCase(BaseTestCase):
self.mox.ReplayAll()
- result = self.compute._get_instances_on_driver(fake_context)
+ result = self.compute._get_instances_on_driver(fake_context,
+ columns_to_join=[])
self.assertEqual(driver_instances, result)
def test_get_instances_on_driver_fallback(self):
@@ -5252,7 +5253,7 @@ class ComputeTestCase(BaseTestCase):
[inst['name'] for inst in driver_instances])
self.compute.conductor_api.instance_get_all_by_filters(
fake_context, filters,
- columns_to_join=[]).AndReturn(all_instances)
+ columns_to_join=None).AndReturn(all_instances)
self.mox.ReplayAll()
diff --git a/nova/tests/db/test_db_api.py b/nova/tests/db/test_db_api.py
index 0b49210fa..e7ae1b76d 100644
--- a/nova/tests/db/test_db_api.py
+++ b/nova/tests/db/test_db_api.py
@@ -153,18 +153,18 @@ class DbApiTestCase(DbTestCase):
self.flags(osapi_compute_unique_server_name_scope=None)
def test_ec2_ids_not_found_are_printable(self):
- def check_exc_format(method):
+ def check_exc_format(method, value):
try:
- method(self.context, 'fake')
+ method(self.context, value)
except exception.NotFound as exc:
- self.assertTrue('fake' in unicode(exc))
-
- check_exc_format(db.get_ec2_volume_id_by_uuid)
- check_exc_format(db.get_volume_uuid_by_ec2_id)
- check_exc_format(db.get_ec2_snapshot_id_by_uuid)
- check_exc_format(db.get_snapshot_uuid_by_ec2_id)
- check_exc_format(db.get_ec2_instance_id_by_uuid)
- check_exc_format(db.get_instance_uuid_by_ec2_id)
+ self.assertTrue(unicode(value) in unicode(exc))
+
+ check_exc_format(db.get_ec2_volume_id_by_uuid, 'fake')
+ check_exc_format(db.get_volume_uuid_by_ec2_id, 123456)
+ check_exc_format(db.get_ec2_snapshot_id_by_uuid, 'fake')
+ check_exc_format(db.get_snapshot_uuid_by_ec2_id, 123456)
+ check_exc_format(db.get_ec2_instance_id_by_uuid, 'fake')
+ check_exc_format(db.get_instance_uuid_by_ec2_id, 123456)
def test_instance_get_all_with_meta(self):
inst = self.create_instance_with_args()
diff --git a/nova/tests/fake_policy.py b/nova/tests/fake_policy.py
index da43115d0..cbd856f4b 100644
--- a/nova/tests/fake_policy.py
+++ b/nova/tests/fake_policy.py
@@ -111,6 +111,7 @@ policy_data = """
"compute_extension:attach_interfaces": "",
"compute_extension:baremetal_nodes": "",
"compute_extension:cells": "",
+ "compute_extension:v3:os-cells": "",
"compute_extension:certificates": "",
"compute_extension:v3:os-certificates": "",
"compute_extension:cloudpipe": "",
@@ -155,6 +156,7 @@ policy_data = """
"compute_extension:hosts": "",
"compute_extension:hypervisors": "",
"compute_extension:image_size": "",
+ "compute_extension:v3:os-images": "",
"compute_extension:instance_actions": "",
"compute_extension:instance_actions:events": "is_admin:True",
"compute_extension:instance_usage_audit_log": "",
@@ -177,6 +179,7 @@ policy_data = """
"compute_extension:security_group_default_rules": "",
"compute_extension:security_groups": "",
"compute_extension:server_diagnostics": "",
+ "compute_extension:v3:os-server-diagnostics": "",
"compute_extension:server_password": "",
"compute_extension:server_usage": "",
"compute_extension:services": "",
diff --git a/setup.cfg b/setup.cfg
index 3d90a8a44..0d7e474cd 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -54,6 +54,7 @@ console_scripts =
nova-xvpvncproxy = nova.cmd.xvpvncproxy:main
nova.api.v3.extensions =
+ cells = nova.api.openstack.compute.plugins.v3.cells:Cells
certificates = nova.api.openstack.compute.plugins.v3.certificates:Certificates
consoles = nova.api.openstack.compute.plugins.v3.consoles:Consoles
evacuate = nova.api.openstack.compute.plugins.v3.evacuate:Evacuate
@@ -62,10 +63,12 @@ nova.api.v3.extensions =
flavors = nova.api.openstack.compute.plugins.v3.flavors:Flavors
flavor_access = nova.api.openstack.compute.plugins.v3.flavor_access:FlavorAccess
flavor_disabled = nova.api.openstack.compute.plugins.v3.flavor_disabled:FlavorDisabled
+ images = nova.api.openstack.compute.plugins.v3.images:Images
ips = nova.api.openstack.compute.plugins.v3.ips:IPs
keypairs = nova.api.openstack.compute.plugins.v3.keypairs:Keypairs
quota_sets = nova.api.openstack.compute.plugins.v3.quota_sets:QuotaSets
rescue = nova.api.openstack.compute.plugins.v3.rescue:Rescue
+ server_diagnostics = nova.api.openstack.compute.plugins.v3.server_diagnostics:ServerDiagnostics
servers = nova.api.openstack.compute.plugins.v3.servers:Servers
nova.api.v3.extensions.server.create =