use of org.apache.xmlrpc.XmlRpcException 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 org.apache.xmlrpc.XmlRpcException 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 org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class NotAValidCommand method testScaleVmCommand.
@Test
public void testScaleVmCommand() {
final String uuid = "6172d8b7-ba10-4a70-93f9-ecaf41f51d53";
final VirtualMachineTO machineTO = Mockito.mock(VirtualMachineTO.class);
final Connection conn = Mockito.mock(Connection.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final Host host = Mockito.mock(Host.class);
final ScaleVmCommand scaleVm = new ScaleVmCommand(machineTO);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getConnection()).thenReturn(conn);
when(citrixResourceBase.getHost()).thenReturn(xsHost);
when(citrixResourceBase.getHost().getUuid()).thenReturn(uuid);
try {
when(citrixResourceBase.isDmcEnabled(conn, host)).thenReturn(true);
} catch (final XenAPIException e) {
fail(e.getMessage());
} catch (final XmlRpcException e) {
fail(e.getMessage());
}
final Answer answer = wrapper.execute(scaleVm, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class XenServerStorageProcessor method deleteSnapshot.
@Override
public Answer deleteSnapshot(final DeleteCommand cmd) {
final SnapshotObjectTO snapshot = (SnapshotObjectTO) cmd.getData();
final DataStoreTO store = snapshot.getDataStore();
if (store.getRole() == DataStoreRole.Primary) {
final Connection conn = hypervisorResource.getConnection();
final VDI snapshotVdi = getVDIbyUuid(conn, snapshot.getPath());
if (snapshotVdi == null) {
return new Answer(null);
}
String errMsg = null;
try {
deleteVDI(conn, snapshotVdi);
} catch (final BadServerResponse e) {
s_logger.debug("delete snapshot failed:" + e.toString());
errMsg = e.toString();
} catch (final XenAPIException e) {
s_logger.debug("delete snapshot failed:" + e.toString());
errMsg = e.toString();
} catch (final XmlRpcException e) {
s_logger.debug("delete snapshot failed:" + e.toString());
errMsg = e.toString();
}
return new Answer(cmd, false, errMsg);
}
return new Answer(cmd, false, "unsupported storage type");
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class CitrixResourceBase method cleanUpTmpDomVif.
public void cleanUpTmpDomVif(final Connection conn, final Network nw) throws XenAPIException, XmlRpcException {
final Pair<VM, VM.Record> vm = getControlDomain(conn);
final VM dom0 = vm.first();
final Set<VIF> dom0Vifs = dom0.getVIFs(conn);
for (final VIF v : dom0Vifs) {
String vifName = "unknown";
try {
final VIF.Record vifr = v.getRecord(conn);
if (v.getNetwork(conn).getUuid(conn).equals(nw.getUuid(conn))) {
if (vifr != null) {
final Map<String, String> config = vifr.otherConfig;
vifName = config.get("nameLabel");
}
s_logger.debug("A VIF in dom0 for the network is found - so destroy the vif");
v.destroy(conn);
s_logger.debug("Destroy temp dom0 vif" + vifName + " success");
}
} catch (final Exception e) {
s_logger.warn("Destroy temp dom0 vif " + vifName + "failed", e);
}
}
}
Aggregations