tower-server-registration.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:cloudcenter-content 作者: datacenter 项目源码 文件源码
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']
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号