Search in sources :

Example 6 with VpnUser

use of com.cloud.legacymodel.network.VpnUser in project cosmic by MissionCriticalCloud.

the class ListVpnUsersCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
    final ListResponse<VpnUsersResponse> response = new ListResponse<>();
    final List<VpnUsersResponse> vpnResponses = new ArrayList<>();
    for (final VpnUser vpnUser : vpnUsers.first()) {
        vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
    }
    response.setResponses(vpnResponses, vpnUsers.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : VpnUser(com.cloud.legacymodel.network.VpnUser) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) VpnUsersResponse(com.cloud.api.response.VpnUsersResponse)

Example 7 with VpnUser

use of com.cloud.legacymodel.network.VpnUser 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.legacymodel.network.VpnUser) ArrayList(java.util.ArrayList) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) AdvancedNetworkTopology(com.cloud.network.topology.AdvancedNetworkTopology) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn) Test(org.junit.Test)

Example 8 with VpnUser

use of com.cloud.legacymodel.network.VpnUser in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElementTest method testApplyVpnUsersException1.

@Test
public void testApplyVpnUsersException1() {
    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<>();
    when(remoteAccessVpn.getVpcId()).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.legacymodel.network.VpnUser) ArrayList(java.util.ArrayList) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) AdvancedNetworkTopology(com.cloud.network.topology.AdvancedNetworkTopology) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn) Test(org.junit.Test)

Aggregations

VpnUser (com.cloud.legacymodel.network.VpnUser)8 ArrayList (java.util.ArrayList)5 RemoteAccessVpn (com.cloud.network.RemoteAccessVpn)4 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)3 Account (com.cloud.legacymodel.user.Account)3 Test (org.junit.Test)3 ServerApiException (com.cloud.api.ServerApiException)2 VpnUsersResponse (com.cloud.api.response.VpnUsersResponse)2 Zone (com.cloud.db.model.Zone)2 Vpc (com.cloud.legacymodel.network.vpc.Vpc)2 AdvancedNetworkTopology (com.cloud.network.topology.AdvancedNetworkTopology)2 BasicNetworkTopology (com.cloud.network.topology.BasicNetworkTopology)2 DomainRouterVO (com.cloud.vm.DomainRouterVO)2 Commands (com.cloud.agent.manager.Commands)1 ListResponse (com.cloud.api.response.ListResponse)1 Config (com.cloud.configuration.Config)1 ZoneRepository (com.cloud.db.repository.ZoneRepository)1 VlanVO (com.cloud.dc.VlanVO)1 VlanDao (com.cloud.dc.dao.VlanDao)1 ConfigurationDao (com.cloud.framework.config.dao.ConfigurationDao)1