diff options
Diffstat (limited to 'huawei/vnfmadapter')
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 |