Search in sources :

Example 1 with ImportVmTemplateFromConfParameters

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

the class BackendStorageDomainTemplateResource method register.

@Override
public Response register(Action action) {
    ImportVmTemplateFromConfParameters params = new ImportVmTemplateFromConfParameters();
    if (BackendVnicProfileHelper.foundOnlyDeprecatedVnicProfileMapping(action)) {
        // This code block is for backward compatibility with {@link VnicProfileMapping}s that are specified
        // outside the registration_configuration code, which 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.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.getTemplate().isSetName()) {
            params.getVmTemplate().setName(action.getTemplate().getName());
        }
    }
    if (action.isSetAllowPartialImport()) {
        params.setAllowPartialImport(action.isAllowPartialImport());
    }
    return doAction(ActionType.ImportVmTemplateFromConfiguration, params, action);
}
Also used : ImportVmTemplateFromConfParameters(org.ovirt.engine.core.common.action.ImportVmTemplateFromConfParameters) ExternalVnicProfileMapping(org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)

Example 2 with ImportVmTemplateFromConfParameters

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

the class RegisterTemplateModel method prepareActionParameters.

private List<ActionParametersBase> prepareActionParameters() {
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (ImportTemplateData entityData : getEntities().getItems()) {
        VmTemplate vmTemplate = entityData.getEntity();
        Cluster cluster = entityData.getCluster().getSelectedItem();
        ImportVmTemplateFromConfParameters params = new ImportVmTemplateFromConfParameters();
        params.setExternalVnicProfileMappings(cloneExternalVnicProfiles(cluster));
        params.setContainerId(vmTemplate.getId());
        params.setStorageDomainId(getStorageDomainId());
        params.setImagesExistOnTargetStorageDomain(true);
        params.setClusterId(cluster != null ? cluster.getId() : null);
        if (isQuotaEnabled()) {
            Quota quota = entityData.getClusterQuota().getSelectedItem();
            params.setQuotaId(quota != null ? quota.getId() : null);
            params.setDiskTemplateMap(vmTemplate.getDiskTemplateMap());
            updateDiskQuotas(new ArrayList<Disk>(params.getDiskTemplateMap().values()));
        }
        parameters.add(params);
    }
    return parameters;
}
Also used : ImportVmTemplateFromConfParameters(org.ovirt.engine.core.common.action.ImportVmTemplateFromConfParameters) ImportTemplateData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData) Quota(org.ovirt.engine.core.common.businessentities.Quota) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

ImportVmTemplateFromConfParameters (org.ovirt.engine.core.common.action.ImportVmTemplateFromConfParameters)2 ArrayList (java.util.ArrayList)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 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1 ExternalVnicProfileMapping (org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 ImportTemplateData (org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData)1