Search in sources :

Example 1 with ImportVmFromConfParameters

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;
}
Also used : Quota(org.ovirt.engine.core.common.businessentities.Quota) RegisterVmData(org.ovirt.engine.ui.uicommonweb.models.vms.register.RegisterVmData) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 2 with ImportVmFromConfParameters

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);
}
Also used : ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters) ExternalVnicProfileMapping(org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)

Example 3 with ImportVmFromConfParameters

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));
}
Also used : Initialization(org.ovirt.engine.api.model.Initialization) VM(org.ovirt.engine.core.common.businessentities.VM) GetVmFromConfigurationQueryParameters(org.ovirt.engine.core.common.queries.GetVmFromConfigurationQueryParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Configuration(org.ovirt.engine.api.model.Configuration) ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 4 with ImportVmFromConfParameters

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;
}
Also used : ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters)

Aggregations

ImportVmFromConfParameters (org.ovirt.engine.core.common.action.ImportVmFromConfParameters)4 VM (org.ovirt.engine.core.common.businessentities.VM)2 ArrayList (java.util.ArrayList)1 Configuration (org.ovirt.engine.api.model.Configuration)1 Initialization (org.ovirt.engine.api.model.Initialization)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 Quota (org.ovirt.engine.core.common.businessentities.Quota)1 ExternalVnicProfileMapping (org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)1 GetVmFromConfigurationQueryParameters (org.ovirt.engine.core.common.queries.GetVmFromConfigurationQueryParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1 RegisterVmData (org.ovirt.engine.ui.uicommonweb.models.vms.register.RegisterVmData)1