use of com.cloud.network.Site2SiteVpnGateway in project cosmic by MissionCriticalCloud.
the class Site2SiteVpnManagerImpl method deleteVpnGateway.
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_GATEWAY_DELETE, eventDescription = "deleting s2s vpn gateway", async = true)
public boolean deleteVpnGateway(final DeleteVpnGatewayCmd cmd) {
CallContext.current().setEventDetails(" Id: " + cmd.getId());
final Account caller = CallContext.current().getCallingAccount();
final Long id = cmd.getId();
final Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(id);
if (vpnGateway == null) {
throw new InvalidParameterValueException("Fail to find vpn gateway with " + id + " !");
}
_accountMgr.checkAccess(caller, null, false, vpnGateway);
doDeleteVpnGateway(vpnGateway);
return true;
}
use of com.cloud.network.Site2SiteVpnGateway in project cosmic by MissionCriticalCloud.
the class ListVpnGatewaysCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends Site2SiteVpnGateway>, Integer> gws = _s2sVpnService.searchForVpnGateways(this);
final ListResponse<Site2SiteVpnGatewayResponse> response = new ListResponse<>();
final List<Site2SiteVpnGatewayResponse> gwResponses = new ArrayList<>();
for (final Site2SiteVpnGateway gw : gws.first()) {
if (gw == null) {
continue;
}
final Site2SiteVpnGatewayResponse site2SiteVpnGatewayRes = _responseGenerator.createSite2SiteVpnGatewayResponse(gw);
site2SiteVpnGatewayRes.setObjectName("vpngateway");
gwResponses.add(site2SiteVpnGatewayRes);
}
response.setResponses(gwResponses, gws.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.network.Site2SiteVpnGateway in project cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method startSite2SiteVpn.
@Override
public boolean startSite2SiteVpn(final Site2SiteVpnConnection conn) throws ResourceUnavailableException {
final Site2SiteVpnGateway vpnGw = _vpnGatewayDao.findById(conn.getVpnGatewayId());
final IpAddress ip = _ipAddressDao.findById(vpnGw.getAddrId());
final Map<Capability, String> vpnCapabilities = capabilities.get(Service.Vpn);
if (!vpnCapabilities.get(Capability.VpnTypes).contains("s2svpn")) {
s_logger.error("try to start site 2 site vpn on unsupported network element?");
return false;
}
final Long vpcId = ip.getVpcId();
final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
if (!_ntwkModel.isProviderEnabledInZone(vpc.getZoneId(), Provider.VPCVirtualRouter.getName())) {
throw new ResourceUnavailableException("VPC provider is not enabled in zone " + vpc.getZoneId(), DataCenter.class, vpc.getZoneId());
}
final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(ip.getVpcId());
if (routers == null) {
throw new ResourceUnavailableException("Cannot enable site-to-site VPN on the backend; virtual router doesn't exist in the vpc " + ip.getVpcId(), DataCenter.class, vpc.getZoneId());
}
boolean result = true;
for (final DomainRouterVO domainRouterVO : routers) {
result = result && _vpcRouterMgr.startSite2SiteVpn(conn, domainRouterVO);
}
return result;
}
use of com.cloud.network.Site2SiteVpnGateway in project cloudstack by apache.
the class ApiResponseHelper method createSite2SiteVpnConnectionResponse.
@Override
public Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result) {
Site2SiteVpnConnectionResponse response = new Site2SiteVpnConnectionResponse();
response.setId(result.getUuid());
response.setPassive(result.isPassive());
Long vpnGatewayId = result.getVpnGatewayId();
if (vpnGatewayId != null) {
Site2SiteVpnGateway vpnGateway = ApiDBUtils.findVpnGatewayById(vpnGatewayId);
if (vpnGateway != null) {
response.setVpnGatewayId(vpnGateway.getUuid());
long ipId = vpnGateway.getAddrId();
IPAddressVO ipObj = ApiDBUtils.findIpAddressById(ipId);
response.setIp(ipObj.getAddress().addr());
}
}
Long customerGatewayId = result.getCustomerGatewayId();
if (customerGatewayId != null) {
Site2SiteCustomerGateway customerGateway = ApiDBUtils.findCustomerGatewayById(customerGatewayId);
if (customerGateway != null) {
response.setCustomerGatewayId(customerGateway.getUuid());
response.setGatewayIp(customerGateway.getGatewayIp());
response.setGuestCidrList(customerGateway.getGuestCidrList());
response.setIpsecPsk(customerGateway.getIpsecPsk());
response.setIkePolicy(customerGateway.getIkePolicy());
response.setEspPolicy(customerGateway.getEspPolicy());
response.setIkeLifetime(customerGateway.getIkeLifetime());
response.setEspLifetime(customerGateway.getEspLifetime());
response.setDpd(customerGateway.getDpd());
response.setEncap(customerGateway.getEncap());
response.setIkeVersion(customerGateway.getIkeVersion());
response.setSplitConnections(customerGateway.getSplitConnections());
}
}
populateAccount(response, result.getAccountId());
populateDomain(response, result.getDomainId());
response.setState(result.getState().toString());
response.setCreated(result.getCreated());
response.setRemoved(result.getRemoved());
response.setForDisplay(result.isDisplay());
response.setObjectName("vpnconnection");
return response;
}
Aggregations