diff options
author | Gao Weitao <victor.gao@huawei.com> | 2018-05-24 08:45:55 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-05-24 08:45:55 +0000 |
commit | d4bb37c62a6360885145221928b1bd47f16b2bb9 (patch) | |
tree | e5b16228d719d2996f0a9f215d41a4801b450823 /huawei/vnfmadapter/VnfmadapterService/service | |
parent | 1dca0e2ef23d1d51e4d2b2f6675aeaa7320d44f6 (diff) | |
parent | 0ca9baabf9ad09ea1a65f832a9ed4637b87087a1 (diff) |
Merge "modify healVnf vmid"
Diffstat (limited to 'huawei/vnfmadapter/VnfmadapterService/service')
-rw-r--r-- | huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java index 42d5b875..92b28f36 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java @@ -350,13 +350,13 @@ public class VnfMgrVnfm implements InterfaceVnfMgr { String action = jsonObject.getString("action"); JSONObject affectedVm = jsonObject.getJSONObject("affectedvm"); - String vmId = affectedVm.getString("vmid"); + String vmId = getNativeVmId(affectedVm.getString("vmid"), vnfmObjcet, vnfInstanceId); String path = String.format(ParamConstants.HEAL_VNF, vmId); JSONObject subJsonObject = new JSONObject(); subJsonObject.put("type", "hard"); subJsonObject.put("boot_mode", ""); - if("vmReset".equals(action)) { + if("vmReset".equalsIgnoreCase(action)) { subJsonObject.put("action", "reset"); } LOG.info("healVnf subJsonObject :" + subJsonObject); @@ -374,6 +374,22 @@ public class VnfMgrVnfm implements InterfaceVnfMgr { return restJson; } + private String getNativeVmId(String vimVmId, JSONObject vnfmObjcet, String vnfInstanceId) { + JSONObject queryVms = ResultRequestUtil.call(vnfmObjcet, + String.format(ParamConstants.VNF_GET_VMINFO, vnfInstanceId), Constant.GET, null, Constant.CERTIFICATE); + LOG.info("function=getNativeVmId, msg=query vms result=" + queryVms); + JSONArray vms = queryVms.getJSONObject("data").getJSONArray("vms"); + for(int i = 0; i < vms.size(); i++) { + JSONObject obj = vms.getJSONObject(i); + String tmpVimVmId = obj.getString("backend_id"); + if(vimVmId.equalsIgnoreCase(tmpVimVmId)) { + return obj.getString("id"); + } + } + LOG.error("function=getNativeVmId, msg=get native vmId failed."); + return ""; + } + public JSONObject getJobFromVnfm(JSONObject vnfmObjcet, String jobId) { LOG.warn("function=getJobFromVnfm, jobId: {}", jobId); |