Пример #1
0
def do_restore_create(cs, args):
    """Creates a restore."""
    if not uuidutils.is_uuid_like(args.provider_id):
        raise exceptions.CommandError("Invalid provider id provided.")

    if not uuidutils.is_uuid_like(args.checkpoint_id):
        raise exceptions.CommandError("Invalid checkpoint id provided.")

    restore_parameters = _extract_parameters(args)
    restore_auth = None
    if args.restore_target is not None:
        if args.restore_username is None:
            raise exceptions.CommandError(
                "Must specify username for restore_target.")
        if args.restore_password is None:
            raise exceptions.CommandError(
                "Must specify password for restore_target.")
        restore_auth = {
            'type': 'password',
            'username': args.restore_username,
            'password': args.restore_password,
        }
    restore = cs.restores.create(args.provider_id, args.checkpoint_id,
                                 args.restore_target, restore_parameters,
                                 restore_auth)
    dict_format_list = {"parameters"}
    utils.print_dict(restore.to_dict(), dict_format_list=dict_format_list)
Пример #2
0
def do_checkpoint_show(cs, args):
    """Shows checkpoint details."""
    checkpoint = cs.checkpoints.get(args.provider_id, args.checkpoint_id)
    dict_format_list = {"protection_plan"}
    json_format_list = {"resource_graph"}
    utils.print_dict(checkpoint.to_dict(),
                     dict_format_list=dict_format_list,
                     json_format_list=json_format_list)
Пример #3
0
def do_scheduledoperation_create(cs, args):
    """Creates a scheduled operation."""
    operation_definition = _extract_operation_definition(args)
    scheduledoperation = cs.scheduled_operations.create(
        args.name, args.operation_type, args.trigger_id, operation_definition)
    dict_format_list = {"operation_definition"}
    utils.print_dict(scheduledoperation.to_dict(),
                     dict_format_list=dict_format_list)
Пример #4
0
def do_trigger_update(cs, args):
    """Update a trigger."""
    trigger_info = {}
    trigger_properties = _extract_properties(args)
    trigger_info['name'] = args.name
    trigger_info['properties'] = trigger_properties
    trigger = cs.triggers.update(args.trigger_id, trigger_info)
    dict_format_list = {"properties"}
    utils.print_dict(trigger.to_dict(), dict_format_list=dict_format_list)
Пример #5
0
def do_protectable_show_instance(cs, args):
    """Shows instance details."""
    search_opts = {
        'parameters':
        (_extract_instances_parameters(args) if args.parameters else None),
    }
    instance = cs.protectables.get_instance(args.protectable_type,
                                            args.protectable_id,
                                            search_opts=search_opts)
    dict_format_list = {"dependent_resources"}
    utils.print_dict(instance.to_dict(), dict_format_list=dict_format_list)
Пример #6
0
def do_plan_create(cs, args):
    """Creates a plan."""
    plan_resources = _extract_resources(args)
    _check_resources(cs, plan_resources)
    plan_parameters = _extract_parameters(args)
    plan = cs.plans.create(args.name,
                           args.provider_id,
                           plan_resources,
                           plan_parameters,
                           description=args.description)
    dict_format_list = {"resources", "parameters"}
    utils.print_dict(plan.to_dict(), dict_format_list=dict_format_list)
Пример #7
0
def do_checkpoint_create(cs, args):
    """Creates a checkpoint."""

    checkpoint_extra_info = None
    if args.extra_info is not None:
        checkpoint_extra_info = _extract_extra_info(args)
    checkpoint = cs.checkpoints.create(args.provider_id, args.plan_id,
                                       checkpoint_extra_info)
    dict_format_list = {"protection_plan"}
    json_format_list = {"resource_graph"}
    utils.print_dict(checkpoint.to_dict(),
                     dict_format_list=dict_format_list,
                     json_format_list=json_format_list)
Пример #8
0
def do_plan_update(cs, args):
    """Updatas a plan."""
    data = {}
    if args.name is not None:
        data['name'] = args.name
    if args.resources is not None:
        plan_resources = _extract_resources(args)
        data['resources'] = plan_resources
    if args.status is not None:
        data['status'] = args.status
    try:
        plan = utils.find_resource(cs.plans, args.plan_id)
        plan = cs.plans.update(plan.id, data)
    except exceptions.NotFound:
        raise exceptions.CommandError("Plan %s not found" % args.plan_id)
    else:
        utils.print_dict(plan.to_dict())
Пример #9
0
def do_trigger_show(cs, args):
    """Shows trigger details."""
    trigger = cs.triggers.get(args.trigger)
    dict_format_list = {"properties"}
    utils.print_dict(trigger.to_dict(), dict_format_list=dict_format_list)
Пример #10
0
def do_trigger_create(cs, args):
    """Creates a trigger."""
    trigger_properties = _extract_properties(args)
    trigger = cs.triggers.create(args.name, args.type, trigger_properties)
    dict_format_list = {"properties"}
    utils.print_dict(trigger.to_dict(), dict_format_list=dict_format_list)
Пример #11
0
def do_provider_show(cs, args):
    """Shows provider details."""
    provider = cs.providers.get(args.provider_id)
    dict_format_list = {"extended_info_schema"}
    utils.print_dict(provider.to_dict(), dict_format_list=dict_format_list)
Пример #12
0
def do_protectable_show(cs, args):
    """Shows protectable type details."""
    protectable = cs.protectables.get(args.protectable_type)
    utils.print_dict(protectable.to_dict())
Пример #13
0
def do_restore_show(cs, args):
    """Shows restore details."""
    restore = cs.restores.get(args.restore)
    dict_format_list = {"parameters"}
    utils.print_dict(restore.to_dict(), dict_format_list=dict_format_list)
Пример #14
0
def do_plan_show(cs, args):
    """Shows plan details."""
    plan = cs.plans.get(args.plan)
    dict_format_list = {"resources", "parameters"}
    utils.print_dict(plan.to_dict(), dict_format_list=dict_format_list)
Пример #15
0
def do_scheduledoperation_show(cs, args):
    """Shows scheduledoperation details."""
    scheduledoperation = cs.scheduled_operations.get(args.scheduledoperation)
    dict_format_list = {"operation_definition"}
    utils.print_dict(scheduledoperation.to_dict(),
                     dict_format_list=dict_format_list)