Browse Source

Support Manila actions in Mistral

Adds manila actions into the available list of actions for mistral

Change-Id: Ic0a3c24f72d91a8a87ffcf81db763058bcbf8566
Closes-Bug: #1783291
tags/7.0.0.0b3
Jose Castro Leon 10 months ago
parent
commit
a2756a34c2

+ 1
- 0
lower-constraints.txt View File

@@ -116,6 +116,7 @@ python-ironic-inspector-client==1.5.0
116 116
 python-ironicclient==2.3.0
117 117
 python-keystoneclient==3.8.0
118 118
 python-magnumclient==2.1.0
119
+python-manilaclient==1.23.0
119 120
 python-mimeparse==1.6.0
120 121
 python-mistralclient==3.1.0
121 122
 python-muranoclient==0.8.2

+ 1
- 1
mistral/actions/generator_factory.py View File

@@ -21,7 +21,7 @@ SUPPORTED_MODULES = [
21 21
     'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder',
22 22
     'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'SwiftService',
23 23
     'Zaqar', 'Barbican', 'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker',
24
-    'Aodh', 'Gnocchi', 'Glare', 'Vitrage', 'Senlin', 'Zun', 'Qinling'
24
+    'Aodh', 'Gnocchi', 'Glare', 'Vitrage', 'Senlin', 'Zun', 'Qinling', 'Manila'
25 25
 ]
26 26
 
27 27
 

+ 45
- 0
mistral/actions/openstack/actions.py View File

@@ -60,6 +60,9 @@ heatclient = _try_import('heatclient.client')
60 60
 ironic_inspector_client = _try_import('ironic_inspector_client.v1')
61 61
 ironicclient = _try_import('ironicclient.v1.client')
62 62
 keystoneclient = _try_import('keystoneclient.v3.client')
63
+manila = _try_import('manilaclient')
64
+manilaclient = _try_import('manilaclient.client')
65
+manila_api_versions = _try_import('manilaclient.api_versions')
63 66
 magnumclient = _try_import('magnumclient.v1.client')
64 67
 mistralclient = _try_import('mistralclient.api.v2.client')
65 68
 muranoclient = _try_import('muranoclient.v1.client')
@@ -998,3 +1001,45 @@ class QinlingAction(base.OpenStackAction):
998 1001
             endpoint_override="http://127.0.0.1:7070/",
999 1002
             session=session
1000 1003
         )
1004
+
1005
+
1006
+class ManilaAction(base.OpenStackAction):
1007
+    _service_type = 'sharev2'
1008
+
1009
+    @classmethod
1010
+    def _get_client_class(cls):
1011
+        return manilaclient.Client
1012
+
1013
+    def _create_client(self, context):
1014
+
1015
+        LOG.debug("Manila action security context: %s", context)
1016
+
1017
+        manila_endpoint = self.get_service_endpoint()
1018
+
1019
+        session_and_auth = self.get_session_and_auth(context)
1020
+
1021
+        temp_client = self._get_client_class()(
1022
+            manila.API_MAX_VERSION,
1023
+            service_catalog_url=manila_endpoint.url,
1024
+            session=session_and_auth['auth']
1025
+        )
1026
+
1027
+        discovered_version = manila_api_versions.discover_version(
1028
+            temp_client,
1029
+            manila.API_MAX_VERSION
1030
+        )
1031
+
1032
+        client = self._get_client_class()(
1033
+            discovered_version,
1034
+            service_catalog_url=manila_endpoint.url,
1035
+            session=session_and_auth['session']
1036
+        )
1037
+
1038
+        return client
1039
+
1040
+    @classmethod
1041
+    def _get_fake_client(cls):
1042
+        return cls._get_client_class()(
1043
+            manila.API_MAX_VERSION,
1044
+            input_auth_token='token',
1045
+            service_catalog_url='http://127.0.0.1:8786')

+ 168
- 0
mistral/actions/openstack/mapping.json View File

@@ -1349,5 +1349,173 @@
1349 1349
         "webhooks_get": "webhooks.get",
1350 1350
         "webhooks_update": "webhooks.update",
