Search in sources :

Example 1 with RemoteAccessVpnResponse

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;
}
Also used : RemoteAccessVpnResponse(org.apache.cloudstack.api.response.RemoteAccessVpnResponse) IpAddress(com.cloud.network.IpAddress)

Example 2 with RemoteAccessVpnResponse

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);
}
Also used : RemoteAccessVpnResponse(org.apache.cloudstack.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 3 with RemoteAccessVpnResponse

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());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) RemoteAccessVpnResponse(org.apache.cloudstack.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 4 with RemoteAccessVpnResponse

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);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RemoteAccessVpnResponse(org.apache.cloudstack.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Aggregations

RemoteAccessVpnResponse (org.apache.cloudstack.api.response.RemoteAccessVpnResponse)4 RemoteAccessVpn (com.cloud.network.RemoteAccessVpn)3 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 IpAddress (com.cloud.network.IpAddress)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