Fix vim info from esr 67/19867/1
authorluxin <luxin7@huawei.com>
Fri, 20 Oct 2017 06:14:06 +0000 (14:14 +0800)
committerluxin <luxin7@huawei.com>
Fri, 20 Oct 2017 06:14:06 +0000 (14:14 +0800)
Change-Id: Ic08ddf57fa8b908ea71865715146729f6e5dc6a6
Issue-Id:VFC-542
Signed-off-by: luxin <luxin7@huawei.com>
ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/common/VimUtil.java
ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/common/constant/UrlConstant.java

index 92ab459..2e595d6 100644 (file)
@@ -61,9 +61,11 @@ public class VimUtil {
     }
 
     /**
-     * Get vimId by vimName.
+     * Get vimId by vimName.<br>
      * 
+     * @param name
      * @return
+     * @since VFC 1.0
      */
     public static String getVimIdByName(String name) {
         JSONArray vims = getVims();
@@ -86,7 +88,21 @@ public class VimUtil {
      * Get VIM.
      * 
      * @param vimId
-     * @return
+     * @return vimInfo
+     *         {
+     *         "vimId": "57674786-5b2e-4c92-bb68-578dbd79e2f5",
+     *         "name": "vim",
+     *         "url": "http://10.74.151.13:5000/v2.0",
+     *         "userName": "admin",
+     *         "password": "admin",
+     *         "tenant": "admin",
+     *         "vendor": "HW",
+     *         "version": "v1.0",
+     *         "description": "",
+     *         "domain": "",
+     *         "type": "openstack",
+     *         "createTime": "2016-07-18 12:22:53"
+     *         }
      */
     public static JSONObject getVimById(String vimId) {
         if(vimId == null || "".equals(vimId.trim())) {
@@ -99,10 +115,57 @@ public class VimUtil {
             LOG.error("ESR return fail.");
             return null;
         } else {
-            return esrResponse;
+            return parseEsrResponse(vimId, esrResponse);
         }
     }
 
+    /**
+     * <br>
+     * 
+     * @param vimId
+     * @param esrResponse
+     *            {
+     *            "esr-system-info-id": "",
+     *            "system-name": "",
+     *            "type": "",
+     *            "vendor": "",
+     *            "version": "",
+     *            "service-url": "",
+     *            "user-name": "",
+     *            "password": "",
+     *            "system-type": "",
+     *            "protocal": "",
+     *            "ssl-cacert": "",
+     *            "ssl-insecure": "",
+     *            "ip-address": "",
+     *            "port": "",
+     *            "cloud-domain": "",
+     *            "default-tenant": "",
+     *            "resource-version": "",
+     *            "relationship-list": [
+     *            ]
+     *            }
+     * @return
+     * @since VFC 1.0
+     */
+    private static JSONObject parseEsrResponse(String vimId, JSONObject esrResponse) {
+        JSONObject vimInfo = new JSONObject();
+        vimInfo.put("vimId", vimId);
+        vimInfo.put("name", esrResponse.getString("system-name"));
+        vimInfo.put("url", esrResponse.getString("service-url"));
+        vimInfo.put("userName", esrResponse.getString("user-name"));
+        vimInfo.put("password", esrResponse.getString("password"));
+        vimInfo.put("tenant", esrResponse.getString("default-tenant"));
+        vimInfo.put("vendor", esrResponse.getString("vendor"));
+        vimInfo.put("version", esrResponse.getString("version"));
+        vimInfo.put("description", "");
+        vimInfo.put("domain", esrResponse.getString("cloud-domain"));
+        vimInfo.put("type", esrResponse.getString("type"));
+        vimInfo.put("createTime", "");
+        LOG.info("parseEsrResponse vimInfo: {}", vimInfo);
+        return vimInfo;
+    }
+
     /**
      * Get tenants.
      * 
index 8fd7702..0a32f0f 100644 (file)
@@ -37,9 +37,13 @@ public class UrlConstant {
      */
     public static final String REST_MSB_REGISTER = "/api/microservices/v1/services";
 
-    public static final String ESR_GET_VIM_URL = "/api/extsys/v1/vims/%s";
+    // /api/extsys/v1/vims/%s
+    public static final String ESR_GET_VIM_URL =
+            "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/%s/%s/esr-system-info-list/esr-system-info/%s";
 
-    public static final String ESR_GET_VIMS_URL = "/api/extsys/v1/vims";
+    // /api/extsys/v1/vims
+    public static final String ESR_GET_VIMS_URL =
+            "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/%s/%s/esr-system-info-list";
 
     /**
      * send resource info to monitor url
@@ -154,7 +158,7 @@ public class UrlConstant {
     /**
      * getTenantURL.
      */
-    public static final String GET_TENANT_URL = "/api/multivim/v1/%s/tenants";
+    public static final String GET_TENANT_URL = "/api/multicloud/v0/%s/tenants";
 
     /**
      * getHostURL.