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());
}
}
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());
}
}
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);
}
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());
}
}
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);
}
Aggregations