service.py 文件源码

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

项目:ISB-CGC-pipelines 作者: isb-cgc 项目源码 文件源码
def delete(config, disk_name=None, disk_zone=None):  # TODO: implement
        # submit a request to the gce api for a new disk with the given parameters
        # if inputs is not None, run a pipeline job to populate the disk
        projectId = config.project_id
        zones = [disk_zone if disk_zone is not None else x for x in config.zones.split(',')]

        credentials = GoogleCredentials.get_application_default()
        http = credentials.authorize(httplib2.Http())

        if credentials.access_token_expired:
            credentials.refresh(http)

        gce = discovery.build('compute', 'v1', http=http)

        for z in zones:
            try:
                resp = gce.disks().delete(project=projectId, zone=z, disk=disk_name).execute()
            except HttpError as e:
                raise DataDiskError("Couldn't delete data disk {n}: {reason}".format(n=disk_name, reason=e))

            while True:
                try:
                    result = gce.zoneOperations().get(project=projectId, zone=z, operation=resp['name']).execute()
                except HttpError:
                    break
                else:
                    if result['status'] == 'DONE':
                        break
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号