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();
String vimVimId = vm.getString("vim_vm_id");
affectedVm.put("vnfcInstanceId", 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);