install_finished = True exit else: print ('there are some clusters/hosts in installing. \r\nsleep 10 seconds and retry') time.sleep(2.0) if __name__ == '__main__': COMPASS_SERVER_URL="http://10.1.0.12/api" COMPASS_USER_EMAIL="*****@*****.**" COMPASS_USER_PASSWORD="******" logsetting.init() client = Client(COMPASS_SERVER_URL) _login(client,COMPASS_USER_EMAIL,COMPASS_USER_PASSWORD) status, resp = client.list_hosts() #print '\r\nget all hosts status: %s resp\r\n' % (status) #print json.dumps(resp,indent=2) if status >= 400: msg = 'failed to get subnets' raise Exception(msg) host_mapping = {} for host in resp: host_mapping[host['hostname']] = host['id'] print '\r\nget hostmapping: %s \r\n' % (host_mapping) status, resp = client.list_clusters() #print '\r\nget all cluster status: %s resp: \r\n' % (status) #print json.dumps(resp,indent=2) if status >= 400: msg = 'failed to get subnets'