Search in sources :

Example 1 with Site2SiteVpnGatewayResponse

use of com.cloud.api.response.Site2SiteVpnGatewayResponse in project cosmic by MissionCriticalCloud.

the class CreateVpnGatewayCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("VPN gateway Id: " + getEntityId());
    final Site2SiteVpnGateway result = _s2sVpnService.getVpnGateway(getEntityId());
    if (result != null) {
        final 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(com.cloud.api.response.Site2SiteVpnGatewayResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 2 with Site2SiteVpnGatewayResponse

use of com.cloud.api.response.Site2SiteVpnGatewayResponse in project cosmic by MissionCriticalCloud.

the class UpdateVpnGatewayCmd method execute.

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

Example 3 with Site2SiteVpnGatewayResponse

use of com.cloud.api.response.Site2SiteVpnGatewayResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createSite2SiteVpnGatewayResponse.

@Override
public Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(final Site2SiteVpnGateway result) {
    final Site2SiteVpnGatewayResponse response = new Site2SiteVpnGatewayResponse();
    response.setId(result.getUuid());
    response.setIp(ApiDBUtils.findIpAddressById(result.getAddrId()).getAddress().toString());
    final 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(com.cloud.api.response.Site2SiteVpnGatewayResponse) Vpc(com.cloud.network.vpc.Vpc)

Example 4 with Site2SiteVpnGatewayResponse

use of com.cloud.api.response.Site2SiteVpnGatewayResponse 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)

Aggregations

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