Merge "Bump MANILACLIENT_VERSION and use sharev2 endpoint"

This commit is contained in:
Zuul 2020-08-25 20:53:45 +00:00 committed by Gerrit Code Review
commit b18aadc84d
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": ""}]}'.