summaryrefslogtreecommitdiffstats
path: root/huawei
diff options
context:
space:
mode:
authorliuqian <liuqian13@huawei.com>2018-05-16 10:01:22 +0800
committerliuqian <liuqian13@huawei.com>2018-05-16 10:01:22 +0800
commitb274e9e57cd32e9fd42725d22db33584e2d8407c (patch)
tree6071b33adbab523c676066357ba333ec038a97be /huawei
parent29ec1736ac4558082b5a979e1ec882eb6e63affb (diff)
update driver scaling process
Change-Id: I058647bf164f529264dbde89b1b349a7d779e1e5 Issue-ID: VFC-868 Signed-off-by: liuqian <liuqian13@huawei.com>
Diffstat (limited to 'huawei')
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/scalein_vm_ids.json10
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java37
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java14
3 files changed, 57 insertions, 4 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/scalein_vm_ids.json b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/scalein_vm_ids.json
new file mode 100644
index 00000000..a62900dd
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/scalein_vm_ids.json
@@ -0,0 +1,10 @@
+{
+ "vm_list": [
+ {
+ "vm_id": ""
+ },
+ {
+ "vim_id": ""
+ }
+ ]
+} \ No newline at end of file
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java
index f9bafb68..ef7a07ae 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java
@@ -655,6 +655,43 @@ public class AdapterResourceManager implements IResourceManager {
return fileContent;
}
+ /**
+ * Get scalein vm ids.<br>
+ *
+ * @return
+ * @throws IOException
+ * @since VFC 1.0
+ */
+ public static JSONObject readScaleInVmIdFromJson() {
+ String fileContent = "";
+
+ String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot()
+ + System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR)
+ + "vnfpkginfo" + System.getProperty(Constant.FILE_SEPARATOR) + "scalein_vm_ids.json";
+
+ try (InputStream ins = new FileInputStream(fileName)) {
+ try (BufferedInputStream bins = new BufferedInputStream(ins)) {
+ byte[] contentByte = new byte[ins.available()];
+ int num = bins.read(contentByte);
+
+ if(num > 0) {
+ fileContent = new String(contentByte);
+ }
+ }
+
+ if(StringUtils.isNotEmpty(fileContent)) {
+ return JSONObject.fromObject(fileContent);
+ }
+ } catch(FileNotFoundException e) {
+ LOG.error(fileName + "is not found!", e);
+ } catch(JSONException e) {
+ LOG.error(fileName + "is not json!", e);
+ } catch(IOException e) {
+ LOG.error(fileName + "io exception!", e);
+ }
+ return null;
+ }
+
private static JSONObject readVnfdIdInfoFromJson() {
JSONObject jsonObject = new JSONObject();
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 e57d23f4..242ccbdf 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
@@ -21,6 +21,7 @@ import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.ResultRequestUtil;
+import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.AdapterResourceManager;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.ParamConstants;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.UrlConstant;
@@ -75,12 +76,15 @@ public class VnfMgrVnfm implements InterfaceVnfMgr {
// scale_in
JSONArray vmList = new JSONArray();
try {
- JSONObject additionalParam = vnfObject.getJSONObject("additionalParam");
- vmList = additionalParam.getJSONArray("vm_list");
+ // JSONObject additionalParam = vnfObject.getJSONObject("additionalParam");
+ // vmList = additionalParam.getJSONArray("vm_list");
+ vmList = AdapterResourceManager.readScaleInVmIdFromJson().getJSONArray("vm_list");
} catch(JSONException e) {
LOG.error("the param 'additionalParam' or 'vm_list' not found,please check it", e);
}
- scaleInfo.put("vm_list", vmList);
+ if(null != vmList && !vmList.isEmpty()) {
+ scaleInfo.put("vm_list", vmList);
+ }
}
paramJson.put("scale_info", scaleInfo);
JSONObject queryResult =
@@ -93,7 +97,9 @@ public class VnfMgrVnfm implements InterfaceVnfMgr {
restJson.put(Constant.RETCODE, Constant.REST_SUCCESS);
// restJson.put("data",
// queryResult.getJSONObject("data").getJSONObject("scale_info"));
- JSONObject appInfo = queryResult.getJSONObject("data").getJSONObject("scale_info");
+ // JSONObject appInfo =
+ // queryResult.getJSONObject("data").getJSONObject("scale_info");
+ JSONObject appInfo = new JSONObject();
JSONObject resultObj = new JSONObject();
// resultObj.put(Constant.JOBID, vnfInstanceId + "_" + Constant.PUT);
handleResponse(resultObj, appInfo, vnfInstanceId, Constant.PUT);