Search in sources :

Example 11 with VmDynamic

use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.

the class ProcessOvfUpdateForStorageDomainCommand method addVmsStatus.

private void addVmsStatus(List<Guid> vmAndTemplatesIds, Map<String, Object> data) {
    Map<String, Object> vmsStatus = new HashMap<>();
    for (Guid vmId : vmAndTemplatesIds) {
        VmDynamic vmDynamic = vmDynamicDao.get(vmId);
        if (vmDynamic != null && vmDynamic.getStatus() != VMStatus.Down) {
            vmsStatus.put(vmId.toString(), vmDynamic.getStatus().getValue());
            log.debug("OVF_STORE - Add vm id '{}' with status: '{}'", vmId, vmDynamic.getStatus());
        } else {
            log.debug("OVF_STORE - Skip entity id '{}' with status: '{}'", vmId, vmDynamic != null ? vmDynamic.getStatus() : "N/A");
        }
    }
    data.put(OvfInfoFileConstants.VmStatus, vmsStatus);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid)

Example 12 with VmDynamic

use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method buildVMDynamicData.

public static VmDynamic buildVMDynamicData(Map<String, Object> struct, VDS host) {
    VmDynamic vmdynamic = new VmDynamic();
    updateVMDynamicData(vmdynamic, struct, host);
    return vmdynamic;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 13 with VmDynamic

use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.

the class VmStatsVdsBrokerCommand method createVdsmVm.

protected VdsmVm createVdsmVm(Map<String, Object> struct) {
    VmDynamic vmDynamic = new VmDynamic();
    VdsBrokerObjectsBuilder.updateVMDynamicData(vmDynamic, struct, getVds());
    Guid vmId = vmDynamic.getId();
    return new VdsmVm(getVdsmCallTimestamp(struct)).setVmDynamic(vmDynamic).setDevicesHash(getVmDevicesHash(struct)).setVmStatistics(buildVMStatisticsData(struct)).setVmJobs(buildVmJobsData(struct)).setInterfaceStatistics(buildInterfaceStatisticsData(struct)).setVmBalloonInfo(buildVmBalloonInfo(struct)).setVmGuestAgentInterfaces(buildVmGuestAgentInterfacesData(vmId, struct)).setLunsMap(buildVmLunDisksData(struct)).setDiskStatistics(buildVmDiskStatistics(struct));
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VdsmVm(org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm) Guid(org.ovirt.engine.core.compat.Guid)

Example 14 with VmDynamic

use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.

the class DestroyVmVDSCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.Destroy, getParameters());
    if (vdsReturnValue.getSucceeded()) {
        VmDynamic vm = vmDynamicDao.get(getParameters().getVmId());
        changeStatus(vm);
        vm.setStopReason(getParameters().getReason());
        vmManager.update(vm);
        getVDSReturnValue().setReturnValue(vm.getStatus());
    } else if (vdsReturnValue.getExceptionObject() != null) {
        logFailureToDestroy(vdsReturnValue);
        getVDSReturnValue().setSucceeded(false);
        getVDSReturnValue().setExceptionString(vdsReturnValue.getExceptionString());
        getVDSReturnValue().setExceptionObject(vdsReturnValue.getExceptionObject());
        getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
    }
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 15 with VmDynamic

use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.

the class StorageDomainValidator method isRunningVmsOrVmLeasesForBackupDomain.

public ValidationResult isRunningVmsOrVmLeasesForBackupDomain(VmHandler vmHandler) {
    Set<String> invalidVmsForBackupStorageDomain = new HashSet<>();
    QueryReturnValue ret = getEntitiesWithLeaseIdForStorageDomain(storageDomain.getId());
    if (!ret.getSucceeded()) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_RETRIEVE_VMS_FOR_WITH_LEASES);
    }
    getRetVal(ret).forEach(vmBase -> {
        VmDynamic vm = getVmDynamicDao().get(vmBase.getId());
        if (vm != null && vm.getStatus() != VMStatus.Down) {
            invalidVmsForBackupStorageDomain.add(vmBase.getName());
        }
    });
    List<VM> vms = getVmDao().getAllActiveForStorageDomain(storageDomain.getId());
    vms.forEach(vmHandler::updateDisksFromDb);
    invalidVmsForBackupStorageDomain.addAll(vms.stream().filter(vm -> vm.getDiskMap().values().stream().filter(DisksFilter.ONLY_IMAGES).filter(DisksFilter.ONLY_PLUGGED).map(DiskImage.class::cast).anyMatch(vmDisk -> vmDisk.getStorageIds().get(0).equals(storageDomain.getId()))).map(VM::getName).collect(Collectors.toList()));
    if (!invalidVmsForBackupStorageDomain.isEmpty()) {
        log.warn("Can't update the backup property of the storage domain since it contains VMs with " + "leases or active disks which are attached to running VMs." + "The following VMs list are: '{}'", invalidVmsForBackupStorageDomain);
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_RUNNING_VM_OR_VM_LEASES_PRESENT_ON_STORAGE_DOMAIN);
    }
    return ValidationResult.VALID;
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Backend(org.ovirt.engine.core.bll.Backend) Guid(org.ovirt.engine.core.compat.Guid) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) LoggerFactory(org.slf4j.LoggerFactory) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) Supplier(java.util.function.Supplier) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DbFacade(org.ovirt.engine.core.dal.dbbroker.DbFacade) HashSet(java.util.HashSet) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) BackendInternal(org.ovirt.engine.core.bll.interfaces.BackendInternal) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic) Version(org.ovirt.engine.core.compat.Version) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ImagesHandler(org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler) Logger(org.slf4j.Logger) VmHandler(org.ovirt.engine.core.bll.VmHandler) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) StorageConstants(org.ovirt.engine.core.common.constants.StorageConstants) Set(java.util.Set) BlockStorageDiscardFunctionalityHelper(org.ovirt.engine.core.bll.storage.utils.BlockStorageDiscardFunctionalityHelper) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Collectors(java.util.stream.Collectors) VmDao(org.ovirt.engine.core.dao.VmDao) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Injector(org.ovirt.engine.core.di.Injector) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo) Collections(java.util.Collections) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VM(org.ovirt.engine.core.common.businessentities.VM) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) HashSet(java.util.HashSet)

Aggregations

VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)54 Test (org.junit.Test)13 Guid (org.ovirt.engine.core.compat.Guid)12 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)8 VM (org.ovirt.engine.core.common.businessentities.VM)7 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)6 Vm (org.ovirt.engine.api.model.Vm)4 Date (java.util.Date)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 VdsmVm (org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1