示例#1
0
def do_backup_list(cs, args):
    """list backups."""
    all_tenants = 1 if args.tenant else \
        int(os.environ.get("ALL_TENANTS", args.all_tenants))
    search_opts = {
        'all_tenants': all_tenants,
        'project_id': args.tenant,
        'name': args.name,
        'status': args.status,
        'volume_id': args.volume_id
    }

    if args.sort and (args.sort_key or args.sort_dir):
        raise exceptions.CommandError(
            'The --sort_key and --sort_dir arguments are deprecated and are '
            'not supported with --sort.')

    backups = cs.backups.list(search_opts=search_opts,
                              marker=args.marker,
                              limit=args.limit,
                              sort_key=args.sort_key,
                              sort_dir=args.sort_dir,
                              sort=args.sort)
    columns = ['Id', 'Name', 'Status', 'Volume id']

    if args.sort_key or args.sort_dir or args.sort:
        sortby_index = None
    else:
        sortby_index = 0
    utils.print_list(backups,
                     columns,
                     exclude_unavailable=True,
                     sortby_index=sortby_index)
示例#2
0
def do_checkpoint_delete(cs, args):
    """Delete checkpoint."""
    failure_count = 0
    for item in args.checkpoint:
        try:
            checkpoint = shell_utils.find_checkpoint(cs, item)
            cs.checkpoints.delete(checkpoint.id)
            print("Request to delete checkpoint %s has been accepted." % item)
        except Exception as e:
            print("Delete for checkpoint %s failed: %s" % (item, e))
    if failure_count == len(args.checkpoint):
        raise exceptions.CommandError("Unable to delete any of the specified "
                                      "checkpoints.")
示例#3
0
def do_backup_delete(cs, args):
    """Delete snapshot."""
    failure_count = 0
    for item in args.backup:
        try:
            backup = shell_utils.find_backup(cs, item)
            cs.backups.delete(backup.id)
            print("Request to delete backup %s has been accepted." % item)
        except Exception as e:
            print("Delete for backup %s failed: %s" % (item, e))
    if failure_count == len(args.backup):
        raise exceptions.CommandError("Unable to delete any of the specified "
                                      "backups.")
示例#4
0
def do_replication_delete(cs, args):
    """Delete a replication."""
    failure_count = 0
    for item in args.replication:
        try:
            replication = shell_utils.find_replication(cs, item)
            cs.replications.delete(replication.id)
            print("Request to delete replication %s has been accepted." % item)
        except Exception as e:
            failure_count += 1
            print("Delete for replication %s failed: %s" % (item, e))
    if failure_count == len(args.replication):
        raise exceptions.CommandError("Unable to delete any of the specified "
                                      "replications.")
示例#5
0
def do_snapshot_delete(cs, args):
    """Delete snapshot."""
    failure_count = 0
    for item in args.snapshot:
        try:
            snapshot = shell_utils.find_snapshot(cs, item)
            cs.snapshots.delete(snapshot.id)
            print("Request to delete snapshot %s has been accepted." % item)
        except Exception as e:
            failure_count += 1
            print("Delete for snapshot %s failed: %s" % (item, e))
    if failure_count == len(args.snapshot):
        raise exceptions.CommandError("Unable to delete any of the specified "
                                      "snapshots.")
示例#6
0
def do_delete(cs, args):
    """Delete error or available sg volume."""
    failure_count = 0
    for item in args.volume:
        try:
            volume = shell_utils.find_volume(cs, item)
            cs.volumes.delete(volume.id)
            print("Request to delete volume %s has been accepted." % item)
        except Exception as e:
            failure_count += 1
            print("Request to delete volume %s failed: %s." % (item, e))
    if failure_count == len(args.volume):
        raise exceptions.CommandError("Unable to delete any of the specified "
                                      "volumes.")
示例#7
0
def _extract_driver_data(args):
    if all((args.driver_data_json, args.driver_data)):
        raise exceptions.CommandError(
            "Must provider parameters "
            "driver-data-json or driver-data, not both")
    if not any((args.driver_data_json, args.driver_data)):
        return {}

    if args.driver_data_json:
        return jsonutils.loads(args.driver_data_json)
    driver_data = {}
    for resource_params in args.driver_data:
        for param_kv in resource_params.split(','):
            key, value = param_kv.split('=')
            driver_data[key] = value
    return driver_data