Search in sources :

Example 1 with RemoteAccessVpnCfgCommand

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

the class RemoteAccessVpnConfigItem method generateConfig.

@Override
public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) {
    final RemoteAccessVpnCfgCommand command = (RemoteAccessVpnCfgCommand) cmd;
    final RemoteAccessVpn remoteAccessVpn = new RemoteAccessVpn(command.isCreate(), command.getIpRange(), command.getPresharedKey(), command.getVpnServerIp(), command.getLocalIp(), command.getLocalCidr(), command.getPublicInterface());
    return generateConfigItems(remoteAccessVpn);
}
Also used : RemoteAccessVpnCfgCommand(com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand) RemoteAccessVpn(com.cloud.agent.resource.virtualnetwork.model.RemoteAccessVpn)

Example 2 with RemoteAccessVpnCfgCommand

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

the class VirtualRoutingResourceTest method generateRemoteAccessVpnCfgCommand2.

protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand2() {
    final RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(false, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    cmd.setLocalCidr("10.1.1.1/24");
    return cmd;
}
Also used : RemoteAccessVpnCfgCommand(com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand)

Example 3 with RemoteAccessVpnCfgCommand

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

the class VirtualRoutingResourceTest method generateRemoteAccessVpnCfgCommand3.

protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand3() {
    final RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", true);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    cmd.setLocalCidr("10.1.1.1/24");
    return cmd;
}
Also used : RemoteAccessVpnCfgCommand(com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand)

Example 4 with RemoteAccessVpnCfgCommand

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

the class VirtualRoutingResourceTest method generateRemoteAccessVpnCfgCommand1.

protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand1() {
    final RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    cmd.setLocalCidr("10.1.1.1/24");
    return cmd;
}
Also used : RemoteAccessVpnCfgCommand(com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand)

Example 5 with RemoteAccessVpnCfgCommand

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

the class ExternalFirewallDeviceManagerImpl method manageRemoteAccessVpn.

public boolean manageRemoteAccessVpn(boolean create, Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException {
    ExternalFirewallDeviceVO fwDeviceVO = getExternalFirewallForNetwork(network);
    HostVO externalFirewall = _hostDao.findById(fwDeviceVO.getHostId());
    if (externalFirewall == null) {
        return false;
    }
    // Create/delete VPN
    IpAddress ip = _networkModel.getIp(vpn.getServerAddressId());
    // Mask the IP range with the network's VLAN tag
    String[] ipRange = vpn.getIpRange().split("-");
    DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
    int vlanTag = Integer.parseInt(BroadcastDomainType.getValue(network.getBroadcastUri()));
    int offset = getVlanOffset(network.getPhysicalNetworkId(), vlanTag);
    int cidrSize = getGloballyConfiguredCidrSize();
    for (int i = 0; i < 2; i++) {
        ipRange[i] = NetUtils.long2Ip((NetUtils.ip2Long(ipRange[i]) & 0xff000000) | (offset << (32 - cidrSize)));
    }
    String maskedIpRange = ipRange[0] + "-" + ipRange[1];
    RemoteAccessVpnCfgCommand createVpnCmd = new RemoteAccessVpnCfgCommand(create, ip.getAddress().addr(), vpn.getLocalIp(), maskedIpRange, vpn.getIpsecPresharedKey(), false);
    createVpnCmd.setAccessDetail(NetworkElementCommand.ACCOUNT_ID, String.valueOf(network.getAccountId()));
    createVpnCmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR, network.getCidr());
    Answer answer = _agentMgr.easySend(externalFirewall.getId(), createVpnCmd);
    if (answer == null || !answer.getResult()) {
        String details = (answer != null) ? answer.getDetails() : "details unavailable";
        String msg = "External firewall was unable to create a remote access VPN in zone " + zone.getName() + " due to: " + details + ".";
        s_logger.error(msg);
        throw new ResourceUnavailableException(msg, DataCenter.class, zone.getId());
    }
    // Add/delete users
    List<VpnUserVO> vpnUsers = _vpnUsersDao.listByAccount(vpn.getAccountId());
    return manageRemoteAccessVpnUsers(network, vpn, vpnUsers);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Answer(com.cloud.agent.api.Answer) ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) RemoteAccessVpnCfgCommand(com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand) HostVO(com.cloud.host.HostVO)

Aggregations

RemoteAccessVpnCfgCommand (com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand)7 Answer (com.cloud.agent.api.Answer)2 DataCenterVO (com.cloud.dc.DataCenterVO)2 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)1 BackupSnapshotCommand (com.cloud.agent.api.BackupSnapshotCommand)1 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)1 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)1 CheckRouterCommand (com.cloud.agent.api.CheckRouterCommand)1 CheckS2SVpnConnectionsCommand (com.cloud.agent.api.CheckS2SVpnConnectionsCommand)1 CheckVirtualMachineCommand (com.cloud.agent.api.CheckVirtualMachineCommand)1 CleanupNetworkRulesCmd (com.cloud.agent.api.CleanupNetworkRulesCmd)1 ComputeChecksumCommand (com.cloud.agent.api.ComputeChecksumCommand)1 CreatePrivateTemplateFromSnapshotCommand (com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand)1 CreatePrivateTemplateFromVolumeCommand (com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand)1 CreateStoragePoolCommand (com.cloud.agent.api.CreateStoragePoolCommand)1 CreateVMSnapshotCommand (com.cloud.agent.api.CreateVMSnapshotCommand)1 CreateVolumeFromSnapshotCommand (com.cloud.agent.api.CreateVolumeFromSnapshotCommand)1 DeleteStoragePoolCommand (com.cloud.agent.api.DeleteStoragePoolCommand)1 DeleteVMSnapshotCommand (com.cloud.agent.api.DeleteVMSnapshotCommand)1 FenceCommand (com.cloud.agent.api.FenceCommand)1