Search in sources :

Example 81 with ExecutionException

use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.

the class NetscalerResource method addLBMonitor.

// Monitor related methods
private void addLBMonitor(final String nsMonitorName, final String lbProtocol, final HealthCheckPolicyTO hcp) throws ExecutionException {
    try {
        // check if the monitor exists
        boolean csMonitorExisis = false;
        final lbmonitor csMonitor = getMonitorIfExisits(nsMonitorName);
        if (csMonitor != null) {
            if (!csMonitor.get_type().equalsIgnoreCase(lbProtocol)) {
                throw new ExecutionException("Can not update monitor :" + nsMonitorName + " as current protocol:" + csMonitor.get_type() + " of monitor is different from the " + " intended protocol:" + lbProtocol);
            }
            csMonitorExisis = true;
        }
        if (!csMonitorExisis) {
            final lbmonitor csMon = new lbmonitor();
            csMon.set_monitorname(nsMonitorName);
            csMon.set_type(lbProtocol);
            if (lbProtocol.equalsIgnoreCase("HTTP")) {
                csMon.set_httprequest(hcp.getpingPath());
                s_logger.trace("LB Protocol is HTTP,  Applying  ping path on HealthCheck Policy");
            } else {
                s_logger.debug("LB Protocol is not HTTP, Skipping to apply  ping path on HealthCheck Policy");
            }
            csMon.set_interval(hcp.getHealthcheckInterval());
            csMon.set_retries(Math.max(hcp.getHealthcheckThresshold(), hcp.getUnhealthThresshold()) + 1);
            csMon.set_resptimeout(hcp.getResponseTime());
            csMon.set_failureretries(hcp.getUnhealthThresshold());
            csMon.set_successretries(hcp.getHealthcheckThresshold());
            s_logger.debug("Monitor properites going to get created :interval :: " + csMon.get_interval() + "respTimeOUt:: " + csMon.get_resptimeout() + "failure retires(unhealththresshold) :: " + csMon.get_failureretries() + "successtries(healththresshold) ::" + csMon.get_successretries());
            lbmonitor.add(_netscalerService, csMon);
        } else {
            s_logger.debug("Monitor :" + nsMonitorName + " is already existing. Skipping to delete and create it");
        }
    } catch (final nitro_exception e) {
        throw new ExecutionException("Failed to create new monitor :" + nsMonitorName + " due to " + e.getMessage());
    } catch (final Exception e) {
        throw new ExecutionException("Failed to create new monitor :" + nsMonitorName + " due to " + e.getMessage());
    }
}
Also used : com.citrix.netscaler.nitro.exception.nitro_exception(com.citrix.netscaler.nitro.exception.nitro_exception) com.citrix.netscaler.nitro.resource.config.lb.lbmonitor(com.citrix.netscaler.nitro.resource.config.lb.lbmonitor) ExecutionException(com.cloud.utils.exception.ExecutionException) ExecutionException(com.cloud.utils.exception.ExecutionException) IOException(java.io.IOException) ConfigurationException(javax.naming.ConfigurationException)

Example 82 with ExecutionException

use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.

the class NetscalerResource method execute.

private synchronized Answer execute(final IpAssocCommand cmd, final int numRetries) {
    if (_isSdx) {
        return Answer.createUnsupportedCommandAnswer(cmd);
    }
    final String[] results = new String[cmd.getIpAddresses().length];
    int i = 0;
    try {
        final IpAddressTO[] ips = cmd.getIpAddresses();
        for (final IpAddressTO ip : ips) {
            final long guestVlanTag = Long.parseLong(ip.getBroadcastUri());
            final String vlanSelfIp = ip.getVlanGateway();
            final String vlanNetmask = ip.getVlanNetmask();
            if (ip.isAdd()) {
                // Add a new guest VLAN and its subnet and bind it to private interface
                addGuestVlanAndSubnet(guestVlanTag, vlanSelfIp, vlanNetmask, true);
            } else {
                // Check and delete guest VLAN with this tag, self IP, and netmask
                deleteGuestVlan(guestVlanTag, vlanSelfIp, vlanNetmask);
            }
            saveConfiguration();
            results[i++] = ip.getPublicIp() + " - success";
            final String action = ip.isAdd() ? "associate" : "remove";
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Netscaler load balancer " + _ip + " successfully executed IPAssocCommand to " + action + " IP " + ip);
            }
        }
    } catch (final ExecutionException e) {
        s_logger.error("Netscaler loadbalancer " + _ip + " failed to execute IPAssocCommand due to " + e.getMessage());
        if (shouldRetry(numRetries)) {
            return retry(cmd, numRetries);
        } else {
            results[i++] = IpAssocAnswer.errorResult;
        }
    }
    return new IpAssocAnswer(cmd, results);
}
Also used : IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) IpAddressTO(com.cloud.agent.api.to.IpAddressTO) ExecutionException(com.cloud.utils.exception.ExecutionException)

