From a97127783318ee42d800085ceb44dc361c02e3c3 Mon Sep 17 00:00:00 2001 From: liuqian Date: Fri, 25 May 2018 17:47:17 +0800 Subject: fix bug Change-Id: Icde7c7ebdf27646522aeab223e41e1a2316022e9 Issue-ID: VFC-923 Signed-off-by: liuqian --- .../svnfm/vnfmadapter/service/rest/VnfResourceRoa.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfResourceRoa.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfResourceRoa.java index dbd87301..fa1e4c39 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfResourceRoa.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfResourceRoa.java @@ -121,16 +121,17 @@ public class VnfResourceRoa { JSONArray vmList = dataObject.getJSONArray("vm_list"); String changeType = ""; String operation = ""; - if(1 == dataObject.getInt("event_type")) { + int eventType = dataObject.getInt("event_type"); + if(1 == eventType) { changeType = "added"; operation = "Instantiate"; - } else if(4 == dataObject.getInt("event_type")) { + } else if(4 == eventType) { changeType = "removed"; operation = "Terminal"; - } else if(3 == dataObject.getInt("event_type")) { + } else if(3 == eventType) { changeType = "added"; operation = "Scaleout"; - } else if(2 == dataObject.getInt("event_type")) { + } else if(2 == eventType) { changeType = "removed"; operation = "Scalein"; } @@ -138,6 +139,9 @@ public class VnfResourceRoa { for(int i = 0; i < vmList.size(); i++) { JSONObject vm = vmList.getJSONObject(i); LOG.info("function=callLcmNotify, vm: {}", vm); + if((2 == eventType) && ("Active".equalsIgnoreCase(vm.getString("status")))) { + continue; + } JSONObject affectedVm = new JSONObject(); String vimVimId = vm.getString("vim_vm_id"); affectedVm.put("vnfcInstanceId", vimVimId); @@ -149,6 +153,10 @@ public class VnfResourceRoa { LOG.info("function=callLcmNotify, affectedVm: {}", affectedVm); affectedVnfc.add(affectedVm); } + if(affectedVnfc.isEmpty()) { + LOG.warn("function=callLcmNotify, affectedVnfc is empty."); + return; + } JSONObject notification = new JSONObject(); notification.put("status", dataObject.getString("vnf_status")); notification.put("vnfInstanceId", vnfInstanceId); -- cgit 1.2.3-korg