Search in sources :

Example 1 with Site2SiteVpnConnection

use of com.cloud.network.Site2SiteVpnConnection in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImplTest method testUpdateSite2SiteVpnConnectionState.

@Test
public void testUpdateSite2SiteVpnConnectionState() throws Exception {
    DomainRouterVO router = new DomainRouterVO(1L, 1L, 1L, "First testing router", 1L, Hypervisor.HypervisorType.XenServer, 1L, 1L, 1L, 1L, false, VirtualRouter.RedundantState.PRIMARY, true, true, 1L);
    router.setState(VirtualMachine.State.Running);
    router.setPrivateIpAddress("192.168.50.15");
    List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>();
    routers.add(router);
    Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(1L, 1L, 1L, 1L, false);
    Site2SiteVpnConnectionVO conn1 = new Site2SiteVpnConnectionVO(1L, 1L, 1L, 1L, false);
    conn.setState(Site2SiteVpnConnection.State.Disconnected);
    conn1.setState(Site2SiteVpnConnection.State.Disconnected);
    List<Site2SiteVpnConnectionVO> conns = new ArrayList<Site2SiteVpnConnectionVO>();
    conns.add(conn);
    conns.add(conn1);
    Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO("Testing gateway", 1L, 1L, "192.168.50.15", "Guest List", "ipsecPsk", "ikePolicy", "espPolicy", 1L, 1L, true, true, false, "ike");
    HostVO hostVo = new HostVO(1L, "Testing host", Host.Type.Routing, "192.168.50.15", "privateNetmask", "privateMacAddress", "publicIpAddress", "publicNetmask", "publicMacAddress", "storageIpAddress", "storageNetmask", "storageMacAddress", "deuxStorageIpAddress", "duxStorageNetmask", "deuxStorageMacAddress", "guid", Status.Up, "version", "iqn", new Date(), 1L, 1L, 1L, 1L, "parent", 20L, Storage.StoragePoolType.Gluster);
    hostVo.setManagementServerId(ManagementServerNode.getManagementServerId());
    ArrayList<String> ipList = new ArrayList<>();
    ipList.add("192.168.50.15");
    _s2sConnCommand = new CheckS2SVpnConnectionsCommand(ipList);
    when(_s2sVpnMgr.getConnectionsForRouter(router)).thenReturn(conns);
    when(_s2sVpnConnectionDao.persist(conn)).thenReturn(null);
    when(_s2sCustomerGatewayDao.findById(conn.getCustomerGatewayId())).thenReturn(gw);
    when(_hostDao.findById(router.getHostId())).thenReturn(hostVo);
    when(_routerControlHelper.getRouterControlIp(router.getId())).thenReturn("192.168.50.15");
    doReturn(_s2sVpnAnswer).when(_agentMgr).easySend(nullable(Long.class), nullable(CheckS2SVpnConnectionsCommand.class));
    when(_s2sVpnAnswer.getResult()).thenReturn(true);
    when(_s2sVpnConnectionDao.acquireInLockTable(conn.getId())).thenReturn(conn);
    when(_s2sVpnAnswer.isIPPresent("192.168.50.15")).thenReturn(true);
    when(_s2sVpnAnswer.isConnected("192.168.50.15")).thenReturn(true);
    lenient().doNothing().when(_alertMgr).sendAlert(any(AlertManager.AlertType.class), anyLong(), anyLong(), anyString(), anyString());
    virtualNetworkApplianceManagerImpl.updateSite2SiteVpnConnectionState(routers);
    for (Site2SiteVpnConnection connection : conns) {
        assertEquals(Site2SiteVpnConnection.State.Connected, connection.getState());
    }
}
Also used : Site2SiteCustomerGatewayVO(com.cloud.network.dao.Site2SiteCustomerGatewayVO) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Site2SiteVpnConnectionVO(com.cloud.network.dao.Site2SiteVpnConnectionVO) HostVO(com.cloud.host.HostVO) Date(java.util.Date) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection) Matchers.anyLong(org.mockito.Matchers.anyLong) CheckS2SVpnConnectionsCommand(com.cloud.agent.api.CheckS2SVpnConnectionsCommand) DomainRouterVO(com.cloud.vm.DomainRouterVO) Test(org.junit.Test)

Example 2 with Site2SiteVpnConnection

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

the class CreateVpnConnectionCmd method create.

@Override
public void create() {
    try {
        final Site2SiteVpnConnection conn = _s2sVpnService.createVpnConnection(this);
        if (conn != null) {
            setEntityId(conn.getId());
            setEntityUuid(conn.getUuid());
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create site to site vpn connection");
        }
    } catch (final NetworkRuleConflictException e) {
        s_logger.info("Network rule conflict: " + e.getMessage());
        s_logger.trace("Network Rule Conflict: ", e);
        throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Example 3 with Site2SiteVpnConnection

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

the class UpdateVpnConnectionCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId(), getDisplay());
    final Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : Site2SiteVpnConnectionResponse(com.cloud.api.response.Site2SiteVpnConnectionResponse) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Example 4 with Site2SiteVpnConnection

use of com.cloud.network.Site2SiteVpnConnection in project cloudstack by apache.

the class CreateVpnConnectionCmd method create.

@Override
public void create() {
    try {
        Site2SiteVpnConnection conn = _s2sVpnService.createVpnConnection(this);
        if (conn != null) {
            setEntityId(conn.getId());
            setEntityUuid(conn.getUuid());
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create site to site vpn connection");
        }
    } catch (NetworkRuleConflictException e) {
        s_logger.info("Network rule conflict: " + e.getMessage());
        s_logger.trace("Network Rule Conflict: ", e);
        throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Example 5 with Site2SiteVpnConnection

use of com.cloud.network.Site2SiteVpnConnection in project cloudstack by apache.

the class UpdateVpnConnectionCmd method execute.

@Override
public void execute() {
    Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId(), getDisplay());
    Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : Site2SiteVpnConnectionResponse(org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection)

Aggregations

Site2SiteVpnConnection (com.cloud.network.Site2SiteVpnConnection)11 Site2SiteVpnConnectionResponse (com.cloud.api.response.Site2SiteVpnConnectionResponse)4 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)4 Site2SiteVpnConnectionResponse (org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse)4 ServerApiException (com.cloud.api.ServerApiException)3 ArrayList (java.util.ArrayList)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)3 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)2 List (java.util.List)2 CheckS2SVpnConnectionsCommand (com.cloud.agent.api.CheckS2SVpnConnectionsCommand)1 ListResponse (com.cloud.api.response.ListResponse)1 HostVO (com.cloud.host.HostVO)1 Site2SiteCustomerGatewayVO (com.cloud.network.dao.Site2SiteCustomerGatewayVO)1 Site2SiteVpnConnectionVO (com.cloud.network.dao.Site2SiteVpnConnectionVO)1 DomainRouterVO (com.cloud.vm.DomainRouterVO)1 Date (java.util.Date)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 Test (org.junit.Test)1 Matchers.anyLong (org.mockito.Matchers.anyLong)1 Matchers.anyString (org.mockito.Matchers.anyString)1