Search in sources :

Example 1 with Site2SiteVpnConnectionResponse

use of org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse in project cloudstack by apache.

the class UpdateVpnConnectionCmd method execute.

@Override
public void execute() {
    Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId(), getDisplay());
    Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : Site2SiteVpnConnectionResponse(org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Example 2 with Site2SiteVpnConnectionResponse

use of org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse 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)

Example 3 with Site2SiteVpnConnectionResponse

use of org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse in project cloudstack by apache.

the class ListVpnConnectionsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends Site2SiteVpnConnection>, Integer> conns = _s2sVpnService.searchForVpnConnections(this);
    ListResponse<Site2SiteVpnConnectionResponse> response = new ListResponse<Site2SiteVpnConnectionResponse>();
    List<Site2SiteVpnConnectionResponse> connResponses = new ArrayList<Site2SiteVpnConnectionResponse>();
    for (Site2SiteVpnConnection conn : conns.first()) {
        if (conn == null) {
            continue;
        }
        Site2SiteVpnConnectionResponse site2SiteVpnConnectonRes = _responseGenerator.createSite2SiteVpnConnectionResponse(conn);
        site2SiteVpnConnectonRes.setObjectName("vpnconnection");
        connResponses.add(site2SiteVpnConnectonRes);
    }
    response.setResponses(connResponses, conns.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) Site2SiteVpnConnectionResponse(org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse) ArrayList(java.util.ArrayList) List(java.util.List) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Example 4 with Site2SiteVpnConnectionResponse

use of org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse in project cloudstack by apache.

the class ResetVpnConnectionCmd method execute.

@Override
public void execute() {
    try {
        Site2SiteVpnConnection result = _s2sVpnService.resetVpnConnection(this);
        if (result != null) {
            Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset site to site VPN connection");
        }
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Site2SiteVpnConnectionResponse(org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Example 5 with Site2SiteVpnConnectionResponse

use of org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse in project cloudstack by apache.

the class CreateVpnConnectionCmd method execute.

@Override
public void execute() {
    try {
        Site2SiteVpnConnection result = _s2sVpnService.startVpnConnection(getEntityId());
        if (result != null) {
            Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create site to site vpn connection");
        }
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Site2SiteVpnConnectionResponse(org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Aggregations

Site2SiteVpnConnectionResponse (org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse)5 Site2SiteVpnConnection (com.cloud.network.Site2SiteVpnConnection)4 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 Site2SiteCustomerGateway (com.cloud.network.Site2SiteCustomerGateway)1 Site2SiteVpnGateway (com.cloud.network.Site2SiteVpnGateway)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1