Example #1
0
def _get_leaf_checkpoint_name(vm, dom):
    flags = libvirt.VIR_DOMAIN_CHECKPOINT_LIST_TOPOLOGICAL
    try:
        checkpoints = dom.listAllCheckpoints(flags=flags)
        return checkpoints[-1].getName() if checkpoints else None
    except libvirt.libvirtError as e:
        raise exception.CheckpointError(
            reason="Failed to fetch defined leaf checkpoint: {}".format(e),
            vm_id=vm.id)
Example #2
0
def _validate_parent_id(vm, dom, parent_checkpoint_id):
    leaf_checkpoint_id = _get_leaf_checkpoint_name(vm, dom)
    if parent_checkpoint_id != leaf_checkpoint_id:
        raise exception.CheckpointError(
            reason="Parent checkpoint ID does not "
            "match the actual leaf checkpoint",
            parent_checkpoint_id=parent_checkpoint_id,
            leaf_checkpoint_id=leaf_checkpoint_id,
            vm_id=vm.id)
Example #3
0
def list_checkpoints(vm, dom):
    flags = libvirt.VIR_DOMAIN_CHECKPOINT_LIST_TOPOLOGICAL
    try:
        checkpoints = dom.listAllCheckpoints(flags=flags)
        result = [checkpoint.getName() for checkpoint in checkpoints]
    except libvirt.libvirtError as e:
        raise exception.CheckpointError(
            reason="Failed to fetch defined checkpoints list: {}".format(e),
            vm_id=vm.id)

    return dict(result=result)
Example #4
0
    def __init__(self, checkpoint_config):
        self.id = checkpoint_config.get("id")
        self.xml = checkpoint_config.get("xml")
        if "config" in checkpoint_config:
            self.config = BackupConfig(checkpoint_config["config"])
        else:
            self.config = None

        if self.config is None and self.xml is None:
            raise exception.CheckpointError(
                reason="Cannot redefine checkpoint without "
                "checkpoint XML or backup config",
                checkpoint_id=self.id)