use of com.cloud.agent.api.OvsFetchInterfaceCommand in project cloudstack by apache.
the class LibvirtComputingResourceTest method testOvsFetchInterfaceCommand.
@Test
public void testOvsFetchInterfaceCommand() {
final String label = "eth0";
final OvsFetchInterfaceCommand command = new OvsFetchInterfaceCommand(label);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, libvirtComputingResource);
assertTrue(answer.getResult());
}
use of com.cloud.agent.api.OvsFetchInterfaceCommand in project cloudstack by apache.
the class NotAValidCommand method testOvsFetchInterfaceCommand.
@Test
public void testOvsFetchInterfaceCommand() {
final String label = "[abc]";
final String uuid = "befc4dcd-f5c6-4015-8791-3c18622b7c7f";
final Connection conn = Mockito.mock(Connection.class);
final XsLocalNetwork network = Mockito.mock(XsLocalNetwork.class);
final Network network2 = Mockito.mock(Network.class);
final PIF pif = Mockito.mock(PIF.class);
final PIF.Record pifRec = Mockito.mock(PIF.Record.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final OvsFetchInterfaceCommand fetchInterCommand = new OvsFetchInterfaceCommand(label);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.isXcp()).thenReturn(true);
when(citrixResourceBase.getLabel()).thenReturn("[abc]");
when(citrixResourceBase.getConnection()).thenReturn(conn);
when(citrixResourceBase.getHost()).thenReturn(xsHost);
try {
when(network.getNetwork()).thenReturn(network2);
when(network.getPif(conn)).thenReturn(pif);
when(network.getPif(conn)).thenReturn(pif);
when(pif.getRecord(conn)).thenReturn(pifRec);
when(network.getNetwork().getUuid(conn)).thenReturn(uuid);
when(citrixResourceBase.getNetworkByName(conn, label)).thenReturn(network);
} catch (final XenAPIException e) {
fail(e.getMessage());
} catch (final XmlRpcException e) {
fail(e.getMessage());
}
final Answer answer = wrapper.execute(fetchInterCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
use of com.cloud.agent.api.OvsFetchInterfaceCommand in project cloudstack by apache.
the class OvsTunnelManagerImpl method getGreEndpointIP.
private String getGreEndpointIP(Host host, Network nw) throws AgentUnavailableException, OperationTimedoutException {
String endpointIp = null;
// Fetch fefault name for network label from configuration
String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
Long physNetId = nw.getPhysicalNetworkId();
PhysicalNetworkTrafficType physNetTT = _physNetTTDao.findBy(physNetId, TrafficType.Guest);
HypervisorType hvType = host.getHypervisorType();
String label = null;
switch(hvType) {
case XenServer:
label = physNetTT.getXenNetworkLabel();
if ((label != null) && (!label.equals(""))) {
physNetLabel = label;
}
break;
case KVM:
label = physNetTT.getKvmNetworkLabel();
if ((label != null) && (!label.equals(""))) {
physNetLabel = label;
}
break;
default:
throw new CloudRuntimeException("Hypervisor " + hvType.toString() + " unsupported by OVS Tunnel Manager");
}
// Try to fetch GRE endpoint IP address for cloud db
// If not found, then find it on the hypervisor
OvsTunnelInterfaceVO tunnelIface = _tunnelInterfaceDao.getByHostAndLabel(host.getId(), physNetLabel);
if (tunnelIface == null) {
// Now find and fetch configuration for physical interface
// for network with label on target host
Commands fetchIfaceCmds = new Commands(new OvsFetchInterfaceCommand(physNetLabel));
s_logger.debug("Ask host " + host.getId() + " to retrieve interface for phy net with label:" + physNetLabel);
Answer[] fetchIfaceAnswers = _agentMgr.send(host.getId(), fetchIfaceCmds);
// And finally save it for future use
endpointIp = handleFetchInterfaceAnswer(fetchIfaceAnswers, host.getId());
} else {
endpointIp = tunnelIface.getIp();
}
return endpointIp;
}
Aggregations