コード例 #1
0
ファイル: disk.py プロジェクト: lisptick/gandi.cli
def list(gandi, only_data, only_snapshot, type, id, vm, snapshotprofile,
         limit):
    """ List disks. """
    options = {
        'items_per_page': limit,
    }

    if only_data:
        options.setdefault('type', []).append('data')
    if only_snapshot:
        options.setdefault('type', []).append('snapshot')

    output_keys = ['name', 'state', 'size']
    if type:
        output_keys.append('type')
    if id:
        output_keys.append('id')
    if vm:
        output_keys.append('vm')

    profiles = []
    if snapshotprofile:
        output_keys.append('profile')
        profiles = gandi.snapshotprofile.list()

    result = gandi.disk.list(options)
    vms = dict([(vm_['id'], vm_) for vm_ in gandi.iaas.list()])

    for num, disk in enumerate(result):
        if num:
            gandi.separator_line()
        output_disk(gandi, disk, [], vms, profiles, output_keys)

    return result
コード例 #2
0
ファイル: disk.py プロジェクト: webcracy/gandi.cli
def list(gandi, only_data, only_snapshot, type, id, vm, snapshotprofile,
         limit):
    """ List disks. """
    options = {
        'items_per_page': limit,
    }

    if only_data:
        options.setdefault('type', []).append('data')
    if only_snapshot:
        options.setdefault('type', []).append('snapshot')

    output_keys = ['name', 'state', 'size']
    if type:
        output_keys.append('type')
    if id:
        output_keys.append('id')
    if vm:
        output_keys.append('vm')

    profiles = []
    if snapshotprofile:
        output_keys.append('profile')
        profiles = gandi.snapshotprofile.list()

    result = gandi.disk.list(options)
    vms = dict([(vm_['id'], vm_) for vm_ in gandi.iaas.list()])

    for num, disk in enumerate(result):
        if num:
            gandi.separator_line()
        output_disk(gandi, disk, [], vms, profiles, output_keys)

    return result
コード例 #3
0
ファイル: disk.py プロジェクト: JD-Multimedia/gandi.cli
def info(gandi, resource):
    """ Display information about a disk.

    Resource can be a disk name, or it's ID
    """
    output_keys = ['name', 'state', 'size', 'type', 'id', 'dc', 'vm',
                   'profile']

    disk = gandi.disk.info(resource)
    vms = dict([(vm['id'], vm) for vm in gandi.iaas.list()])
    output_disk(gandi, disk, [], vms, [], output_keys)

    return disk
コード例 #4
0
def info(gandi, resource):
    """ Display information about a disk.

    Resource can be a disk name, or it's ID
    """
    output_keys = [
        'name', 'state', 'size', 'type', 'id', 'dc', 'vm', 'profile'
    ]

    disk = gandi.disk.info(resource)
    vms = dict([(vm['id'], vm) for vm in gandi.iaas.list()])
    output_disk(gandi, disk, [], vms, [], output_keys)

    return disk
コード例 #5
0
ファイル: disk.py プロジェクト: costingalan/gandi.cli
def list(gandi, only_data, only_snapshot, attached, detached, type, id, vm,
         snapshotprofile, datacenter, limit):
    """ List disks. """
    options = {
        'items_per_page': limit,
    }

    if attached and detached:
        raise UsageError('You cannot use both --attached and --detached.')

    if only_data:
        options.setdefault('type', []).append('data')
    if only_snapshot:
        options.setdefault('type', []).append('snapshot')
    if datacenter:
        options['datacenter_id'] = gandi.datacenter.usable_id(datacenter)

    output_keys = ['name', 'state', 'size']
    if type:
        output_keys.append('type')
    if id:
        output_keys.append('id')
    if vm:
        output_keys.append('vm')

    profiles = []
    if snapshotprofile:
        output_keys.append('profile')
        profiles = gandi.snapshotprofile.list()

    result = gandi.disk.list(options)
    vms = dict([(vm_['id'], vm_) for vm_ in gandi.iaas.list()])

    # filter results per attached/detached
    disks = []
    for disk in result:
        if attached and not disk['vms_id']:
            continue
        if detached and disk['vms_id']:
            continue
        disks.append(disk)

    for num, disk in enumerate(disks):
        if num:
            gandi.separator_line()
        output_disk(gandi, disk, [], vms, profiles, output_keys)

    return result
コード例 #6
0
ファイル: disk.py プロジェクト: Gandi/gandi.cli
def list(gandi, only_data, only_snapshot, attached, detached, type, id, vm,
         snapshotprofile, datacenter, limit):
    """ List disks. """
    options = {
        'items_per_page': limit,
    }

    if attached and detached:
        raise UsageError('You cannot use both --attached and --detached.')

    if only_data:
        options.setdefault('type', []).append('data')
    if only_snapshot:
        options.setdefault('type', []).append('snapshot')
    if datacenter:
        options['datacenter_id'] = gandi.datacenter.usable_id(datacenter)

    output_keys = ['name', 'state', 'size']
    if type:
        output_keys.append('type')
    if id:
        output_keys.append('id')
    if vm:
        output_keys.append('vm')

    profiles = []
    if snapshotprofile:
        output_keys.append('profile')
        profiles = gandi.snapshotprofile.list()

    result = gandi.disk.list(options)
    vms = dict([(vm_['id'], vm_) for vm_ in gandi.iaas.list()])

    # filter results per attached/detached
    disks = []
    for disk in result:
        if attached and not disk['vms_id']:
            continue
        if detached and disk['vms_id']:
            continue
        disks.append(disk)

    for num, disk in enumerate(disks):
        if num:
            gandi.separator_line()
        output_disk(gandi, disk, [], vms, profiles, output_keys)

    return result
コード例 #7
0
ファイル: disk.py プロジェクト: Gandi/gandi.cli
def info(gandi, resource):
    """ Display information about a disk.

    Resource can be a disk name or ID
    """
    output_keys = ['name', 'state', 'size', 'type', 'id', 'dc', 'vm',
                   'profile', 'kernel', 'cmdline']

    resource = sorted(tuple(set(resource)))
    vms = dict([(vm['id'], vm) for vm in gandi.iaas.list()])
    datacenters = gandi.datacenter.list()

    result = []
    for num, item in enumerate(resource):
        if num:
            gandi.separator_line()
        disk = gandi.disk.info(item)
        output_disk(gandi, disk, datacenters, vms, [], output_keys)
        result.append(disk)

    return result
コード例 #8
0
ファイル: disk.py プロジェクト: smehboub/gandi.cli
def info(gandi, resource):
    """ Display information about a disk.

    Resource can be a disk name or ID
    """
    output_keys = ['name', 'state', 'size', 'type', 'id', 'dc', 'vm',
                   'profile', 'kernel', 'cmdline']

    resource = sorted(tuple(set(resource)))
    vms = dict([(vm['id'], vm) for vm in gandi.iaas.list()])
    datacenters = gandi.datacenter.list()

    result = []
    for num, item in enumerate(resource):
        if num:
            gandi.separator_line()
        disk = gandi.disk.info(item)
        output_disk(gandi, disk, datacenters, vms, [], output_keys)
        result.append(disk)

    return result