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