Ejemplo n.º 1
0
    def get_snapshot_xml(self, snap_info):
        """Libvirt snapshot XML"""
        if 'diskType' in snap_info:
            if self.diskType != snap_info['diskType']:
                raise exception.UnsupportedOperation(
                    "Unexpected diskType",
                    drive_disk_type=self.diskType,
                    snapshot_disk_type=snap_info["diskType"])

        if self.diskType == DISK_TYPE.NETWORK:
            if self.protocol != snap_info['protocol']:
                raise exception.UnsupportedOperation(
                    "Unexpected protocol",
                    drive_protocol=self.protocol,
                    snapshot_protocol=snap_info["protocol"])

        disk = vmxml.Element('disk',
                             name=self.name,
                             snapshot='external',
                             type=self.diskType)

        drive_info = snap_info.copy()
        drive_info["diskType"] = self.diskType
        snap_elem = _getSourceXML(drive_info)

        # Type attribute is needed but not documented:
        # https://bugzilla.redhat.com/1452103
        snap_elem.setAttrs(type=self.diskType)

        disk.appendChild(snap_elem)
        return disk
Ejemplo n.º 2
0
    def diskType(self, value):
        if value not in SOURCE_ATTR:
            raise exception.UnsupportedOperation("Unsupported diskType %r" %
                                                 value)
        if self.device in ['cdrom', 'floppy'] and value != DISK_TYPE.FILE:
            raise exception.UnsupportedOperation(
                "diskType of %r can only be 'file'" % self.device)

        if self._diskType is not None and self._diskType != value:
            self.log.debug("Drive %s type changed from %r to %r", self.name,
                           self._diskType, value)

        self._diskType = value
Ejemplo n.º 3
0
 def wrapper(*a, **kw):
     if not backup_enabled:
         raise exception.UnsupportedOperation(
             "Libvirt version doesn't support "
             "incremental backup operations"
         )
     return f(*a, **kw)
Ejemplo n.º 4
0
    def diskType(self, value):
        if value not in SOURCE_ATTR:
            raise exception.UnsupportedOperation("Unsupported diskType %r" %
                                                 value)
        if self.device == 'floppy' and value != DISK_TYPE.FILE:
            raise exception.UnsupportedOperation(
                "diskType of device 'floppy' can only be 'file'")

        # TODO: Check if a cdrom can be on network device
        if self.device == 'cdrom' and value == DISK_TYPE.NETWORK:
            raise exception.UnsupportedOperation(
                "diskType of device 'cdrom' can not be 'network'")

        if self._diskType is not None and self._diskType != value:
            self.log.debug("Drive %s type changed from %r to %r", self.name,
                           self._diskType, value)

        self._diskType = value
