Search in sources :

Example 16 with Site2SiteVpnGateway

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;
}
Also used : Account(com.cloud.user.Account) Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) ActionEvent(com.cloud.event.ActionEvent)

Example 17 with Site2SiteVpnGateway

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);
}
Also used : Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) Site2SiteVpnGatewayResponse(com.cloud.api.response.Site2SiteVpnGatewayResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with Site2SiteVpnGateway

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;
}
Also used : Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) Capability(com.cloud.network.Network.Capability) Vpc(com.cloud.network.vpc.Vpc) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) IpAddress(com.cloud.network.IpAddress) PublicIpAddress(com.cloud.network.PublicIpAddress) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 19 with Site2SiteVpnGateway

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;
}
Also used : Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) Site2SiteVpnConnectionResponse(org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse) IPAddressVO(com.cloud.network.dao.IPAddressVO) Site2SiteCustomerGateway(com.cloud.network.Site2SiteCustomerGateway)

Aggregations

Site2SiteVpnGateway (com.cloud.network.Site2SiteVpnGateway)19 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)5 IpAddress (com.cloud.network.IpAddress)5 Capability (com.cloud.network.Network.Capability)5 PublicIpAddress (com.cloud.network.PublicIpAddress)5 Vpc (com.cloud.network.vpc.Vpc)5 DomainRouterVO (com.cloud.vm.DomainRouterVO)5 ActionEvent (com.cloud.event.ActionEvent)4 Site2SiteCustomerGateway (com.cloud.network.Site2SiteCustomerGateway)4 Account (com.cloud.user.Account)4 Site2SiteVpnGatewayResponse (com.cloud.api.response.Site2SiteVpnGatewayResponse)3 Site2SiteVpnGatewayResponse (org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse)3 ServerApiException (com.cloud.api.ServerApiException)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 IPAddressVO (com.cloud.network.dao.IPAddressVO)2 Site2SiteCustomerGatewayVO (com.cloud.network.dao.Site2SiteCustomerGatewayVO)2 Site2SiteVpnConnectionVO (com.cloud.network.dao.Site2SiteVpnConnectionVO)2 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2