use of org.ovirt.engine.core.common.action.ImportVmFromConfParameters in project ovirt-engine by oVirt.
the class RegisterVmModel method prepareParameters.
private List<ActionParametersBase> prepareParameters() {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (RegisterVmData registerVmData : getEntities().getItems()) {
VM vm = registerVmData.getEntity();
Cluster cluster = registerVmData.getCluster().getSelectedItem();
ImportVmFromConfParameters params = new ImportVmFromConfParameters(cloneExternalVnicProfiles(cluster), registerVmData.getReassignMacs().getEntity());
params.setContainerId(vm.getId());
params.setStorageDomainId(getStorageDomainId());
params.setImagesExistOnTargetStorageDomain(true);
params.setClusterId(cluster != null ? cluster.getId() : null);
params.setAllowPartialImport(registerVmData.getAllowPartialImport().getEntity());
if (isQuotaEnabled()) {
Quota quota = registerVmData.getClusterQuota().getSelectedItem();
params.setQuotaId(quota != null ? quota.getId() : null);
params.setDiskMap(vm.getDiskMap());
updateDiskQuotas(new ArrayList<>(params.getDiskMap().values()));
}
parameters.add(params);
}
return parameters;
}
use of org.ovirt.engine.core.common.action.ImportVmFromConfParameters in project ovirt-engine by oVirt.
the class BackendStorageDomainVmResource method register.
@Override
public Response register(Action action) {
ImportVmFromConfParameters params = new ImportVmFromConfParameters();
if (action.isSetRegistrationConfiguration()) {
validateClusterMappings(action);
validateRoleMappings(action);
validateDomainMappings(action);
validateAffinityGroupMappings(action);
validateAffinityLabelMappings(action);
validateLunMappings(action);
}
if (BackendVnicProfileHelper.foundOnlyDeprecatedVnicProfileMapping(action)) {
// This code block is for backward compatibility with {@link VnicProfileMapping}s that are specified
// outside the registration_configuration code. This specification is deprecated since 4.2.1 .
// When these mappings are removed from the ovirt-engine-api-model, this whole code block can be removed
// as well. In the meantime, if there are {@link VnicProfileMapping}s outside the registration_configuration
// block and no {@link RegistrationVnicProfileMapping}s inside it, they will be processed and used.
BackendVnicProfileHelper.validateVnicMappings(this, action);
Collection<ExternalVnicProfileMapping> vnicProfileMappings = ExternalVnicProfileMappingMapper.mapFromModel(action.getVnicProfileMappings());
params.setExternalVnicProfileMappings(vnicProfileMappings);
}
ExternalRegistrationConfigurationMapper.mapFromModel(action.getRegistrationConfiguration(), params);
params.setReassignBadMacs(getReassignBadMacs(action));
params.setContainerId(guid);
params.setStorageDomainId(parent.getStorageDomainId());
if (action.isSetCluster()) {
params.setClusterId(getClusterId(action));
}
params.setImagesExistOnTargetStorageDomain(true);
if (action.isSetClone()) {
params.setImportAsNewEntity(action.isClone());
if (action.isSetVm() && action.getVm().isSetName()) {
params.getVm().setName(action.getVm().getName());
}
}
if (action.isSetAllowPartialImport()) {
params.setAllowPartialImport(action.isAllowPartialImport());
}
return doAction(ActionType.ImportVmFromConfiguration, params, action);
}
use of org.ovirt.engine.core.common.action.ImportVmFromConfParameters in project ovirt-engine by oVirt.
the class BackendVmsResource method importVmFromConfiguration.
public Response importVmFromConfiguration(Vm vm) {
Initialization initialization = vm.getInitialization();
Configuration config = initialization.getConfiguration();
org.ovirt.engine.core.common.businessentities.VM vmConfiguration = getEntity(org.ovirt.engine.core.common.businessentities.VM.class, QueryType.GetVmFromConfiguration, new GetVmFromConfigurationQueryParameters(VmMapper.map(config.getType(), null), config.getData().trim()), "");
VmMapper.map(vm, vmConfiguration.getStaticData());
Guid clusterId = namedCluster(vm) ? getCluster(vm).getId() : asGuid(vm.getCluster().getId());
ImportVmFromConfParameters parameters = new ImportVmFromConfParameters();
parameters.setVm(vmConfiguration);
parameters.setClusterId(clusterId);
if (initialization.isSetRegenerateIds()) {
parameters.setImportAsNewEntity(initialization.isRegenerateIds());
}
return performCreate(ActionType.ImportVmFromConfiguration, parameters, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
use of org.ovirt.engine.core.common.action.ImportVmFromConfParameters in project ovirt-engine by oVirt.
the class ImportVMFromConfigurationCommandTest method createParametersWhenImagesExistOnTargetStorageDomain.
private ImportVmFromConfParameters createParametersWhenImagesExistOnTargetStorageDomain() {
ImportVmFromConfParameters params = new ImportVmFromConfParameters(emptyList(), true);
params.setContainerId(vmId);
params.setStorageDomainId(storageDomainId);
params.setClusterId(clusterId);
params.setImagesExistOnTargetStorageDomain(true);
return params;
}
Aggregations