Allow cascade deletion of load balancer
Change-Id: I44efaa5156098b66c6542667d3c7dfb00cda1d01 Story: 1713849 Task: 5364
This commit is contained in:
parent
f4baef6848
commit
72f8ff16eb
@ -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
|
||||
|
@ -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']]
|
||||
|
@ -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.');
|
||||
});
|
||||
|
||||
});
|
||||
})();
|
||||
|
@ -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',
|
||||
|
8
releasenotes/notes/cascade-delete-e4c9d80a31076540.yaml
Normal file
8
releasenotes/notes/cascade-delete-e4c9d80a31076540.yaml
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user