def get_host_id(name):
s = requests.Session()
url = tower_base_url+"hosts/"
headers = {
'content-type': "application/json"
}
querystring = {"name": name}
response = s.request("GET", url, headers=headers, params=querystring, verify=False,
auth=HTTPBasicAuth(args.tower_username, args.tower_password))
results = response.json()['results']
if len(results) < 1:
print("No host found with that name.")
sys.exit(1)
elif len(results) > 1:
print("Multiple hosts found with that name, so I won't remove any of them.")
sys.exit(1)
else:
return results[0]['id']
tower-server-registration.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录