diff options
Diffstat (limited to 'huawei/vnfmadapter')
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); |