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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations