tear_down.py 文件源码

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

项目:krafters 作者: GianlucaBortoli 项目源码 文件源码
def tear_down_gce_cluster(conf):
    credentials = GoogleCredentials.get_application_default()
    gce = discovery.build("compute", "v1", credentials=credentials)
    zone_operations = []
    for node in conf["nodes"]:
        print("Deleting node on virtual machine {}...".format(node["vmID"]))
        zone_operations.append(delete_instance(gce, node["vmID"]))
    for op in zone_operations:
        while True:
            result = gce.zoneOperations().get(project=GCP_PROJECT_ID, zone=GCE_ZONE_ID, operation=op["name"]).execute()
            if result["status"] == "DONE":
                # if "error" in result: raise Exception(result["error"])  # TODO handle error
                print("Deleted node on virtual machine {}".format(result["targetLink"].split("/")[-1]))
                break
            sleep(1)
    print("Cluster torn down correctly. Bye!")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号