Package com.cloud.utils.exception

Examples of com.cloud.utils.exception.ExecutionException


        String xml = SrxXml.OPEN_CONFIGURATION.getXml();
        String successMsg = "Opened a private configuration.";
        String errorMsg = "Failed to open a private configuration.";

        if (!sendRequestAndCheckResponse(SrxCommand.OPEN_CONFIGURATION, xml)) {
            throw new ExecutionException(errorMsg);
        } else {
            s_logger.debug(successMsg);
        }
    }
View Full Code Here


        String xml = SrxXml.COMMIT.getXml();
        String successMsg = "Committed to global configuration.";
        String errorMsg = "Failed to commit to global configuration.";

        if (!sendRequestAndCheckResponse(SrxCommand.COMMIT, xml)) {
            throw new ExecutionException(errorMsg);
        } else {     
            s_logger.debug(successMsg);
            closeConfiguration();
        }
    }
View Full Code Here

        String[] results = new String[cmd.getIpAddresses().length];
        int i = 0;
        try {
            IpAddressTO ip;
            if (cmd.getIpAddresses().length != 1) {
                throw new ExecutionException("Received an invalid number of guest IPs to associate.");
            } else {
                ip = cmd.getIpAddresses()[0];
            }                              

            String sourceNatIpAddress = null;
            GuestNetworkType type = GuestNetworkType.INTERFACE_NAT;

            if (ip.isSourceNat()) {
                type = GuestNetworkType.SOURCE_NAT;

                if (ip.getPublicIp() == null) {
                    throw new ExecutionException("Source NAT IP address must not be null.");
                } else {
                    sourceNatIpAddress = ip.getPublicIp();
                }
            }

            long guestVlanTag = Long.parseLong(cmd.getAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG));
            String guestVlanGateway = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
            String cidr = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR);
            long cidrSize = NetUtils.cidrToLong(cidr)[1];
            String guestVlanSubnet = NetUtils.getCidrSubNet(guestVlanGateway, cidrSize);   
           
            Long publicVlanTag = null;
            if (ip.getVlanId() != null && !ip.getVlanId().equals("untagged")) {
              try {
                publicVlanTag = Long.parseLong(ip.getVlanId());
              } catch (Exception e) {
                throw new ExecutionException("Could not parse public VLAN tag: " + ip.getVlanId());
              }
            }

            openConfiguration();
View Full Code Here

        xml = replaceXmlValue(xml, "policy-name", ikePolicyName);
        xml = replaceXmlValue(xml, "proposal-name", _ikeProposalName);
        xml = replaceXmlValue(xml, "pre-shared-key", preSharedKey);

        if (!sendRequestAndCheckResponse(command, xml)) {
          throw new ExecutionException("Failed to add IKE policy: " + ikePolicyName);
        } else {
          return true;
        }
       
      case DELETE:
        if (!manageIkePolicy(SrxCommand.CHECK_IF_EXISTS, ikePolicyName, accountId, preSharedKey)) {
          return true;
        }

        xml = SrxXml.IKE_GATEWAY_GETONE.getXml();
        xml = setDelete(xml, true);
        xml = replaceXmlValue(xml, "policy-name", ikePolicyName);

        if (!sendRequestAndCheckResponse(command, xml, "name", ikePolicyName)) {
          throw new ExecutionException("Failed to delete IKE policy: " + ikePolicyName);
        } else {
          return true;
        }

      default:
View Full Code Here

        xml = replaceXmlValue(xml, "ike-gateway-hostname", ikeGatewayHostname);
        xml = replaceXmlValue(xml, "public-interface-name", _publicInterface);
        xml = replaceXmlValue(xml, "access-profile-name", genAccessProfileName(accountId, username));

        if (!sendRequestAndCheckResponse(command, xml)) {
          throw new ExecutionException("Failed to add IKE gateway: " + ikeGatewayName);
        } else {
          return true;
        }
       
      case DELETE:
        if (!manageIkeGateway(SrxCommand.CHECK_IF_EXISTS, ikeGatewayName, accountId, ikePolicyName, ikeGatewayHostname, username)) {
          return true;
        }

        xml = SrxXml.IKE_GATEWAY_GETONE.getXml();
        xml = setDelete(xml, true);
        xml = replaceXmlValue(xml, "gateway-name", ikeGatewayName);

        if (!sendRequestAndCheckResponse(command, xml, "name", ikeGatewayName)) {
          throw new ExecutionException("Failed to delete IKE gateway: " + ikeGatewayName);
        } else {
          return true;
        }

      default:
