Search in sources :

Example 56 with VmStatic

use of org.ovirt.engine.core.common.businessentities.VmStatic 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 57 with VmStatic

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

the class Cloner method cloneVmStatic.

private static VmStatic cloneVmStatic(VmStatic instance) {
    VmStatic obj = new VmStatic();
    obj.setFailBack(instance.isFailBack());
    obj.setDefaultBootSequence(instance.getDefaultBootSequence());
    obj.setVmType(instance.getVmType());
    obj.setDefaultDisplayType(instance.getDefaultDisplayType());
    obj.setPriority(instance.getPriority());
    obj.setIsoPath(instance.getIsoPath());
    obj.setOrigin(instance.getOrigin());
    obj.setAutoStartup(instance.isAutoStartup());
    obj.setCpuPerSocket(instance.getCpuPerSocket());
    obj.setThreadsPerCpu(instance.getThreadsPerCpu());
    obj.setCreationDate(instance.getCreationDate());
    obj.setDedicatedVmForVdsList(instance.getDedicatedVmForVdsList());
    obj.setDescription(instance.getDescription());
    obj.setComment(instance.getComment());
    obj.setCustomEmulatedMachine(instance.getCustomEmulatedMachine());
    obj.setCustomCpuName(instance.getCustomCpuName());
    obj.setCustomCompatibilityVersion(instance.getCustomCompatibilityVersion());
    obj.setInitialized(instance.isInitialized());
    obj.setStateless(instance.isStateless());
    obj.setRunAndPause(instance.isRunAndPause());
    obj.setMemSizeMb(instance.getMemSizeMb());
    obj.setNiceLevel(instance.getNiceLevel());
    obj.setNumOfMonitors(instance.getNumOfMonitors());
    obj.setAllowConsoleReconnect(instance.isAllowConsoleReconnect());
    obj.setNumOfSockets(instance.getNumOfSockets());
    obj.setTimeZone(instance.getTimeZone());
    obj.setUsbPolicy(instance.getUsbPolicy());
    obj.setClusterId(instance.getClusterId());
    obj.setId(instance.getId());
    obj.setName(instance.getName());
    obj.setVmtGuid(instance.getVmtGuid());
    obj.setUseLatestVersion(instance.isUseLatestVersion());
    obj.setSerialNumberPolicy(instance.getSerialNumberPolicy());
    obj.setCustomSerialNumber(instance.getCustomSerialNumber());
    obj.setBootMenuEnabled(instance.isBootMenuEnabled());
    obj.setSpiceFileTransferEnabled(instance.isSpiceFileTransferEnabled());
    obj.setSpiceCopyPasteEnabled(instance.isSpiceCopyPasteEnabled());
    obj.setCpuProfileId(instance.getCpuProfileId());
    obj.setAutoConverge(instance.getAutoConverge());
    obj.setMigrateCompressed(instance.getMigrateCompressed());
    obj.setPredefinedProperties(instance.getPredefinedProperties());
    obj.setUserDefinedProperties(instance.getUserDefinedProperties());
    obj.setCustomProperties(instance.getCustomProperties());
    obj.setSmallIconId(instance.getSmallIconId());
    obj.setLargeIconId(instance.getLargeIconId());
    obj.setProviderId(instance.getProviderId());
    obj.setLeaseStorageDomainId(instance.getLeaseStorageDomainId());
    return obj;
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 58 with VmStatic

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

the class DeactivateStorageDomainCommand method getVmsWithAttachedISO.

protected List<String> getVmsWithAttachedISO() {
    List<VmStatic> vms = vmStaticDao.getAllByStoragePoolId(getStorageDomain().getStoragePoolId());
    List<String> vmNames = new LinkedList<>();
    for (VmStatic vmStatic : vms) {
        VmDynamic vmDynamic = vmDynamicDao.get(vmStatic.getId());
        if (vmDynamic.getStatus() != VMStatus.Down && !StringUtils.isEmpty(vmDynamic.getCurrentCd())) {
            vmNames.add(vmStatic.getName());
        }
    }
    return vmNames;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) LinkedList(java.util.LinkedList)

Example 59 with VmStatic

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

the class BackendVmsResource method cloneVmFromSnapshot.

private Response cloneVmFromSnapshot(org.ovirt.engine.core.common.businessentities.VM configVm, Vm vm, String snapshotId, HashMap<Guid, DiskImage> images) {
    VmStatic staticVm = configVm.getStaticData();
    Guid sourceSnapshotId = asGuid(snapshotId);
    AddVmFromSnapshotParameters params = new AddVmFromSnapshotParameters(staticVm, sourceSnapshotId);
    params.setDiskInfoDestinationMap(images);
    params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
    params.setVirtioScsiEnabled(vm.isSetVirtioScsi() && vm.getVirtioScsi().isSetEnabled() ? vm.getVirtioScsi().isEnabled() : null);
    if (vm.isSetSoundcardEnabled()) {
        params.setSoundDeviceEnabled(vm.isSoundcardEnabled());
    } else {
        params.setSoundDeviceEnabled(isVMDeviceTypeExist(configVm.getManagedVmDeviceMap(), VmDeviceGeneralType.SOUND));
    }
    params.setConsoleEnabled(vm.isSetConsole() && vm.getConsole().isSetEnabled() ? vm.getConsole().isEnabled() : !getConsoleDevicesForEntity(staticVm.getId()).isEmpty());
    if (vm.isSetRngDevice()) {
        params.setUpdateRngDevice(true);
        params.setRngDevice(RngDeviceMapper.map(vm.getRngDevice(), null));
    }
    DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
    return performCreate(ActionType.AddVmFromSnapshot, params, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Guid(org.ovirt.engine.core.compat.Guid) AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters)

Example 60 with VmStatic

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

the class ImportRepoImageCommand method createTemplate.

private Guid createTemplate() {
    VmTemplate blankTemplate = vmTemplateDao.get(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
    VmStatic masterVm = new VmStatic(blankTemplate);
    DiskImage templateDiskImage = getParameters().getDiskImage();
    String vmTemplateName = getParameters().getTemplateName();
    AddVmTemplateParameters parameters = new AddVmTemplateParameters(masterVm, vmTemplateName, templateDiskImage.getDiskDescription());
    // Setting the user from the parent command, as the session might already be invalid
    parameters.setParametersCurrentUser(getParameters().getParametersCurrentUser());
    // Setting the cluster ID, and other related properties derived from it
    if (getParameters().getClusterId() != null) {
        masterVm.setClusterId(getParameters().getClusterId());
        Cluster vdsGroup = getCluster(masterVm.getClusterId());
        masterVm.setOsId(osRepository.getDefaultOSes().get(vdsGroup.getArchitecture()));
        DisplayType defaultDisplayType = osRepository.getGraphicsAndDisplays(masterVm.getOsId(), vdsGroup.getCompatibilityVersion()).get(0).getSecond();
        masterVm.setDefaultDisplayType(defaultDisplayType);
    }
    parameters.setBalloonEnabled(true);
    ActionReturnValue addVmTemplateReturnValue = Backend.getInstance().runInternalAction(ActionType.AddVmTemplate, parameters, ExecutionHandler.createDefaultContextForTasks(getContext()));
    // No reason for this to return null, but checking just to make sure, and returning the created template, or null if failed
    return addVmTemplateReturnValue.getActionReturnValue() != null ? (Guid) addVmTemplateReturnValue.getActionReturnValue() : null;
}
Also used : DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)87 Test (org.junit.Test)26 Guid (org.ovirt.engine.core.compat.Guid)15 VM (org.ovirt.engine.core.common.businessentities.VM)11 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)8 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)8 Label (org.ovirt.engine.core.common.businessentities.Label)7 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Response (javax.ws.rs.core.Response)4 AddVmTemplateParameters (org.ovirt.engine.core.common.action.AddVmTemplateParameters)4 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)4 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)4 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 PostConstruct (javax.annotation.PostConstruct)3 Before (org.junit.Before)3