Search in sources :

Example 11 with RemoteAccessVpn

use of com.cloud.network.RemoteAccessVpn 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 12 with RemoteAccessVpn

use of com.cloud.network.RemoteAccessVpn 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)

Example 13 with RemoteAccessVpn

use of com.cloud.network.RemoteAccessVpn 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 14 with RemoteAccessVpn

use of com.cloud.network.RemoteAccessVpn 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 15 with RemoteAccessVpn

use of com.cloud.network.RemoteAccessVpn in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElementTest method testApplyVpnUsersException2.

@Test
public void testApplyVpnUsersException2() {
    vpcVirtualRouterElement._vpcRouterMgr = _vpcRouterMgr;
    final AdvancedNetworkTopology advancedNetworkTopology = Mockito.mock(AdvancedNetworkTopology.class);
    final BasicNetworkTopology basicNetworkTopology = Mockito.mock(BasicNetworkTopology.class);
    networkTopologyContext.setAdvancedNetworkTopology(advancedNetworkTopology);
    networkTopologyContext.setBasicNetworkTopology(basicNetworkTopology);
    networkTopologyContext.init();
    final RemoteAccessVpn remoteAccessVpn = Mockito.mock(RemoteAccessVpn.class);
    final List<VpnUser> users = new ArrayList<>();
    final Long vpcId = new Long(1l);
    when(remoteAccessVpn.getVpcId()).thenReturn(vpcId);
    when(_vpcRouterMgr.getVpcRouters(vpcId)).thenReturn(null);
    try {
        final String[] results = vpcVirtualRouterElement.applyVpnUsers(remoteAccessVpn, users);
        assertNull(results);
    } catch (final ResourceUnavailableException e) {
        fail(e.getMessage());
    }
    verify(remoteAccessVpn, times(1)).getVpcId();
}
Also used : BasicNetworkTopology(com.cloud.network.topology.BasicNetworkTopology) VpnUser(com.cloud.network.VpnUser) ArrayList(java.util.ArrayList) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) AdvancedNetworkTopology(com.cloud.network.topology.AdvancedNetworkTopology) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn) Test(org.junit.Test)

Aggregations

RemoteAccessVpn (com.cloud.network.RemoteAccessVpn)22 ArrayList (java.util.ArrayList)11 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)9 VpnUser (com.cloud.network.VpnUser)7 Test (org.junit.Test)6 RemoteAccessVpnResponse (com.cloud.api.response.RemoteAccessVpnResponse)5 Vpc (com.cloud.network.vpc.Vpc)5 Network (com.cloud.network.Network)4 PublicIpAddress (com.cloud.network.PublicIpAddress)4 Zone (com.cloud.db.model.Zone)3 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)3 IPAddressVO (com.cloud.network.dao.IPAddressVO)3 RemoteAccessVpnVO (com.cloud.network.dao.RemoteAccessVpnVO)3 FirewallRuleVO (com.cloud.network.rules.FirewallRuleVO)3 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)3 DomainRouterVO (com.cloud.vm.DomainRouterVO)3 List (java.util.List)3 RemoteAccessVpnResponse (org.apache.cloudstack.api.response.RemoteAccessVpnResponse)3 AdvancedNetworkTopology (org.apache.cloudstack.network.topology.AdvancedNetworkTopology)3 BasicNetworkTopology (org.apache.cloudstack.network.topology.BasicNetworkTopology)3