Merge "Fix CVE-2018-1271, CVE-2018-10237"
[vfc/nfvo/driver/vnfm/svnfm.git] / huawei / vnfmadapter / VnfmadapterService / service / src / main / java / org / onap / vfc / nfvo / vnfm / svnfm / vnfmadapter / service / rest / VnfResourceRoa.java
index bacfb81..fa1e4c3 100644 (file)
@@ -121,27 +121,42 @@ 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 {
+        } else if(4 == eventType) {
             changeType = "removed";
             operation = "Terminal";
+        } else if(3 == eventType) {
+            changeType = "added";
+            operation = "Scaleout";
+        } else if(2 == eventType) {
+            changeType = "removed";
+            operation = "Scalein";
         }
         String vnfInstanceId = dataObject.getString("vnf_id");
         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();
-            affectedVm.put("vnfcInstanceId", vm.getString("vm_id"));
+            String vimVimId = vm.getString("vim_vm_id");
+            affectedVm.put("vnfcInstanceId", vimVimId);
             affectedVm.put("changeType", changeType);
             affectedVm.put("vimid", vimId);
-            affectedVm.put("vmid", vm.getString("vm_id"));
+            affectedVm.put("vmid", vimVimId);
             affectedVm.put("vmname", vm.getString("vm_name"));
-            affectedVm.put("vduid", vm.getString("vm_id"));
+            affectedVm.put("vduid", vimVimId);
             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);