Ejemplo n.º 5
0
    def prepareVolumePath(self, drive, vmId=None):
        if type(drive) is dict:
            device = drive['device']
            # PDIV drive format
            # Since version 4.2 cdrom may use a PDIV format
            if device in ("cdrom", "disk") and isVdsmImage(drive):
                res = self.irs.prepareImage(drive['domainID'], drive['poolID'],
                                            drive['imageID'],
                                            drive['volumeID'])

                if res['status']['code']:
                    raise vm.VolumeError(drive)

                # The order of imgVolumesInfo is not guaranteed
                drive['volumeChain'] = res['imgVolumesInfo']
                drive['volumeInfo'] = res['info']

                if drive.get('diskType') == DISK_TYPE.NETWORK:
                    if device == "cdrom":
                        raise exception.UnsupportedOperation(
                            "A cdrom device is not supported as network disk",
                            drive=drive)

                    # Not applicable for Ceph network disk as
                    # Ceph disks are not vdsm images
                    volPath = self._prepare_network_drive(drive, res)
                else:
                    if 'diskType' not in drive:
                        if res['info']['type'] == DISK_TYPE.BLOCK:
                            drive['diskType'] = DISK_TYPE.BLOCK
                        else:
                            # Volume type may be 'network', but if engine did
                            # not speicfy the type, we must use 'file'.
                            drive['diskType'] = DISK_TYPE.FILE
                    volPath = res['path']
            # GUID drive format
            elif "GUID" in drive:
                res = self.irs.getDevicesVisibility([drive["GUID"]])
                if not res["visible"][drive["GUID"]]:
                    raise vm.VolumeError("Drive %r not visible" %
                                         drive["GUID"])

                res = self.irs.appropriateDevice(drive["GUID"], vmId, 'mpath')
                if res['status']['code']:
                    raise vm.VolumeError("Cannot appropriate drive %r" %
                                         drive["GUID"])

                # Update size for LUN volume
                drive["truesize"] = res['truesize']
                drive["apparentsize"] = res['apparentsize']

                if 'diskType' not in drive:
                    drive['diskType'] = DISK_TYPE.BLOCK

                volPath = res['path']

            elif "RBD" in drive:
                res = self.irs.appropriateDevice(drive["RBD"], vmId, 'rbd')
                volPath = res['path']

            # cdrom and floppy drives
            elif (device in ('cdrom', 'floppy') and 'specParams' in drive):
                params = drive['specParams']
                if 'vmPayload' in params:
                    volPath = self._prepareVolumePathFromPayload(
                        vmId, device, params['vmPayload'])
                # next line can be removed in future, when < 3.3 engine
                # is not supported
                elif (params.get('path', '') == ''
                      and drive.get('path', '') == ''):
                    volPath = ''
                else:
                    volPath = drive.get('path', '')

            elif "path" in drive:
                volPath = drive['path']

            else:
                raise vm.VolumeError(drive)

            # Noramalize the missing diskType when cluster version < 4.2.
            if 'diskType' not in drive:
                drive['diskType'] = DISK_TYPE.FILE

        # For BC sake: None as argument
        elif not drive:
            volPath = drive

        #  For BC sake: path as a string.
        elif os.path.exists(drive):
            volPath = drive

        else:
            raise vm.VolumeError(drive)

        self.log.info("prepared volume path: %s", volPath)
        return volPath
Ejemplo n.º 6
0
Archivo: sd.py Proyecto: benipeled/vdsm
 def reduceVG(self, guid):
     raise exception.UnsupportedOperation()
Ejemplo n.º 7
0
Archivo: sd.py Proyecto: benipeled/vdsm
 def movePV(self, src_device, dst_devices):
     raise exception.UnsupportedOperation()
Ejemplo n.º 8
0
    'haErr': exception.SetHAPolicyFailed().response(),
    'cpuTuneErr': exception.CpuTuneError().response(),
    'updateVmPolicyErr': exception.UpdateVMPolicyFailed().response(),
    'updateIoTuneErr': exception.UpdateIOTuneError().response(),
    'V2VConnection': exception.V2VConnectionError().response(),
    'NoSuchJob': exception.NoSuchJob().response(),
    'V2VNoSuchOvf': exception.V2VNoSuchOVF().response(),
    'JobNotDone': exception.JobNotDone().response(),
    'JobExists': exception.JobExists().response(),
    'JobNotActive': exception.JobNotActive().response(),
    'hotplugMem': exception.HotplugMemFailed().response(),
    'ksmErr': exception.KSMUpdateFailed().response(),
    'secretBadRequestErr': exception.BadSecretRequest().response(),
    'secretRegisterErr': exception.SecretRegistrationFailed().response(),
    'secretUnregisterErr': exception.SecretUnregistrationFailed().response(),
    'unsupportedOperationErr': exception.UnsupportedOperation().response(),
    'freezeErr': exception.FreezeGuestFSFailed().response(),
    'thawErr': exception.ThawGuestFSFailed().response(),
    'hookError': exception.HookFailed().response(),
    'destVolumeTooSmall': exception.DestinationVolumeTooSmall().response(),
    'AbortNotSupported': exception.AbortNotSupported().response(),
    'migNotInProgress': exception.MigrationNotInProgress().response(),
    'migrateLimit': exception.MigrationLimitExceeded().response(),
    'recovery': exception.RecoveryInProgress().response(),
    'hostdevDetachErr': exception.HostdevDetachFailed().response(),
}

doneCode = {'code': 0, 'message': 'Done'}

# exitCodes
ERROR = 1