use of com.xensource.xenapi.Types.BadServerResponse in project cloudstack by apache.
the class CitrixOvsDeleteFlowCommandWrapper method execute.
@Override
public Answer execute(final OvsDeleteFlowCommand command, final CitrixResourceBase citrixResourceBase) {
citrixResourceBase.setIsOvs(true);
final Connection conn = citrixResourceBase.getConnection();
try {
final Network nw = citrixResourceBase.setupvSwitchNetwork(conn);
final String bridge = nw.getBridge(conn);
final String result = citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_delete_flow", "bridge", bridge, "vmName", command.getVmName());
if (result.equalsIgnoreCase("SUCCESS")) {
return new Answer(command, true, "success to delete flows for " + command.getVmName());
} else {
return new Answer(command, false, result);
}
} catch (final BadServerResponse e) {
s_logger.error("Failed to delete flow", e);
} catch (final XenAPIException e) {
s_logger.error("Failed to delete flow", e);
} catch (final XmlRpcException e) {
s_logger.error("Failed to delete flow", e);
}
return new Answer(command, false, "failed to delete flow for " + command.getVmName());
}
use of com.xensource.xenapi.Types.BadServerResponse 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());
}
use of com.xensource.xenapi.Types.BadServerResponse in project cloudstack by apache.
the class NotAValidCommand method testOvsVpcRoutingPolicyConfigCommand.
@Test
public void testOvsVpcRoutingPolicyConfigCommand() {
final String bridge = "gre";
final Connection conn = Mockito.mock(Connection.class);
final Network network = Mockito.mock(Network.class);
final OvsVpcRoutingPolicyConfigCommand.Acl[] acls = new OvsVpcRoutingPolicyConfigCommand.Acl[0];
final OvsVpcRoutingPolicyConfigCommand.Tier[] tiers = new OvsVpcRoutingPolicyConfigCommand.Tier[0];
final OvsVpcRoutingPolicyConfigCommand routingPolicy = new OvsVpcRoutingPolicyConfigCommand("v1", "10.0.0.1/24", acls, tiers);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getConnection()).thenReturn(conn);
try {
when(citrixResourceBase.findOrCreateTunnelNetwork(conn, routingPolicy.getBridgeName())).thenReturn(network);
when(network.getBridge(conn)).thenReturn(bridge);
when(citrixResourceBase.callHostPlugin(conn, "ovstunnel", "configure_ovs_bridge_for_routing_policies", "bridge", bridge, "host-id", ((Long) routingPolicy.getHostId()).toString(), "config", routingPolicy.getVpcConfigInJson(), "seq-no", Long.toString(1))).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(routingPolicy, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
use of com.xensource.xenapi.Types.BadServerResponse in project cloudstack by apache.
the class NotAValidCommand method testClusterVMMetaDataSyncCommand.
@Test
public void testClusterVMMetaDataSyncCommand() {
final String uuid = "6172d8b7-ba10-4a70-93f9-ecaf41f51d53";
final Connection conn = Mockito.mock(Connection.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final Pool pool = PowerMockito.mock(Pool.class);
final Pool.Record poolr = Mockito.mock(Pool.Record.class);
final Host.Record hostr = Mockito.mock(Host.Record.class);
final Host master = Mockito.mock(Host.class);
final ClusterVMMetaDataSyncCommand vmDataSync = new ClusterVMMetaDataSyncCommand(10, 1l);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getConnection()).thenReturn(conn);
try {
when(citrixResourceBase.getHost()).thenReturn(xsHost);
when(citrixResourceBase.getHost().getUuid()).thenReturn(uuid);
PowerMockito.mockStatic(Pool.Record.class);
when(pool.getRecord(conn)).thenReturn(poolr);
poolr.master = master;
when(poolr.master.getRecord(conn)).thenReturn(hostr);
hostr.uuid = uuid;
} 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(vmDataSync, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
use of com.xensource.xenapi.Types.BadServerResponse in project cloudstack by apache.
the class NotAValidCommand method testOvsSetTagAndFlowCommand.
@Test
public void testOvsSetTagAndFlowCommand() {
final Network network = Mockito.mock(Network.class);
final Connection conn = Mockito.mock(Connection.class);
final OvsSetTagAndFlowCommand tagAndFlowCommand = new OvsSetTagAndFlowCommand("Test", "tag", "vlan://1", "123", 1l);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getConnection()).thenReturn(conn);
when(citrixResourceBase.setupvSwitchNetwork(conn)).thenReturn(network);
try {
when(network.getBridge(conn)).thenReturn("br0");
} 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(tagAndFlowCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
verify(citrixResourceBase, times(1)).setupvSwitchNetwork(conn);
verify(citrixResourceBase, times(1)).setIsOvs(true);
assertFalse(answer.getResult());
}
Aggregations