summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Castro Leon <jose.castro.leon@cern.ch>2018-07-24 12:00:47 +0200
committerJose Castro Leon <jose.castro.leon@cern.ch>2018-07-24 15:11:08 +0200
commita2756a34c2638a202c99d960f6c1f86e48c7b626 (patch)
tree7f59e21f3ac3b52f39efa7091b5fbfd93ce68e82
parent8806b5b7d894560a69ce6e709187e2b83d03e075 (diff)
Support Manila actions in Mistral
Adds manila actions into the available list of actions for mistral Change-Id: Ic0a3c24f72d91a8a87ffcf81db763058bcbf8566 Closes-Bug: #1783291
Notes
Notes (review): Code-Review+2: Dougal Matthews <dougal@redhat.com> Code-Review+2: Renat Akhmerov <renat.akhmerov@gmail.com> Workflow+1: Renat Akhmerov <renat.akhmerov@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 31 Jul 2018 11:30:40 +0000 Reviewed-on: https://review.openstack.org/585199 Project: openstack/mistral Branch: refs/heads/master
-rw-r--r--lower-constraints.txt1
-rw-r--r--mistral/actions/generator_factory.py2
-rw-r--r--mistral/actions/openstack/actions.py45
-rw-r--r--mistral/actions/openstack/mapping.json168
-rw-r--r--mistral/tests/unit/actions/openstack/test_generator.py1
-rw-r--r--mistral/tests/unit/actions/openstack/test_openstack_actions.py13
-rw-r--r--releasenotes/notes/support-manila-action-8af256d5fadd1ac5.yaml4
-rw-r--r--requirements.txt1
-rw-r--r--tools/get_action_list.py12
9 files changed, 246 insertions, 1 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 5f6425d..30730cf 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -116,6 +116,7 @@ python-ironic-inspector-client==1.5.0
116python-ironicclient==2.3.0 116python-ironicclient==2.3.0
117python-keystoneclient==3.8.0 117python-keystoneclient==3.8.0
118python-magnumclient==2.1.0 118python-magnumclient==2.1.0
119python-manilaclient==1.23.0
119python-mimeparse==1.6.0 120python-mimeparse==1.6.0
120python-mistralclient==3.1.0 121python-mistralclient==3.1.0
121python-muranoclient==0.8.2 122python-muranoclient==0.8.2
diff --git a/mistral/actions/generator_factory.py b/mistral/actions/generator_factory.py
index 45d1eee..f7f6a9e 100644
--- a/mistral/actions/generator_factory.py
+++ b/mistral/actions/generator_factory.py
@@ -21,7 +21,7 @@ SUPPORTED_MODULES = [
21 'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder', 21 'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder',
22 'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'SwiftService', 22 'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'SwiftService',
23 'Zaqar', 'Barbican', 'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker', 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
diff --git a/mistral/actions/openstack/actions.py b/mistral/actions/openstack/actions.py
index 9426c3e..be28113 100644
--- a/mistral/actions/openstack/actions.py
+++ b/mistral/actions/openstack/actions.py
@@ -60,6 +60,9 @@ heatclient = _try_import('heatclient.client')
60ironic_inspector_client = _try_import('ironic_inspector_client.v1') 60ironic_inspector_client = _try_import('ironic_inspector_client.v1')
61ironicclient = _try_import('ironicclient.v1.client') 61ironicclient = _try_import('ironicclient.v1.client')
62keystoneclient = _try_import('keystoneclient.v3.client') 62keystoneclient = _try_import('keystoneclient.v3.client')
63manila = _try_import('manilaclient')
64manilaclient = _try_import('manilaclient.client')
65manila_api_versions = _try_import('manilaclient.api_versions')
63magnumclient = _try_import('magnumclient.v1.client') 66magnumclient = _try_import('magnumclient.v1.client')
64mistralclient = _try_import('mistralclient.api.v2.client') 67mistralclient = _try_import('mistralclient.api.v2.client')
65muranoclient = _try_import('muranoclient.v1.client') 68muranoclient = _try_import('muranoclient.v1.client')
@@ -998,3 +1001,45 @@ class QinlingAction(base.OpenStackAction):
998 endpoint_override="http://127.0.0.1:7070/", 1001 endpoint_override="http://127.0.0.1:7070/",
999 session=session 1002 session=session
1000 ) 1003 )
1004
1005
1006class 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')
diff --git a/mistral/actions/openstack/mapping.json b/mistral/actions/openstack/mapping.json
index 46af041..5cbe712 100644
--- a/mistral/actions/openstack/mapping.json
+++ b/mistral/actions/openstack/mapping.json
@@ -1349,5 +1349,173 @@
1349 "webhooks_get": "webhooks.get", 1349 "webhooks_get": "webhooks.get",
1350 "webhooks_update": "webhooks.update", 1350 "webhooks_update": "webhooks.update",
1351 "webhooks_delete": "webhooks.delete" 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}
diff --git a/mistral/tests/unit/actions/openstack/test_generator.py b/mistral/tests/unit/actions/openstack/test_generator.py
index 02d198e..294e20b 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 = {
48 'barbican': ['barbican.orders_list', actions.BarbicanAction], 48 'barbican': ['barbican.orders_list', actions.BarbicanAction],
49 'mistral': ['mistral.workflows_get', actions.MistralAction], 49 'mistral': ['mistral.workflows_get', actions.MistralAction],
50 'designate': ['designate.domains_list', actions.DesignateAction], 50 'designate': ['designate.domains_list', actions.DesignateAction],
51 'manila': ['manila.shares_list', actions.ManilaAction],
51 'magnum': ['magnum.bays_list', actions.MagnumAction], 52 'magnum': ['magnum.bays_list', actions.MagnumAction],
52 'murano': ['murano.deployments_list', actions.MuranoAction], 53 'murano': ['murano.deployments_list', actions.MuranoAction],
53 'tacker': ['tacker.list_vims', actions.TackerAction], 54 '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 9af8903..3b3f214 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):
389 self.assertTrue(mocked().runtimes.get.called) 389 self.assertTrue(mocked().runtimes.get.called)
390 mocked().runtimes.get.assert_called_once_with(id="1234-abcd") 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
393class TestImport(base.BaseTestCase): 406class TestImport(base.BaseTestCase):
394 @mock.patch.object(importutils, 'try_import') 407 @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 0000000..379d019
--- /dev/null
+++ b/releasenotes/notes/support-manila-action-8af256d5fadd1ac5.yaml
@@ -0,0 +1,4 @@
1---
2features:
3 - |
4 Add Mistral actions for Openstack Manila, the fileshare management service.
diff --git a/requirements.txt b/requirements.txt
index ac35e08..7fbac3f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -38,6 +38,7 @@ python-glareclient>=0.3.0 # Apache-2.0
38python-heatclient>=1.10.0 # Apache-2.0 38python-heatclient>=1.10.0 # Apache-2.0
39python-keystoneclient>=3.8.0 # Apache-2.0 39python-keystoneclient>=3.8.0 # Apache-2.0
40python-mistralclient!=3.2.0,>=3.1.0 # Apache-2.0 40python-mistralclient!=3.2.0,>=3.1.0 # Apache-2.0
41python-manilaclient>=1.23.0 # Apache-2.0
41python-magnumclient>=2.1.0 # Apache-2.0 42python-magnumclient>=2.1.0 # Apache-2.0
42python-muranoclient>=0.8.2 # Apache-2.0 43python-muranoclient>=0.8.2 # Apache-2.0
43python-neutronclient>=6.7.0 # Apache-2.0 44python-neutronclient>=6.7.0 # Apache-2.0
diff --git a/tools/get_action_list.py b/tools/get_action_list.py
index 62c2f5b..c8f8f8f 100644
--- a/tools/get_action_list.py
+++ b/tools/get_action_list.py
@@ -37,6 +37,8 @@ from keystoneclient import base as keystone_base
37from keystoneclient.v3 import client as keystoneclient 37from keystoneclient.v3 import client as keystoneclient
38from magnumclient.common import base as magnum_base 38from magnumclient.common import base as magnum_base
39from magnumclient.v1 import client as magnumclient 39from magnumclient.v1 import client as magnumclient
40from manilaclient import base as manila_base
41from manilaclient.v2 import client as manilaclient
40from mistralclient.api import base as mistral_base 42from mistralclient.api import base as mistral_base
41from mistralclient.api.v2 import client as mistralclient 43from mistralclient.api.v2 import client as mistralclient
42from muranoclient.common import base as murano_base 44from muranoclient.common import base as murano_base
@@ -88,6 +90,7 @@ BASE_MISTRAL_MANAGER = mistral_base.ResourceManager
88BASE_TROVE_MANAGER = trove_base.Manager 90BASE_TROVE_MANAGER = trove_base.Manager
89BASE_IRONIC_MANAGER = ironic_base.Manager 91BASE_IRONIC_MANAGER = ironic_base.Manager
90BASE_BARBICAN_MANAGER = barbican_base.BaseEntityManager 92BASE_BARBICAN_MANAGER = barbican_base.BaseEntityManager
93BASE_MANILA_MANAGER = manila_base.Manager
91BASE_MAGNUM_MANAGER = magnum_base.Manager 94BASE_MAGNUM_MANAGER = magnum_base.Manager
92BASE_MURANO_MANAGER = murano_base.Manager 95BASE_MURANO_MANAGER = murano_base.Manager
93BASE_AODH_MANAGER = aodh_base.Manager 96BASE_AODH_MANAGER = aodh_base.Manager
@@ -211,6 +214,13 @@ def get_glare_client(**kwargs):
211 return glareclient.Client('') 214 return glareclient.Client('')
212 215
213 216
217def 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
214CLIENTS = { 224CLIENTS = {
215 'nova': get_nova_client, 225 'nova': get_nova_client,
216 'heat': get_heat_client, 226 'heat': get_heat_client,
@@ -227,6 +237,7 @@ CLIENTS = {
227 'aodh': get_aodh_client, 237 'aodh': get_aodh_client,
228 'gnocchi': get_gnocchi_client, 238 'gnocchi': get_gnocchi_client,
229 'glare': get_glare_client, 239 'glare': get_glare_client,
240 'manila': get_manila_client,
230 # 'neutron': get_nova_client 241 # 'neutron': get_nova_client
231 # 'baremetal_introspection': ... 242 # 'baremetal_introspection': ...
232 # 'swift': ... 243 # 'swift': ...
@@ -248,6 +259,7 @@ BASE_MANAGERS = {
248 'aodh': BASE_AODH_MANAGER, 259 'aodh': BASE_AODH_MANAGER,
249 'gnocchi': BASE_GNOCCHI_MANAGER, 260 'gnocchi': BASE_GNOCCHI_MANAGER,
250 'glare': None, 261 'glare': None,
262 'manila': BASE_MANILA_MANAGER,
251 # 'neutron': BASE_NOVA_MANAGER 263 # 'neutron': BASE_NOVA_MANAGER
252 # 'baremetal_introspection': ... 264 # 'baremetal_introspection': ...
253 # 'swift': ... 265 # 'swift': ...