Search in sources :

Example 6 with Site2SiteCustomerGateway

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

the class CreateVpnCustomerGatewayCmd method execute.

@Override
public void execute() {
    Site2SiteCustomerGateway result = _s2sVpnService.createCustomerGateway(this);
    if (result != null) {
        Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create customer VPN gateway");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) Site2SiteCustomerGatewayResponse(org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse) Site2SiteCustomerGateway(com.cloud.network.Site2SiteCustomerGateway)

Example 7 with Site2SiteCustomerGateway

use of com.cloud.network.Site2SiteCustomerGateway 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

Site2SiteCustomerGateway (com.cloud.network.Site2SiteCustomerGateway)7 Site2SiteCustomerGatewayResponse (org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse)3 ActionEvent (com.cloud.event.ActionEvent)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 Site2SiteVpnGateway (com.cloud.network.Site2SiteVpnGateway)2 Site2SiteVpnConnectionVO (com.cloud.network.dao.Site2SiteVpnConnectionVO)2 Account (com.cloud.user.Account)2 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)1 Answer (com.cloud.agent.api.Answer)1 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)1 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)1 CheckS2SVpnConnectionsCommand (com.cloud.agent.api.CheckS2SVpnConnectionsCommand)1 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)1 GetRouterAlertsAnswer (com.cloud.agent.api.GetRouterAlertsAnswer)1 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)1 ManagementServerHostVO (com.cloud.cluster.ManagementServerHostVO)1 HostVO (com.cloud.host.HostVO)1 Site2SiteVpnConnection (com.cloud.network.Site2SiteVpnConnection)1