use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class CitrixOvsSetTagAndFlowCommandWrapper method execute.
@Override
public Answer execute(final OvsSetTagAndFlowCommand 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);
/*
* If VM is domainRouter, this will try to set flow and tag on its
* none guest network nic. don't worry, it will fail silently at
* host plugin side
*/
final String result = citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_set_tag_and_flow", "bridge", bridge, "vmName", command.getVmName(), "tag", command.getTag(), "vlans", command.getVlans(), "seqno", command.getSeqNo());
s_logger.debug("set flow for " + command.getVmName() + " " + result);
if (result != null && result.equalsIgnoreCase("SUCCESS")) {
return new OvsSetTagAndFlowAnswer(command, true, result);
} else {
return new OvsSetTagAndFlowAnswer(command, false, result);
}
} catch (final BadServerResponse e) {
s_logger.error("Failed to set tag and flow", e);
} catch (final XenAPIException e) {
s_logger.error("Failed to set tag and flow", e);
} catch (final XmlRpcException e) {
s_logger.error("Failed to set tag and flow", e);
}
return new OvsSetTagAndFlowAnswer(command, false, "EXCEPTION");
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class XenServerResourceNewBase method initialize.
@Override
public StartupCommand[] initialize() throws IllegalArgumentException {
final StartupCommand[] cmds = super.initialize();
final Connection conn = getConnection();
Pool pool;
try {
pool = Pool.getByUuid(conn, _host.getPool());
final Pool.Record poolr = pool.getRecord(conn);
final Host.Record masterRecord = poolr.master.getRecord(conn);
if (_host.getUuid().equals(masterRecord.uuid)) {
_listener = new VmEventListener(true);
//
// TODO disable event listener for now. Wait until everything else is ready
//
// _listener.start();
} else {
_listener = new VmEventListener(false);
}
} catch (final XenAPIException e) {
throw new CloudRuntimeException("Unable to determine who is the master", e);
} catch (final XmlRpcException e) {
throw new CloudRuntimeException("Unable to determine who is the master", e);
}
return cmds;
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class Connection method callTimeoutInSec.
public Object callTimeoutInSec(String method, Object[] params, int timeout, boolean debug) throws XmlRpcException {
TimingOutCallback callback = new TimingOutCallback(timeout * 1000);
Object[] mParams = new Object[params.length + 1];
mParams[0] = method;
for (int i = 0; i < params.length; i++) {
mParams[i + 1] = params[i];
}
if (debug) {
/*
* some parameters including user password should not be printed in log
*/
s_logger.debug("Call Ovm agent: " + Coder.toJson(mParams));
}
long startTime = System.currentTimeMillis();
_client.executeAsync("OvmDispatch", mParams, callback);
try {
return callback.waitForResponse();
} catch (TimingOutCallback.TimeoutException to) {
throw to;
} catch (Throwable e) {
throw new XmlRpcException(-2, e.getMessage());
} finally {
long endTime = System.currentTimeMillis();
// in secs
long during = (endTime - startTime) / 1000;
s_logger.debug("Ovm call " + method + " finished in " + String.valueOf(during) + " secs");
}
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class OvmResourceBase method fillHostInfo.
protected void fillHostInfo(StartupRoutingCommand cmd) {
try {
OvmHost.Details hostDetails = OvmHost.getDetails(_conn);
cmd.setName(hostDetails.name);
cmd.setSpeed(hostDetails.cpuSpeed);
cmd.setCpus(hostDetails.cpuNum);
cmd.setMemory(hostDetails.freeMemory);
cmd.setDom0MinMemory(hostDetails.dom0Memory);
cmd.setGuid(_guid);
cmd.setDataCenter(_zoneId.toString());
cmd.setPod(_podId.toString());
cmd.setCluster(_clusterId.toString());
cmd.setVersion(OvmResourceBase.class.getPackage().getImplementationVersion());
cmd.setHypervisorType(HypervisorType.Ovm);
//TODO: introudce PIF
cmd.setPrivateIpAddress(_ip);
cmd.setStorageIpAddress(_ip);
String defaultBridge = OvmBridge.getBridgeByIp(_conn, _ip);
if (_publicNetworkName == null) {
_publicNetworkName = defaultBridge;
}
if (_privateNetworkName == null) {
_privateNetworkName = _publicNetworkName;
}
if (_guestNetworkName == null) {
_guestNetworkName = _privateNetworkName;
}
Map<String, String> d = cmd.getHostDetails();
d.put("public.network.device", _publicNetworkName);
d.put("private.network.device", _privateNetworkName);
d.put("guest.network.device", _guestNetworkName);
cmd.setHostDetails(d);
s_logger.debug(String.format("Add a OVM host(%s)", hostDetails.toJson()));
} catch (XmlRpcException e) {
s_logger.debug("XML RPC Exception" + e.getMessage(), e);
throw new CloudRuntimeException("XML RPC Exception" + e.getMessage(), e);
}
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class OvmResourceBase method execute.
protected GetVmStatsAnswer execute(GetVmStatsCommand cmd) {
List<String> vmNames = cmd.getVmNames();
HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>();
for (String vmName : vmNames) {
try {
VmStatsEntry e = getVmStat(vmName);
vmStatsNameMap.put(vmName, e);
} catch (XmlRpcException e) {
s_logger.debug("Get vm stat for " + vmName + " failed", e);
continue;
}
}
return new GetVmStatsAnswer(cmd, vmStatsNameMap);
}
Aggregations