Bump MANILACLIENT_VERSION and use sharev2 endpoint

This commit bumps MANILACLIENT_VERSION to 2.13 and changes the used
service type to sharev2.

In order to support the value of "cephx" in property
'{"access_rules": [{"access_type": ""}]}' in ressource
OS::Manila::Share, manilaclient needs to use at least version 2.13 of
the manila API ([1]). The default minimum version in manilaclient, which
is used when only a mayor version is specified is 2.0.
Additionally the sharev2 service type endpoint has to be used to access
the manila v2 API.

The export_locations response was removed in version 2.9 of manila API
from the "Show share details" request ([2]) and moved to its own
endpoint in [3]. Thus it is requested from there now.
Additionally the new endpoint is more verbose, so only its path
attribute is returned, in order to match the previous behaviour.

[1]
https://docs.openstack.org/manila/latest/contributor/api_microversion_history.html
[2]
https://docs.openstack.org/api-ref/shared-file-system/?expanded=show-single-export-location-detail,show-share-details-detail#show-share-details
[3]
https://docs.openstack.org/api-ref/shared-file-system/?expanded=show-single-export-location-detail,list-export-locations-detail#list-export-locations

Change-Id: I4c37be8fad1edb05d812fed260e97e9188fd23ce
Story: 2007986
Task: 40612
This commit is contained in:
Jan Horstmann 2020-08-10 13:09:52 +02:00
parent 65de8cb436
commit f98aef09e2
4 changed files with 35 additions and 6 deletions

View File

@ -18,7 +18,7 @@ from manilaclient import client as manila_client
from manilaclient import exceptions
from oslo_config import cfg
MANILACLIENT_VERSION = "2"
MANILACLIENT_VERSION = "2.13"
CLIENT_NAME = 'manila'
@ -26,7 +26,7 @@ class ManilaClientPlugin(client_plugin.ClientPlugin):
exceptions_module = exceptions
service_types = [SHARE] = ['share']
service_types = [SHARE] = ['sharev2']
def _create(self):
endpoint_type = self._get_client_option(CLIENT_NAME, 'endpoint_type')

View File

@ -192,11 +192,21 @@ class ManilaShare(resource.Resource):
def _request_share(self):
return self.client().shares.get(self.resource_id)
def _request_export_locations(self):
# Only return the "path" response parameter, because that is what was
# returned before API version "2.9" by the shares endpoint
return [export_location.to_dict()['path']
for export_location in
self.client().share_export_locations.list(self.resource_id)]
def _resolve_attribute(self, name):
if self.resource_id is None:
return
share = self._request_share()
return str(getattr(share, name))
if name == self.EXPORT_LOCATIONS_ATTR:
attr = self._request_export_locations()
else:
attr = getattr(self._request_share(), name)
return str(attr)
def handle_create(self):
# Request IDs of entities from manila

View File

@ -46,13 +46,22 @@ class DummyShare(object):
def __init__(self):
self.availability_zone = 'az'
self.host = 'host'
self.export_locations = 'el'
self.share_server_id = 'id'
self.created_at = 'ca'
self.status = 's'
self.project_id = 'p_id'
class DummyShareExportLocation(object):
def __init__(self):
self.export_location = {
'path': 'el'
}
def to_dict(self):
return self.export_location
class ManilaShareTest(common.HeatTestCase):
def setUp(self):
@ -212,9 +221,11 @@ class ManilaShareTest(common.HeatTestCase):
def test_attributes(self):
share = self._create_share("share")
share.client().shares.get.return_value = DummyShare()
share.client().share_export_locations.list.return_value = [
DummyShareExportLocation()]
self.assertEqual('az', share.FnGetAtt('availability_zone'))
self.assertEqual('host', share.FnGetAtt('host'))
self.assertEqual('el', share.FnGetAtt('export_locations'))
self.assertEqual("['el']", share.FnGetAtt('export_locations'))
self.assertEqual('id', share.FnGetAtt('share_server_id'))
self.assertEqual('ca', share.FnGetAtt('created_at'))
self.assertEqual('s', share.FnGetAtt('status'))

View File

@ -0,0 +1,8 @@
---
upgrade:
- |
Manila resources now use the 'sharev2' endpoint and API version '2.13'.
fixes:
- |
OS::Manila::Share now properly supports 'cephx' as a value for property
'{"access_rules": [{"access_type": ""}]}'.