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;
}
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);
}
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();
}
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);
}
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");
}
}
Aggregations