Search in sources :

Example 1 with UsernamePassword

use of com.cloud.agent.api.routing.VpnUsersCfgCommand.UsernamePassword in project cloudstack by apache.

the class JuniperSrxResource method execute.

private Answer execute(VpnUsersCfgCommand cmd, int numRetries) {
    long accountId = Long.parseLong(cmd.getAccessDetail(NetworkElementCommand.ACCOUNT_ID));
    String guestNetworkCidr = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR);
    String ikePolicyName = genIkePolicyName(accountId);
    UsernamePassword[] users = cmd.getUserpwds();
    try {
        openConfiguration();
        for (UsernamePassword user : users) {
            SrxCommand srxCmd = user.isAdd() ? SrxCommand.ADD : SrxCommand.DELETE;
            String ipsecVpnName = genIpsecVpnName(accountId, user.getUsername());
            // IKE gateway
            manageIkeGateway(srxCmd, null, accountId, ikePolicyName, _ikeGatewayHostname, user.getUsername());
            // IPSec VPN
            manageIpsecVpn(srxCmd, null, accountId, guestNetworkCidr, user.getUsername(), _ipsecPolicyName);
            // Dynamic VPN client
            manageDynamicVpnClient(srxCmd, null, accountId, guestNetworkCidr, ipsecVpnName, user.getUsername());
            // Access profile
            manageAccessProfile(srxCmd, null, accountId, user.getUsername(), user.getPassword(), genAddressPoolName(accountId));
            // Address book entry
            manageAddressBookEntry(srxCmd, _privateZone, guestNetworkCidr, ipsecVpnName);
            // Security policy
            manageSecurityPolicy(SecurityPolicyType.VPN, srxCmd, null, null, guestNetworkCidr, null, null, ipsecVpnName, false);
        }
        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) UsernamePassword(com.cloud.agent.api.routing.VpnUsersCfgCommand.UsernamePassword)

Aggregations

Answer (com.cloud.agent.api.Answer)1 ExternalNetworkResourceUsageAnswer (com.cloud.agent.api.ExternalNetworkResourceUsageAnswer)1 MaintainAnswer (com.cloud.agent.api.MaintainAnswer)1 ReadyAnswer (com.cloud.agent.api.ReadyAnswer)1 IpAssocAnswer (com.cloud.agent.api.routing.IpAssocAnswer)1 UsernamePassword (com.cloud.agent.api.routing.VpnUsersCfgCommand.UsernamePassword)1 ExecutionException (com.cloud.utils.exception.ExecutionException)1