summaryrefslogtreecommitdiffstats
path: root/huawei
diff options
context:
space:
mode:
authorGao Weitao <victor.gao@huawei.com>2018-04-21 09:10:09 +0000
committerGerrit Code Review <gerrit@onap.org>2018-04-21 09:10:09 +0000
commitef890d3b0f4ce1068aabc2fa05d72eff9559d43d (patch)
tree829860238e3043c6f5cab058bf7d9fd9cea2c63b /huawei
parent4ed278fe7fabd119400fa056e0086701cecf8508 (diff)
parent8ab4ae0a340b12bc6c09a29ab9e81382536a5c65 (diff)
Merge "addvnf support emsUuid"
Diffstat (limited to 'huawei')
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/vnfpkginfo.json5
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java8
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfMgr.java14
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java193
4 files changed, 123 insertions, 97 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/vnfpkginfo.json b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/vnfpkginfo.json
index 82fcb480..e8610592 100644
--- a/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/vnfpkginfo.json
+++ b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/etc/vnfpkginfo/vnfpkginfo.json
@@ -15,7 +15,8 @@
"software_file_path": "",
"software_file_name": "",
"catalog": "",
- "vim_id": "NE=34603199"
+ "vim_id": "NE=34603199",
+ "emsUuid": ""
}
},
"2": {
@@ -38,5 +39,5 @@
}
},
"vnfmid": "",
- "vimid": ""
+ "vimid": ""
} \ 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 a7329e39..f6f1f5e1 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
@@ -27,6 +27,7 @@ import java.util.Map;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
@@ -113,11 +114,15 @@ public class AdapterResourceManager implements IResourceManager {
resultObj.put(Constant.RETCODE, Constant.REST_FAIL);
return resultObj;
}
+ String emsUuid = "";
String vnfdName = transferFromCsar(csarName);
JSONObject vnfpkg = vnfpkgJson.getJSONObject(vnfdName);
JSONObject csarTempObj = vnfpkg.getJSONObject("template");
String csarfilepath = csarTempObj.getString("csar_file_path");
String csarfilename = csarTempObj.getString("csar_file_name");
+ if (csarTempObj.containsKey("emsUuid")) {
+ emsUuid = csarTempObj.getString("emsUuid");
+ }
// download csar package and save in location.
JSONObject downloadObject = downloadCsar(downloadUri, csarfilepath + csarfilename);
@@ -269,6 +274,9 @@ public class AdapterResourceManager implements IResourceManager {
resultObj.put("vnfdVersion", vnfdVersion);
resultObj.put("planName", planName);
resultObj.put("planId", planId);
+ if (StringUtils.isNotEmpty(emsUuid)) {
+ resultObj.put("emsUuid", emsUuid);
+ }
resultObj.put("parameters", inputsObj);
LOG.info("resultObj:" + resultObj.toString());
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 ce0fcac9..83c0b557 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
@@ -16,8 +16,10 @@
package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process;
-import net.sf.json.JSONException;
-import net.sf.json.JSONObject;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.ResultRequestUtil;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmUtil;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl.AdapterResourceManager;
@@ -28,9 +30,8 @@ import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.entity.Vnfm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import net.sf.json.JSONException;
+import net.sf.json.JSONObject;
/**
* Provide function for instantiate or terminate VNF
@@ -236,6 +237,9 @@ public class VnfMgr {
restJson.put("vapp_name", vnfObject.get("vnfInstanceName"));
restJson.put("project_id", vnfmId);
restJson.put("parameters", resObject.getJSONObject("parameters"));
+ if (resObject.containsKey("emsUuid")) {
+ restJson.put("emsUuid", resObject.getString("emsUuid"));
+ }
restJson.put("nfvo_id", "");
restJson.put("location", "");
restJson.put("vnfm_id", vnfmId);
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java
index 47ae7dc8..b8eea548 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java
@@ -40,11 +40,9 @@ import org.slf4j.LoggerFactory;
import net.sf.json.JSONObject;
/**
- * Provide interfaces for authInfo
- * <br/>
+ * Provide interfaces for authInfo <br/>
* <p>
- * auth tokens interface is provided by platform
- * not in nfvo for vnfm
+ * auth tokens interface is provided by platform not in nfvo for vnfm
* differences from other interface
* </p>
*
@@ -56,90 +54,105 @@ import net.sf.json.JSONObject;
@Produces(MediaType.APPLICATION_JSON)
public class AuthRoa {
- private static final Logger LOG = LoggerFactory.getLogger(AuthRoa.class);
-
- private AuthMgr authMgr;
-
- public void setAuthMgr(AuthMgr authMgr) {
- this.authMgr = authMgr;
- }
-
- /**
- * Provide interface for add authInfo
- * <br/>
- *
- * @param context
- * @return
- * @since VFC 1.0
- */
- @PUT
- @Path("/plat/smapp/v1/oauth/token")
- public String authToken(@Context HttpServletRequest context, @Context HttpServletResponse resp) {
- LOG.warn("function=login, msg=enter to get token.");
- JSONObject subJsonObject = VnfmJsonUtil.getJsonFromContexts(context);
- LOG.warn("subJsonObject: {}", subJsonObject);
-
- if(null == subJsonObject) {
- LOG.error("function=login, msg=params are insufficient");
- String resultStr = "Login params insufficient";
- resp.setStatus(Constant.HTTP_BAD_REQUEST);
-
- return resultStr;
- }
-
- JSONObject authResult = authMgr.authToken(subJsonObject);
- LOG.warn("authResult: {}", authResult);
- if(authResult.getInt(Constant.RETCODE) == Constant.REST_SUCCESS) {
- JSONObject data = authResult.getJSONObject("data");
- resp.setStatus(Constant.HTTP_OK);
- return data.toString();
- } else if(authResult.getInt(Constant.RETCODE) == Constant.HTTP_INNERERROR) {
- Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(authResult.getString("data")).build();
- return String.format(ParamConstants.GET_TOKEN_FAIL_RESP, authResult.getString("data"));
- } else {
- Response.status(Response.Status.UNAUTHORIZED).entity(authResult.getString("data")).build();
- return String.format(ParamConstants.GET_TOKEN_FAIL_RESP, authResult.getString("data"));
- }
- }
-
- /**
- * Provide interface for delete authInfo
- * <br/>
- *
- * @param userName
- * @param roarand
- * @return
- * @since VFC 1.0
- */
- @DELETE
- @Path("/plat/smapp/v1/auth/tokens/{userName}/{roarand}")
- public String delAuthToken(@PathParam(Constant.USERNAME) String userName, @PathParam("roarand") String roarand,
- @Context HttpServletResponse resp) {
- LOG.warn("function=logout, msg=enter to logout");
- JSONObject resultJson = new JSONObject();
-
- resultJson.put("Information", "Operation success");
- resp.setStatus(Constant.HTTP_NOCONTENT);
- LOG.warn("function=logout, msg=end to logout");
- return resultJson.toString();
- }
-
- /**
- * Provide interface for handshake authInfo
- * <br/>
- *
- * @param roattr
- * @return
- * @since VFC 1.0
- */
- @GET
- @Path("/vnfmmed/v2/nfvo/shakehand")
- public String shakehand(@QueryParam("roattr") String roattr, @Context HttpServletResponse resp) {
- JSONObject resultJson = new JSONObject();
- resultJson.put("status", "running");
- resultJson.put("description", "Operation success");
- resp.setStatus(Constant.HTTP_OK);
-
- return resultJson.toString();
- }
+ private static final Logger LOG = LoggerFactory.getLogger(AuthRoa.class);
+
+ private AuthMgr authMgr;
+
+ public void setAuthMgr(AuthMgr authMgr) {
+ this.authMgr = authMgr;
+ }
+
+ /**
+ * Provide interface for add authInfo <br/>
+ *
+ * @param context
+ * @return
+ * @since VFC 1.0
+ */
+ @PUT
+ @Path("/plat/smapp/v1/oauth/token")
+ public String authToken(@Context HttpServletRequest context, @Context HttpServletResponse resp) {
+ LOG.warn("function=login, msg=enter to get token.");
+ JSONObject subJsonObject = VnfmJsonUtil.getJsonFromContexts(context);
+ LOG.warn("subJsonObject: {}", subJsonObject);
+
+ if (null == subJsonObject) {
+ LOG.error("function=login, msg=params are insufficient");
+ String resultStr = "Login params insufficient";
+ resp.setStatus(Constant.HTTP_BAD_REQUEST);
+
+ return resultStr;
+ }
+
+ JSONObject authResult = authMgr.authToken(subJsonObject);
+ LOG.warn("authResult: {}", authResult);
+ if (authResult.getInt(Constant.RETCODE) == Constant.REST_SUCCESS) {
+ JSONObject data = authResult.getJSONObject("data");
+ resp.setStatus(Constant.HTTP_OK);
+ return data.toString();
+ } else if (authResult.getInt(Constant.RETCODE) == Constant.HTTP_INNERERROR) {
+ Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(authResult.getString("data")).build();
+ return String.format(ParamConstants.GET_TOKEN_FAIL_RESP, authResult.getString("data"));
+ } else {
+ Response.status(Response.Status.UNAUTHORIZED).entity(authResult.getString("data")).build();
+ return String.format(ParamConstants.GET_TOKEN_FAIL_RESP, authResult.getString("data"));
+ }
+ }
+
+ /**
+ * Provide interface for delete authInfo <br/>
+ *
+ * @param userName
+ * @param roarand
+ * @return
+ * @since VFC 1.0
+ */
+ @DELETE
+ @Path("/plat/smapp/v1/auth/tokens/{userName}/{roarand}")
+ public String delAuthToken(@PathParam(Constant.USERNAME) String userName, @PathParam("roarand") String roarand,
+ @Context HttpServletResponse resp) {
+ LOG.warn("function=logout, msg=enter to logout");
+ JSONObject resultJson = new JSONObject();
+
+ resultJson.put("Information", "Operation success");
+ resp.setStatus(Constant.HTTP_NOCONTENT);
+ LOG.warn("function=logout, msg=end to logout");
+ return resultJson.toString();
+ }
+
+ /**
+ * Provide interface for handshake authInfo <br/>
+ *
+ * @param roattr
+ * @return
+ * @since VFC 1.0
+ */
+ @GET
+ @Path("/vnfmmed/v2/nfvo/shakehand")
+ public String shakehand(@QueryParam("roattr") String roattr, @Context HttpServletResponse resp) {
+ JSONObject resultJson = new JSONObject();
+ resultJson.put("status", "running");
+ resultJson.put("description", "Operation success");
+ resp.setStatus(Constant.HTTP_OK);
+
+ return resultJson.toString();
+ }
+
+ /**
+ * Provide interface for handshake authInfo <br/>
+ *
+ * @param roattr
+ * @return
+ * @since VFC 1.0
+ */
+ @GET
+ @Path("/plat/smapp/v1/nfvo/shakehand")
+ public String shakehandOld(@QueryParam("roattr") String roattr, @Context HttpServletResponse resp) {
+ JSONObject resultJson = new JSONObject();
+ resultJson.put("status", "running");
+ resultJson.put("description", "Operation success");
+ resp.setStatus(Constant.HTTP_OK);
+
+ return resultJson.toString();
+ }
}