summaryrefslogtreecommitdiffstats
path: root/huawei/vnfmadapter/VnfmadapterService/service
diff options
context:
space:
mode:
authorluxin <luxin7@huawei.com>2017-10-20 11:00:28 +0800
committerluxin <luxin7@huawei.com>2017-10-20 11:00:28 +0800
commitc51177b287a195ff7aa4ae90d5897da0a99b1f97 (patch)
tree5abc0b96fa22d64673fc83e4cfdb3d8f30842af5 /huawei/vnfmadapter/VnfmadapterService/service
parentd3410fb5cc77b7d58b8d27351345fba09f968019 (diff)
Fix ESR url and response problem
Change-Id: Ib1559185ddc394fd77c2996a1017166e2df2fe97 Issue-Id:VFC-542 Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'huawei/vnfmadapter/VnfmadapterService/service')
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java88
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/ParamConstants.java6
2 files changed, 88 insertions, 6 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java
index c735e784..0ebab2ee 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/VnfmUtil.java
@@ -59,19 +59,99 @@ public final class VnfmUtil {
LOGGER.error("funtion=getVnfmById, status={}", rsp.getStatus());
return null;
}
- return JSONObject.fromObject(rsp.getResponseContent());
+ JSONObject esrVnfm = JSONObject.fromObject(rsp.getResponseContent());
+ LOGGER.info("esrVnfm: {}", esrVnfm);
+ JSONObject vnfmJson = parseEsrVnfm(esrVnfm);
+ LOGGER.info("vnfmJson: {}", esrVnfm);
+ return vnfmJson;
+ }
+
+ /**
+ * <br>
+ *
+ * @param
+ * esrVnfm
+ * {
+ * "vnfm-id": "",
+ * "vim-id": "",
+ * "certificate-url": "",
+ * "resource-version": "",
+ * "esr-system-info-list": [{
+ * "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": [
+ * ]
+ * }
+ * ],
+ * "relationship-list": [{
+ * "related-to": "",
+ * "related-link": "",
+ * "relationship-data": [],
+ * "related-to-property": []
+ * }
+ * ]
+ * }
+ * @return
+ * vnfmJson
+ * {
+ * "vnfmId": "1234",
+ * "name": "vnfm",
+ * "type": "Tacker",
+ * "vimId": "",
+ * "vendor": "huawei",
+ * "version": "v1.0",
+ * "description": "vnfm",
+ * "certificateUrl": "",
+ * "url": "https://192.168.44.126:30001",
+ * "userName": "manoadmin",
+ * "password": "User@12345",
+ * "createTime": "2016-07-06 15:33:18"
+ * }
+ * @since VFC 1.0
+ */
+ private static JSONObject parseEsrVnfm(JSONObject esrVnfm) {
+ JSONObject vnfmObj = new JSONObject();
+ JSONObject esrSysInfo = esrVnfm.getJSONArray("esr-system-info-list").getJSONObject(0);
+ vnfmObj.put(Constant.VNFMID, esrSysInfo.getString("esr-system-info-id"));
+ vnfmObj.put("name", esrSysInfo.getString("system-name"));
+ vnfmObj.put("type", esrSysInfo.getString("type"));
+ vnfmObj.put("vimId", esrVnfm.getString("vim-id"));
+ vnfmObj.put("vendor", esrSysInfo.getString("vendor"));
+ vnfmObj.put("version", esrSysInfo.getString("version"));
+ vnfmObj.put("description", "");
+ vnfmObj.put("certificateUrl", esrVnfm.getString("certificate-url"));
+ vnfmObj.put("url", esrSysInfo.getString("service-url"));
+ vnfmObj.put("userName", esrSysInfo.getString("user-name"));
+ vnfmObj.put("password", esrSysInfo.getString("password"));
+ vnfmObj.put("createTime", "");
+ return vnfmObj;
}
public static JSONObject mockForTest(String vnfmId) {
String vInfo =
"{\"vnfmId\":\"1234\", \"name\":\"vnfm\", \"type\":\"Tacker\", \"vimId\":\"\", \"vendor\":\"huawei\", \"version\":\"v1.0\", \"description\":\"vnfm\", \"certificateUrl\":\"\", \"url\":\"https://192.168.44.126:30001\", \"userName\":\"manoadmin\", \"password\":\"User@12345\", \"createTime\":\"2016-07-06 15:33:18\"}";
JSONObject json = JSONObject.fromObject(vInfo);
- json.put("vnfmId", vnfmId);
+ json.put(Constant.VNFMID, vnfmId);
return json;
}
/**
- * Get vnfmInfo by id
+ * Get vnfmInfo by ip
* <br/>
*
* @param ip
@@ -89,7 +169,7 @@ public final class VnfmUtil {
LOGGER.info("vnfm ip: {}, vnfmList: {}", ip, vnfmList);
for(int i = 0; i < vnfmList.size(); i++) {
if(vnfmList.getJSONObject(i).getString("url").contains(ip)) {
- return vnfmList.getJSONObject(i).getString("vnfmId");
+ return vnfmList.getJSONObject(i).getString(Constant.VNFMID);
}
}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/ParamConstants.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/ParamConstants.java
index 7448ec0e..6aafba8f 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/ParamConstants.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/ParamConstants.java
@@ -109,9 +109,11 @@ public class ParamConstants {
public static final String MSB_UNREGISTER_URL = "/api/microservices/v1/services/hw-vnfm";
- public static final String ESR_GET_VNFM_URL = "/api/extsys/v1/vnfms/%s";
+ // /api/extsys/v1/vnfms/%s
+ public static final String ESR_GET_VNFM_URL = "/external-system/esr-vnfm-list/esr-vnfm/%s";
- public static final String ESR_GET_VNFMS_URL = "/api/extsys/v1/vnfms";
+ // /api/extsys/v1/vnfms
+ public static final String ESR_GET_VNFMS_URL = "/external-system/esr-vnfm-list";
public static final String GRANT_RES_URL = "/api/resmgr/v1/resource/grant";