Search in sources :

Example 36 with VmDynamic

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

the class MigrateVDSCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.MigrateBroker, getParameters());
    VmDynamic vmDynamic = vmDynamicDao.get(getParameters().getVmId());
    if (vdsReturnValue.getSucceeded()) {
        resourceManager.addAsyncRunningVm(getParameters().getVmId());
        vmDynamic.setStatus(VMStatus.MigratingFrom);
        vmDynamic.setMigratingToVds(getParameters().getDstVdsId());
        vmManager.update(vmDynamic);
        getVDSReturnValue().setReturnValue(VMStatus.MigratingFrom);
    } else {
        log.error("Failed to migrate VM '{}' in VDS = '{}' , error = '{}'", getParameters().getVmId(), getParameters().getVdsId(), vdsReturnValue.getExceptionString());
        getVDSReturnValue().setSucceeded(false);
        getVDSReturnValue().setReturnValue(vmDynamic.getStatus());
        getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
        getVDSReturnValue().setExceptionString(vdsReturnValue.getExceptionString());
        getVDSReturnValue().setExceptionObject(vdsReturnValue.getExceptionObject());
    }
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 37 with VmDynamic

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

the class BackendVmSessionsResourceTest method getEntity.

@Override
protected VM getEntity(int index) {
    org.ovirt.engine.core.common.businessentities.VM vm = new org.ovirt.engine.core.common.businessentities.VM();
    VmDynamic vmDynamic = new VmDynamic();
    vmDynamic.setConsoleCurrentUserName("admin@internal");
    vmDynamic.setClientIp("1.1.1.1");
    vmDynamic.setGuestCurrentUserName("Ori");
    vm.setDynamicData(vmDynamic);
    return vm;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 38 with VmDynamic

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

the class VmManager method estimateOverhead.

private int estimateOverhead(VmStatic vmStatic) {
    // Prepare VM object using the available bits and pieces
    VM compose = new VM(vmStatic, new VmDynamic(), new VmStatistics(), clusterArchitecture, clusterCompatibilityVersion);
    // Load device list, TODO ignores unmanaged devices for now
    Map<Guid, VmDevice> devices = vmDeviceDao.getVmDeviceByVmId(vmId).stream().filter(VmDevice::isManaged).collect(Collectors.toMap(d -> d.getId().getDeviceId(), Function.identity()));
    vmStatic.setManagedDeviceMap(devices);
    return vmOverheadCalculator.getTotalRequiredMemoryInMb(compose);
}
Also used : VmStatisticsDao(org.ovirt.engine.core.dao.VmStatisticsDao) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) Function(java.util.function.Function) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) Inject(javax.inject.Inject) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) VmNetworkStatisticsDao(org.ovirt.engine.core.dao.network.VmNetworkStatisticsDao) Map(java.util.Map) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) Version(org.ovirt.engine.core.compat.Version) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) ReentrantLock(java.util.concurrent.locks.ReentrantLock) VmOverheadCalculator(org.ovirt.engine.core.common.scheduling.VmOverheadCalculator) Collectors(java.util.stream.Collectors) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VdsmVm(org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm) PostConstruct(javax.annotation.PostConstruct) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid)

Example 39 with VmDynamic

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

the class VdsBrokerObjectsBuilder method buildVmsDataFromExternalProvider.

public static VM buildVmsDataFromExternalProvider(Map<String, Object> struct) {
    VmStatic vmStatic = buildVmStaticDataFromExternalProvider(struct);
    if (vmStatic == null) {
        return null;
    }
    VmDynamic vmDynamic = buildVMDynamicDataFromList(struct);
    VM vm = new VM(vmStatic, vmDynamic, new VmStatistics());
    for (DiskImage image : vm.getImages()) {
        vm.getDiskMap().put(Guid.newGuid(), image);
    }
    try {
        vm.setClusterArch(parseArchitecture(struct));
    } catch (IllegalArgumentException ex) {
        log.warn("Illegal architecture type: {}, replacing with x86_64", struct.get(VdsProperties.vm_arch));
        vm.setClusterArch(ArchitectureType.x86_64);
    } catch (NullPointerException ex) {
        log.warn("null architecture type, replacing with x86_64, {}", vm);
        vm.setClusterArch(ArchitectureType.x86_64);
    }
    return vm;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 40 with VmDynamic

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

the class ListVDSCommand method executeVdsBrokerCommand.

@Override
protected void executeVdsBrokerCommand() {
    vmListReturn = getBroker().list();
    proceedProxyReturnValue();
    Map<Guid, VdsmVm> returnVMs = new HashMap<>();
    for (int idx = 0; idx < vmListReturn.vmList.length; ++idx) {
        Map<String, Object> vm = vmListReturn.vmList[idx];
        VmDynamic dynamicData = buildVMDynamicDataFromList(vm);
        VdsmVm vdsmVm = new VdsmVm(getVdsmCallTimestamp(vm)).setVmDynamic(dynamicData).setDevicesHash(getVmDevicesHash(vm));
        returnVMs.put(dynamicData.getId(), vdsmVm);
    }
    setReturnValue(returnVMs);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) HashMap(java.util.HashMap) VdsmVm(org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm) Guid(org.ovirt.engine.core.compat.Guid)

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