Skip to content

Instantly share code, notes, and snippets.

@tamirko
Created April 12, 2016 08:47
Show Gist options
  • Save tamirko/94139dcc4b9fc3fa534ed53f91bdf163 to your computer and use it in GitHub Desktop.
Save tamirko/94139dcc4b9fc3fa534ed53f91bdf163 to your computer and use it in GitHub Desktop.
How to delete a Cloudify deployment
#!/usr/bin/env python
import sys
from cloudify_rest_client.executions import Execution
from cloudify_cli.utils import get_rest_client
client = get_rest_client()
deployment_id = sys.argv[1]
print 'Canceling bad executions for deployment {0}'.format(deployment_id)
for execution in client.executions.list(deployment_id=deployment_id):
if execution.status not in Execution.END_STATES:
print 'Updating execution {0} to state {1}'.format(execution.id, Execution.CANCELLED)
client.executions.update(execution.id, Execution.CANCELLED)
print 'Deleting deployment: {0}'.format(deployment_id)
client.deployments.delete(deployment_id)
print 'Deployment deleted successfully'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment