use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class XenServer56FP1FenceCommandWrapper method execute.
@Override
public Answer execute(final FenceCommand command, final XenServer56Resource xenServer56) {
final Connection conn = xenServer56.getConnection();
try {
final Boolean alive = xenServer56.checkHeartbeat(command.getHostGuid());
if (alive == null) {
s_logger.debug("Failed to check heartbeat, so unable to fence");
return new FenceAnswer(command, false, "Failed to check heartbeat, so unable to fence");
}
if (alive) {
s_logger.debug("Heart beat is still going so unable to fence");
return new FenceAnswer(command, false, "Heartbeat is still going on unable to fence");
}
final Set<VM> vms = VM.getByNameLabel(conn, command.getVmName());
for (final VM vm : vms) {
final Set<VDI> vdis = new HashSet<VDI>();
final Set<VBD> vbds = vm.getVBDs(conn);
for (final VBD vbd : vbds) {
final VDI vdi = vbd.getVDI(conn);
if (!xenServer56.isRefNull(vdi)) {
vdis.add(vdi);
}
}
s_logger.info("Fence command for VM " + command.getVmName());
vm.powerStateReset(conn);
vm.destroy(conn);
for (final VDI vdi : vdis) {
final Map<String, String> smConfig = vdi.getSmConfig(conn);
for (final String key : smConfig.keySet()) {
if (key.startsWith("host_")) {
vdi.removeFromSmConfig(conn, key);
break;
}
}
}
}
return new FenceAnswer(command);
} catch (final XmlRpcException e) {
s_logger.warn("Unable to fence", e);
return new FenceAnswer(command, false, e.getMessage());
} catch (final XenAPIException e) {
s_logger.warn("Unable to fence", e);
return new FenceAnswer(command, false, e.getMessage());
} catch (final Exception e) {
s_logger.warn("Unable to fence", e);
return new FenceAnswer(command, false, e.getMessage());
}
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class CitrixOvsCreateGreTunnelCommandWrapper method execute.
@Override
public Answer execute(final OvsCreateGreTunnelCommand command, final CitrixResourceBase citrixResourceBase) {
citrixResourceBase.setIsOvs(true);
final Connection conn = citrixResourceBase.getConnection();
String bridge = "unkonwn";
try {
final Network nw = citrixResourceBase.setupvSwitchNetwork(conn);
bridge = nw.getBridge(conn);
final String result = citrixResourceBase.callHostPlugin(conn, "ovsgre", "ovs_create_gre", "bridge", bridge, "remoteIP", command.getRemoteIp(), "greKey", command.getKey(), "from", Long.toString(command.getFrom()), "to", Long.toString(command.getTo()));
final String[] res = result.split(":");
if (res.length != 2 || res.length == 2 && res[1].equalsIgnoreCase("[]")) {
return new OvsCreateGreTunnelAnswer(command, false, result, citrixResourceBase.getHost().getIp(), bridge);
} else {
return new OvsCreateGreTunnelAnswer(command, true, result, citrixResourceBase.getHost().getIp(), bridge, Integer.parseInt(res[1]));
}
} catch (final BadServerResponse e) {
s_logger.error("An error occurred while creating a GRE tunnel to " + command.getRemoteIp() + " on host " + citrixResourceBase.getHost().getIp(), e);
} catch (final XenAPIException e) {
s_logger.error("An error occurred while creating a GRE tunnel to " + command.getRemoteIp() + " on host " + citrixResourceBase.getHost().getIp(), e);
} catch (final XmlRpcException e) {
s_logger.error("An error occurred while creating a GRE tunnel to " + command.getRemoteIp() + " on host " + citrixResourceBase.getHost().getIp(), e);
}
return new OvsCreateGreTunnelAnswer(command, false, "EXCEPTION", citrixResourceBase.getHost().getIp(), bridge);
}
use of org.apache.xmlrpc.XmlRpcException 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 org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class CitrixOvsFetchInterfaceCommandWrapper method execute.
@Override
public Answer execute(final OvsFetchInterfaceCommand command, final CitrixResourceBase citrixResourceBase) {
String label = command.getLabel();
//FIXME: this is a tricky to pass the network checking in XCP. I temporary get default label from Host.
if (citrixResourceBase.isXcp()) {
label = citrixResourceBase.getLabel();
}
s_logger.debug("Will look for network with name-label:" + label + " on host " + citrixResourceBase.getHost().getIp());
final Connection conn = citrixResourceBase.getConnection();
try {
final XsLocalNetwork nw = citrixResourceBase.getNetworkByName(conn, label);
if (nw == null) {
throw new CloudRuntimeException("Unable to locate the network with name-label: " + label + " on host: " + citrixResourceBase.getHost().getIp());
}
s_logger.debug("Network object:" + nw.getNetwork().getUuid(conn));
final PIF pif = nw.getPif(conn);
final PIF.Record pifRec = pif.getRecord(conn);
s_logger.debug("PIF object:" + pifRec.uuid + "(" + pifRec.device + ")");
return new OvsFetchInterfaceAnswer(command, true, "Interface " + pifRec.device + " retrieved successfully", pifRec.IP, pifRec.netmask, pifRec.MAC);
} catch (final BadServerResponse e) {
s_logger.error("An error occurred while fetching the interface for " + label + " on host " + citrixResourceBase.getHost().getIp(), e);
return new OvsFetchInterfaceAnswer(command, false, "EXCEPTION:" + e.getMessage());
} catch (final XenAPIException e) {
s_logger.error("An error occurred while fetching the interface for " + label + " on host " + citrixResourceBase.getHost().getIp(), e);
return new OvsFetchInterfaceAnswer(command, false, "EXCEPTION:" + e.getMessage());
} catch (final XmlRpcException e) {
s_logger.error("An error occurred while fetching the interface for " + label + " on host " + citrixResourceBase.getHost().getIp(), e);
return new OvsFetchInterfaceAnswer(command, false, "EXCEPTION:" + e.getMessage());
}
}
use of org.apache.xmlrpc.XmlRpcException in project cloudstack by apache.
the class CitrixGetVmStatsCommandWrapper method execute.
@Override
public Answer execute(final GetVmStatsCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final List<String> vmNames = command.getVmNames();
final HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>();
if (vmNames.size() == 0) {
return new GetVmStatsAnswer(command, vmStatsNameMap);
}
try {
// Determine the UUIDs of the requested VMs
final List<String> vmUUIDs = new ArrayList<String>();
for (final String vmName : vmNames) {
final VM vm = citrixResourceBase.getVM(conn, vmName);
vmUUIDs.add(vm.getUuid(conn));
}
final HashMap<String, VmStatsEntry> vmStatsUUIDMap = citrixResourceBase.getVmStats(conn, command, vmUUIDs, command.getHostGuid());
if (vmStatsUUIDMap == null) {
return new GetVmStatsAnswer(command, vmStatsNameMap);
}
for (final Map.Entry<String, VmStatsEntry> entry : vmStatsUUIDMap.entrySet()) {
vmStatsNameMap.put(vmNames.get(vmUUIDs.indexOf(entry.getKey())), entry.getValue());
}
return new GetVmStatsAnswer(command, vmStatsNameMap);
} catch (final XenAPIException e) {
final String msg = "Unable to get VM stats" + e.toString();
s_logger.warn(msg, e);
return new GetVmStatsAnswer(command, vmStatsNameMap);
} catch (final XmlRpcException e) {
final String msg = "Unable to get VM stats" + e.getMessage();
s_logger.warn(msg, e);
return new GetVmStatsAnswer(command, vmStatsNameMap);
}
}
Aggregations