Search in sources :

Example 6 with Site2SiteVpnGateway

use of com.cloud.network.Site2SiteVpnGateway in project cloudstack by apache.

the class Site2SiteVpnManagerImpl method deleteVpnGateway.

@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_GATEWAY_DELETE, eventDescription = "deleting s2s vpn gateway", async = true)
public boolean deleteVpnGateway(DeleteVpnGatewayCmd cmd) {
    CallContext.current().setEventDetails(" Id: " + cmd.getId());
    Account caller = CallContext.current().getCallingAccount();
    Long id = cmd.getId();
    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.exception.InvalidParameterValueException) ActionEvent(com.cloud.event.ActionEvent)

Example 7 with Site2SiteVpnGateway

use of com.cloud.network.Site2SiteVpnGateway in project cloudstack by apache.

the class CreateVpnGatewayCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("VPN gateway Id: " + getEntityId());
    Site2SiteVpnGateway result = _s2sVpnService.getVpnGateway(getEntityId());
    if (result != null) {
        Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPN gateway");
    }
}
Also used : Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) Site2SiteVpnGatewayResponse(org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 8 with Site2SiteVpnGateway

use of com.cloud.network.Site2SiteVpnGateway in project cloudstack by apache.

the class CreateVpnGatewayCmd method create.

@Override
public void create() throws ResourceAllocationException {
    Site2SiteVpnGateway result = _s2sVpnService.createVpnGateway(this);
    if (result != null) {
        setEntityId(result.getId());
        setEntityUuid(result.getUuid());
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPN gateway");
    }
}
Also used : Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 9 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());
        }
    }
    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)9 Site2SiteVpnGatewayResponse (org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse)3 ActionEvent (com.cloud.event.ActionEvent)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 IpAddress (com.cloud.network.IpAddress)2 Capability (com.cloud.network.Network.Capability)2 PublicIpAddress (com.cloud.network.PublicIpAddress)2 Site2SiteCustomerGateway (com.cloud.network.Site2SiteCustomerGateway)2 Vpc (com.cloud.network.vpc.Vpc)2 Account (com.cloud.user.Account)2 DomainRouterVO (com.cloud.vm.DomainRouterVO)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 Site2SiteCustomerGatewayVO (com.cloud.network.dao.Site2SiteCustomerGatewayVO)1 Site2SiteVpnConnectionVO (com.cloud.network.dao.Site2SiteVpnConnectionVO)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 Site2SiteVpnConnectionResponse (org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse)1