Search in sources :

Example 1 with ExternalVnicProfileMapping

use of org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping in project ovirt-engine by oVirt.

the class ExternalRegistrationConfigurationMapper method createExternalVnicProfileMapping.

/**
 * <pre>
 * - Best effort conversion of the input user mapping REST API object into an internal representation.
 * - If there is no target 'to' then it is considered as 'no mapping specified' for this 'from'. therefore the
 *   user entry is ignored and the bll logic will try to use the sources on the ovf nic as the target.
 * </pre>
 * @param regMapping - user input for mapping
 * @return internal object representing the input user mapping
 */
private static ExternalVnicProfileMapping createExternalVnicProfileMapping(RegistrationVnicProfileMapping regMapping) {
    ExternalVnicProfileMapping m = new ExternalVnicProfileMapping(regMapping.getFrom().getNetwork().getName(), regMapping.getFrom().getName());
    if (isSetToId(regMapping)) {
        try {
            Guid targetId = asGuid(regMapping.getTo().getId());
            m.setTargetProfileId(targetId);
        } catch (Exception e) {
        // bad id - ignore
        }
    }
    if (isSetToName(regMapping)) {
        m.setTargetProfileName(regMapping.getTo().getName());
    }
    if (isSetToNetworkName(regMapping)) {
        m.setTargetNetworkName(regMapping.getTo().getNetwork().getName());
    }
    return m;
}
Also used : GuidUtils.asGuid(org.ovirt.engine.api.restapi.utils.GuidUtils.asGuid) Guid(org.ovirt.engine.core.compat.Guid) ExternalVnicProfileMapping(org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)

Example 2 with ExternalVnicProfileMapping

use of org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping 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 3 with ExternalVnicProfileMapping

use of org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping in project ovirt-engine by oVirt.

the class MapVnicFlowTestUtils method printMapping.

private static String printMapping(ExternalVnicProfileMapping mapping) {
    if (mapping == null) {
        return "null";
    }
    if (new ExternalVnicProfileMapping(null, null, null).equalsEntire(mapping)) {
        return "empty";
    }
    StringBuilder sb = new StringBuilder();
    sb.append(mapping.getSourceNetworkName()).append(", ").append(mapping.getSourceProfileName()).append(", ").append(mapping.getTargetProfileId() != null ? mapping.getTargetProfileId().toString() : "null").append(", ").append(mapping.getTargetNetworkName()).append(", ").append(mapping.getTargetProfileName());
    return sb.toString();
}
Also used : ExternalVnicProfileMapping(org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)

Example 4 with ExternalVnicProfileMapping

use of org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping 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 5 with ExternalVnicProfileMapping

use of org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping in project ovirt-engine by oVirt.

the class MatchUserMappingToOvfVnicTest method print.

private void print(VmNetworkInterface ovfVnicUnderTest, MapVnicsContext ctx, int count) {
    System.out.println("---------------- test #" + count + " ----------------");
    System.out.println("ovf vnic:" + ovfVnicUnderTest.getVnicProfileName() + " " + ovfVnicUnderTest.getNetworkName());
    ExternalVnicProfileMapping matched = ctx.getMatched().get(ovfVnicUnderTest);
    if (matched != null) {
        System.out.println("matched:" + matched.getSourceProfileName() + " " + matched.getSourceNetworkName());
    } else {
        System.out.println("matched is null");
    }
}
Also used : ExternalVnicProfileMapping(org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)

Aggregations

ExternalVnicProfileMapping (org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)7 Before (org.junit.Before)1 GuidUtils.asGuid (org.ovirt.engine.api.restapi.utils.GuidUtils.asGuid)1 MatchUserMappingToOvfVnic (org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsHandlers.MatchUserMappingToOvfVnic)1 ImportVmFromConfParameters (org.ovirt.engine.core.common.action.ImportVmFromConfParameters)1 ImportVmTemplateFromConfParameters (org.ovirt.engine.core.common.action.ImportVmTemplateFromConfParameters)1 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)1 Guid (org.ovirt.engine.core.compat.Guid)1