Example 83 with ExecutionException

use of com.cloud.utils.exception.ExecutionException in project cloudstack by apache.

the class NetscalerResource method removeLBVirtualServer.

private void removeLBVirtualServer(final String virtualServerName) throws ExecutionException {
    try {
        final lbvserver vserver = lbvserver.get(_netscalerService, virtualServerName);
        if (vserver == null) {
            return;
        }
        apiCallResult = lbvserver.delete(_netscalerService, vserver);
        if (apiCallResult.errorcode != 0) {
            throw new ExecutionException("Failed to delete virtual server:" + virtualServerName + " due to " + apiCallResult.message);
        }
    } catch (final nitro_exception e) {
        if (e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS) {
            return;
        } else {
            throw new ExecutionException("Failed remove virtual server:" + virtualServerName + " due to " + e.getMessage());
        }
    } catch (final Exception e) {
        throw new ExecutionException("Failed to remove virtual server:" + virtualServerName + " due to " + e.getMessage());
    }
}
Also used : com.citrix.netscaler.nitro.resource.config.gslb.gslbvserver(com.citrix.netscaler.nitro.resource.config.gslb.gslbvserver) com.citrix.netscaler.nitro.resource.config.lb.lbvserver(com.citrix.netscaler.nitro.resource.config.lb.lbvserver) com.citrix.netscaler.nitro.exception.nitro_exception(com.citrix.netscaler.nitro.exception.nitro_exception) ExecutionException(com.cloud.utils.exception.ExecutionException) ExecutionException(com.cloud.utils.exception.ExecutionException) IOException(java.io.IOException) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

ExecutionException (com.cloud.utils.exception.ExecutionException)83 ConfigurationException (javax.naming.ConfigurationException)31 IOException (java.io.IOException)30 ArrayList (java.util.ArrayList)23 IpAssocAnswer (com.cloud.agent.api.routing.IpAssocAnswer)20 RemoteException (java.rmi.RemoteException)20 ExternalNetworkResourceUsageAnswer (com.cloud.agent.api.ExternalNetworkResourceUsageAnswer)19 Answer (com.cloud.agent.api.Answer)17 MaintainAnswer (com.cloud.agent.api.MaintainAnswer)16 ReadyAnswer (com.cloud.agent.api.ReadyAnswer)16 com.citrix.netscaler.nitro.exception.nitro_exception (com.citrix.netscaler.nitro.exception.nitro_exception)13 Document (org.w3c.dom.Document)12 XPathExpressionException (javax.xml.xpath.XPathExpressionException)11 HashMap (java.util.HashMap)10 XPath (javax.xml.xpath.XPath)8 XPathExpression (javax.xml.xpath.XPathExpression)8 NodeList (org.w3c.dom.NodeList)7 com.citrix.netscaler.nitro.resource.config.gslb.gslbvserver (com.citrix.netscaler.nitro.resource.config.gslb.gslbvserver)5 com.citrix.netscaler.nitro.resource.config.lb.lbvserver (com.citrix.netscaler.nitro.resource.config.lb.lbvserver)5 com.citrix.netscaler.nitro.resource.config.ns.nsconfig (com.citrix.netscaler.nitro.resource.config.ns.nsconfig)5