diff options
author | 2018-05-16 10:01:22 +0800 | |
---|---|---|
committer | 2018-05-16 10:01:22 +0800 | |
commit | b274e9e57cd32e9fd42725d22db33584e2d8407c (patch) | |
tree | 6071b33adbab523c676066357ba333ec038a97be /huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap | |
parent | 29ec1736ac4558082b5a979e1ec882eb6e63affb (diff) |
update driver scaling process
Change-Id: I058647bf164f529264dbde89b1b349a7d779e1e5
Issue-ID: VFC-868
Signed-off-by: liuqian <liuqian13@huawei.com>
Diffstat (limited to 'huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap')
2 files changed, 47 insertions, 4 deletions
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); |