diff options
author | Zuul <zuul@review.opendev.org> | 2020-08-25 20:53:45 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-08-25 20:53:45 +0000 |
commit | b18aadc84d39e0bf91af796674b9fd43b417d0d1 (patch) | |
tree | 2c1dfaff0221432470b68e1951cc1368f5265ab5 | |
parent | 0b01294612fbbb7be7bda849741a8125419ac6e0 (diff) | |
parent | f98aef09e2ac0191fb7fb6b949154fedde0bc525 (diff) | |
download | heat-b18aadc84d39e0bf91af796674b9fd43b417d0d1.tar.gz |
Merge "Bump MANILACLIENT_VERSION and use sharev2 endpoint"
4 files changed, 35 insertions, 6 deletions
diff --git a/heat/engine/clients/os/manila.py b/heat/engine/clients/os/manila.py index f5adf1937..43ff43c24 100644 --- a/heat/engine/clients/os/manila.py +++ b/heat/engine/clients/os/manila.py @@ -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') diff --git a/heat/engine/resources/openstack/manila/share.py b/heat/engine/resources/openstack/manila/share.py index 17b164a7c..61e93163c 100644 --- a/heat/engine/resources/openstack/manila/share.py +++ b/heat/engine/resources/openstack/manila/share.py @@ -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 diff --git a/heat/tests/openstack/manila/test_share.py b/heat/tests/openstack/manila/test_share.py index 9c23360a9..cf4e787ed 100644 --- a/heat/tests/openstack/manila/test_share.py +++ b/heat/tests/openstack/manila/test_share.py @@ -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')) diff --git a/releasenotes/notes/support-cephx-access-type-in-manila-share-71a416bf55aea214.yaml b/releasenotes/notes/support-cephx-access-type-in-manila-share-71a416bf55aea214.yaml new file mode 100644 index 000000000..9ccb63370 --- /dev/null +++ b/releasenotes/notes/support-cephx-access-type-in-manila-share-71a416bf55aea214.yaml @@ -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": ""}]}'. |