Search in sources :

Example 1 with OvsDeleteFlowCommand

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

the class NotAValidCommand method testOvsDeleteFlowCommandFailure.

@Test
public void testOvsDeleteFlowCommandFailure() {
    final String bridge = "gre";
    final Connection conn = Mockito.mock(Connection.class);
    final Network network = Mockito.mock(Network.class);
    final OvsDeleteFlowCommand deleteFlowCommand = new OvsDeleteFlowCommand("Test");
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(citrixResourceBase.getConnection()).thenReturn(conn);
    when(citrixResourceBase.setupvSwitchNetwork(conn)).thenReturn(network);
    try {
        when(network.getBridge(conn)).thenReturn(bridge);
        when(citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_delete_flow", "bridge", bridge, "vmName", deleteFlowCommand.getVmName())).thenReturn("FAILED");
    } 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(deleteFlowCommand, citrixResourceBase);
    verify(citrixResourceBase, times(1)).getConnection();
    verify(citrixResourceBase, times(1)).setIsOvs(true);
    assertFalse(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) BadServerResponse(com.xensource.xenapi.Types.BadServerResponse) Network(com.xensource.xenapi.Network) XsLocalNetwork(com.cloud.hypervisor.xenserver.resource.XsLocalNetwork) Connection(com.xensource.xenapi.Connection) OvsDeleteFlowCommand(com.cloud.agent.api.OvsDeleteFlowCommand) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Test(org.junit.Test)

Example 2 with OvsDeleteFlowCommand

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

the class NotAValidCommand method testOvsDeleteFlowCommandSuccess.

@Test
public void testOvsDeleteFlowCommandSuccess() {
    final String bridge = "gre";
    final Connection conn = Mockito.mock(Connection.class);
    final Network network = Mockito.mock(Network.class);
    final OvsDeleteFlowCommand deleteFlowCommand = new OvsDeleteFlowCommand("Test");
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(citrixResourceBase.getConnection()).thenReturn(conn);
    when(citrixResourceBase.setupvSwitchNetwork(conn)).thenReturn(network);
    try {
        when(network.getBridge(conn)).thenReturn(bridge);
        when(citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_delete_flow", "bridge", bridge, "vmName", deleteFlowCommand.getVmName())).thenReturn("SUCCESS");
    } 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(deleteFlowCommand, 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) BadServerResponse(com.xensource.xenapi.Types.BadServerResponse) Network(com.xensource.xenapi.Network) XsLocalNetwork(com.cloud.hypervisor.xenserver.resource.XsLocalNetwork) Connection(com.xensource.xenapi.Connection) OvsDeleteFlowCommand(com.cloud.agent.api.OvsDeleteFlowCommand) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Test(org.junit.Test)

Aggregations

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