fix bug 91/49091/1
authorliuqian <liuqian13@huawei.com>
Fri, 25 May 2018 09:47:17 +0000 (17:47 +0800)
committerliuqian <liuqian13@huawei.com>
Fri, 25 May 2018 09:47:17 +0000 (17:47 +0800)
Change-Id: Icde7c7ebdf27646522aeab223e41e1a2316022e9
Issue-ID: VFC-923
Signed-off-by: liuqian <liuqian13@huawei.com>
huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfResourceRoa.java

index dbd8730..fa1e4c3 100644 (file)
@@ -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);