private Site2SiteVpnGateway getVpnGateway() { return _s2sVpnService.getVpnGateway(vpnGatewayId); } }
@Override public boolean cleanupVpnGatewayByVpc(long vpcId) { Site2SiteVpnGatewayVO gw = _vpnGatewayDao.findByVpcId(vpcId); if (gw == null) { return true; } doDeleteVpnGateway(gw); return true; }
@Override public boolean deleteCustomerGatewayByAccount(long accountId) { boolean result = true; ; List<Site2SiteCustomerGatewayVO> gws = _customerGatewayDao.listByAccountId(accountId); for (Site2SiteCustomerGatewayVO gw : gws) { result = result & doDeleteCustomerGateway(gw); } return result; }
@Test public void testCreateSuccess() { AccountService accountService = Mockito.mock(AccountService.class); Account account = Mockito.mock(Account.class); Mockito.when(accountService.getAccount(Matchers.anyLong())).thenReturn(account); addVpnUserCmd._accountService = accountService; RemoteAccessVpnService ravService = Mockito.mock(RemoteAccessVpnService.class); VpnUser vpnUser = Mockito.mock(VpnUser.class); Mockito.when(ravService.addVpnUser(Matchers.anyLong(), Matchers.anyString(), Matchers.anyString())).thenReturn(vpnUser); addVpnUserCmd._ravService = ravService; addVpnUserCmd.create(); }
@Override public void execute() throws ResourceUnavailableException { if (! _ravService.destroyRemoteAccessVpnForIp(publicIpId, CallContext.current().getCallingAccount(), false)) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete remote access vpn"); } }
@Override public Long getSyncObjId() { return _ravService.getRemoteAccessVpn(publicIpId).getNetworkId(); }
@Override public long getEntityOwnerId() { if (ownerId == null) { RemoteAccessVpn vpnEntity = _ravService.getRemoteAccessVpnById(id); if (vpnEntity != null) return vpnEntity.getAccountId(); throw new InvalidParameterValueException("The specified id is invalid"); } return ownerId; }
@Override public void execute() { boolean result = _s2sVpnService.deleteCustomerGateway(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete customer VPN gateway"); } } }
@Override public void execute() { boolean result = false; result = _s2sVpnService.deleteVpnGateway(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete customer VPN gateway"); } } }
@Override public void create() throws ResourceAllocationException { Site2SiteVpnGateway result = _s2sVpnService.createVpnGateway(this); if (result != null) { setEntityId(result.getId()); setEntityUuid(result.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPN gateway"); } } }
@Override public void execute() { Site2SiteVpnGateway result = _s2sVpnService.updateVpnGateway(id, this.getCustomId(), getDisplay()); if (result != null) { Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result); response.setResponseName(getCommandName()); } }
@Override public void execute() { Site2SiteCustomerGateway result = _s2sVpnService.updateCustomerGateway(this); if (result != null) { Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update customer VPN gateway"); } } }
@Override public void execute() { Site2SiteCustomerGateway result = _s2sVpnService.createCustomerGateway(this); if (result != null) { Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create customer VPN gateway"); } } }
@Override public void execute() { RemoteAccessVpn result = _ravService.updateRemoteAccessVpn(id, this.getCustomId(), getDisplay()); RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result); response.setResponseName(getCommandName()); this.setResponseObject(response); }
@Override public void execute() { Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId(), getDisplay()); Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); }
@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()); } }
@Override public void finalizeStop(final VirtualMachineProfile profile, final Answer answer) { super.finalizeStop(profile, answer); // Mark VPN connections as Disconnected final DomainRouterVO router = _routerDao.findById(profile.getId()); final Long vpcId = router.getVpcId(); if (vpcId != null) { _s2sVpnMgr.markDisconnectVpnConnByVpc(vpcId); } }
@Override public void create() { Account owner = _accountService.getAccount(getEntityOwnerId()); VpnUser vpnUser = _ravService.addVpnUser(owner.getId(), userName, password); if (vpnUser == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user"); } setEntityId(vpnUser.getId()); setEntityUuid(vpnUser.getUuid()); } }
@Override public void execute() { CallContext.current().setEventDetails("VPN gateway Id: " + getEntityId()); Site2SiteVpnGateway result = _s2sVpnService.getVpnGateway(getEntityId()); if (result != null) { Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPN gateway"); } }
@Override public long getEntityOwnerId() { if (ownerId == null) { RemoteAccessVpn vpnEntity = _ravService.getRemoteAccessVpn(publicIpId); if (vpnEntity != null) return vpnEntity.getAccountId(); throw new InvalidParameterValueException("The specified public ip is not allocated to any account"); } return ownerId; }