class DecomissionHosts: def __init__(self): print('Decommission Hosts') self.utils = Utils(sys.argv) self.hostname = sys.argv[1] def decommission_hosts(self): decommission_url = 'https://'+self.hostname+'/v1/hosts' payload = self.utils.read_input(os.path.abspath(__file__ +'/../')+'/decommission_hosts_spec.json') print ('Decommissioning hosts...') response = self.utils.delete_request(payload,decommission_url) pprint.pprint(response) task_id = response['id'] task_url = 'https://'+self.hostname+'/v1/tasks/'+task_id print ('Decommissioning of hosts is ' + self.utils.poll_on_id(task_url,True))
class DeleteCluster: def __init__(self): print('Delete Cluster') self.utils = Utils(sys.argv) self.hostname = sys.argv[1] self.cluster_id = sys.argv[4] def delete_cluster(self): data = {"markForDeletion": True} delete_cluster_url = 'https://' + self.hostname + '/v1/clusters/' + self.cluster_id self.utils.patch_request(data, delete_cluster_url) response = self.utils.delete_request({}, delete_cluster_url) task_id = response['id'] task_url = 'https://' + self.hostname + '/v1/tasks/' + task_id print("Cluster deletion Status:" + self.utils.poll_on_id(task_url, True))
class DeleteDomain: def __init__(self): print('Delete Domain') self.utils = Utils(sys.argv) self.hostname = sys.argv[1] self.domain_id = sys.argv[4] def delete_domain(self): data = {"markForDeletion": True} delete_domain_url = 'https://' + self.hostname + '/v1/domains/' + self.domain_id self.utils.patch_request(data, delete_domain_url) response = self.utils.delete_request({}, delete_domain_url) print("Deleting Domain ...") task_id = response['id'] tasks_url = 'https://' + self.hostname + '/v1/tasks/' + task_id print("Domain deletion Status:" + self.utils.poll_on_id(tasks_url, True))