Search in sources :

Example 1 with ImportVmFromExternalProviderParameters

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

the class ImportVmFromExternalSourceModel method buildImportVmFromExternalProviderParameters.

private List<ActionParametersBase> buildImportVmFromExternalProviderParameters() {
    List<ActionParametersBase> prms = new ArrayList<>();
    for (Object item : getItems()) {
        ImportVmData importVmData = (ImportVmData) item;
        VM vm = importVmData.getVm();
        ImportVmFromExternalProviderParameters prm = new ImportVmFromExternalProviderParameters(vm, getStorage().getSelectedItem().getId(), getStoragePool().getId(), getCluster().getSelectedItem().getId());
        prm.setUrl(url);
        prm.setUsername(username);
        prm.setPassword(password);
        prm.setProxyHostId(proxyHostId);
        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());
            // virt-v2v which converts the image format as well
            if (vm.getOrigin() != OriginType.KVM) {
                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);
        }
        prms.add(prm);
    }
    return prms;
}
Also used : ArrayList(java.util.ArrayList) ImportVmFromExternalProviderParameters(org.ovirt.engine.core.common.action.ImportVmFromExternalProviderParameters) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) VM(org.ovirt.engine.core.common.businessentities.VM) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) Map(java.util.Map) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ImportVmFromExternalProviderParameters (org.ovirt.engine.core.common.action.ImportVmFromExternalProviderParameters)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