Search in sources :

Example 1 with RemoteAccessVpnResponse

use of com.cloud.api.response.RemoteAccessVpnResponse in project CloudStack-archive by CloudStack-extras.

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());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create remote access vpn");
        }
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) RemoteAccessVpnResponse(com.cloud.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 2 with RemoteAccessVpnResponse

use of com.cloud.api.response.RemoteAccessVpnResponse in project CloudStack-archive by CloudStack-extras.

the class ListRemoteAccessVpnsCmd method execute.

@Override
public void execute() {
    List<? extends RemoteAccessVpn> vpns = _ravService.searchForRemoteAccessVpns(this);
    ListResponse<RemoteAccessVpnResponse> response = new ListResponse<RemoteAccessVpnResponse>();
    List<RemoteAccessVpnResponse> vpnResponses = new ArrayList<RemoteAccessVpnResponse>();
    if (vpns != null && !vpns.isEmpty()) {
        for (RemoteAccessVpn vpn : vpns) {
            vpnResponses.add(_responseGenerator.createRemoteAccessVpnResponse(vpn));
        }
    }
    response.setResponses(vpnResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) RemoteAccessVpnResponse(com.cloud.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 3 with RemoteAccessVpnResponse

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

the class ListRemoteAccessVpnsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends RemoteAccessVpn>, Integer> vpns = _ravService.searchForRemoteAccessVpns(this);
    final ListResponse<RemoteAccessVpnResponse> response = new ListResponse<>();
    final List<RemoteAccessVpnResponse> vpnResponses = new ArrayList<>();
    if (vpns.first() != null && !vpns.first().isEmpty()) {
        for (final RemoteAccessVpn vpn : vpns.first()) {
            vpnResponses.add(_responseGenerator.createRemoteAccessVpnResponse(vpn));
        }
    }
    response.setResponses(vpnResponses, vpns.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RemoteAccessVpnResponse(com.cloud.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 4 with RemoteAccessVpnResponse

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

the class UpdateRemoteAccessVpnCmd method execute.

@Override
public void execute() {
    final RemoteAccessVpn result = _ravService.updateRemoteAccessVpn(id, this.getCustomId(), getDisplay());
    final RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : RemoteAccessVpnResponse(com.cloud.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 5 with RemoteAccessVpnResponse

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

the class ApiResponseHelper method createRemoteAccessVpnResponse.

@Override
public RemoteAccessVpnResponse createRemoteAccessVpnResponse(final RemoteAccessVpn vpn) {
    final RemoteAccessVpnResponse vpnResponse = new RemoteAccessVpnResponse();
    final 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(com.cloud.api.response.RemoteAccessVpnResponse) IpAddress(com.cloud.network.IpAddress)

Aggregations

RemoteAccessVpnResponse (com.cloud.api.response.RemoteAccessVpnResponse)6 RemoteAccessVpn (com.cloud.network.RemoteAccessVpn)5 ServerApiException (com.cloud.api.ServerApiException)2 ListResponse (com.cloud.api.response.ListResponse)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 ArrayList (java.util.ArrayList)2 IpAddress (com.cloud.network.IpAddress)1 List (java.util.List)1