@Test public void testGetTunnelEndpoint() throws Exception { InetAddress testAddress = InetAddress.getByName("10.10.10.10"); Node mockNode = mock(Node.class); ConcurrentMap<String, Table<?>> ovsMap = new ConcurrentHashMap<>(); Open_vSwitch ovsTable = new Open_vSwitch(); OvsDBMap localIp = new OvsDBMap(); localIp.put("local_ip", "10.10.10.10"); ovsTable.setOther_config(localIp); ovsMap.put("Open_vSwitch", ovsTable); OVSDBConfigService ovsdbConfig = mock(ConfigurationService.class); when(ovsdbConfig.getRows(any(Node.class), anyString())).thenReturn(null) .thenReturn(ovsMap); PowerMockito.mockStatic(ServiceHelper.class); when(ServiceHelper.getGlobalInstance(eq(OVSDBConfigService.class), anyObject())).thenReturn(ovsdbConfig); assertEquals(null, AdminConfigManager.getManager().getTunnelEndPoint(mockNode)); assertEquals(testAddress, AdminConfigManager.getManager().getTunnelEndPoint(mockNode)); }
public InetAddress getTunnelEndPoint(Node node) { InetAddress address = null; OVSDBConfigService ovsdbConfig = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this); try { Map<String, Table<?>> ovsTable = ovsdbConfig.getRows(node, Open_vSwitch.NAME.getName()); if (ovsTable == null) { logger.error("Open_vSwitch table is null for Node {} ", node); return null; } for (Table<?> row : ovsTable.values()) { Open_vSwitch ovsRow = (Open_vSwitch)row; Map<String, String> configs = ovsRow.getOther_config(); if (configs == null) { logger.debug("Open_vSwitch table is null for Node {} ", node); continue; } String tunnelEndpoint = configs.get(tunnelEndpointConfigName); if (tunnelEndpoint == null) { continue; } address = InetAddress.getByName(tunnelEndpoint); logger.debug("Tunnel Endpoint for Node {} {}", node, address.getHostAddress()); break; } } catch (Exception e) { logger.error("Error populating Tunnel Endpoint for Node {} ", node, e); } return address; }
AdminConfigManager { public InetAddress getTunnelEndPoint(Node node) { InetAddress address = null; OVSDBConfigService ovsdbConfig = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this); try { Map<String, Table<?>> ovsTable = ovsdbConfig.getRows(node, Open_vSwitch.NAME.getName()); if (ovsTable == null) { logger.error("Open_vSwitch table is null for Node {} ", node); return null; } for (Table<?> row : ovsTable.values()) { Open_vSwitch ovsRow = (Open_vSwitch)row; Map<String, String> configs = ovsRow.getOther_config(); if (configs == null) { logger.debug("Open_vSwitch table is null for Node {} ", node); continue; } String tunnelEndpoint = configs.get(tunnelEndpointConfigName); if (tunnelEndpoint == null) { continue; } address = InetAddress.getByName(tunnelEndpoint); logger.debug("Tunnel Endpoint for Node {} {}", node, address.getHostAddress()); break; } } catch (Exception e) { logger.error("Error populating Tunnel Endpoint for Node {} ", node, e); } return address; } }
AdminConfigManager { public InetAddress getTunnelEndPoint(Node node) { InetAddress address = null; OVSDBConfigService ovsdbConfig = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this); try { Map<String, Table<?>> ovsTable = ovsdbConfig.getRows(node, Open_vSwitch.NAME.getName()); if (ovsTable == null) { logger.error("Open_vSwitch table is null for Node {} ", node); return null; } for (Table<?> row : ovsTable.values()) { Open_vSwitch ovsRow = (Open_vSwitch)row; Map<String, String> configs = ovsRow.getOther_config(); if (configs == null) { logger.debug("Open_vSwitch table is null for Node {} ", node); continue; } String tunnelEndpoint = configs.get(tunnelEndpointConfigName); if (tunnelEndpoint == null) { continue; } address = InetAddress.getByName(tunnelEndpoint); logger.debug("Tunnel Endpoint for Node {} {}", node, address.getHostAddress()); break; } } catch (Exception e) { logger.error("Error populating Tunnel Endpoint for Node {} ", node, e); } return address; } private  AdminConfigManager(); }
AdminConfigManager { public InetAddress getTunnelEndPoint(Node node) { InetAddress address = null; OVSDBConfigService ovsdbConfig = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this); try { Map<String, Table<?>> ovsTable = ovsdbConfig.getRows(node, Open_vSwitch.NAME.getName()); if (ovsTable == null) { logger.error("Open_vSwitch table is null for Node {} ", node); return null; } for (Table<?> row : ovsTable.values()) { Open_vSwitch ovsRow = (Open_vSwitch)row; Map<String, String> configs = ovsRow.getOther_config(); if (configs == null) { logger.debug("Open_vSwitch table is null for Node {} ", node); continue; } String tunnelEndpoint = configs.get(tunnelEndpointConfigName); if (tunnelEndpoint == null) { continue; } address = InetAddress.getByName(tunnelEndpoint); logger.debug("Tunnel Endpoint for Node {} {}", node, address.getHostAddress()); break; } } catch (Exception e) { logger.error("Error populating Tunnel Endpoint for Node {} ", node, e); } return address; } private  AdminConfigManager(); static AdminConfigManager getManager(); String getIntegrationBridgeName(); void setIntegrationBridgeName(String integrationBridgeName); String getTunnelBridgeName(); void setTunnelBridgeName(String tunnelBridgeName); String getExternalBridgeName(); void setExternalBridgeName(String externalBridgeName); String getPatchToIntegration(); void setPatchToIntegration(String patchToIntegration); String getPatchToTunnel(); void setPatchToTunnel(String patchToTunnel); InetAddress getTunnelEndPoint(Node node); boolean isInterested(String tableName); }
AdminConfigManager { public InetAddress getTunnelEndPoint(Node node) { InetAddress address = null; OVSDBConfigService ovsdbConfig = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this); try { Map<String, Table<?>> ovsTable = ovsdbConfig.getRows(node, Open_vSwitch.NAME.getName()); if (ovsTable == null) { logger.error("Open_vSwitch table is null for Node {} ", node); return null; } for (Table<?> row : ovsTable.values()) { Open_vSwitch ovsRow = (Open_vSwitch)row; Map<String, String> configs = ovsRow.getOther_config(); if (configs == null) { logger.debug("Open_vSwitch table is null for Node {} ", node); continue; } String tunnelEndpoint = configs.get(tunnelEndpointConfigName); if (tunnelEndpoint == null) { continue; } address = InetAddress.getByName(tunnelEndpoint); logger.debug("Tunnel Endpoint for Node {} {}", node, address.getHostAddress()); break; } } catch (Exception e) { logger.error("Error populating Tunnel Endpoint for Node {} ", node, e); } return address; } private  AdminConfigManager(); static AdminConfigManager getManager(); String getIntegrationBridgeName(); void setIntegrationBridgeName(String integrationBridgeName); String getTunnelBridgeName(); void setTunnelBridgeName(String tunnelBridgeName); String getExternalBridgeName(); void setExternalBridgeName(String externalBridgeName); String getPatchToIntegration(); void setPatchToIntegration(String patchToIntegration); String getPatchToTunnel(); void setPatchToTunnel(String patchToTunnel); InetAddress getTunnelEndPoint(Node node); boolean isInterested(String tableName);  }