Last active
August 29, 2015 14:15
-
-
Save ryancurrah/a5f1ea88ee32a4765a27 to your computer and use it in GitHub Desktop.
Delete Cloud Cruiser Customers by ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| OS packages required: | |
| 1. libxml2-dev (Debian), libxml2-devel (RHEL) | |
| 2. libxslt-dev (Debian), libxslt-devel (RHEL) | |
| 3. python-dev (Debian), python-devel (RHEL) | |
| Python packages required: | |
| 1. lxml | |
| 2. requests | |
| Description: | |
| Deletes customer entries in cloud cruiser using the rest api. | |
| Execution Instructions: | |
| python delete_customers.py | |
| """ | |
| from lxml import objectify | |
| import requests | |
| r = requests.get('http://cloudcruiser.acme.com:8080/rest/v2/customers/summaries', auth=('restuser', 'password')) | |
| result = str(r.text) | |
| main = objectify.fromstring(result) | |
| customer_ids = [] | |
| for child in main.customerSummary: | |
| item = child.items() | |
| customer_ids.append(item[0][1]) | |
| for customer_id in customer_ids: | |
| r = requests.delete('http://cloudcruiser.acme.com:8080/rest/v2/customers/{id}'.format(id=customer_id), auth=('restuser', 'password')) | |
| print "Deleting customer with ID {id}... HTTP result code {http_result}".format(id=customer_id, http_result=r.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment