当前位置: 首页>>代码示例>>Python>>正文


Python VDC.get_disks方法代码示例

本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.get_disks方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.get_disks方法的具体用法?Python VDC.get_disks怎么用?Python VDC.get_disks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvcloud.vcd.vdc.VDC的用法示例。


在下文中一共展示了VDC.get_disks方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list_disks

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_disks [as 别名]
def list_disks(ctx):
    try:
        restore_session(ctx, vdc_required=True)
        client = ctx.obj['client']
        vdc_href = ctx.obj['profiles'].get('vdc_href')
        vdc = VDC(client, href=vdc_href)
        disks = vdc.get_disks()
        result = []
        for disk in disks:
            attached_vms = ''
            if hasattr(disk, 'attached_vms') and \
               hasattr(disk.attached_vms, 'VmReference'):
                attached_vms = disk.attached_vms.VmReference.get('name')
            result.append({
                'name':
                disk.get('name'),
                'id':
                extract_id(disk.get('id')),
                'owner':
                disk.Owner.User.get('name'),
                'size':
                humanfriendly.format_size(int(disk.get('size'))),
                'size_bytes':
                disk.get('size'),
                'status':
                VCLOUD_STATUS_MAP.get(int(disk.get('status'))),
                'vms_attached':
                attached_vms
            })
        stdout(result, ctx, show_id=True)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:34,代码来源:disk.py

示例2: delete_disks

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_disks [as 别名]
def delete_disks(client):
    logging.info('INIT create_disk')

    logged_in_org = client.get_org()
    org = Org(client, resource=logged_in_org)
    v = org.get_vdc('OVD2')
    if v is None:
        raise errors.VDCNotFoundError(vappInfo.vdc)
    vdc = VDC(client, href=v.get('href'))
    disks = vdc.get_disks()

    print(etree.tostring(disks[0], pretty_print=True))
    #logging.info(disks[].get('href'))
    result = vdc.delete_disk('disk02')
    task = client.get_task_monitor().wait_for_status(
        task=result,
        timeout=60,
        poll_frequency=2,
        fail_on_status=None,
        expected_target_statuses=[
            TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
            TaskStatus.CANCELED
        ],
        callback=task_callback)
    st = task.get('status')
    if st == TaskStatus.SUCCESS.value:
        logging.info("__LOG__ created DISK")
        #cresult.created = True
    else:
        raise errors.VCDDiskDeletionError(
            etree.tostring(task, pretty_print=True))
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:33,代码来源:test_org.py

示例3: test_020_get_all_disks

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_disks [as 别名]
    def test_020_get_all_disks(self):
        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)
        vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
        vdc = VDC(self.client, resource=vdc_resource)

        disks = vdc.get_disks()

        assert len(disks) > 0
        assert disks[0].get('name') == self.config['vcd']['idisk_name']
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:12,代码来源:vcd_disk.py

示例4: test_040_get_disk_by_id

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_disks [as 别名]
    def test_040_get_disk_by_id(self):
        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)
        vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
        vdc = VDC(self.client, resource=vdc_resource)

        disks = vdc.get_disks()
        assert len(disks) > 0

        fetched_disk = vdc.get_disk(disk_id=disks[0].get('id'))
        assert fetched_disk is not None
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:13,代码来源:vcd_disk.py

示例5: test_200_delete_all_disks

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_disks [as 别名]
    def test_200_delete_all_disks(self):
        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)
        vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
        vdc = VDC(self.client, resource=vdc_resource)

        disks = vdc.get_disks()

        for disk in disks:
            result = vdc.delete_disk(disk_id=disk.get('id'))

            task = self.client.get_task_monitor().wait_for_status(
                task=result,
                timeout=30,
                poll_frequency=2,
                fail_on_status=None,
                expected_target_statuses=[
                    TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
                    TaskStatus.CANCELED
                ],
                callback=None)
            assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:24,代码来源:vcd_disk.py


注:本文中的pyvcloud.vcd.vdc.VDC.get_disks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。