use of com.cloud.api.response.Site2SiteVpnConnectionResponse in project cosmic by MissionCriticalCloud.
the class UpdateVpnConnectionCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId(), getDisplay());
final Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.Site2SiteVpnConnectionResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createSite2SiteVpnConnectionResponse.
@Override
public Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(final Site2SiteVpnConnection result) {
final Site2SiteVpnConnectionResponse response = new Site2SiteVpnConnectionResponse();
response.setId(result.getUuid());
response.setPassive(result.isPassive());
final Long vpnGatewayId = result.getVpnGatewayId();
if (vpnGatewayId != null) {
final Site2SiteVpnGateway vpnGateway = ApiDBUtils.findVpnGatewayById(vpnGatewayId);
if (vpnGateway != null) {
response.setVpnGatewayId(vpnGateway.getUuid());
final long ipId = vpnGateway.getAddrId();
final IPAddressVO ipObj = ApiDBUtils.findIpAddressById(ipId);
response.setIp(ipObj.getAddress().addr());
}
}
final Long customerGatewayId = result.getCustomerGatewayId();
if (customerGatewayId != null) {
final 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;
}
use of com.cloud.api.response.Site2SiteVpnConnectionResponse in project cosmic by MissionCriticalCloud.
the class ListVpnConnectionsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends Site2SiteVpnConnection>, Integer> conns = _s2sVpnService.searchForVpnConnections(this);
final ListResponse<Site2SiteVpnConnectionResponse> response = new ListResponse<>();
final List<Site2SiteVpnConnectionResponse> connResponses = new ArrayList<>();
for (final Site2SiteVpnConnection conn : conns.first()) {
if (conn == null) {
continue;
}
final Site2SiteVpnConnectionResponse site2SiteVpnConnectonRes = _responseGenerator.createSite2SiteVpnConnectionResponse(conn);
site2SiteVpnConnectonRes.setObjectName("vpnconnection");
connResponses.add(site2SiteVpnConnectonRes);
}
response.setResponses(connResponses, conns.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.Site2SiteVpnConnectionResponse in project cosmic by MissionCriticalCloud.
the class ResetVpnConnectionCmd method execute.
@Override
public void execute() {
try {
final Site2SiteVpnConnection result = _s2sVpnService.resetVpnConnection(this);
if (result != null) {
final 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 (final ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}
use of com.cloud.api.response.Site2SiteVpnConnectionResponse in project cosmic by MissionCriticalCloud.
the class CreateVpnConnectionCmd method execute.
@Override
public void execute() {
try {
final Site2SiteVpnConnection result = _s2sVpnService.startVpnConnection(getEntityId());
if (result != null) {
final 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 (final ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}
Aggregations