use of com.cloud.network.Site2SiteVpnGateway in project cloudstack by apache.
the class Site2SiteVpnManagerImpl method deleteVpnGateway.
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_GATEWAY_DELETE, eventDescription = "deleting s2s vpn gateway", async = true)
public boolean deleteVpnGateway(DeleteVpnGatewayCmd cmd) {
CallContext.current().setEventDetails(" Id: " + cmd.getId());
Account caller = CallContext.current().getCallingAccount();
Long id = cmd.getId();
Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(id);
if (vpnGateway == null) {
throw new InvalidParameterValueException("Fail to find vpn gateway with " + id + " !");
}
_accountMgr.checkAccess(caller, null, false, vpnGateway);
doDeleteVpnGateway(vpnGateway);
return true;
}
use of com.cloud.network.Site2SiteVpnGateway 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");
}
}
use of com.cloud.network.Site2SiteVpnGateway in project cloudstack by apache.
the class CreateVpnGatewayCmd method create.
@Override
public void create() throws ResourceAllocationException {
Site2SiteVpnGateway result = _s2sVpnService.createVpnGateway(this);
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPN gateway");
}
}
use of com.cloud.network.Site2SiteVpnGateway 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;
}
Aggregations