Search in sources :

Example 1 with ImportVmFromOvaParameters

use of org.ovirt.engine.core.common.action.ImportVmFromOvaParameters in project ovirt-engine by oVirt.

the class ImportVmFromOvaModel method buildImportVmFromOvaParameters.

private List<ActionParametersBase> buildImportVmFromOvaParameters() {
    ImportVmData importVmData = (ImportVmData) getItems().iterator().next();
    VM vm = importVmData.getVm();
    ImportVmFromOvaParameters prm = new ImportVmFromOvaParameters(vm, getStorage().getSelectedItem().getId(), getStoragePool().getId(), getCluster().getSelectedItem().getId());
    prm.setOvaPath(ovaPath);
    prm.setProxyHostId(hostId);
    prm.setVirtioIsoName(getIso().getIsChangable() && getIso().getSelectedItem() != null ? getIso().getSelectedItem().getRepoImageId() : null);
    prm.setExternalName(importVmData.getName());
    if (getClusterQuota().getSelectedItem() != null && getClusterQuota().getIsAvailable()) {
        prm.setQuotaId(getClusterQuota().getSelectedItem().getId());
    }
    CpuProfile cpuProfile = getCpuProfiles().getSelectedItem();
    if (cpuProfile != null) {
        prm.setCpuProfileId(cpuProfile.getId());
    }
    prm.setForceOverride(true);
    prm.setCopyCollapse(importVmData.getCollapseSnapshots().getEntity());
    for (Map.Entry<Guid, Disk> entry : vm.getDiskMap().entrySet()) {
        DiskImage disk = (DiskImage) entry.getValue();
        ImportDiskData importDiskData = getDiskImportData(disk.getDiskAlias());
        disk.setVolumeType(getAllocation().getSelectedItem());
        disk.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(disk.getVolumeType(), getStorage().getSelectedItem().getStorageType()));
        if (getDiskImportData(disk.getDiskAlias()).getSelectedQuota() != null) {
            disk.setQuotaId(importDiskData.getSelectedQuota().getId());
        }
    }
    updateNetworkInterfacesForVm(vm);
    if (importVmData.isExistsInSystem() || importVmData.getClone().getEntity()) {
        prm.setImportAsNewEntity(true);
        prm.setCopyCollapse(true);
    }
    return Collections.singletonList(prm);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) ImportVmFromOvaParameters(org.ovirt.engine.core.common.action.ImportVmFromOvaParameters) Guid(org.ovirt.engine.core.compat.Guid) Map(java.util.Map) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

Map (java.util.Map)1 ImportVmFromOvaParameters (org.ovirt.engine.core.common.action.ImportVmFromOvaParameters)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 CpuProfile (org.ovirt.engine.core.common.businessentities.profiles.CpuProfile)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 Guid (org.ovirt.engine.core.compat.Guid)1