summaryrefslogtreecommitdiffstats
path: root/esr-mgr/src
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-16 12:49:17 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-16 12:49:17 +0800
commit861c24d17f2c1d351f75ef4b4c280b6dcca762e5 (patch)
tree0db1535ef55000b5453765d1aac0526e4b7098e1 /esr-mgr/src
parent2022e6a4773e016d5fb169586d20a0839fa51b94 (diff)
Realize the VNFM register API
Realize the VNFM register API, Add Serializable annotation for AAI entity. Change-Id: I74d1026b8f6dab06e4a1b36dd342635631c284a9 Issue-ID: AAI-310 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src')
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsDetail.java20
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java13
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java13
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java1
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java45
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java1
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVnfmProvider.java58
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java6
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java24
11 files changed, 168 insertions, 21 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsDetail.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsDetail.java
index c43572a..139c0e2 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsDetail.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsDetail.java
@@ -15,13 +15,21 @@
*/
package org.onap.aai.esr.entity.aai;
+import java.io.Serializable;
-public class EsrEmsDetail {
+import com.google.gson.annotations.SerializedName;
+public class EsrEmsDetail implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("ems-id")
private String emsId;
- private String resouceVersion;
+ @SerializedName("resource-version")
+ private String resourceVersion;
+ @SerializedName("esr-system-info-list")
private EsrSystemInfoList esrSystemInfoList;
public String getEmsId() {
@@ -40,11 +48,11 @@ public class EsrEmsDetail {
this.esrSystemInfoList = esrSystemInfoList;
}
- public String getResouceVersion() {
- return resouceVersion;
+ public String getResourceVersion() {
+ return resourceVersion;
}
- public void setResouceVersion(String resouceVersion) {
- this.resouceVersion = resouceVersion;
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java
index cd173f4..f49d973 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java
@@ -15,16 +15,27 @@
*/
package org.onap.aai.esr.entity.aai;
-public class EsrThirdpartySdncDetail {
+import java.io.Serializable;
+import com.google.gson.annotations.SerializedName;
+
+public class EsrThirdpartySdncDetail implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("thirdparty-sdnc-id")
private String thirdpartySdncId;
+ @SerializedName("location")
private String location;
+ @SerializedName("product-name")
private String productName;
+ @SerializedName("resouce-version")
private String resouceVersion;
+ @SerializedName("esr-system-info-list")
private EsrSystemInfoList esrSystemInfoList;
public String getThirdpartySdncId() {
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java
index ca2fe8f..24f3423 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java
@@ -15,16 +15,27 @@
*/
package org.onap.aai.esr.entity.aai;
-public class EsrVnfmDetail {
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class EsrVnfmDetail implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+ @SerializedName("vnfm-id")
private String vnfmId;
+ @SerializedName("vim-id")
private String vimId;
+ @SerializedName("certificate-id")
private String certificateUrl;
+ @SerializedName("resouce-version")
private String resouceVersion;
+ @SerializedName("esr-system-info-list")
private EsrSystemInfoList esrSystemInfoList;
public String getVnfmId() {
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
index b1a8c31..53e5fef 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
@@ -33,7 +33,6 @@ public class CloudRegionProxy {
config, ICloudRegion.class);
}
-
public static void registerVim(String cloudOwner, String cloudRegionId, CloudRegionDetail cloudRegion)
throws Exception {
ClientConfig config = new ClientConfig(new RegisterVimProvider());
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
new file mode 100644
index 0000000..9550541
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr.externalservice.aai;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+
+public class ExternalSystemProxy {
+
+ private static IExternalSystem adapterServiceproxy;
+
+ private static String transactionId = "9999";
+ private static String fromAppId = "esr-server";
+ private static String authorization = AaiCommon.getAuthenticationCredentials();
+ static {
+ ClientConfig config = new ClientConfig();
+ adapterServiceproxy = ConsumerFactory.createConsumer(AaiAdapterConfig.getExternalSystemAddr(),
+ config, IExternalSystem.class);
+ }
+
+ public static void registerVnfm(String vnfmId, EsrVnfmDetail esrVnfmDetail) throws Exception {
+ ClientConfig config = new ClientConfig(new RegisterVnfmProvider());
+ IExternalSystem registerVnfmServiceproxy = ConsumerFactory
+ .createConsumer(AaiAdapterConfig.getExternalSystemAddr(), config, IExternalSystem.class);
+ registerVnfmServiceproxy.registerVNFM(transactionId, fromAppId, authorization, vnfmId,
+ esrVnfmDetail);
+ }
+
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java
index 13b172a..c38935b 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java
@@ -30,6 +30,7 @@ import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+@Path("/")
public interface IExternalSystem {
@PUT
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java
index a070e18..8f6394d 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
-public class RegisterVimProvider implements MessageBodyWriter<CloudRegionDetail>{
+public class RegisterVimProvider implements MessageBodyWriter<CloudRegionDetail>{
private static final Logger logger = LoggerFactory.getLogger(RegisterVimProvider.class);
@Override
@@ -51,7 +51,7 @@ public class RegisterVimProvider implements MessageBodyWriter<CloudRegionDetail
Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
String json = new Gson().toJson(t, CloudRegionDetail.class);
- logger.info("the param to createNetworkByAdapter input is:" + json);
+ logger.info("the param to register VIM input is:" + json);
entityStream.write(json.getBytes("UTF-8"));
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVnfmProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVnfmProvider.java
new file mode 100644
index 0000000..42ad5f5
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVnfmProvider.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr.externalservice.aai;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+public class RegisterVnfmProvider implements MessageBodyWriter<EsrVnfmDetail>{
+
+ private static final Logger logger = LoggerFactory.getLogger(RegisterVnfmProvider.class);
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType) {
+ return EsrVnfmDetail.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(EsrVnfmDetail t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(EsrVnfmDetail t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ String json = new Gson().toJson(t, EsrVnfmDetail.class);
+ logger.info("the param to register VNFM input is:" + json);
+ entityStream.write(json.getBytes("UTF-8"));
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java
index 2079cb2..f94b118 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java
@@ -23,7 +23,7 @@ import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
public class VnfmManagerUtil {
- public EsrVnfmDetail vnfmRegisterInfo2EsrVnfm(VnfmRegisterInfo vnfmRegisterInfo) {
+ public static EsrVnfmDetail vnfmRegisterInfo2EsrVnfm(VnfmRegisterInfo vnfmRegisterInfo) {
EsrVnfmDetail esrVnfm = new EsrVnfmDetail();
EsrSystemInfoList esrSystemInfo = new EsrSystemInfoList();
EsrSystemInfo authInfo = new EsrSystemInfo();
@@ -41,7 +41,7 @@ public class VnfmManagerUtil {
* @param vnfmRegisterInfo vnfm register informantion from portal
* @return
*/
- private EsrSystemInfo getAuthInfoFromVnfmRegisterInfo(VnfmRegisterInfo vnfmRegisterInfo) {
+ private static EsrSystemInfo getAuthInfoFromVnfmRegisterInfo(VnfmRegisterInfo vnfmRegisterInfo) {
EsrSystemInfo authInfo = new EsrSystemInfo();
authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
authInfo.setSystemName(vnfmRegisterInfo.getName());
@@ -55,7 +55,7 @@ public class VnfmManagerUtil {
return authInfo;
}
- public VnfmRegisterInfo esrVnfm2VnfmRegisterInfo(EsrVnfmDetail esrVnfm) {
+ public static VnfmRegisterInfo esrVnfm2VnfmRegisterInfo(EsrVnfmDetail esrVnfm) {
VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
EsrSystemInfo authInfo = new EsrSystemInfo();
vnfmRegisterInfo.setVnfmId(esrVnfm.getVnfmId());
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
index 260d209..b6e19ff 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
@@ -62,10 +62,11 @@ public class VimManagerWrapper {
result.setCloudRegionId(cloudRegionId);
return Response.ok(result).build();
} catch (Exception e) {
- e.printStackTrace();
+ LOG.error("Register VIM failed !" + e.getMessage());
return Response.serverError().build();
}
}
+
public Response updateVim(VimRegisterInfo vimRegisterInfo) {
LOG.info("Start update VIM, input VIM info is: " + ExtsysUtil.objectToString(vimRegisterInfo));
String cloudOwner = vimRegisterInfo.getCloudOwner();
@@ -83,6 +84,7 @@ public class VimManagerWrapper {
return Response.ok(result).build();
} catch (Exception e) {
e.printStackTrace();
+ LOG.error("Update VIM failed !" + e.getMessage());
return Response.serverError().build();
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
index 755fcf6..7749c26 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
@@ -19,14 +19,17 @@ import java.util.ArrayList;
import javax.ws.rs.core.Response;
+import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
+import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
+import org.onap.aai.esr.util.VnfmManagerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class VnfmManagerWrapper {
private static VnfmManagerWrapper vnfmManagerWrapper;
-// private static final Logger LOG = LoggerFactory.getLogger(VnfmManagerWrapper.class);
+ private static final Logger LOG = LoggerFactory.getLogger(VnfmManagerWrapper.class);
/**
* get VnfmManagerWrapper instance.
@@ -40,9 +43,18 @@ public class VnfmManagerWrapper {
}
public Response registerVnfm(VnfmRegisterInfo vnfm) {
- //TODO
- CommonRegisterResponse result = null;
- return Response.ok(result).build();
+ CommonRegisterResponse result = new CommonRegisterResponse();
+ EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail();
+ esrVnfmDetail = VnfmManagerUtil.vnfmRegisterInfo2EsrVnfm(vnfm);
+ String vnfmId = esrVnfmDetail.getVnfmId();
+ try {
+ ExternalSystemProxy.registerVnfm(vnfmId, esrVnfmDetail);
+ result.setId(vnfmId);
+ return Response.ok(result).build();
+ } catch (Exception e) {
+ LOG.error("Register VNFM failed !" + e.getMessage());
+ return Response.serverError().build();
+ }
}
public Response updateVnfm(VnfmRegisterInfo vnfm, String vnfmId) {