diff --git a/AUTHORS b/AUTHORS index b2a76461..a532d8fc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -41,6 +41,7 @@ Nikolay Mahotkin Noa Koffman Oleksii Chuprykov Pierre-Arthur MATHIEU +Ravikiran Kommalapati Ray Chen Renat Akhmerov Renat Akhmerov diff --git a/mistral/actions/generator_factory.py b/mistral/actions/generator_factory.py index 1a071c9e..1d4b5fcb 100644 --- a/mistral/actions/generator_factory.py +++ b/mistral/actions/generator_factory.py @@ -20,7 +20,7 @@ from mistral.actions.openstack.action_generator import base SUPPORTED_MODULES = [ 'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder', 'Ceilometer', 'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'Zaqar', 'Barbican', - 'Mistral' + 'Mistral', 'Designate' ] diff --git a/mistral/actions/openstack/actions.py b/mistral/actions/openstack/actions.py index 71dcb174..2255845f 100644 --- a/mistral/actions/openstack/actions.py +++ b/mistral/actions/openstack/actions.py @@ -17,6 +17,7 @@ import functools from barbicanclient import client as barbicanclient from ceilometerclient.v2 import client as ceilometerclient from cinderclient.v2 import client as cinderclient +from designateclient import client as designateclient from glanceclient.v2 import client as glanceclient from heatclient.v1 import client as heatclient from ironic_inspector_client import v1 as ironic_inspector_client @@ -570,3 +571,39 @@ class BarbicanAction(base.OpenStackAction): entity.store() return entity._get_formatted_entity() + + +class DesignateAction(base.OpenStackAction): + _client_class = designateclient.Client + + def _get_client(self): + ctx = context.ctx() + + LOG.debug("Designate action security context: %s" % ctx) + + designate_endpoint = keystone_utils.get_endpoint_for_project( + service_type='dns' + ) + + designate_url = keystone_utils.format_url( + designate_endpoint.url, + {'tenant_id': ctx.project_id} + ) + + client = self._client_class( + 1, + ctx.user_name, + ctx.auth_token, + project_id=ctx.project_id, + auth_url=designate_url, + region_name=designate_endpoint.region + ) + + client.client.auth_token = ctx.auth_token + client.client.management_url = designate_url + + return client + + @classmethod + def _get_fake_client(cls): + return cls._client_class() diff --git a/mistral/actions/openstack/mapping.json b/mistral/actions/openstack/mapping.json index 8de8c7fc..55914012 100644 --- a/mistral/actions/openstack/mapping.json +++ b/mistral/actions/openstack/mapping.json @@ -1084,5 +1084,38 @@ "workflows_list": "workflows.list", "workflows_update": "workflows.update", "workflows_validate": "workflows.validate" + }, + "designate": { + "_comment": "It uses designateclient.v1.", + "diagnostics_ping": "diagnostics.ping", + "domain_create ": "domain.create", + "domain_delete": "domain.delete", + "domain_get": "domain.get", + "domain_list": "domain.list", + "domain_servers_list": "domain.servers_list", + "domain_update": "domain.update", + "quota_get": "quota.get", + "quota_reset": "quota.reset", + "quota_update": "quota.update", + "record_create": "record.create", + "record_delete": "record.delete", + "record_get": "record.get", + "record_list": "record.list", + "record_update": "record.update", + "report_count_all": "report.count_all", + "report_count_domains": "report.count_domains", + "report_count_records": "report.count_records", + "report_count_tenants": "report.count_tenats", + "report_tenant_domains": "report.tenant_domains", + "report_tenants_all": "report.tenant_all", + "server_create": "server.create", + "server_delete": "server.delete", + "server_get": "server.get", + "server_list": "server.list", + "server_update": "server.update", + "sync_all": "sync.all", + "sync_domain": "sync.domain", + "sync_record": "sync.record", + "touch_domain": "touch.domain" } } diff --git a/mistral/tests/unit/actions/openstack/test_generator.py b/mistral/tests/unit/actions/openstack/test_generator.py index 719d062d..c0640651 100644 --- a/mistral/tests/unit/actions/openstack/test_generator.py +++ b/mistral/tests/unit/actions/openstack/test_generator.py @@ -32,6 +32,7 @@ MODULE_MAPPING = { 'zaqar': ['zaqar.queue_messages', actions.ZaqarAction], 'barbican': ['barbican.orders_list', actions.BarbicanAction], 'mistral': ['mistral.workflows_get', actions.MistralAction], + 'designate': ['designate.domain_list', actions.DesignateAction], } EXTRA_MODULES = ['neutron', 'swift', 'zaqar'] diff --git a/mistral/tests/unit/actions/openstack/test_openstack_actions.py b/mistral/tests/unit/actions/openstack/test_openstack_actions.py index 3bc65ba5..3108cf2c 100644 --- a/mistral/tests/unit/actions/openstack/test_openstack_actions.py +++ b/mistral/tests/unit/actions/openstack/test_openstack_actions.py @@ -187,3 +187,15 @@ class OpenStackActionTest(base.BaseTestCase): self.assertTrue(mocked().orders_list.called) mocked().orders_list.assert_called_once_with(limit=5) + + @mock.patch.object(actions.DesignateAction, '_get_client') + def test_designate_action(self, mocked): + method_name = "domain.get" + action_class = actions.DesignateAction + action_class.client_method_name = method_name + params = {'domain': 'example.com'} + action = action_class(**params) + action.run() + + self.assertTrue(mocked().domain.get.called) + mocked().domain.get.assert_called_once_with(domain="example.com") diff --git a/requirements.txt b/requirements.txt index e05fe1da..938dbd6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,6 +25,7 @@ pecan>=1.0.0 # BSD python-barbicanclient>=4.0.0 # Apache-2.0 python-ceilometerclient>=2.2.1 # Apache-2.0 python-cinderclient>=1.6.0 # Apache-2.0 +python-designateclient>=1.5.0 # Apache-2.0 python-glanceclient>=2.0.0 # Apache-2.0 python-heatclient>=0.6.0 # Apache-2.0 python-keystoneclient!=1.8.0,!=2.1.0,>=1.6.0 # Apache-2.0 diff --git a/tools/get_action_list.py b/tools/get_action_list.py index 96915516..eea0cf0a 100644 --- a/tools/get_action_list.py +++ b/tools/get_action_list.py @@ -23,6 +23,7 @@ from barbicanclient import client as barbicanclient from ceilometerclient.v2 import client as ceilometerclient from cinderclient.openstack.common.apiclient import base as cinder_base from cinderclient.v2 import client as cinderclient +from designateclient import client as designateclient from glanceclient.v2 import client as glanceclient from heatclient.openstack.common.apiclient import base as heat_base from heatclient.v1 import client as heatclient @@ -127,6 +128,11 @@ CEILOMETER_NAMESPACE_LIST = [ 'resources', 'samples', 'statistics', 'trait_descriptions', 'traits' ] +DESIGNATE_NAMESPACE_LIST = [ + 'diagnostics', 'domain', 'quota', 'record', 'report_count', + 'report_tenant', 'server', 'sync', 'touch' +] + def get_nova_client(**kwargs): return novaclient.Client(2) @@ -171,6 +177,10 @@ def get_barbican_client(**kwargs): ) +def get_designate_client(**kwargs): + return designateclient.Client(1) + + CLIENTS = { 'nova': get_nova_client, 'heat': get_heat_client, @@ -182,6 +192,7 @@ CLIENTS = { 'ironic': get_ironic_client, 'barbican': get_barbican_client, 'mistral': get_mistral_client, + 'designate': get_designate_client # 'neutron': get_nova_client # 'baremetal_introspection': ... # 'swift': ... @@ -198,6 +209,7 @@ BASE_MANAGERS = { 'ironic': BASE_IRONIC_MANAGER, 'barbican': BASE_BARBICAN_MANAGER, 'mistral': BASE_MISTRAL_MANAGER, + 'designate': None, # 'neutron': BASE_NOVA_MANAGER # 'baremetal_introspection': ... # 'swift': ... @@ -205,7 +217,8 @@ BASE_MANAGERS = { } NAMESPACES = { 'glance': GLANCE_NAMESPACE_LIST, - 'ceilometer': CEILOMETER_NAMESPACE_LIST + 'ceilometer': CEILOMETER_NAMESPACE_LIST, + 'designate': DESIGNATE_NAMESPACE_LIST } ALLOWED_ATTRS = ['service_catalog', 'catalog'] FORBIDDEN_METHODS = [