use of org.ovirt.engine.core.common.action.ImportVmParameters in project ovirt-engine by oVirt.
the class ImportValidatorTest method createParameters.
protected ImportVmParameters createParameters() {
final VM v = createVM();
v.setName("testVm");
return new ImportVmParameters(v, Guid.newGuid(), Guid.newGuid(), Guid.newGuid(), Guid.newGuid());
}
use of org.ovirt.engine.core.common.action.ImportVmParameters in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainModel method buildImportVmParameters.
private List<ActionParametersBase> buildImportVmParameters() {
List<ActionParametersBase> prms = new ArrayList<>();
for (Object item : getItems()) {
VM vm = ((ImportVmData) item).getVm();
ImportVmParameters prm = new ImportVmParameters(vm, (Guid) getEntity(), Guid.Empty, getStoragePool().getId(), getCluster().getSelectedItem().getId());
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) item).getCollapseSnapshots().getEntity());
Map<Guid, Guid> map = new HashMap<>();
for (Map.Entry<Guid, Disk> entry : vm.getDiskMap().entrySet()) {
DiskImage disk = (DiskImage) entry.getValue();
map.put(disk.getId(), getDiskImportData(disk.getId()).getSelectedStorageDomain().getId());
disk.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(getDiskImportData(disk.getId()).getSelectedVolumeType(), getDiskImportData(disk.getId()).getSelectedStorageDomain().getStorageType()));
disk.setVolumeType(getDiskImportData(disk.getId()).getSelectedVolumeType());
if (getDiskImportData(disk.getId()).getSelectedQuota() != null) {
disk.setQuotaId(getDiskImportData(disk.getId()).getSelectedQuota().getId());
}
}
prm.setImageToDestinationDomainMap(map);
if (((ImportVmData) item).isExistsInSystem() || ((ImportVmData) item).getClone().getEntity()) {
prm.setImportAsNewEntity(true);
prm.setCopyCollapse(true);
}
prms.add(prm);
}
return prms;
}
use of org.ovirt.engine.core.common.action.ImportVmParameters in project ovirt-engine by oVirt.
the class BackendStorageDomainVmResource method doImport.
@Override
public Response doImport(Action action) {
validateParameters(action, "storageDomain.id|name");
Guid destStorageDomainId = getDestStorageDomainId(action);
Guid clusterId = null;
if (action.isSetCluster()) {
clusterId = getClusterId(action);
}
ImportVmParameters params = new ImportVmParameters(getEntity(), parent.getStorageDomainId(), destStorageDomainId, parent.getDataCenterId(destStorageDomainId), clusterId);
params.setImageToDestinationDomainMap(getDiskToDestinationMap(action));
params.setForceOverride(action.isSetExclusive() ? action.isExclusive() : false);
boolean collapseSnapshots = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, COLLAPSE_SNAPSHOTS, true, false);
if (collapseSnapshots) {
params.setCopyCollapse(collapseSnapshots);
}
setVolumesTypeFormat(action);
if (action.isSetClone()) {
params.setImportAsNewEntity(action.isClone());
if (action.isSetVm() && action.getVm().isSetName()) {
params.getVm().setName(action.getVm().getName());
}
}
return doAction(ActionType.ImportVm, params, action);
}
use of org.ovirt.engine.core.common.action.ImportVmParameters in project ovirt-engine by oVirt.
the class HostedEngineImporter method createImportParams.
private ImportVmParameters createImportParams(VM vm, StorageDomain sd) {
ImportVmParameters parameters = new ImportVmParameters(vm, sd.getId(), sd.getId(), sd.getStoragePoolId(), vm.getClusterId());
// assumption is that there's only 1 profile for hosted engine domain. its an unmanged domain.
Guid sdProfileId = diskProfileDao.getAllForStorageDomain(sd.getId()).get(0).getId();
for (DiskImage image : vm.getImages()) {
image.setDiskProfileId(sdProfileId);
image.setStorageIds(Collections.singletonList(sd.getId()));
image.setVmSnapshotId(Guid.newGuid());
image.setImageStatus(ImageStatus.OK);
}
// disks are there already(the vm is running)
parameters.setImagesExistOnTargetStorageDomain(true);
// distinguish from "regular" he vm.
vm.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
// architecture is a missing attribute from vdsm structure. relying on the cluster is perfectly reliable.
Cluster cluster = clusterDAO.get(vm.getClusterId());
vm.setClusterArch(cluster.getArchitecture());
vm.setVmCreationDate(new Date());
vm.setMigrationSupport(MigrationSupport.IMPLICITLY_NON_MIGRATABLE);
osRepository.getLinuxOss().stream().sorted().findFirst().ifPresent(vm::setVmOs);
vm.setPriority(1);
vmHandler.updateDefaultTimeZone(vm.getStaticData());
return parameters;
}
use of org.ovirt.engine.core.common.action.ImportVmParameters in project ovirt-engine by oVirt.
the class ImportValidatorTest method lowThresholdStorageSpace.
@Test
public void lowThresholdStorageSpace() {
ImportVmParameters parameters = createParameters();
ImportValidator validator = setupDiskSpaceTest(parameters);
doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN)).when(multipleSdValidator).allDomainsWithinThresholds();
assertThat(validator.validateSpaceRequirements(Collections.emptyList()), failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN));
}
Aggregations