summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluxin <luxin7@huawei.com>2018-03-22 10:01:13 +0800
committerluxin <luxin7@huawei.com>2018-03-22 10:01:13 +0800
commit37e6b6790110cf83c9a882cf637fe5fb97601e82 (patch)
treeceb9fd966ae60393ea7b4d302da396308ed4ee21
parent9478f6a826cffd3b9f5f6aabbcc9c57bb7696b32 (diff)
Fix query vms interface
Change-Id: I6a1ff613b1564d61cddc5df9762faa0d19c27b53 Issue-ID: VFC-725 Signed-off-by: luxin <luxin7@huawei.com>
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java20
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java30
2 files changed, 40 insertions, 10 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java
index a4f0a697..be8268a4 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java
@@ -19,6 +19,7 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.ResultRequestUtil;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmUtil;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.AdapterResourceManager;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
@@ -346,4 +347,23 @@ public class VnfMgr {
LOG.warn("function=getJobBody, jobInfoJson: {}", jobInfoJson);
return jobInfoJson.toString();
}
+
+ public JSONObject getVmsFromVnfm(String vnfmId, String vnfInstanceId) {
+ JSONObject restJson = new JSONObject();
+ JSONObject vnfmObjcet = VnfmUtil.getVnfmById(vnfmId);
+ if(vnfmObjcet.isNullObject()) {
+ LOG.error("function=getVmsFromVnfm, msg=vnfm not exists, vnfmId: {}", vnfmId);
+ restJson.put("message", "vnfm not exists");
+ return restJson;
+ }
+ String url = "";
+ if(vnfInstanceId == null) {
+ url = "/v2/vapps/instances/query/vms";
+ } else {
+ url = String.format("/v2/vapps/instances/%s/vms", vnfInstanceId);
+ }
+ restJson = ResultRequestUtil.call(vnfmObjcet, url, Constant.GET, null, Constant.CERTIFICATE);
+ LOG.info("function=getVmsFromVnfm, restJson: {}", restJson);
+ return restJson;
+ }
}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java
index ad963e75..0fc36587 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java
@@ -33,7 +33,6 @@ import javax.ws.rs.core.MediaType;
import org.apache.commons.collections.map.UnmodifiableMap;
import org.apache.commons.lang3.StringUtils;
-import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.ResultRequestUtil;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmJsonUtil;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmUtil;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
@@ -356,21 +355,32 @@ public class VnfRoa {
@Path("/{vnfmId}/vms")
public String getVms(@PathParam("vnfmId") String vnfmId, @Context HttpServletResponse resp) {
LOG.info("function=getVms, msg=enter to get vms: vnfmId: {}", vnfmId);
- JSONObject restJson = new JSONObject();
- JSONObject vnfmObjcet = VnfmUtil.getVnfmById(vnfmId);
- if(vnfmObjcet.isNullObject()) {
- LOG.error("function=getVnf, msg=vnfm not exists, vnfmId: {}", vnfmId);
- restJson.put("message", "vnfm not exists");
- return restJson.toString();
- }
- String url = "/v2/vapps/instances/query/vms";
- restJson = ResultRequestUtil.call(vnfmObjcet, url, Constant.GET, null, Constant.CERTIFICATE);
+ JSONObject restJson = vnfMgr.getVmsFromVnfm(vnfmId, null);
LOG.info("function=getVms, restJson: {}", restJson);
return restJson.getString("data");
}
/**
* <br>
+ * Query vms info by vnfId from vnfm
+ *
+ * @param vnfmId
+ * @param vnfInstanceId
+ * @param resp
+ * @return
+ */
+ @GET
+ @Path("/{vnfmId}/{vnfInstanceId}/vms")
+ public String getVmsByVnfId(@PathParam("vnfmId") String vnfmId, @PathParam("vnfInstanceId") String vnfInstanceId,
+ @Context HttpServletResponse resp) {
+ LOG.info("function=getVmsByVnfId, msg=enter to get vms: vnfmId: {}", vnfmId);
+ JSONObject restJson = vnfMgr.getVmsFromVnfm(vnfmId, vnfInstanceId);
+ LOG.info("function=getVmsByVnfId, restJson: {}", restJson);
+ return restJson.getString("data");
+ }
+
+ /**
+ * <br>
* Query job status from vnfm version 18.1
*
* @param jobId