diff --git a/poppy/distributed_task/taskflow/flow/delete_service.py b/poppy/distributed_task/taskflow/flow/delete_service.py index b88daf08..b3e28b49 100644 --- a/poppy/distributed_task/taskflow/flow/delete_service.py +++ b/poppy/distributed_task/taskflow/flow/delete_service.py @@ -45,6 +45,9 @@ def delete_service(): linear_flow.Flow('Delete service storage operation').add( common.UpdateProviderDetailIfNotEmptyTask( rebind=['provider_details_dict']), - delete_service_tasks.DeleteStorageServiceTask()) + delete_service_tasks.DeleteStorageServiceTask()), + linear_flow.Flow('Delete san certificates for service').add( + delete_service_tasks.DeleteCertificatesForServiceSanDomains() + ) ) return flow diff --git a/poppy/distributed_task/taskflow/task/delete_service_tasks.py b/poppy/distributed_task/taskflow/task/delete_service_tasks.py index 99cd4c58..fab25df6 100644 --- a/poppy/distributed_task/taskflow/task/delete_service_tasks.py +++ b/poppy/distributed_task/taskflow/task/delete_service_tasks.py @@ -19,9 +19,11 @@ import json import time from oslo_config import cfg +from oslo_context import context as context_utils from oslo_log import log from taskflow import task +from poppy.distributed_task.taskflow.flow import delete_ssl_certificate from poppy.distributed_task.taskflow.task import common from poppy.distributed_task.utils import exc_loader from poppy.distributed_task.utils import memoized_controllers @@ -214,3 +216,34 @@ class DeleteStorageServiceTask(task.Task): LOG.info('Cassandra session being shutdown') except AttributeError: LOG.info('Cassandra session already shutdown') + + +class DeleteCertificatesForServiceSanDomains(task.Task): + + def execute(self, project_id, service_id): + service_controller, self.storage_controller = \ + memoized_controllers.task_controllers('poppy', 'storage') + + service_obj = self.storage_controller.get_service( + project_id, + service_id + ) + + kwargs = { + 'project_id': project_id, + 'cert_type': 'san', + 'context_dict': context_utils.get_current().to_dict() + } + + for domain in service_obj.domains: + if domain.protocol == 'https' and domain.certificate == 'san': + kwargs["domain"] = domain.domain + LOG.info( + "Delete service submit task san_cert deletion {0}".format( + domain.domain + ) + ) + service_controller.distributed_task_controller.submit_task( + delete_ssl_certificate.delete_ssl_certificate, + **kwargs + ) diff --git a/tests/unit/distributed_task/taskflow/test_flows.py b/tests/unit/distributed_task/taskflow/test_flows.py index f739fd75..ea91db20 100644 --- a/tests/unit/distributed_task/taskflow/test_flows.py +++ b/tests/unit/distributed_task/taskflow/test_flows.py @@ -522,6 +522,10 @@ class TestFlowRuns(base.TestCase): self.patch_delete_flow(service_controller, storage_controller, dns_controller) + + service_mock = mock.Mock() + type(service_mock).domains = [] + storage_controller.get_service.return_value = service_mock dns_controller.delete = mock.Mock() dns_controller.delete._mock_return_value = { 'cdn_provider': {