Search in sources :

Example 66 with XmlRpcException

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");
}
Also used : BadServerResponse(com.xensource.xenapi.Types.BadServerResponse) Network(com.xensource.xenapi.Network) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) OvsSetTagAndFlowAnswer(com.cloud.agent.api.OvsSetTagAndFlowAnswer) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 67 with XmlRpcException

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;
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) Pool(com.xensource.xenapi.Pool) Host(com.xensource.xenapi.Host) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 68 with XmlRpcException

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");
    }
}
Also used : TimingOutCallback(org.apache.xmlrpc.client.TimingOutCallback) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 69 with XmlRpcException

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);
    }
}
Also used : OvmHost(com.cloud.ovm.object.OvmHost) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 70 with XmlRpcException

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);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) VmStatsEntry(com.cloud.agent.api.VmStatsEntry) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Aggregations

XmlRpcException (org.apache.xmlrpc.XmlRpcException)100 XenAPIException (com.xensource.xenapi.Types.XenAPIException)75 Connection (com.xensource.xenapi.Connection)49 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)35 Answer (com.cloud.agent.api.Answer)33 IOException (java.io.IOException)27 BadServerResponse (com.xensource.xenapi.Types.BadServerResponse)26 Network (com.xensource.xenapi.Network)25 Test (org.junit.Test)25 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)22 XsLocalNetwork (com.cloud.hypervisor.xenserver.resource.XsLocalNetwork)21 Host (com.xensource.xenapi.Host)21 RebootAnswer (com.cloud.agent.api.RebootAnswer)20 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)20 HashMap (java.util.HashMap)20 VM (com.xensource.xenapi.VM)17 VDI (com.xensource.xenapi.VDI)16 ConfigurationException (javax.naming.ConfigurationException)16 SR (com.xensource.xenapi.SR)15 InternalErrorException (com.cloud.exception.InternalErrorException)13