Search in sources :

Example 1 with Site2SiteVpnGatewayResponse

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

the class ListVpnGatewaysCmd method execute.

@Override
public void execute() {
    Pair<List<? extends Site2SiteVpnGateway>, Integer> gws = _s2sVpnService.searchForVpnGateways(this);
    ListResponse<Site2SiteVpnGatewayResponse> response = new ListResponse<Site2SiteVpnGatewayResponse>();
    List<Site2SiteVpnGatewayResponse> gwResponses = new ArrayList<Site2SiteVpnGatewayResponse>();
    for (Site2SiteVpnGateway gw : gws.first()) {
        if (gw == null) {
            continue;
        }
        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) ListResponse(org.apache.cloudstack.api.response.ListResponse) Site2SiteVpnGatewayResponse(org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with Site2SiteVpnGatewayResponse

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

the class UpdateVpnGatewayCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    Site2SiteVpnGateway result = _s2sVpnService.updateVpnGateway(id, this.getCustomId(), getDisplay());
    if (result != null) {
        Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
        response.setResponseName(getCommandName());
    }
}
Also used : Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) Site2SiteVpnGatewayResponse(org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse)

Example 3 with Site2SiteVpnGatewayResponse

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

the class ApiResponseHelper method createSite2SiteVpnGatewayResponse.

@Override
public Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVpnGateway result) {
    Site2SiteVpnGatewayResponse response = new Site2SiteVpnGatewayResponse();
    response.setId(result.getUuid());
    response.setIp(ApiDBUtils.findIpAddressById(result.getAddrId()).getAddress().toString());
    Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId());
    if (vpc != null) {
        response.setVpcId(vpc.getUuid());
    }
    response.setRemoved(result.getRemoved());
    response.setForDisplay(result.isDisplay());
    response.setObjectName("vpngateway");
    populateAccount(response, result.getAccountId());
    populateDomain(response, result.getDomainId());
    return response;
}
Also used : Site2SiteVpnGatewayResponse(org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse) Vpc(com.cloud.network.vpc.Vpc)

Example 4 with Site2SiteVpnGatewayResponse

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

Aggregations

Site2SiteVpnGatewayResponse (org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse)4 Site2SiteVpnGateway (com.cloud.network.Site2SiteVpnGateway)3 Vpc (com.cloud.network.vpc.Vpc)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1