def do_storage_tier_show(cc, args):
    """Show storage tier attributes."""

    cluster = cluster_utils._find_cluster(cc, args.cluster_or_uuid)
    tier = storage_tier_utils._find_storage_tier(cc, cluster,
                                                 args.storage_tier_or_uuid)
    _print_tier_show(tier)
def do_storage_tier_modify(cc, args):
    """Modify the attributes of a storage tier."""

    # Get all the fields from the command arguments
    field_list = ['name']
    user_specified_fields = dict((k, v) for (k, v) in vars(args).items()
                                 if k in field_list and not (v is None))

    if not user_specified_fields:
        raise exc.CommandError('No update parameters specified, '
                               'storage tier is unchanged.')

    # Get the cluster object
    cluster = cluster_utils._find_cluster(cc, args.cluster_or_uuid)

    # Get the storage tier
    tier = storage_tier_utils._find_storage_tier(cc, cluster,
                                                 args.storage_tier_or_uuid)
    patch = []
    for (k, v) in user_specified_fields.items():
        patch.append({'op': 'replace', 'path': '/' + k, 'value': v})

    # Update the storage tier attributes
    try:
        updated_tier = cc.storage_tier.update(tier.uuid, patch)
    except exc.HTTPNotFound:
        raise exc.CommandError(
            "ERROR: Storage tier update failed: "
            "cluster %s tier %s : update %s"
            % (args.cluster_or_uuid, args.storage_tier_or_uuid, patch))

    _print_tier_show(updated_tier)
def do_storage_tier_list(cc, args):
    """List storage tiers."""

    cluster = cluster_utils._find_cluster(cc, args.cluster_or_uuid)
    tiers = cc.storage_tier.list(cluster.uuid)

    fields = ['uuid', 'name', 'status', 'backend_uuid']
    labels = ['uuid', 'name', 'status', 'backend_using']

    utils.print_list(tiers, fields, labels, sortby=1)
def do_storage_tier_delete(cc, args):
    """Delete a storage tier."""

    # Get the cluster object
    cluster = cluster_utils._find_cluster(cc, args.cluster_or_uuid)
    tier = storage_tier_utils._find_storage_tier(cc, cluster,
                                                 args.storage_tier_or_uuid)
    try:
        cc.storage_tier.delete(tier.uuid)
    except exc.HTTPNotFound:
        raise exc.CommandError('Storage Tier delete failed for cluster %s: '
                               ' %s' % (cluster.name,
                                        args.storage_tier_or_uuid))
def do_storage_tier_add(cc, args):
    """Add a storage tier to a disk of a specified cluster."""

    # Get the cluster object
    cluster = cluster_utils._find_cluster(cc, args.cluster_or_uuid)

    # default values
    fields = {'cluster_uuid': cluster.uuid, 'name': args.storage_tier_name}

    try:
        tier = cc.storage_tier.create(**fields)
    except exc.HTTPNotFound:
        raise exc.CommandError('Storage tier create failed: cluster %s: '
                               'fields %s' % (args.cluster_or_uuid, fields))

    tier_uuid = getattr(tier, 'uuid', '')
    try:
        tier = cc.storage_tier.get(tier_uuid)
    except exc.HTTPNotFound:
        raise exc.CommandError('Created storage_tier UUID not found: '
                               '%s' % tier_uuid)

    _print_tier_show(tier)
Esempio n. 6
0
def do_cluster_show(cc, args):
    """Show Cluster attributes."""
    cluster = cluster_utils._find_cluster(cc, args.cluster_or_uuid)
    cluster_obj = cc.cluster.get(cluster.uuid)
    _print_cluster_show(cluster_obj)