Search in sources :

Example 1 with OvsVifDriver

use of com.cloud.hypervisor.kvm.resource.OvsVifDriver in project cloudstack by apache.

the class LibvirtReplugNicCommandWrapperTest method setUp.

@Before
public void setUp() throws Exception {
    Scanner scanner = new Scanner(memInfo);
    PowerMockito.whenNew(Scanner.class).withAnyArguments().thenReturn(scanner);
    // Use a spy because we only want to override getVifDriverClass
    LibvirtComputingResource resReal = new LibvirtComputingResource();
    res = spy(resReal);
    Connect conn = mock(Connect.class);
    LibvirtUtilitiesHelper helper = mock(LibvirtUtilitiesHelper.class);
    when(_domain.getXMLDesc(0)).thenReturn(fullfile).thenReturn(part_1 + part_3);
    when(conn.domainLookupByName(anyString())).thenReturn(_domain);
    when(helper.getConnectionByVmName(anyString())).thenReturn(conn);
    PowerMockito.mockStatic(Script.class);
    BDDMockito.given(Script.findScript(anyString(), anyString())).willReturn("dummypath/tofile.sh");
    Map<String, String> pifs = new HashMap<>();
    pifs.put(GUEST_BR, "eth0");
    Map<String, Object> params = new HashMap<>();
    params.put("libvirt.computing.resource", res);
    params.put("libvirt.host.pifs", pifs);
    BridgeVifDriver bridgeVifDriver = spy(new BridgeVifDriver());
    OvsVifDriver ovsVifDriver = spy(new OvsVifDriver());
    doNothing().when(bridgeVifDriver).getPifs();
    doNothing().when(ovsVifDriver).getPifs();
    doReturn(helper).when(res).getLibvirtUtilitiesHelper();
    doReturn(bridgeVifDriver).when(res).getVifDriver(eq(Networks.TrafficType.Guest), anyString());
    doReturn(ovsVifDriver).when(res).getVifDriver(Networks.TrafficType.Guest, GUEST_BR);
    doReturn(bridgeVifDriver).when(res).getVifDriver(not(eq(Networks.TrafficType.Guest)));
    doReturn(Arrays.asList(bridgeVifDriver, ovsVifDriver)).when(res).getAllVifDrivers();
    bridgeVifDriver.configure(params);
    ovsVifDriver.configure(params);
}
Also used : Scanner(java.util.Scanner) HashMap(java.util.HashMap) Connect(org.libvirt.Connect) LibvirtComputingResource(com.cloud.hypervisor.kvm.resource.LibvirtComputingResource) BridgeVifDriver(com.cloud.hypervisor.kvm.resource.BridgeVifDriver) Matchers.anyString(org.mockito.Matchers.anyString) OvsVifDriver(com.cloud.hypervisor.kvm.resource.OvsVifDriver) Before(org.junit.Before)

Aggregations

BridgeVifDriver (com.cloud.hypervisor.kvm.resource.BridgeVifDriver)1 LibvirtComputingResource (com.cloud.hypervisor.kvm.resource.LibvirtComputingResource)1 OvsVifDriver (com.cloud.hypervisor.kvm.resource.OvsVifDriver)1 HashMap (java.util.HashMap)1 Scanner (java.util.Scanner)1 Before (org.junit.Before)1 Connect (org.libvirt.Connect)1 Matchers.anyString (org.mockito.Matchers.anyString)1