1351 1351
         "webhooks_delete": "webhooks.delete"
1352
+    },
1353
+    "manila": {
1354
+        "_comment": "It uses manilaclient.v2.",
1355
+        "availability_zones_list": "availability_zones.list",
1356
+        "limits_get": "limits.get",
1357
+        "messages_delete": "messages.delete",
1358
+        "messages_find": "messages.find",
1359
+        "messages_findall": "messages.findall",
1360
+        "messages_get": "messages.get",
1361
+        "messages_list": "messages.list",
1362
+        "pools_list": "pools.list",
1363
+        "quota_classes_find": "quota_classes.find",
1364
+        "quota_classes_findall": "quota_classes.findall",
1365
+        "quota_classes_get": "quota_classes.get",
1366
+        "quota_classes_list": "quota_classes.list",
1367
+        "quota_classes_update": "quota_classes.update",
1368
+        "quotas_defaults": "quotas.defaults",
1369
+        "quotas_delete": "quotas.delete",
1370
+        "quotas_find": "quotas.find",
1371
+        "quotas_findall": "quotas.findall",
1372
+        "quotas_get": "quotas.get",
1373
+        "quotas_list": "quotas.list",
1374
+        "quotas_update": "quotas.update",
1375
+        "security_services_create": "security_services.create",
1376
+        "security_services_delete": "security_services.delete",
1377
+        "security_services_find": "security_services.find",
1378
+        "security_services_findall": "security_services.findall",
1379
+        "security_services_get": "security_services.get",
1380
+        "security_services_list": "security_services.list",
1381
+        "security_services_update": "security_services.update",
1382
+        "services_disable": "services.disable",
1383
+        "services_enable": "services.enable",
1384
+        "services_list": "services.list",
1385
+        "services_server_api_version": "services.server_api_version",
1386
+        "share_export_locations_find": "share_export_locations.find",
1387
+        "share_export_locations_findall": "share_export_locations.findall",
1388
+        "share_export_locations_get": "share_export_locations.get",
1389
+        "share_export_locations_list": "share_export_locations.list",
1390
+        "share_group_snapshots_create": "share_group_snapshots.create",
1391
+        "share_group_snapshots_delete": "share_group_snapshots.delete",
1392
+        "share_group_snapshots_find": "share_group_snapshots.find",
1393
+        "share_group_snapshots_findall": "share_group_snapshots.findall",
1394
+        "share_group_snapshots_get": "share_group_snapshots.get",
1395
+        "share_group_snapshots_list": "share_group_snapshots.list",
1396
+        "share_group_snapshots_reset_state": "share_group_snapshots.reset_state",
1397
+        "share_group_snapshots_update": "share_group_snapshots.update",
1398
+        "share_group_type_access_add_project_access": "share_group_type_access.add_project_access",
1399
+        "share_group_type_access_find": "share_group_type_access.find",
1400
+        "share_group_type_access_findall": "share_group_type_access.findall",
1401
+        "share_group_type_access_list": "share_group_type_access.list",
1402
+        "share_group_type_access_remove_project_access": "share_group_type_access.remove_project_access",
1403
+        "share_group_types_create": "share_group_types.create",
1404
+        "share_group_types_delete": "share_group_types.delete",
1405
+        "share_group_types_find": "share_group_types.find",
1406
+        "share_group_types_findall": "share_group_types.findall",
1407
+        "share_group_types_get": "share_group_types.get",
1408
+        "share_group_types_list": "share_group_types.list",
1409
+        "share_groups_create": "share_groups.create",
1410
+        "share_groups_delete": "share_groups.delete",
1411
+        "share_groups_find": "share_groups.find",
1412
+        "share_groups_findall": "share_groups.findall",
1413
+        "share_groups_get": "share_groups.get",
1414
+        "share_groups_list": "share_groups.list",
1415
+        "share_groups_reset_state": "share_groups.reset_state",
1416
+        "share_groups_update": "share_groups.update",
1417
+        "share_instance_export_locations_find": "share_instance_export_locations.find",
1418
+        "share_instance_export_locations_findall": "share_instance_export_locations.findall",
1419
+        "share_instance_export_locations_get": "share_instance_export_locations.get",
1420
+        "share_instance_export_locations_list": "share_instance_export_locations.list",
1421
+        "share_instances_do_list": "share_instances.do_list",
1422
+        "share_instances_find": "share_instances.find",
1423
+        "share_instances_findall": "share_instances.findall",
1424
+        "share_instances_force_delete": "share_instances.force_delete",
1425
+        "share_instances_get": "share_instances.get",
1426
+        "share_instances_list": "share_instances.list",
1427
+        "share_instances_reset_state": "share_instances.reset_state",
1428
+        "share_networks_add_security_service": "share_networks.add_security_service",
1429
+        "share_networks_create": "share_networks.create",
1430
+        "share_networks_delete": "share_networks.delete",
1431
+        "share_networks_find": "share_networks.find",
1432
+        "share_networks_findall": "share_networks.findall",
1433
+        "share_networks_get": "share_networks.get",
1434
+        "share_networks_list": "share_networks.list",
1435
+        "share_networks_remove_security_service": "share_networks.remove_security_service",
1436
+        "share_networks_update": "share_networks.update",
1437
+        "share_replicas_create": "share_replicas.create",
1438
+        "share_replicas_delete": "share_replicas.delete",
1439
+        "share_replicas_find": "share_replicas.find",
1440
+        "share_replicas_findall": "share_replicas.findall",
1441
+        "share_replicas_get": "share_replicas.get",
1442
+        "share_replicas_list": "share_replicas.list",
1443
+        "share_replicas_promote": "share_replicas.promote",
1444
+        "share_replicas_reset_replica_state": "share_replicas.reset_replica_state",
1445
+        "share_replicas_reset_state": "share_replicas.reset_state",
1446
+        "share_replicas_resync": "share_replicas.resync",
1447
+        "share_servers_delete": "share_servers.delete",
1448
+        "share_servers_details": "share_servers.details",
1449
+        "share_servers_find": "share_servers.find",
1450
+        "share_servers_findall": "share_servers.findall",
1451
+        "share_servers_get": "share_servers.get",
1452
+        "share_servers_list": "share_servers.list",
1453
+        "share_snapshot_export_locations_find": "share_snapshot_export_locations.find",
1454
+        "share_snapshot_export_locations_findall": "share_snapshot_export_locations.findall",
1455
+        "share_snapshot_export_locations_get": "share_snapshot_export_locations.get",
1456
+        "share_snapshot_export_locations_list": "share_snapshot_export_locations.list",
1457
+        "share_snapshot_instance_export_locations_find": "share_snapshot_instance_export_locations.find",
1458
+        "share_snapshot_instance_export_locations_findall": "share_snapshot_instance_export_locations.findall",
1459
+        "share_snapshot_instance_export_locations_get": "share_snapshot_instance_export_locations.get",
1460
+        "share_snapshot_instance_export_locations_list": "share_snapshot_instance_export_locations.list",
1461
+        "share_snapshot_instances_find": "share_snapshot_instances.find",
1462
+        "share_snapshot_instances_findall": "share_snapshot_instances.findall",
1463
+        "share_snapshot_instances_get": "share_snapshot_instances.get",
1464
+        "share_snapshot_instances_list": "share_snapshot_instances.list",
1465
+        "share_snapshot_instances_reset_state": "share_snapshot_instances.reset_state",
1466
+        "share_snapshots_access_list": "share_snapshots.access_list",
1467
+        "share_snapshots_allow": "share_snapshots.allow",
1468
+        "share_snapshots_create": "share_snapshots.create",
1469
+        "share_snapshots_delete": "share_snapshots.delete",
1470
+        "share_snapshots_deny": "share_snapshots.deny",
1471
+        "share_snapshots_find": "share_snapshots.find",
1472
+        "share_snapshots_findall": "share_snapshots.findall",
1473
+        "share_snapshots_force_delete": "share_snapshots.force_delete",
1474
+        "share_snapshots_get": "share_snapshots.get",
1475
+        "share_snapshots_list": "share_snapshots.list",
1476
+        "share_snapshots_manage": "share_snapshots.manage",
1477
+        "share_snapshots_reset_state": "share_snapshots.reset_state",
1478
+        "share_snapshots_unmanage": "share_snapshots.unmanage",
1479
+        "share_snapshots_update": "share_snapshots.update",
1480
+        "share_type_access_add_project_access": "share_type_access.add_project_access",
1481
+        "share_type_access_find": "share_type_access.find",
1482
+        "share_type_access_findall": "share_type_access.findall",
1483
+        "share_type_access_list": "share_type_access.list",
1484
+        "share_type_access_remove_project_access": "share_type_access.remove_project_access",
1485
+        "share_types_create": "share_types.create",
1486
+        "share_types_delete": "share_types.delete",
1487
+        "share_types_find": "share_types.find",
1488
+        "share_types_findall": "share_types.findall",
1489
+        "share_types_get": "share_types.get",
1490
+        "share_types_list": "share_types.list",
1491
+        "share_types_show": "share_types.show",
1492
+        "shares_access_list": "shares.access_list",
1493
+        "shares_allow": "shares.allow",
1494
+        "shares_create": "shares.create",
1495
+        "shares_delete": "shares.delete",
1496
+        "shares_delete_metadata": "shares.delete_metadata",
1497
+        "shares_deny": "shares.deny",
1498
+        "shares_do_list": "shares.do_list",
1499
+        "shares_extend": "shares.extend",
1500
+        "shares_find": "shares.find",
1501
+        "shares_findall": "shares.findall",
1502
+        "shares_force_delete": "shares.force_delete",
1503
+        "shares_get": "shares.get",
1504
+        "shares_get_metadata": "shares.get_metadata",
1505
+        "shares_list": "shares.list",
1506
+        "shares_list_instances": "shares.list_instances",
1507
+        "shares_manage": "shares.manage",
1508
+        "shares_migration_cancel": "shares.migration_cancel",
1509
+        "shares_migration_complete": "shares.migration_complete",
1510
+        "shares_migration_get_progress": "shares.migration_get_progress",
1511
+        "shares_migration_start": "shares.migration_start",
1512
+        "shares_reset_state": "shares.reset_state",
1513
+        "shares_reset_task_state": "shares.reset_task_state",
1514
+        "shares_revert_to_snapshot": "shares.revert_to_snapshot",
1515
+        "shares_set_metadata": "shares.set_metadata",
1516
+        "shares_shrink": "shares.shrink",
1517
+        "shares_unmanage": "shares.unmanage",
1518
+        "shares_update": "shares.update",
1519
+        "shares_update_all_metadata": "shares.update_all_metadata"
1352 1520
     }
