def do_checkpoint_reset_state(cs, args): checkpoint = shell_utils.find_checkpoint(cs, args.checkpoint) try: cs.checkpoints.reset_state(checkpoint.id, args.state) print("Request to reset-state checkpoint %s has been accepted." % (checkpoint.id)) except Exception as e: print("Reset-state for checkpoint %s failed: %s" % (checkpoint.id, e))
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.")
def do_checkpoint_update(cs, args): kwargs = {} if args.name is not None: kwargs['name'] = args.name if args.description is not None: kwargs['description'] = args.description if not kwargs: msg = 'Must supply either name or description.' raise exceptions.ClientException(code=1, message=msg) checkpoint = shell_utils.find_checkpoint(cs, args.checkpoint) checkpoint = cs.checkpoints.update(checkpoint.id, kwargs) utils.print_dict(checkpoint.to_dict())
def do_checkpoint_show(cs, args): """Get checkpoint.""" checkpoint = shell_utils.find_checkpoint(cs, args.checkpoint) utils.print_dict(checkpoint.to_dict())
def do_checkpoint_rollback(cs, args): """Rollback checkpoint.""" checkpoint = shell_utils.find_checkpoint(cs, args.checkpoint) rollback = cs.checkpoints.rollback(checkpoint.id) utils.print_dict(rollback.to_dict())