diff --git a/lower-constraints.txt b/lower-constraints.txt index 5f6425d66..30730cf07 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -116,6 +116,7 @@ python-ironic-inspector-client==1.5.0 python-ironicclient==2.3.0 python-keystoneclient==3.8.0 python-magnumclient==2.1.0 +python-manilaclient==1.23.0 python-mimeparse==1.6.0 python-mistralclient==3.1.0 python-muranoclient==0.8.2 diff --git a/mistral/actions/generator_factory.py b/mistral/actions/generator_factory.py index 45d1eee0a..f7f6a9e39 100644 --- a/mistral/actions/generator_factory.py +++ b/mistral/actions/generator_factory.py @@ -21,7 +21,7 @@ SUPPORTED_MODULES = [ 'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder', 'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'SwiftService', 'Zaqar', 'Barbican', 'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker', - 'Aodh', 'Gnocchi', 'Glare', 'Vitrage', 'Senlin', 'Zun', 'Qinling' + 'Aodh', 'Gnocchi', 'Glare', 'Vitrage', 'Senlin', 'Zun', 'Qinling', 'Manila' ] diff --git a/mistral/actions/openstack/actions.py b/mistral/actions/openstack/actions.py index 9426c3ef4..be281139b 100644 --- a/mistral/actions/openstack/actions.py +++ b/mistral/actions/openstack/actions.py @@ -60,6 +60,9 @@ heatclient = _try_import('heatclient.client') ironic_inspector_client = _try_import('ironic_inspector_client.v1') ironicclient = _try_import('ironicclient.v1.client') keystoneclient = _try_import('keystoneclient.v3.client') +manila = _try_import('manilaclient') +manilaclient = _try_import('manilaclient.client') +manila_api_versions = _try_import('manilaclient.api_versions') magnumclient = _try_import('magnumclient.v1.client') mistralclient = _try_import('mistralclient.api.v2.client') muranoclient = _try_import('muranoclient.v1.client') @@ -998,3 +1001,45 @@ class QinlingAction(base.OpenStackAction): endpoint_override="http://127.0.0.1:7070/", session=session ) + + +class ManilaAction(base.OpenStackAction): + _service_type = 'sharev2' + + @classmethod + def _get_client_class(cls): + return manilaclient.Client + + def _create_client(self, context): + + LOG.debug("Manila action security context: %s", context) + + manila_endpoint = self.get_service_endpoint() + + session_and_auth = self.get_session_and_auth(context) + + temp_client = self._get_client_class()( + manila.API_MAX_VERSION, + service_catalog_url=manila_endpoint.url, + session=session_and_auth['auth'] + ) + + discovered_version = manila_api_versions.discover_version( + temp_client, + manila.API_MAX_VERSION + ) + + client = self._get_client_class()( + discovered_version, + service_catalog_url=manila_endpoint.url, + session=session_and_auth['session'] + ) + + return client + + @classmethod + def _get_fake_client(cls): + return cls._get_client_class()( + manila.API_MAX_VERSION, + input_auth_token='token', + service_catalog_url='http://127.0.0.1:8786') diff --git a/mistral/actions/openstack/mapping.json b/mistral/actions/openstack/mapping.json index 46af041c8..5cbe7129a 100644 --- a/mistral/actions/openstack/mapping.json +++ b/mistral/actions/openstack/mapping.json @@ -1349,5 +1349,173 @@ "webhooks_get": "webhooks.get", "webhooks_update": "webhooks.update", "webhooks_delete": "webhooks.delete" + }, + "manila": { + "_comment": "It uses manilaclient.v2.", + "availability_zones_list": "availability_zones.list", + "limits_get": "limits.get", + "messages_delete": "messages.delete", + "messages_find": "messages.find", + "messages_findall": "messages.findall", + "messages_get": "messages.get", + "messages_list": "messages.list", + "pools_list": "pools.list", + "quota_classes_find": "quota_classes.find", + "quota_classes_findall": "quota_classes.findall", + "quota_classes_get": "quota_classes.get", + "quota_classes_list": "quota_classes.list", + "quota_classes_update": "quota_classes.update", + "quotas_defaults": "quotas.defaults", + "quotas_delete": "quotas.delete", + "quotas_find": "quotas.find", + "quotas_findall": "quotas.findall", + "quotas_get": "quotas.get", + "quotas_list": "quotas.list", + "quotas_update": "quotas.update", + "security_services_create": "security_services.create", + "security_services_delete": "security_services.delete", + "security_services_find": "security_services.find", + "security_services_findall": "security_services.findall", + "security_services_get": "security_services.get", + "security_services_list": "security_services.list", + "security_services_update": "security_services.update", + "services_disable": "services.disable", + "services_enable": "services.enable", + "services_list": "services.list", + "services_server_api_version": "services.server_api_version", + "share_export_locations_find": "share_export_locations.find", + "share_export_locations_findall": "share_export_locations.findall", + "share_export_locations_get": "share_export_locations.get", + "share_export_locations_list": "share_export_locations.list", + "share_group_snapshots_create": "share_group_snapshots.create", + "share_group_snapshots_delete": "share_group_snapshots.delete", + "share_group_snapshots_find": "share_group_snapshots.find", + "share_group_snapshots_findall": "share_group_snapshots.findall", + "share_group_snapshots_get": "share_group_snapshots.get", + "share_group_snapshots_list": "share_group_snapshots.list", + "share_group_snapshots_reset_state": "share_group_snapshots.reset_state", + "share_group_snapshots_update": "share_group_snapshots.update", + "share_group_type_access_add_project_access": "share_group_type_access.add_project_access", + "share_group_type_access_find": "share_group_type_access.find", + "share_group_type_access_findall": "share_group_type_access.findall", + "share_group_type_access_list": "share_group_type_access.list", + "share_group_type_access_remove_project_access": "share_group_type_access.remove_project_access", + "share_group_types_create": "share_group_types.create", + "share_group_types_delete": "share_group_types.delete", + "share_group_types_find": "share_group_types.find", + "share_group_types_findall": "share_group_types.findall", + "share_group_types_get": "share_group_types.get", + "share_group_types_list": "share_group_types.list", + "share_groups_create": "share_groups.create", + "share_groups_delete": "share_groups.delete", + "share_groups_find": "share_groups.find", + "share_groups_findall": "share_groups.findall", + "share_groups_get": "share_groups.get", + "share_groups_list": "share_groups.list", + "share_groups_reset_state": "share_groups.reset_state", + "share_groups_update": "share_groups.update", + "share_instance_export_locations_find": "share_instance_export_locations.find", + "share_instance_export_locations_findall": "share_instance_export_locations.findall", + "share_instance_export_locations_get": "share_instance_export_locations.get", + "share_instance_export_locations_list": "share_instance_export_locations.list", + "share_instances_do_list": "share_instances.do_list", + "share_instances_find": "share_instances.find", + "share_instances_findall": "share_instances.findall", + "share_instances_force_delete": "share_instances.force_delete", + "share_instances_get": "share_instances.get", + "share_instances_list": "share_instances.list", + "share_instances_reset_state": "share_instances.reset_state", + "share_networks_add_security_service": "share_networks.add_security_service", + "share_networks_create": "share_networks.create", + "share_networks_delete": "share_networks.delete", + "share_networks_find": "share_networks.find", + "share_networks_findall": "share_networks.findall", + "share_networks_get": "share_networks.get", + "share_networks_list": "share_networks.list", + "share_networks_remove_security_service": "share_networks.remove_security_service", + "share_networks_update": "share_networks.update", + "share_replicas_create": "share_replicas.create", + "share_replicas_delete": "share_replicas.delete", + "share_replicas_find": "share_replicas.find", + "share_replicas_findall": "share_replicas.findall", + "share_replicas_get": "share_replicas.get", + "share_replicas_list": "share_replicas.list", + "share_replicas_promote": "share_replicas.promote", + "share_replicas_reset_replica_state": "share_replicas.reset_replica_state", + "share_replicas_reset_state": "share_replicas.reset_state", + "share_replicas_resync": "share_replicas.resync", + "share_servers_delete": "share_servers.delete", + "share_servers_details": "share_servers.details", + "share_servers_find": "share_servers.find", + "share_servers_findall": "share_servers.findall", + "share_servers_get": "share_servers.get", + "share_servers_list": "share_servers.list", + "share_snapshot_export_locations_find": "share_snapshot_export_locations.find", + "share_snapshot_export_locations_findall": "share_snapshot_export_locations.findall", + "share_snapshot_export_locations_get": "share_snapshot_export_locations.get", + "share_snapshot_export_locations_list": "share_snapshot_export_locations.list", + "share_snapshot_instance_export_locations_find": "share_snapshot_instance_export_locations.find", + "share_snapshot_instance_export_locations_findall": "share_snapshot_instance_export_locations.findall", + "share_snapshot_instance_export_locations_get": "share_snapshot_instance_export_locations.get", + "share_snapshot_instance_export_locations_list": "share_snapshot_instance_export_locations.list", + "share_snapshot_instances_find": "share_snapshot_instances.find", + "share_snapshot_instances_findall": "share_snapshot_instances.findall", + "share_snapshot_instances_get": "share_snapshot_instances.get", + "share_snapshot_instances_list": "share_snapshot_instances.list", + "share_snapshot_instances_reset_state": "share_snapshot_instances.reset_state", + "share_snapshots_access_list": "share_snapshots.access_list", + "share_snapshots_allow": "share_snapshots.allow", + "share_snapshots_create": "share_snapshots.create", + "share_snapshots_delete": "share_snapshots.delete", + "share_snapshots_deny": "share_snapshots.deny", + "share_snapshots_find": "share_snapshots.find", + "share_snapshots_findall": "share_snapshots.findall", + "share_snapshots_force_delete": "share_snapshots.force_delete", + "share_snapshots_get": "share_snapshots.get", + "share_snapshots_list": "share_snapshots.list", + "share_snapshots_manage": "share_snapshots.manage", + "share_snapshots_reset_state": "share_snapshots.reset_state", + "share_snapshots_unmanage": "share_snapshots.unmanage", + "share_snapshots_update": "share_snapshots.update", + "share_type_access_add_project_access": "share_type_access.add_project_access", + "share_type_access_find": "share_type_access.find", + "share_type_access_findall": "share_type_access.findall", + "share_type_access_list": "share_type_access.list", + "share_type_access_remove_project_access": "share_type_access.remove_project_access", + "share_types_create": "share_types.create", + "share_types_delete": "share_types.delete", + "share_types_find": "share_types.find", + "share_types_findall": "share_types.findall", + "share_types_get": "share_types.get", + "share_types_list": "share_types.list", + "share_types_show": "share_types.show", + "shares_access_list": "shares.access_list", + "shares_allow": "shares.allow", + "shares_create": "shares.create", + "shares_delete": "shares.delete", + "shares_delete_metadata": "shares.delete_metadata", + "shares_deny": "shares.deny", + "shares_do_list": "shares.do_list", + "shares_extend": "shares.extend", + "shares_find": "shares.find", + "shares_findall": "shares.findall", + "shares_force_delete": "shares.force_delete", + "shares_get": "shares.get", + "shares_get_metadata": "shares.get_metadata", + "shares_list": "shares.list", + "shares_list_instances": "shares.list_instances", + "shares_manage": "shares.manage", + "shares_migration_cancel": "shares.migration_cancel", + "shares_migration_complete": "shares.migration_complete", + "shares_migration_get_progress": "shares.migration_get_progress", + "shares_migration_start": "shares.migration_start", + "shares_reset_state": "shares.reset_state", + "shares_reset_task_state": "shares.reset_task_state", + "shares_revert_to_snapshot": "shares.revert_to_snapshot", + "shares_set_metadata": "shares.set_metadata", + "shares_shrink": "shares.shrink", + "shares_unmanage": "shares.unmanage", + "shares_update": "shares.update", + "shares_update_all_metadata": "shares.update_all_metadata" } } diff --git a/mistral/tests/unit/actions/openstack/test_generator.py b/mistral/tests/unit/actions/openstack/test_generator.py index 02d198e09..294e20b94 100644 --- a/mistral/tests/unit/actions/openstack/test_generator.py +++ b/mistral/tests/unit/actions/openstack/test_generator.py @@ -48,6 +48,7 @@ MODULE_MAPPING = { 'barbican': ['barbican.orders_list', actions.BarbicanAction], 'mistral': ['mistral.workflows_get', actions.MistralAction], 'designate': ['designate.domains_list', actions.DesignateAction], + 'manila': ['manila.shares_list', actions.ManilaAction], 'magnum': ['magnum.bays_list', actions.MagnumAction], 'murano': ['murano.deployments_list', actions.MuranoAction], 'tacker': ['tacker.list_vims', actions.TackerAction], diff --git a/mistral/tests/unit/actions/openstack/test_openstack_actions.py b/mistral/tests/unit/actions/openstack/test_openstack_actions.py index 9af89039c..3b3f21407 100644 --- a/mistral/tests/unit/actions/openstack/test_openstack_actions.py +++ b/mistral/tests/unit/actions/openstack/test_openstack_actions.py @@ -389,6 +389,19 @@ class OpenStackActionTest(base.BaseTestCase): self.assertTrue(mocked().runtimes.get.called) mocked().runtimes.get.assert_called_once_with(id="1234-abcd") + @mock.patch.object(actions.ManilaAction, '_get_client') + def test_manila_action(self, mocked): + mock_ctx = mock.Mock() + method_name = "shares.get" + action_class = actions.ManilaAction + action_class.client_method_name = method_name + params = {'share': '1234-abcd'} + action = action_class(**params) + action.run(mock_ctx) + + self.assertTrue(mocked().shares.get.called) + mocked().shares.get.assert_called_once_with(share="1234-abcd") + class TestImport(base.BaseTestCase): @mock.patch.object(importutils, 'try_import') diff --git a/releasenotes/notes/support-manila-action-8af256d5fadd1ac5.yaml b/releasenotes/notes/support-manila-action-8af256d5fadd1ac5.yaml new file mode 100644 index 000000000..379d0199c --- /dev/null +++ b/releasenotes/notes/support-manila-action-8af256d5fadd1ac5.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add Mistral actions for Openstack Manila, the fileshare management service. diff --git a/requirements.txt b/requirements.txt index ac35e0805..7fbac3fe4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,6 +38,7 @@ python-glareclient>=0.3.0 # Apache-2.0 python-heatclient>=1.10.0 # Apache-2.0 python-keystoneclient>=3.8.0 # Apache-2.0 python-mistralclient!=3.2.0,>=3.1.0 # Apache-2.0 +python-manilaclient>=1.23.0 # Apache-2.0 python-magnumclient>=2.1.0 # Apache-2.0 python-muranoclient>=0.8.2 # Apache-2.0 python-neutronclient>=6.7.0 # Apache-2.0 diff --git a/tools/get_action_list.py b/tools/get_action_list.py index 62c2f5b7c..c8f8f8fed 100644 --- a/tools/get_action_list.py +++ b/tools/get_action_list.py @@ -37,6 +37,8 @@ from keystoneclient import base as keystone_base from keystoneclient.v3 import client as keystoneclient from magnumclient.common import base as magnum_base from magnumclient.v1 import client as magnumclient +from manilaclient import base as manila_base +from manilaclient.v2 import client as manilaclient from mistralclient.api import base as mistral_base from mistralclient.api.v2 import client as mistralclient from muranoclient.common import base as murano_base @@ -88,6 +90,7 @@ BASE_MISTRAL_MANAGER = mistral_base.ResourceManager BASE_TROVE_MANAGER = trove_base.Manager BASE_IRONIC_MANAGER = ironic_base.Manager BASE_BARBICAN_MANAGER = barbican_base.BaseEntityManager +BASE_MANILA_MANAGER = manila_base.Manager BASE_MAGNUM_MANAGER = magnum_base.Manager BASE_MURANO_MANAGER = murano_base.Manager BASE_AODH_MANAGER = aodh_base.Manager @@ -211,6 +214,13 @@ def get_glare_client(**kwargs): return glareclient.Client('') +def get_manila_client(**kwargs): + return manilaclient.Client( + input_auth_token='token', + service_catalog_url='http://127.0.0.1:8786' + ) + + CLIENTS = { 'nova': get_nova_client, 'heat': get_heat_client, @@ -227,6 +237,7 @@ CLIENTS = { 'aodh': get_aodh_client, 'gnocchi': get_gnocchi_client, 'glare': get_glare_client, + 'manila': get_manila_client, # 'neutron': get_nova_client # 'baremetal_introspection': ... # 'swift': ... @@ -248,6 +259,7 @@ BASE_MANAGERS = { 'aodh': BASE_AODH_MANAGER, 'gnocchi': BASE_GNOCCHI_MANAGER, 'glare': None, + 'manila': BASE_MANILA_MANAGER, # 'neutron': BASE_NOVA_MANAGER # 'baremetal_introspection': ... # 'swift': ...