diff --git a/octavia_dashboard/api/rest/lbaasv2.py b/octavia_dashboard/api/rest/lbaasv2.py index ff8c86cc..10d183c2 100644 --- a/octavia_dashboard/api/rest/lbaasv2.py +++ b/octavia_dashboard/api/rest/lbaasv2.py @@ -653,7 +653,8 @@ class LoadBalancer(generic.View): """ conn = _get_sdk_connection(request) conn.load_balancer.delete_load_balancer(loadbalancer_id, - ignore_missing=True) + ignore_missing=True, + cascade=True) @urls.register diff --git a/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.js b/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.js index d7d7f298..3014e2b8 100644 --- a/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.js +++ b/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.js @@ -28,10 +28,7 @@ '$location', 'horizon.framework.widgets.modal.deleteModalService', 'horizon.app.core.openstack-service-api.lbaasv2', - 'horizon.app.core.openstack-service-api.policy', - 'horizon.framework.widgets.toast.service', - 'horizon.framework.util.i18n.gettext', - 'horizon.framework.util.q.extensions' + 'horizon.app.core.openstack-service-api.policy' ]; /** @@ -50,16 +47,13 @@ * @param deleteModal The horizon delete modal service. * @param api The LBaaS v2 API service. * @param policy The horizon policy service. - * @param toast The horizon message service. - * @param gettext The horizon gettext function for translation. - * @param qExtensions Horizon extensions to the $q service. * * @returns The listeners delete service. */ function deleteService( resourceType, actionResultService, $q, $location, - deleteModal, api, policy, toast, gettext, qExtensions + deleteModal, api, policy ) { var loadbalancerId, scope; var context = { }; @@ -81,7 +75,7 @@ listeners.map(function(item) { loadbalancerId = item.loadbalancerId; }); - return qExtensions.allSettled(listeners.map(checkPermission)).then(afterCheck); + return deleteModal.open(scope, listeners, context).then(deleteResult); } function labelize(count) { @@ -126,35 +120,6 @@ return actionResult.result; } - function checkPermission(item) { - return { promise: canBeDeleted(item), context: item }; - } - - function afterCheck(result) { - if (result.fail.length > 0) { - toast.add('error', getMessage(context.labels.error, result.fail)); - } - if (result.pass.length > 0) { - return deleteModal.open(scope, result.pass.map(getEntity), context).then(deleteResult); - } - } - - function canBeDeleted(item) { - return qExtensions.booleanAsPromise(!item.default_pool_id); - } - - function getMessage(message, entities) { - return interpolate(message, [entities.map(getName).join(", ")]); - } - - function getName(result) { - return getEntity(result).name; - } - - function getEntity(result) { - return result.context; - } - function allowed() { return policy.ifAllowed({ rules: [['load-balancer', 'os_load-balancer_api:listener:delete']] diff --git a/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.spec.js b/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.spec.js index a8671252..6678e721 100644 --- a/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.spec.js +++ b/octavia_dashboard/static/dashboard/project/lbaasv2/listeners/actions/delete/delete.action.service.spec.js @@ -147,18 +147,5 @@ expect(toast.add).toHaveBeenCalledWith('success', 'Deleted Listener: First.'); }); - it('should show message if any selected items do not allow for delete (batch)', function() { - spyOn(modal, 'open'); - spyOn(toast, 'add'); - items[0].default_pool_id = 'pool1'; - items[1].default_pool_id = 'pool2'; - service.perform(items, $scope); - $scope.$apply(); - expect(modal.open).not.toHaveBeenCalled(); - expect(toast.add).toHaveBeenCalledWith('error', - 'Unable to delete Listeners' + - ': First, Second.'); - }); - }); })(); diff --git a/octavia_dashboard/static/dashboard/project/lbaasv2/loadbalancers/actions/delete/delete.action.service.js b/octavia_dashboard/static/dashboard/project/lbaasv2/loadbalancers/actions/delete/delete.action.service.js index d770c5af..e4e6c3bc 100644 --- a/octavia_dashboard/static/dashboard/project/lbaasv2/loadbalancers/actions/delete/delete.action.service.js +++ b/octavia_dashboard/static/dashboard/project/lbaasv2/loadbalancers/actions/delete/delete.action.service.js @@ -88,8 +88,10 @@ 'Confirm Delete Load Balancers', count), message: ngettext( - 'You have selected "%s". Deleted load balancer is not recoverable.', - 'You have selected "%s". Deleted load balancers are not recoverable.', count), + 'You have selected "%s". Deleted load balancer is not recoverable ' + + 'and this deletion will delete all of the sub-resources.', + 'You have selected "%s". Deleted load balancers are not recoverable ' + + 'and this deletion will delete all of the sub-resources.', count), submit: ngettext( 'Delete Load Balancer', diff --git a/releasenotes/notes/cascade-delete-e4c9d80a31076540.yaml b/releasenotes/notes/cascade-delete-e4c9d80a31076540.yaml new file mode 100644 index 00000000..e895d194 --- /dev/null +++ b/releasenotes/notes/cascade-delete-e4c9d80a31076540.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Allow cascade deletion of load balancer. +other: + - | + This changed the default behavior of load balancer deletion from + non-cascade deletion to cascade deletion.