Beispiel #1
0
def create_backup_xml(address, drives, scratch_disks):
    domainbackup = vmxml.Element('domainbackup', mode='pull')

    server = vmxml.Element(
        'server', transport=address.transport, socket=address.path)

    domainbackup.appendChild(server)

    disks = vmxml.Element('disks')

    # fill the backup XML disks
    for drive in drives.values():
        disk = vmxml.Element('disk', name=drive.name, type='file')
        # scratch element can have dev=/path/to/block/disk
        # or file=/path/to/file/disk attribute according to
        # the disk type.
        # Currently, all the scratch disks resides on the
        # host local file storage.
        scratch = vmxml.Element('scratch', file=scratch_disks[drive.name])

        storage.disable_dynamic_ownership(scratch, write_type=False)
        disk.appendChild(scratch)

        disks.appendChild(disk)

    domainbackup.appendChild(disks)

    return xmlutils.tostring(domainbackup)
Beispiel #2
0
def _process_domxml(tree):
    for disk_type in (
            storage.DISK_TYPE.BLOCK,
            storage.DISK_TYPE.FILE,
    ):
        xpath = "./devices//disk[@type='%s']//source" % (disk_type, )
        for element in tree.findall(xpath):
            storage.disable_dynamic_ownership(element)
Beispiel #3
0
def _process_domxml(tree):
    for xpath in ("./devices//disk[@type='%s']//source" %
                  (storage.DISK_TYPE.BLOCK, ),
                  "./devices//disk[@type='%s']//source" %
                  (storage.DISK_TYPE.FILE, ),
                  "./devices//disk[@type='%s']//source[@protocol='gluster']" %
                  (storage.DISK_TYPE.NETWORK, )):
        for element in tree.findall(xpath):
            storage.disable_dynamic_ownership(element)
Beispiel #4
0
def create_backup_xml(address, backup_disks, from_checkpoint_id=None):
    domainbackup = vmxml.Element('domainbackup', mode='pull')

    if from_checkpoint_id is not None:
        incremental = vmxml.Element('incremental')
        incremental.appendTextNode(from_checkpoint_id)
        domainbackup.appendChild(incremental)

    server = vmxml.Element('server',
                           transport=address.transport,
                           socket=address.path)

    domainbackup.appendChild(server)

    disks = vmxml.Element('disks')

    # fill the backup XML disks
    for backup_disk in backup_disks.values():
        disk = vmxml.Element('disk',
                             name=backup_disk.drive.name,
                             type=backup_disk.scratch_disk.type)

        # If backup mode reported by the engine it should be added
        # to the backup XML.
        if backup_disk.backup_mode is not None:
            vmxml.set_attr(disk, "backupmode", backup_disk.backup_mode)

            if backup_disk.backup_mode == MODE_INCREMENTAL:
                # if backupmode is 'incremental' we should also provide the
                # checkpoint ID we start the incremental backup from.
                vmxml.set_attr(disk, MODE_INCREMENTAL, from_checkpoint_id)

        # scratch element can have dev=/path/to/block/disk
        # or file=/path/to/file/disk attribute according to
        # the disk type.
        if backup_disk.scratch_disk.type == DISK_TYPE.BLOCK:
            scratch = vmxml.Element('scratch',
                                    dev=backup_disk.scratch_disk.path)
        else:
            scratch = vmxml.Element('scratch',
                                    file=backup_disk.scratch_disk.path)

        storage.disable_dynamic_ownership(scratch, write_type=False)
        disk.appendChild(scratch)

        disks.appendChild(disk)

    domainbackup.appendChild(disks)

    return xmlutils.tostring(domainbackup)
Beispiel #5
0
def _process_domxml(tree):
    for disk_type in (storage.DISK_TYPE.BLOCK, storage.DISK_TYPE.FILE,):
        xpath = "./devices//disk[@type='%s']//source" % (disk_type,)
        for element in tree.findall(xpath):
            storage.disable_dynamic_ownership(element)