1353 1521
 }

+ 1
- 0
mistral/tests/unit/actions/openstack/test_generator.py View File

@@ -48,6 +48,7 @@ MODULE_MAPPING = {
48 48
     'barbican': ['barbican.orders_list', actions.BarbicanAction],
49 49
     'mistral': ['mistral.workflows_get', actions.MistralAction],
50 50
     'designate': ['designate.domains_list', actions.DesignateAction],
51
+    'manila': ['manila.shares_list', actions.ManilaAction],
51 52
     'magnum': ['magnum.bays_list', actions.MagnumAction],
52 53
     'murano': ['murano.deployments_list', actions.MuranoAction],
53 54
     'tacker': ['tacker.list_vims', actions.TackerAction],

+ 13
- 0
mistral/tests/unit/actions/openstack/test_openstack_actions.py View File

@@ -389,6 +389,19 @@ class OpenStackActionTest(base.BaseTestCase):
389 389
         self.assertTrue(mocked().runtimes.get.called)
390 390
         mocked().runtimes.get.assert_called_once_with(id="1234-abcd")
391 391
 
392
+    @mock.patch.object(actions.ManilaAction, '_get_client')
393
+    def test_manila_action(self, mocked):
394
+        mock_ctx = mock.Mock()
395
+        method_name = "shares.get"
396
+        action_class = actions.ManilaAction
397
+        action_class.client_method_name = method_name
398
+        params = {'share': '1234-abcd'}
399
+        action = action_class(**params)
400
+        action.run(mock_ctx)
401
+
402
+        self.assertTrue(mocked().shares.get.called)
403
+        mocked().shares.get.assert_called_once_with(share="1234-abcd")
404
+
392 405
 
393 406
 class TestImport(base.BaseTestCase):
394 407
     @mock.patch.object(importutils, 'try_import')

+ 4
- 0
releasenotes/notes/support-manila-action-8af256d5fadd1ac5.yaml View File

@@ -0,0 +1,4 @@
1
+---
2
+features:
3
+  - |
4
+    Add Mistral actions for Openstack Manila, the fileshare management service.

+ 1
- 0
requirements.txt View File

@@ -38,6 +38,7 @@ python-glareclient>=0.3.0 # Apache-2.0
38 38
 python-heatclient>=1.10.0 # Apache-2.0
39 39
 python-keystoneclient>=3.8.0 # Apache-2.0
40 40
 python-mistralclient!=3.2.0,>=3.1.0 # Apache-2.0
41
+python-manilaclient>=1.23.0 # Apache-2.0
41 42
 python-magnumclient>=2.1.0 # Apache-2.0
42 43
 python-muranoclient>=0.8.2 # Apache-2.0
43 44
 python-neutronclient>=6.7.0 # Apache-2.0

+ 12
- 0
tools/get_action_list.py View File

@@ -37,6 +37,8 @@ from keystoneclient import base as keystone_base
37 37
 from keystoneclient.v3 import client as keystoneclient
38 38
 from magnumclient.common import base as magnum_base
39 39
 from magnumclient.v1 import client as magnumclient
40
+from manilaclient import base as manila_base
41
+from manilaclient.v2 import client as manilaclient
40 42
 from mistralclient.api import base as mistral_base
41 43
 from mistralclient.api.v2 import client as mistralclient
42 44
 from muranoclient.common import base as murano_base
@@ -88,6 +90,7 @@ BASE_MISTRAL_MANAGER = mistral_base.ResourceManager
88 90
 BASE_TROVE_MANAGER = trove_base.Manager
89 91
 BASE_IRONIC_MANAGER = ironic_base.Manager
90 92
 BASE_BARBICAN_MANAGER = barbican_base.BaseEntityManager
93
+BASE_MANILA_MANAGER = manila_base.Manager
91 94
 BASE_MAGNUM_MANAGER = magnum_base.Manager
92 95
 BASE_MURANO_MANAGER = murano_base.Manager
93 96
 BASE_AODH_MANAGER = aodh_base.Manager
@@ -211,6 +214,13 @@ def get_glare_client(**kwargs):
211 214
     return glareclient.Client('')
212 215
 
213 216
 
217
+def get_manila_client(**kwargs):
218
+    return manilaclient.Client(
219
+        input_auth_token='token',
220
+        service_catalog_url='http://127.0.0.1:8786'
221
+    )
222
+
223
+
214 224
 CLIENTS = {
215 225
     'nova': get_nova_client,
216 226
     'heat': get_heat_client,
@@ -227,6 +237,7 @@ CLIENTS = {
227 237
     'aodh': get_aodh_client,
228 238
     'gnocchi': get_gnocchi_client,
229 239
     'glare': get_glare_client,
240
+    'manila': get_manila_client,
230 241
     # 'neutron': get_nova_client
231 242
     # 'baremetal_introspection': ...
232 243
     # 'swift': ...
@@ -248,6 +259,7 @@ BASE_MANAGERS = {
248 259
     'aodh': BASE_AODH_MANAGER,
249 260
     'gnocchi': BASE_GNOCCHI_MANAGER,
250 261
     'glare': None,
262
+    'manila': BASE_MANILA_MANAGER,
251 263
     # 'neutron': BASE_NOVA_MANAGER
252 264
     # 'baremetal_introspection': ...
253 265
     # 'swift': ...

Loading…
Cancel
Save