solve msb ip hardcoding 33/13633/1
authorHarry Huang <huangxiangyu5@huawei.com>
Wed, 20 Sep 2017 02:44:04 +0000 (10:44 +0800)
committerHarry Huang <huangxiangyu5@huawei.com>
Wed, 20 Sep 2017 02:55:51 +0000 (10:55 +0800)
critical: L20

Change-Id: I4ace8f3b9867fb2ea1f06f1e369b9bbf97ae7832
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Issue-Id: VNFSDK-85

vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java

index efeef06..1ba18cd 100644 (file)
@@ -16,8 +16,6 @@
 package org.onap.vnfsdk.marketplace.common;
 
 public class CommonConstant {
-  // Address
-  public static final String DEFAULT_MSB_ADDRESS = "http://127.0.0.1:8080";
 
   // Package Status
   public static final String PACKAGE_STATUS_DELETING = "deleting";
@@ -87,15 +85,6 @@ public class CommonConstant {
       }
   }
 
-  public static class LifeCycleTest
-  {
-      public static final String LIFECYCLE_TEST_URL = "/openoapi/nslcm/v1/vnfpackage";
-      public static final String LIFECYCLE_TEST_OPERTYPE_ID = "lifecycletest";
-      public static final String LIFECYCLE_TEST_EXEC = "lifecycleTestexec";
-      private LifeCycleTest() {
-      }
-  }
-
   public static class HttpContext {
 
       public static final String CONTENT_TYPE = "Content-Type";
@@ -110,6 +99,15 @@ public class CommonConstant {
       }
   }
 
+  public static class LifeCycleTest
+  {
+      public static final String LIFECYCLE_TEST_URL = "/openoapi/nslcm/v1/vnfpackage";
+      public static final String LIFECYCLE_TEST_OPERTYPE_ID = "lifecycletest";
+      public static final String LIFECYCLE_TEST_EXEC = "lifecycleTestexec";
+      private LifeCycleTest() {
+      }
+  }
+
   public static class MethodType {
 
       public static final String POST = "post";
index f7a499b..af6f428 100644 (file)
  * limitations under the License.
  */
 package org.onap.vnfsdk.marketplace.common;
+import java.net.InetAddress;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class HttpServerPathConfig {
+  public static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
+
   protected static String httpServerPath;
 
   private HttpServerPathConfig() {
@@ -23,9 +29,15 @@ public class HttpServerPathConfig {
 
   static
   {
-    MsbAddrConfig.setMsbAddress(CommonConstant.DEFAULT_MSB_ADDRESS);
-    HttpServerAddrConfig.setHttpServerAddress(CommonConstant.DEFAULT_MSB_ADDRESS);
-    HttpServerPathConfig.setHttpServerPath("../tomcat/webapps/ROOT/");
+    try {
+      InetAddress address = InetAddress.getByName("localhost");
+      String msbAddress = "http://" + address.getHostAddress() + ":8080";
+      MsbAddrConfig.setMsbAddress(msbAddress);
+      HttpServerAddrConfig.setHttpServerAddress(msbAddress);
+      HttpServerPathConfig.setHttpServerPath("../tomcat/webapps/ROOT/");
+    } catch (Exception e) {
+      logger.info("error while config htttp server", e);
+    }
   }
 
   public static String getHttpServerPath() {