Search in sources :

Example 6 with ExecutionException

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

the class JuniperSrxResource method execute.

private Answer execute(RemoteAccessVpnCfgCommand cmd, int numRetries) {
    long accountId = Long.parseLong(cmd.getAccessDetail(NetworkElementCommand.ACCOUNT_ID));
    String guestNetworkCidr = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR);
    String preSharedKey = cmd.getPresharedKey();
    String[] ipRange = cmd.getIpRange().split("-");
    try {
        openConfiguration();
        // Delete existing VPN objects for this account
        deleteVpnObjectsForAccount(accountId);
        if (cmd.isCreate()) {
            // Add IKE policy
            manageIkePolicy(SrxCommand.ADD, null, accountId, preSharedKey);
            // Add address pool
            manageAddressPool(SrxCommand.ADD, null, accountId, guestNetworkCidr, ipRange[0], ipRange[1], _primaryDnsAddress);
        }
        commitConfiguration();
        return new Answer(cmd);
    } catch (ExecutionException e) {
        s_logger.error(e);
        closeConfiguration();
        if (numRetries > 0 && refreshSrxConnection()) {
            int numRetriesRemaining = numRetries - 1;
            s_logger.debug("Retrying RemoteAccessVpnCfgCommand. Number of retries remaining: " + numRetriesRemaining);
            return execute(cmd, numRetriesRemaining);
        } else {
            return new Answer(cmd, e);
        }
    }
}
Also used : Answer(com.cloud.agent.api.Answer) MaintainAnswer(com.cloud.agent.api.MaintainAnswer) IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) ExternalNetworkResourceUsageAnswer(com.cloud.agent.api.ExternalNetworkResourceUsageAnswer) ExecutionException(com.cloud.utils.exception.ExecutionException)

Example 7 with ExecutionException

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

the class F5BigIpResource method getMembers.

private List<String> getMembers(String virtualServerName) throws ExecutionException {
    try {
        List<String> members = new ArrayList<String>();
        String[] virtualServerNames = genStringArray(virtualServerName);
        CommonIPPortDefinition[] membersArray = _loadbalancerApi.get_member(virtualServerNames)[0];
        for (CommonIPPortDefinition member : membersArray) {
            members.add(member.getAddress() + "-" + member.getPort());
        }
        return members;
    } catch (RemoteException e) {
        throw new ExecutionException(e.getMessage());
    }
}
Also used : CommonIPPortDefinition(iControl.CommonIPPortDefinition) ArrayList(java.util.ArrayList) RemoteException(java.rmi.RemoteException) ExecutionException(com.cloud.utils.exception.ExecutionException)

Example 8 with ExecutionException

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

the class F5BigIpResource method saveConfiguration.

private void saveConfiguration() throws ExecutionException {
    try {
        _configSyncApi.save_configuration("", SystemConfigSyncSaveMode.SAVE_BASE_LEVEL_CONFIG);
        _configSyncApi.save_configuration("", SystemConfigSyncSaveMode.SAVE_HIGH_LEVEL_CONFIG);
        s_logger.debug("Successfully saved F5 BigIp configuration.");
    } catch (RemoteException e) {
        s_logger.error("Failed to save F5 BigIp configuration due to: " + e);
        throw new ExecutionException(e.getMessage());
    }
}
Also used : RemoteException(java.rmi.RemoteException) ExecutionException(com.cloud.utils.exception.ExecutionException)

Example 9 with ExecutionException

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

the class F5BigIpResource method getStrippedVirtualServers.

/*    getStrippedVirtualServers retuns VirtualServers without user partition information
    ex: if VirtualServers is vs-tcp-10.147.44.8-22 then the get_list() will return /Common/vs-tcp-10.147.44.8-22
    This method will strip the partition information and only returns a list with VirtualServers (vs-tcp-10.147.44.8-22)*/
private List<String> getStrippedVirtualServers() throws ExecutionException {
    try {
        List<String> virtualServers = new ArrayList<String>();
        String[] virtualServersArray = _virtualServerApi.get_list();
        for (String virtualServer : virtualServersArray) {
            if (virtualServer.contains("/")) {
                virtualServers.add(virtualServer.substring(virtualServer.lastIndexOf("/") + 1));
            } else {
                virtualServers.add(virtualServer);
            }
        }
        return virtualServers;
    } catch (RemoteException e) {
        throw new ExecutionException(e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) RemoteException(java.rmi.RemoteException) ExecutionException(com.cloud.utils.exception.ExecutionException)

Example 10 with ExecutionException

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

the class F5BigIpResource method execute.

private synchronized Answer execute(IpAssocCommand cmd, int numRetries) {
    String[] results = new String[cmd.getIpAddresses().length];
    int i = 0;
    try {
        IpAddressTO[] ips = cmd.getIpAddresses();
        for (IpAddressTO ip : ips) {
            // is it saver to use Long.valueOf(BroadcastDomain.getValue(ip.getBroadcastUri())) ???
            // i.o.w. can this contain vlan:// then change !!!
            long guestVlanTag = Long.parseLong(ip.getBroadcastUri());
            // It's a hack, using isOneToOneNat field for indicate if it's inline or not
            boolean inline = ip.isOneToOneNat();
            String vlanSelfIp = inline ? tagAddressWithRouteDomain(ip.getVlanGateway(), guestVlanTag) : ip.getVlanGateway();
            String vlanNetmask = ip.getVlanNetmask();
            // Delete any existing guest VLAN with this tag, self IP, and netmask
            deleteGuestVlan(guestVlanTag, vlanSelfIp, vlanNetmask, inline);
            if (ip.isAdd()) {
                // Add a new guest VLAN
                addGuestVlan(guestVlanTag, vlanSelfIp, vlanNetmask, inline);
            }
            saveConfiguration();
            results[i++] = ip.getPublicIp() + " - success";
        }
    } catch (ExecutionException e) {
        s_logger.error("Failed to execute IPAssocCommand due to " + e);
        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)

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