summaryrefslogtreecommitdiffstats
path: root/huawei/vnfmadapter
diff options
context:
space:
mode:
authorluxin <luxin7@huawei.com>2017-09-21 16:57:34 +0800
committerluxin <luxin7@huawei.com>2017-09-21 16:57:34 +0800
commit402f0e05c91db0d52cc91e360fd98f0aac455068 (patch)
treea2cd167a3c8d3c4943ffbec3a623ca06562f1676 /huawei/vnfmadapter
parent73edaecd636ca73657aeef7bcc4b0c6e13d03068 (diff)
Fix VNF instantiate problem
Change-Id: Ie277ddd2bd59a296684b63c2b0c84bf238c29bc8 Issue-Id:VFC-391 Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'huawei/vnfmadapter')
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java17
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java2
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoa.java2
3 files changed, 13 insertions, 8 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 5e386376..98e3fa04 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
@@ -57,14 +57,14 @@ public class AdapterResourceManager implements IResourceManager {
@Override
public JSONObject uploadVNFPackage(JSONObject vnfpkg, Map<String, String> paramsMap) {
JSONObject resultObj = new JSONObject();
- JSONObject csarTempObj = new JSONObject();
-
+ String vnfDescriptorId = paramsMap.get("vnfDescriptorId");
try {
// if upper layer do not provide vnfpackage info,then get the
// vnfpackage info from JSON file.
if(vnfpkg == null || vnfpkg.isEmpty()) {
String vnfPkgInfo = readVfnPkgInfoFromJson();
- vnfpkg = JSONObject.fromObject(vnfPkgInfo); // NOSONAR
+ JSONObject vnfpkgJson = JSONObject.fromObject(vnfPkgInfo);
+ vnfpkg = vnfpkgJson.getJSONObject(vnfDescriptorId);
}
} catch(IOException e) {
LOG.error("function=uploadVNFPackage", e);
@@ -80,7 +80,7 @@ public class AdapterResourceManager implements IResourceManager {
String csarid = paramsMap.get("csarid");
String vnfmid = paramsMap.get("vnfmid");
String vnfdid = "";
- String vnfDescriptorId = paramsMap.get("vnfDescriptorId");
+
if(null == csarid || "".equals(csarid)) {
resultObj.put("reason", "csarid is null.");
resultObj.put("retCode", Constant.REST_FAIL);
@@ -104,7 +104,7 @@ public class AdapterResourceManager implements IResourceManager {
resultObj.put("retCode", Constant.REST_FAIL);
return resultObj;
}
-
+ JSONObject csarTempObj = new JSONObject();
csarTempObj = vnfpkg.getJSONObject("template");
String csarfilepath = csarTempObj.getString("csar_file_path");
String csarfilename = csarTempObj.getString("csar_file_name");
@@ -180,12 +180,17 @@ public class AdapterResourceManager implements IResourceManager {
}
// upload VNF package
- csarTempObj.getJSONArray("vim_list").getJSONObject(0).put("vim_id", vimId);
+ csarTempObj.put("vim_id", vimId);
vnfpkg.put("template", csarTempObj);
LOG.info("vnfpkg: " + vnfpkg);
JSONObject uploadPkgObject = upload(vnfpkg, vnfmUrl, connToken);
LOG.info("uploadPkgObject:" + uploadPkgObject);
+ if(!uploadPkgObject.isEmpty() && uploadPkgObject.get(Constant.RETCODE).equals(HttpStatus.SC_OK)) {
+ LOG.info("upload vnf package info successful.", uploadPkgObject.get(Constant.RETCODE));
+ vnfdid = uploadPkgObject.getString("id");
+ }
+
if(vnfdid == null || "".equals(vnfdid.trim())) {
JSONObject vnfdConf = readVnfdIdInfoFromJson();
LOG.info("vnfdConf=" + vnfdConf);
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 33730fd2..d1508ba0 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
@@ -159,7 +159,7 @@ public class VnfMgrVnfm implements InterfaceVnfMgr {
int statusCode = queryResult.getInt(Constant.RETCODE);
- if(statusCode == Constant.HTTP_NOCONTENT) {
+ if(statusCode == Constant.HTTP_NOCONTENT || statusCode == Constant.HTTP_OK) {
restJson.put(Constant.RETCODE, Constant.REST_SUCCESS);
JSONObject resultObj = new JSONObject();
resultObj.put(Constant.JOBID, vnfId + "_" + Constant.DELETE);
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 7d3c14c2..35f7ceaa 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
@@ -252,7 +252,7 @@ public class VnfRoa {
@Path("/{vnfmId}/jobs/{jobId}")
public String getJob(@PathParam("jobId") String jobId, @PathParam("vnfmId") String vnfmId,
@Context HttpServletResponse resp, @QueryParam("@responseId") String responseId) throws ServiceException {
- LOG.warn("function=getJob, msg=enter to get a job: jobId: {}", jobId);
+ LOG.warn("function=getJob, msg=enter to get a job: jobId: {}, responseId: {}", jobId, responseId);
JSONObject restJson = new JSONObject();
if(StringUtils.isEmpty(jobId) || StringUtils.isEmpty(vnfmId)) {