From f17906f0dcff8c17258117c72376850840d3b21a Mon Sep 17 00:00:00 2001 From: "Tait,Trevor(rt0435)" Date: Wed, 26 Sep 2018 15:17:36 -0400 Subject: Network Discovery callback URL is incorrect Issue-ID: LOG-700 The Network Discovery Context Builder should use the serviceName when building the callback URL for Network Discovery Micro Servie. Make this configurable. Change-Id: I97ed8e78b006ff5d587beedcefc577701c0d33b9 Signed-off-by: Tait,Trevor(rt0435) --- .../networkdiscovery/NdctxbConfiguration.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java index a8f6f7f..7781d1a 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java +++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/NdctxbConfiguration.java @@ -52,6 +52,9 @@ public class NdctxbConfiguration { @Value("${networkDiscoveryCtxBuilder.port}") private String networkDiscoveryCtxBuilderPort; + @Value("${networkDiscoveryCtxBuilder.serviceName}") + private String networkDiscoveryCtxBuilderServiceName; + @Value("${networkDiscoveryCtxBuilder.userId:admin}") private String networkDiscoveryCtxBuilderUserId; @@ -129,15 +132,10 @@ public class NdctxbConfiguration { @Bean(name = "networkDiscoveryCtxBuilderBaseUrl") public String getNetworkDiscoveryCtxBuilderBaseUrl() throws DiscoveryException { String url = null; - try { - String localIp = InetAddress.getLocalHost().getHostAddress(); - url = this.httpNetworkDiscoveryCtxBuilderProtocol + "://" + localIp + ":" + url = this.httpNetworkDiscoveryCtxBuilderProtocol + + "://" + this.networkDiscoveryCtxBuilderServiceName + + ":" + this.networkDiscoveryCtxBuilderPort; - } catch (Exception e) { - log.error("Unable to obtain localIp: " + e.getMessage()); - throw new DiscoveryException(e.getMessage(), e); - } - return url; } @@ -175,7 +173,7 @@ public class NdctxbConfiguration { @Autowired private Environment env; - + // This method builds a map between Service Decomposition resource type and Network Discovery // Context Builder resource type using dynamic mapping technique. // It scans the contents of the configuration file "application.properties", @@ -183,7 +181,7 @@ public class NdctxbConfiguration { // anything from the remaining string will be used as the key (Service Decomposition resource Type) // to match to the value of assignment (network discovery context builder resource type). // For example,"networkDiscoveryCtxBuilder.resourceTypeMapping.BBB = bbb", - // Service Decomposition resource type BBB matches to context builder resource type bbb + // Service Decomposition resource type BBB matches to context builder resource type bbb @Bean(name = "networkDiscoveryCtxBuilderResourceTypeMapping") public Map getResourceTypeMapping() { Map props = new HashMap<>(); @@ -202,5 +200,5 @@ public class NdctxbConfiguration { log.info(props.toString()); return props; - } + } } -- cgit 1.2.3-korg