Search in sources :

Example 1 with MapVnicsContext

use of org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext in project ovirt-engine by oVirt.

the class MatchUserMappingToOvfVnicTest method testFindMappingEntry.

@Test
public void testFindMappingEntry() {
    VmNetworkInterface vnic = new VmNetworkInterface();
    vnic.setNetworkName(NETWORK_NAME);
    vnic.setVnicProfileName(VNIC_PROFILE1_NAME);
    MapVnicsContext ctx = new MapVnicsContext();
    ctx.setUserMappings(externalVnicProfileMappings);
    ctx.setOvfVnics(singletonList(vnic));
    underTest.handle(ctx);
    assertThat(ctx.getMatched().get(vnic), sameInstance(externalVnicProfileMapping1));
}
Also used : MapVnicsContext(org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Example 2 with MapVnicsContext

use of org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext in project ovirt-engine by oVirt.

the class MatchUserMappingToOvfVnicTest method testFindMappingEntryEmptyExternal.

@Test
public void testFindMappingEntryEmptyExternal() {
    VmNetworkInterface vnic = new VmNetworkInterface();
    vnic.setNetworkName(NETWORK_NAME);
    vnic.setVnicProfileName(VNIC_PROFILE1_NAME);
    MapVnicsContext ctx = new MapVnicsContext();
    ctx.setUserMappings(singletonList(emptySourceMapping));
    ctx.setOvfVnics(singletonList(vnic));
    underTest.handle(ctx);
    assertEquals(null, ctx.getMatched().get(vnic));
}
Also used : MapVnicsContext(org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Example 3 with MapVnicsContext

use of org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext in project ovirt-engine by oVirt.

the class MatchUserMappingToOvfVnicTest method testFindMappingEntryEmptyInput.

@Test
public void testFindMappingEntryEmptyInput() {
    VmNetworkInterface vnic = new VmNetworkInterface();
    MapVnicsContext ctx = new MapVnicsContext();
    ctx.setUserMappings(emptyList());
    ctx.setOvfVnics(singletonList(vnic));
    underTest.handle(ctx);
    assertEquals(1, ctx.getMatched().size());
    assertEquals(null, ctx.getMatched().get(vnic));
}
Also used : MapVnicsContext(org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Example 4 with MapVnicsContext

use of org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext in project ovirt-engine by oVirt.

the class DrMappingHelper method updateVnicsFromMappings.

public List<String> updateVnicsFromMappings(Guid clusterId, String vmName, List<VmNetworkInterface> vnics, Collection<ExternalVnicProfileMapping> mappings) {
    MapVnicsContext ctx = new MapVnicsContext("updateVnicsFromMappings").setClusterId(clusterId).setVmName(vmName).setOvfVnics(vnics).setUserMappings(mappings);
    mapVnicsFlow.getHead().process(ctx);
    return !CollectionUtils.isEmpty(ctx.getNonAssociableVnics()) ? ctx.getNonAssociableVnics() : Collections.emptyList();
}
Also used : MapVnicsContext(org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext)

Example 5 with MapVnicsContext

use of org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext in project ovirt-engine by oVirt.

the class MatchUserMappingToOvfVnicTest method testFindMappingEntryEmptySourceVnicProfile.

@Test
public void testFindMappingEntryEmptySourceVnicProfile() {
    VmNetworkInterface vnic = new VmNetworkInterface();
    vnic.setNetworkName(null);
    vnic.setVnicProfileName(null);
    MapVnicsContext ctx = new MapVnicsContext();
    ctx.setUserMappings(singletonList(emptySourceMapping));
    ctx.setOvfVnics(singletonList(vnic));
    underTest.handle(ctx);
    assertThat(ctx.getMatched().get(vnic), sameInstance(emptySourceMapping));
}
Also used : MapVnicsContext(org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Aggregations

MapVnicsContext (org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext)6 Test (org.junit.Test)5 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)5