use of org.apache.cloudstack.api.response.RemoteAccessVpnResponse in project cloudstack by apache.
the class ApiResponseHelper method createRemoteAccessVpnResponse.
@Override
public RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn) {
RemoteAccessVpnResponse vpnResponse = new RemoteAccessVpnResponse();
IpAddress ip = ApiDBUtils.findIpAddressById(vpn.getServerAddressId());
if (ip != null) {
vpnResponse.setPublicIpId(ip.getUuid());
vpnResponse.setPublicIp(ip.getAddress().addr());
}
vpnResponse.setIpRange(vpn.getIpRange());
vpnResponse.setPresharedKey(vpn.getIpsecPresharedKey());
populateOwner(vpnResponse, vpn);
vpnResponse.setState(vpn.getState().toString());
vpnResponse.setId(vpn.getUuid());
vpnResponse.setForDisplay(vpn.isDisplay());
vpnResponse.setObjectName("remoteaccessvpn");
return vpnResponse;
}
use of org.apache.cloudstack.api.response.RemoteAccessVpnResponse in project cloudstack by apache.
the class UpdateRemoteAccessVpnCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
RemoteAccessVpn result = _ravService.updateRemoteAccessVpn(id, this.getCustomId(), getDisplay());
RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.RemoteAccessVpnResponse in project cloudstack by apache.
the class CreateRemoteAccessVpnCmd method execute.
@Override
public void execute() {
try {
RemoteAccessVpn result = _ravService.startRemoteAccessVpn(publicIpId, getOpenFirewall());
if (result != null) {
RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create remote access vpn");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}
use of org.apache.cloudstack.api.response.RemoteAccessVpnResponse in project cloudstack by apache.
the class ListRemoteAccessVpnsCmd method execute.
@Override
public void execute() {
Pair<List<? extends RemoteAccessVpn>, Integer> vpns = _ravService.searchForRemoteAccessVpns(this);
ListResponse<RemoteAccessVpnResponse> response = new ListResponse<RemoteAccessVpnResponse>();
List<RemoteAccessVpnResponse> vpnResponses = new ArrayList<RemoteAccessVpnResponse>();
if (vpns.first() != null && !vpns.first().isEmpty()) {
for (RemoteAccessVpn vpn : vpns.first()) {
vpnResponses.add(_responseGenerator.createRemoteAccessVpnResponse(vpn));
}
}
response.setResponses(vpnResponses, vpns.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
Aggregations