summaryrefslogtreecommitdiffstats
path: root/huawei
diff options
context:
space:
mode:
Diffstat (limited to 'huawei')
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java20
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java8
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfResourceRoa.java18
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java22
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/resources/spring/Vnfmadapter/services.xml2
5 files changed, 61 insertions, 9 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);
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java
index 7b5c1baf..cf0e3b39 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java
@@ -359,18 +359,22 @@ public class VnfMgr {
JSONObject jobInfoJson = new JSONObject();
JSONObject jobInfo = restJson.getJSONObject("data").getJSONObject("job_info");
jobInfoJson.put("jobId", jobInfo.getString("job_id") + ":job");
- responseJson.put("progress", jobInfo.getString("task_progress_rate"));
+ String taskProgress = jobInfo.getString("task_progress_rate");
+ responseJson.put("progress", taskProgress);
+ int responseId = Integer.parseInt(taskProgress);
String taskStatus = jobInfo.getString("task_status");
if(taskStatus.equalsIgnoreCase("Successfully") || taskStatus.equalsIgnoreCase("finished")) {
responseJson.put("status", "finished");
+ responseId++;
} else if(taskStatus.equalsIgnoreCase("Failed")) {
responseJson.put("status", "error");
+ responseId++;
} else {
responseJson.put("status", "processing");
}
responseJson.put("errorCode", jobInfo.getString("error_code"));
- responseJson.put("responseId", jobInfo.getString("task_progress_rate"));
+ responseJson.put("responseId", String.valueOf(responseId));
jobInfoJson.put("responsedescriptor", responseJson);
LOG.warn("function=getJobBody, jobInfoJson: {}", jobInfoJson);
return jobInfoJson.toString();
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 c16f0730..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,17 +121,27 @@ 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();
String vimVimId = vm.getString("vim_vm_id");
affectedVm.put("vnfcInstanceId", vimVimId);
@@ -143,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);
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java
index 15786b66..e56eef1f 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java
@@ -302,7 +302,7 @@ public class VnfRoa {
* "affectedvm": {
* "vmid": "804cca71 - 9ae9 - 4511 - 8e30 - d1387718caff",
* "vduid": "vdu_100",
- * "vmname": "ZTE_SSS_111_PP_2_L"
+ * "vmname": "SBC_111_PP_2_L"
* }
* }
* @param resp
@@ -333,10 +333,26 @@ public class VnfRoa {
}
restJson.remove(Constant.RETCODE);
- restJson.put("jobId", vnfInstanceId + "_post");
+ //restJson.put("jobId", vnfInstanceId + "_post");
+ restJson.put("jobId", vnfInstanceId + ":heal");
return restJson.toString();
}
+ private String getHealJobBody(String jobId) {
+ LOG.warn("function=getHealJobBody");
+ JSONObject responseJson = new JSONObject();
+ JSONObject jobInfoJson = new JSONObject();
+ jobInfoJson.put("jobId", jobId);
+ responseJson.put("progress", "100");
+ responseJson.put("status", "finished");
+ responseJson.put("errorCode", "null");
+ responseJson.put("responseId", "100");
+ jobInfoJson.put("responsedescriptor", responseJson);
+
+ LOG.warn("function=getJobBody, jobInfoJson: {}", jobInfoJson);
+ return jobInfoJson.toString();
+ }
+
private String getJobBody(JSONObject restJson, String jobId) {
LOG.warn("function=getJobBody, restJson: {}", restJson);
JSONObject responseJson = new JSONObject();
@@ -419,6 +435,8 @@ public class VnfRoa {
if(flag.equalsIgnoreCase("no")) {
return getJobProcess(tmpJobId, vnfmId, resp, jobId);
+ } else if (flag.equalsIgnoreCase("heal")){
+ return getHealJobBody(jobId);
} else {
JSONObject restJson = vnfMgr.getJobFromVnfm(tmpJobId, vnfmId);
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/resources/spring/Vnfmadapter/services.xml b/huawei/vnfmadapter/VnfmadapterService/service/src/main/resources/spring/Vnfmadapter/services.xml
index f71aa51a..312365d1 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/resources/spring/Vnfmadapter/services.xml
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/resources/spring/Vnfmadapter/services.xml
@@ -41,7 +41,7 @@
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
- <context:property-placeholder location="classpath:jdbc.properties" ignore-unresolvable="true"/>
+ <ctx:property-placeholder location="classpath:config.properties" ignore-unresolvable="true"/>
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>