Search in sources :

Example 1 with OvsCreateGreTunnelCommand

use of com.cloud.agent.api.OvsCreateGreTunnelCommand in project cloudstack by apache.

the class NotAValidCommand method testOvsCreateGreTunnelCommand.

@Test
public void testOvsCreateGreTunnelCommand() {
    final String bridge = "gre";
    final Connection conn = Mockito.mock(Connection.class);
    final Network network = Mockito.mock(Network.class);
    final XsHost xsHost = Mockito.mock(XsHost.class);
    final OvsCreateGreTunnelCommand createGreCommand = new OvsCreateGreTunnelCommand("127.0.0.1", "KEY", 1l, 2l);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(citrixResourceBase.getConnection()).thenReturn(conn);
    when(citrixResourceBase.getHost()).thenReturn(xsHost);
    when(citrixResourceBase.setupvSwitchNetwork(conn)).thenReturn(network);
    try {
        when(network.getBridge(conn)).thenReturn(bridge);
        when(citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_create_gre", "bridge", bridge, "remoteIP", createGreCommand.getRemoteIp(), "greKey", createGreCommand.getKey(), "from", Long.toString(createGreCommand.getFrom()), "to", Long.toString(createGreCommand.getTo()))).thenReturn("1:2");
    } catch (final BadServerResponse e) {
        fail(e.getMessage());
    } catch (final XenAPIException e) {
        fail(e.getMessage());
    } catch (final XmlRpcException e) {
        fail(e.getMessage());
    }
    final Answer answer = wrapper.execute(createGreCommand, citrixResourceBase);
    verify(citrixResourceBase, times(1)).getConnection();
    verify(citrixResourceBase, times(1)).setIsOvs(true);
    assertTrue(answer.getResult());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) BadServerResponse(com.xensource.xenapi.Types.BadServerResponse) Network(com.xensource.xenapi.Network) XsLocalNetwork(com.cloud.hypervisor.xenserver.resource.XsLocalNetwork) OvsCreateGreTunnelCommand(com.cloud.agent.api.OvsCreateGreTunnelCommand) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Test(org.junit.Test)

Aggregations

Answer (com.cloud.agent.api.Answer)1 OvsCreateGreTunnelCommand (com.cloud.agent.api.OvsCreateGreTunnelCommand)1 RebootAnswer (com.cloud.agent.api.RebootAnswer)1 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)1 XsHost (com.cloud.hypervisor.xenserver.resource.XsHost)1 XsLocalNetwork (com.cloud.hypervisor.xenserver.resource.XsLocalNetwork)1 Connection (com.xensource.xenapi.Connection)1 Network (com.xensource.xenapi.Network)1 BadServerResponse (com.xensource.xenapi.Types.BadServerResponse)1 XenAPIException (com.xensource.xenapi.Types.XenAPIException)1 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1 Test (org.junit.Test)1