summaryrefslogtreecommitdiff
path: root/heatclient/v1
diff options
context:
space:
mode:
authorzengyingzhe <zengyingzhe@huawei.com>2015-10-23 09:38:41 +0800
committerzengyingzhe <zengyingzhe@huawei.com>2015-11-12 20:10:38 +0800
commit0a42fb8412c35eb4455144e54ead5d13bd623ae0 (patch)
tree78e2482e5473aaba45f36c278d9d9b9236620fa5 /heatclient/v1
parent5aeaf3d57bf8dae3acefe605486b6d8afaeed738 (diff)
downloadpython-heatclient-0a42fb8412c35eb4455144e54ead5d13bd623ae0.tar.gz
Delete the corresponding config when deleting a deployment
Change-Id: I26049a60f8bb5702ede69d46e3a989bd09a2b3af Closes-Bug: #1504384
Diffstat (limited to 'heatclient/v1')
-rw-r--r--heatclient/v1/shell.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py
index 9c76f89..1c84b52 100644
--- a/heatclient/v1/shell.py
+++ b/heatclient/v1/shell.py
@@ -1363,15 +1363,28 @@ def do_deployment_metadata_show(hc, args):
@utils.arg('id', metavar='<ID>', nargs='+',
help=_('IDs of the deployments to delete.'))
def do_deployment_delete(hc, args):
- '''Delete a software deployment.'''
+ '''Delete software deployments.'''
failure_count = 0
for deploy_id in args.id:
try:
+ sd = hc.software_deployments.get(deployment_id=deploy_id)
hc.software_deployments.delete(deployment_id=deploy_id)
- except exc.HTTPNotFound as e:
+ except Exception as e:
+ if isinstance(e, exc.HTTPNotFound):
+ print(_('Deployment with ID %s not found') % deploy_id)
failure_count += 1
- print(e)
+ continue
+
+ # just try best to delete the corresponding config
+ try:
+ config_id = getattr(sd, 'config_id')
+ hc.software_configs.delete(config_id=config_id)
+ except Exception:
+ print(_('Failed to delete the correlative config'
+ ' %(config_id)s of deployment %(deploy_id)s') %
+ {'config_id': config_id, 'deploy_id': deploy_id})
+
if failure_count == len(args.id):
raise exc.CommandError(_("Unable to delete any of the specified "
"deployments."))