Merge "Use Cinder API v3 by default"
This commit is contained in:
commit
7dbaf50afd
@ -55,12 +55,15 @@ CONSUMER_CHOICES = (
|
|||||||
('both', pgettext_lazy('Both of front-end and back-end', u'both')),
|
('both', pgettext_lazy('Both of front-end and back-end', u'both')),
|
||||||
)
|
)
|
||||||
|
|
||||||
VERSIONS = base.APIVersionManager("volume", preferred_version='2')
|
VERSIONS = base.APIVersionManager("volume", preferred_version='3')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from cinderclient.v2 import client as cinder_client_v2
|
from cinderclient.v2 import client as cinder_client_v2
|
||||||
VERSIONS.load_supported_version('2', {"client": cinder_client_v2,
|
VERSIONS.load_supported_version('2', {"client": cinder_client_v2,
|
||||||
"version": '2'})
|
"version": '2'})
|
||||||
|
from cinderclient.v3 import client as cinder_client_v3
|
||||||
|
VERSIONS.load_supported_version('3', {"client": cinder_client_v3,
|
||||||
|
"version": '3'})
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -1071,9 +1074,9 @@ def message_list(request, search_opts=None):
|
|||||||
|
|
||||||
def is_volume_service_enabled(request):
|
def is_volume_service_enabled(request):
|
||||||
return bool(
|
return bool(
|
||||||
base.is_service_enabled(request, 'volume') or
|
base.is_service_enabled(request, 'volumev3') or
|
||||||
base.is_service_enabled(request, 'volumev2') or
|
base.is_service_enabled(request, 'volumev2') or
|
||||||
base.is_service_enabled(request, 'volumev3')
|
base.is_service_enabled(request, 'volume')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ class CinderServicesTab(tabs.TableTab):
|
|||||||
slug = tables.CinderServicesTable.Meta.name
|
slug = tables.CinderServicesTable.Meta.name
|
||||||
template_name = constants.INFO_DETAIL_TEMPLATE_NAME
|
template_name = constants.INFO_DETAIL_TEMPLATE_NAME
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_cinder_services_data(self):
|
def get_cinder_services_data(self):
|
||||||
|
@ -21,6 +21,7 @@ class Snapshots(horizon.Panel):
|
|||||||
name = _("Snapshots")
|
name = _("Snapshots")
|
||||||
slug = 'snapshots'
|
slug = 'snapshots'
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "context_is_admin"),)
|
policy_rules = (("volume", "context_is_admin"),)
|
||||||
|
@ -21,6 +21,7 @@ class VolumeTypes(horizon.Panel):
|
|||||||
name = _("Volume Types")
|
name = _("Volume Types")
|
||||||
slug = 'volume_types'
|
slug = 'volume_types'
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "volume_extension:types_manage"),)
|
policy_rules = (("volume", "volume_extension:types_manage"),)
|
||||||
|
@ -19,6 +19,7 @@ class Volumes(horizon.Panel):
|
|||||||
name = _("Volumes")
|
name = _("Volumes")
|
||||||
slug = "volumes"
|
slug = "volumes"
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "context_is_admin"),)
|
policy_rules = (("volume", "context_is_admin"),)
|
||||||
|
@ -21,6 +21,7 @@ class Backups(horizon.Panel):
|
|||||||
name = _("Backups")
|
name = _("Backups")
|
||||||
slug = 'backups'
|
slug = 'backups'
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "backup:get_all"),)
|
policy_rules = (("volume", "backup:get_all"),)
|
||||||
|
@ -21,6 +21,7 @@ class CGSnapshots(horizon.Panel):
|
|||||||
name = _("Consistency Group Snapshots")
|
name = _("Consistency Group Snapshots")
|
||||||
slug = 'cg_snapshots'
|
slug = 'cg_snapshots'
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "consistencygroup:get_all_cgsnapshots"),)
|
policy_rules = (("volume", "consistencygroup:get_all_cgsnapshots"),)
|
||||||
|
@ -113,5 +113,6 @@ class CGSnapshotsTable(tables.DataTable):
|
|||||||
row_class = UpdateRow
|
row_class = UpdateRow
|
||||||
status_columns = ("status",)
|
status_columns = ("status",)
|
||||||
permissions = [
|
permissions = [
|
||||||
('openstack.services.volume', 'openstack.services.volumev2')
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3')
|
||||||
]
|
]
|
||||||
|
@ -21,6 +21,7 @@ class CGroups(horizon.Panel):
|
|||||||
name = _("Consistency Groups")
|
name = _("Consistency Groups")
|
||||||
slug = 'cgroups'
|
slug = 'cgroups'
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "consistencygroup:get_all"),)
|
policy_rules = (("volume", "consistencygroup:get_all"),)
|
||||||
|
@ -21,6 +21,7 @@ class Snapshots(horizon.Panel):
|
|||||||
name = _("Snapshots")
|
name = _("Snapshots")
|
||||||
slug = 'snapshots'
|
slug = 'snapshots'
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "volume:get_all_snapshots"),)
|
policy_rules = (("volume", "volume:get_all_snapshots"),)
|
||||||
|
@ -208,7 +208,8 @@ class VolumeDetailsSnapshotsTable(volume_tables.VolumesTableBase):
|
|||||||
row_class = UpdateRow
|
row_class = UpdateRow
|
||||||
status_columns = ("status",)
|
status_columns = ("status",)
|
||||||
permissions = [
|
permissions = [
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ class VolumeSnapshotsViewTests(test.TestCase):
|
|||||||
api.base: ('is_service_enabled',)})
|
api.base: ('is_service_enabled',)})
|
||||||
def _test_snapshots_index_paginated(self, marker, sort_dir, snapshots, url,
|
def _test_snapshots_index_paginated(self, marker, sort_dir, snapshots, url,
|
||||||
has_more, has_prev):
|
has_more, has_prev):
|
||||||
api.base.is_service_enabled(IsA(http.HttpRequest), 'volumev2') \
|
api.base.is_service_enabled(IsA(http.HttpRequest), 'volumev3') \
|
||||||
.AndReturn(True)
|
.AndReturn(True)
|
||||||
api.base.is_service_enabled(IsA(http.HttpRequest), 'volume') \
|
api.base.is_service_enabled(IsA(http.HttpRequest), 'volumev3') \
|
||||||
.AndReturn(True)
|
.AndReturn(True)
|
||||||
api.cinder.volume_snapshot_list_paged(
|
api.cinder.volume_snapshot_list_paged(
|
||||||
IsA(http.HttpRequest), marker=marker, sort_dir=sort_dir,
|
IsA(http.HttpRequest), marker=marker, sort_dir=sort_dir,
|
||||||
|
@ -21,7 +21,7 @@ from horizon import tables
|
|||||||
from horizon import tabs
|
from horizon import tabs
|
||||||
from horizon.utils import memoized
|
from horizon.utils import memoized
|
||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard.api import cinder
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.project.snapshots \
|
from openstack_dashboard.dashboards.project.snapshots \
|
||||||
import forms as vol_snapshot_forms
|
import forms as vol_snapshot_forms
|
||||||
@ -38,14 +38,14 @@ class SnapshotsView(tables.PagedTableMixin, tables.DataTableView):
|
|||||||
def get_data(self):
|
def get_data(self):
|
||||||
snapshots = []
|
snapshots = []
|
||||||
volumes = {}
|
volumes = {}
|
||||||
if api.base.is_service_enabled(self.request, 'volumev2'):
|
if cinder.is_volume_service_enabled(self.request):
|
||||||
try:
|
try:
|
||||||
marker, sort_dir = self._get_marker()
|
marker, sort_dir = self._get_marker()
|
||||||
snapshots, self._has_more_data, self._has_prev_data = \
|
snapshots, self._has_more_data, self._has_prev_data = \
|
||||||
api.cinder.volume_snapshot_list_paged(
|
cinder.volume_snapshot_list_paged(
|
||||||
self.request, paginate=True, marker=marker,
|
self.request, paginate=True, marker=marker,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
volumes = api.cinder.volume_list(self.request)
|
volumes = cinder.volume_list(self.request)
|
||||||
volumes = dict((v.id, v) for v in volumes)
|
volumes = dict((v.id, v) for v in volumes)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(self.request, _("Unable to retrieve "
|
exceptions.handle(self.request, _("Unable to retrieve "
|
||||||
@ -71,8 +71,8 @@ class UpdateView(forms.ModalFormView):
|
|||||||
def get_object(self):
|
def get_object(self):
|
||||||
snap_id = self.kwargs['snapshot_id']
|
snap_id = self.kwargs['snapshot_id']
|
||||||
try:
|
try:
|
||||||
self._object = api.cinder.volume_snapshot_get(self.request,
|
self._object = cinder.volume_snapshot_get(self.request,
|
||||||
snap_id)
|
snap_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = _('Unable to retrieve volume snapshot.')
|
msg = _('Unable to retrieve volume snapshot.')
|
||||||
url = reverse('horizon:project:snapshots:index')
|
url = reverse('horizon:project:snapshots:index')
|
||||||
@ -123,10 +123,10 @@ class DetailView(tabs.TabView):
|
|||||||
def get_data(self):
|
def get_data(self):
|
||||||
try:
|
try:
|
||||||
snapshot_id = self.kwargs['snapshot_id']
|
snapshot_id = self.kwargs['snapshot_id']
|
||||||
snapshot = api.cinder.volume_snapshot_get(self.request,
|
snapshot = cinder.volume_snapshot_get(self.request,
|
||||||
snapshot_id)
|
snapshot_id)
|
||||||
snapshot._volume = api.cinder.volume_get(self.request,
|
snapshot._volume = cinder.volume_get(self.request,
|
||||||
snapshot.volume_id)
|
snapshot.volume_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
redirect = self.get_redirect_url()
|
redirect = self.get_redirect_url()
|
||||||
exceptions.handle(self.request,
|
exceptions.handle(self.request,
|
||||||
|
@ -21,6 +21,7 @@ class Volumes(horizon.Panel):
|
|||||||
name = _("Volumes")
|
name = _("Volumes")
|
||||||
slug = 'volumes'
|
slug = 'volumes'
|
||||||
permissions = (
|
permissions = (
|
||||||
('openstack.services.volume', 'openstack.services.volumev2'),
|
('openstack.services.volume', 'openstack.services.volumev2',
|
||||||
|
'openstack.services.volumev3'),
|
||||||
)
|
)
|
||||||
policy_rules = (("volume", "volume:get_all"),)
|
policy_rules = (("volume", "volume:get_all"),)
|
||||||
|
@ -56,13 +56,25 @@ SERVICE_CATALOG = [
|
|||||||
"endpoints_links": [],
|
"endpoints_links": [],
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
{"region": "RegionOne",
|
{"region": "RegionOne",
|
||||||
"adminURL": "http://admin.nova.example.com:8776/v2",
|
"adminURL": "http://admin.cinder.example.com:8776/v2",
|
||||||
"internalURL": "http://int.nova.example.com:8776/v2",
|
"internalURL": "http://int.cinder.example.com:8776/v2",
|
||||||
"publicURL": "http://public.nova.example.com:8776/v2"},
|
"publicURL": "http://public.cinder.example.com:8776/v2"},
|
||||||
{"region": "RegionTwo",
|
{"region": "RegionTwo",
|
||||||
"adminURL": "http://admin.nova.example.com:8776/v2",
|
"adminURL": "http://admin.cinder.example.com:8776/v2",
|
||||||
"internalURL": "http://int.nova.example.com:8776/v2",
|
"internalURL": "http://int.cinder.example.com:8776/v2",
|
||||||
"publicURL": "http://public.nova.example.com:8776/v2"}]},
|
"publicURL": "http://public.cinder.example.com:8776/v2"}]},
|
||||||
|
{"type": "volumev3",
|
||||||
|
"name": "cinderv3",
|
||||||
|
"endpoints_links": [],
|
||||||
|
"endpoints": [
|
||||||
|
{"region": "RegionOne",
|
||||||
|
"adminURL": "http://admin.cinder.example.com:8776/v3",
|
||||||
|
"internalURL": "http://int.cinder.example.com:8776/v3",
|
||||||
|
"publicURL": "http://public.cinder.example.com:8776/v3"},
|
||||||
|
{"region": "RegionTwo",
|
||||||
|
"adminURL": "http://admin.cinder.example.com:8776/v3",
|
||||||
|
"internalURL": "http://int.cinder.example.com:8776/v3",
|
||||||
|
"publicURL": "http://public.cinder.example.com:8776/v3"}]},
|
||||||
{"type": "image",
|
{"type": "image",
|
||||||
"name": "glance",
|
"name": "glance",
|
||||||
"endpoints_links": [],
|
"endpoints_links": [],
|
||||||
|
@ -249,16 +249,16 @@ class ApiHelperTests(test.TestCase):
|
|||||||
endpoint_type='adminURL')
|
endpoint_type='adminURL')
|
||||||
self.assertEqual('http://admin.nova.example.com:8774/v2', url)
|
self.assertEqual('http://admin.nova.example.com:8774/v2', url)
|
||||||
|
|
||||||
url = api_base.url_for(self.request, 'volumev2')
|
url = api_base.url_for(self.request, 'volumev3')
|
||||||
self.assertEqual('http://public.nova.example.com:8776/v2', url)
|
self.assertEqual('http://public.cinder.example.com:8776/v3', url)
|
||||||
|
|
||||||
url = api_base.url_for(self.request, 'volumev2',
|
url = api_base.url_for(self.request, 'volumev3',
|
||||||
endpoint_type="internalURL")
|
endpoint_type="internalURL")
|
||||||
self.assertEqual('http://int.nova.example.com:8776/v2', url)
|
self.assertEqual('http://int.cinder.example.com:8776/v3', url)
|
||||||
|
|
||||||
url = api_base.url_for(self.request, 'volumev2',
|
url = api_base.url_for(self.request, 'volumev3',
|
||||||
endpoint_type='adminURL')
|
endpoint_type='adminURL')
|
||||||
self.assertEqual('http://admin.nova.example.com:8776/v2', url)
|
self.assertEqual('http://admin.cinder.example.com:8776/v3', url)
|
||||||
|
|
||||||
self.assertNotIn('notAnApi', self.request.user.service_catalog,
|
self.assertNotIn('notAnApi', self.request.user.service_catalog,
|
||||||
'Select a new nonexistent service catalog key')
|
'Select a new nonexistent service catalog key')
|
||||||
|
@ -458,12 +458,16 @@ class CinderApiVersionTests(test.TestCase):
|
|||||||
# versions.
|
# versions.
|
||||||
api.cinder.VERSIONS._active = None
|
api.cinder.VERSIONS._active = None
|
||||||
|
|
||||||
def test_default_client_is_v2(self):
|
def test_default_client_is_v3(self):
|
||||||
client = api.cinder.cinderclient(self.request)
|
client = api.cinder.cinderclient(self.request)
|
||||||
self.assertIsInstance(client, cinder_client.v2.client.Client)
|
self.assertIsInstance(client, cinder_client.v3.client.Client)
|
||||||
|
|
||||||
@override_settings(OPENSTACK_API_VERSIONS={'volume': 2})
|
@override_settings(OPENSTACK_API_VERSIONS={'volume': 2})
|
||||||
def test_v2_setting_returns_v2_client(self):
|
def test_v2_setting_returns_v2_client(self):
|
||||||
|
# FIXME(e0ne): this is a temporary workaround to bypass
|
||||||
|
# @memoized_with_request decorator caching. We have to find a better
|
||||||
|
# solution instead this hack.
|
||||||
|
self.request.user.username = 'test_user_cinder_v2'
|
||||||
client = api.cinder.cinderclient(self.request)
|
client = api.cinder.cinderclient(self.request)
|
||||||
self.assertIsInstance(client, cinder_client.v2.client.Client)
|
self.assertIsInstance(client, cinder_client.v2.client.Client)
|
||||||
|
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Cinder API v3 is used by default now. It was introduced in Mitaka release
|
||||||
|
and has all features from API v2.
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
If your deployment doesn't have Cinder API v3 endpoint like ``volumev3``
|
||||||
|
you should create new endpoint or use Cinder API v2 via setting
|
||||||
|
OPENSTACK_API_VERSIONS['volume'] = 2 in your OpenStack Dashboard (Horizon)
|
||||||
|
configuration file.
|
Loading…
Reference in New Issue
Block a user