View Full Code Here

        xml = replaceXmlValue(xml, "ipsec-vpn-name", ipsecVpnName);
        xml = replaceXmlValue(xml, "ike-gateway", genIkeGatewayName(accountId, username));
        xml = replaceXmlValue(xml, "ipsec-policy-name", ipsecPolicyName);

        if (!sendRequestAndCheckResponse(command, xml)) {
          throw new ExecutionException("Failed to add IPSec VPN: " + ipsecVpnName);
        } else {
          return true;
        }
       
      case DELETE:
        if (!manageIpsecVpn(SrxCommand.CHECK_IF_EXISTS, ipsecVpnName, accountId, guestNetworkCidr, username, ipsecPolicyName)) {
          return true;
        }

        xml = SrxXml.IPSEC_VPN_GETONE.getXml();
        xml = setDelete(xml, true);
        xml = replaceXmlValue(xml, "ipsec-vpn-name", ipsecVpnName);

        if (!sendRequestAndCheckResponse(command, xml, "name", ipsecVpnName)) {
          throw new ExecutionException("Failed to delete IPSec VPN: " + ipsecVpnName);
        } else {
          return true;
        }

      default:
View Full Code Here

        xml = replaceXmlValue(xml, "guest-network-cidr", guestNetworkCidr);
        xml = replaceXmlValue(xml, "ipsec-vpn-name", ipsecVpnName);
        xml = replaceXmlValue(xml, "username", username);

        if (!sendRequestAndCheckResponse(command, xml)) {
          throw new ExecutionException("Failed to add dynamic VPN client: " + clientName);
        } else {
          return true;
        }
       
      case DELETE:
        if (!manageDynamicVpnClient(SrxCommand.CHECK_IF_EXISTS, clientName, accountId, guestNetworkCidr, ipsecVpnName, username)) {
          return true;
        }

        xml = SrxXml.DYNAMIC_VPN_CLIENT_GETONE.getXml();
        xml = setDelete(xml, true);
        xml = replaceXmlValue(xml, "client-name", clientName);

        if (!sendRequestAndCheckResponse(command, xml, "name", clientName)) {
          throw new ExecutionException("Failed to delete dynamic VPN client: " + clientName);
        } else {
          return true;
        }

      default:
View Full Code Here

        xml = replaceXmlValue(xml, "low-address", lowAddress);
        xml = replaceXmlValue(xml, "high-address", highAddress);
        xml = replaceXmlValue(xml, "primary-dns-address", primaryDnsAddress);

        if (!sendRequestAndCheckResponse(command, xml)) {
          throw new ExecutionException("Failed to add address pool: " + addressPoolName);
        } else {
          return true;
        }
       
      case DELETE:
        if (!manageAddressPool(SrxCommand.CHECK_IF_EXISTS, addressPoolName, accountId, guestNetworkCidr, lowAddress, highAddress, primaryDnsAddress)) {
          return true;
        }

        xml = SrxXml.ADDRESS_POOL_GETONE.getXml();
        xml = setDelete(xml, true);
        xml = replaceXmlValue(xml, "address-pool-name", addressPoolName);

        if (!sendRequestAndCheckResponse(command, xml, "name", addressPoolName)) {
          throw new ExecutionException("Failed to delete address pool: " + addressPoolName);
        } else {
          return true;
        }

      default:
View Full Code Here

        xml = replaceXmlValue(xml, "username", username);
        xml = replaceXmlValue(xml, "password", password);
        xml = replaceXmlValue(xml, "address-pool-name", addressPoolName);

        if (!sendRequestAndCheckResponse(command, xml)) {
          throw new ExecutionException("Failed to add access profile: " + accessProfileName);
        } else {
          return true;
        }
       
      case DELETE:
        if (!manageAccessProfile(SrxCommand.CHECK_IF_EXISTS, accessProfileName, accountId, username, password, addressPoolName)) {
          return true;
        }

        xml = SrxXml.ACCESS_PROFILE_GETONE.getXml();
        xml = setDelete(xml, true);
        xml = replaceXmlValue(xml, "access-profile-name", accessProfileName);

        if (!sendRequestAndCheckResponse(command, xml, "name", username)) {
          throw new ExecutionException("Failed to delete access profile: " + accessProfileName);
        } else {
          return true;
        }

      default:
View Full Code Here

                xml = replaceXmlValue(xml, "input-filter-name", _usageFilterVlanInput.getName() + "-" + vlanTag);
                xml = replaceXmlValue(xml, "output-filter-name", _usageFilterVlanOutput.getName() + "-" + vlanTag);
            }

            if (!sendRequestAndCheckResponse(command, xml)) {
                throw new ExecutionException("Failed to add private interface for guest VLAN tag " + vlanTag);
            } else {
                return true;
            }

        case DELETE:
            if (!managePrivateInterface(SrxCommand.CHECK_IF_EXISTS, false, vlanTag, privateInterfaceIp)) {
                return true;
            }

            xml = SrxXml.PRIVATE_INTERFACE_GETONE.getXml();
            xml = setDelete(xml, true);
            xml = replaceXmlValue(xml, "private-interface-name", _privateInterface);
            xml = replaceXmlValue(xml, "vlan-id", String.valueOf(vlanTag));

            if (!sendRequestAndCheckResponse(command, xml, "name", String.valueOf(vlanTag))) {
                throw new ExecutionException("Failed to delete private interface for guest VLAN tag " + vlanTag);
            } else {
                return true;
            }

        default:
View Full Code Here

TOP

Related Classes of com.cloud.utils.exception.ExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.