summaryrefslogtreecommitdiffstats
path: root/esr-mgr/src/main/java/org/onap/aai/esr
diff options
context:
space:
mode:
Diffstat (limited to 'esr-mgr/src/main/java/org/onap/aai/esr')
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java5
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java61
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java69
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java37
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java100
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java44
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java36
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java54
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java142
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java68
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java175
13 files changed, 793 insertions, 2 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
index 290df15..b45692f 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
@@ -24,6 +24,7 @@ import org.onap.aai.esr.resource.ServiceTest;
import org.onap.aai.esr.resource.ThirdpartySdncManager;
import org.onap.aai.esr.resource.VimManager;
import org.onap.aai.esr.resource.VnfmManager;
+import org.onap.aai.esr.resource.NfvoManager;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,6 +59,7 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> {
environment.jersey().register(new ThirdpartySdncManager());
environment.jersey().register(new VimManager());
environment.jersey().register(new VnfmManager());
+ environment.jersey().register(new NfvoManager());
environment.jersey().register(new PnfManager());
environment.jersey().register(new ServiceTest());
initSwaggerConfig(environment, configuration);
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java b/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
index a9858e3..4b48c12 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
@@ -47,6 +47,11 @@ public class MsbConfig {
return msbServerAddr + "/api/aai-externalSystem/v11";
}
+ public static String getExternalSystemAddrV16() {
+ return msbServerAddr + "/api/aai-externalSystem/v16";
+ }
+
+
public static void setExternalSystemAddr(String Addr) {
externalSystemAddr = Addr;
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java b/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java
index c637c5e..dda54fe 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java
@@ -17,5 +17,5 @@
package org.onap.aai.esr.common;
public enum SystemType {
- VNFM, EMS_RESOUCE, EMS_PERFORMANCE, EMS_ALARM, thirdparty_SDNC, VIM
+ VNFM, EMS_RESOUCE, EMS_PERFORMANCE, EMS_ALARM, thirdparty_SDNC, VIM, NFVO
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java
new file mode 100644
index 0000000..6632db6
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import java.io.Serializable;
+import com.google.gson.annotations.SerializedName;
+
+public class EsrNfvo implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("nfvo-id")
+ private String nfvoId;
+
+ @SerializedName("resource-version")
+ private String resourceVersion;
+
+ @SerializedName("api-root")
+ private String apiroot;
+
+ public String getNfvoId() {
+ return nfvoId;
+ }
+
+ public void setNfvoId(String nfvoId) {
+ this.nfvoId = nfvoId;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getApiroot() {
+ return apiroot;
+ }
+
+ public void setApiroot(String apiroot) {
+ this.apiroot = apiroot;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java
new file mode 100644
index 0000000..89528ff
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import java.io.Serializable;
+import com.google.gson.annotations.SerializedName;
+
+public class EsrNfvoDetail implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("nfvo-id")
+ private String nfvoId;
+
+ @SerializedName("resource-version")
+ private String resourceVersion;
+
+ @SerializedName("api-root")
+ private String apiroot;
+
+ @SerializedName("esr-system-info-list")
+ private EsrSystemInfoList esrSystemInfoList;
+
+ public String getNfvoId() {
+ return nfvoId;
+ }
+
+ public void setNfvoId(String nfvoId) {
+ this.nfvoId = nfvoId;
+ }
+
+ public void setApiroot(String apiroot) {
+ this.apiroot = apiroot;
+ }
+
+ public EsrSystemInfoList getEsrSystemInfoList() {
+ return esrSystemInfoList;
+ }
+
+ public void setEsrSystemInfoList(EsrSystemInfoList esrSystemInfoList) {
+ this.esrSystemInfoList = esrSystemInfoList;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public String getApiroot() {
+ return apiroot;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java
new file mode 100644
index 0000000..af3cad3
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import java.io.Serializable;
+import java.util.List;
+import com.google.gson.annotations.SerializedName;
+
+public class EsrNfvoList implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("esr-nfvo")
+ private List<EsrNfvo> esrNfvo;
+
+ public List<EsrNfvo> getEsrNfvo() {
+ return esrNfvo;
+ }
+
+ public void setEsrNfvo(List<EsrNfvo> esrNfvo) {
+ this.esrNfvo = esrNfvo;
+ }
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java
new file mode 100644
index 0000000..575cf20
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.rest;
+
+public class NfvoRegisterInfo {
+
+ private String nfvoId;
+
+ private String name;
+
+ private String apiroot;
+
+ private String vendor;
+
+ private String version;
+
+ private String url;
+
+ private String userName;
+
+ private String password;
+
+ public String getNfvoId() {
+ return nfvoId;
+ }
+
+ public void setNfvoId(String nfvoId) {
+ this.nfvoId = nfvoId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getApiroot() {
+ return apiroot;
+ }
+
+ public void setApiroot(String apiroot) {
+ this.apiroot = apiroot;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(String vendor) {
+ this.vendor = vendor;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
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
index bd8c77d..e5b49d6 100644
--- 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
@@ -20,12 +20,13 @@ import org.onap.aai.esr.common.MsbConfig;
import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
import org.onap.aai.esr.exception.ExtsysException;
import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
public class ExternalSystemProxy {
- private static IExternalSystem externalSystem;
+ private static IExternalSystem externalSystem, externalSystemV16;
private static String transactionId = "9999";
private static String fromAppId = "esr-server";
private static String authorization = AaiCommon.getAuthenticationCredentials();
@@ -33,6 +34,8 @@ public class ExternalSystemProxy {
ClientConfig config = new ClientConfig();
externalSystem =
ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
+ externalSystemV16 =
+ ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddrV16(), config, IExternalSystem.class);
}
public void registerVnfm(String vnfmId, EsrVnfmDetail esrVnfmDetail) throws ExtsysException {
@@ -70,6 +73,45 @@ public class ExternalSystemProxy {
}
}
+ public void registerNfvo(String nfvoId, EsrNfvoDetail esrNfvoDetail) throws ExtsysException {
+ ClientConfig config = new ClientConfig(new NfvoRegisterProvider());
+ IExternalSystem registerNfvoServiceproxy =
+ ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddrV16(), config, IExternalSystem.class);
+ try {
+ registerNfvoServiceproxy.registerNFVO(transactionId, fromAppId, authorization, nfvoId, esrNfvoDetail);
+ } catch (Exception e) {
+ throw new ExtsysException("PUT NFVO to A&AI failed.", e);
+ }
+ }
+
+ public String queryNfvoDetail(String nfvoId) throws ExtsysException {
+ try {
+ return externalSystemV16.queryNFVODetail(transactionId, fromAppId, authorization, nfvoId);
+ } catch (Exception e) {
+ throw new ExtsysException("Query NFVO detail from A&AI failed.", e);
+ }
+ }
+
+ public String queryNfvoList() throws ExtsysException {
+ try {
+ return externalSystemV16.queryNFVOList(transactionId, fromAppId, authorization);
+ } catch (Exception e) {
+ throw new ExtsysException("Query NFVO list from A&AI failed.", e);
+ }
+ }
+
+ public void deleteNfvo(String nfvoId, String resourceVersion) throws ExtsysException {
+ try {
+ externalSystemV16.deleteNFVO(transactionId, fromAppId, authorization, nfvoId, resourceVersion);
+ } catch (Exception e) {
+ throw new ExtsysException("Delete NFVO from A&AI failed.", e);
+ }
+ }
+
+
+
+
+
public void registerSdnc(String thirdpartySdncId, EsrThirdpartySdncDetail esrSdncDetail) throws ExtsysException {
ClientConfig config = new ClientConfig(new ThirdpartySdncRegisterProvider());
IExternalSystem registerSdncServiceproxy =
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 c066654..7e1a425 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
@@ -28,6 +28,7 @@ import javax.ws.rs.core.MediaType;
import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
import org.onap.aai.esr.exception.ExtsysException;
@Path("/")
@@ -67,6 +68,41 @@ public interface IExternalSystem {
throws ExtsysException;
@PUT
+ @Path("/esr-nfvo-list/esr-nfvo/{nfvo_id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public void registerNFVO(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization,
+ @PathParam("nfvo_id") String nfvoId, EsrNfvoDetail esrNfvoDetail) throws ExtsysException;
+
+ @GET
+ @Path("/esr-nfvo-list/esr-nfvo/{nfvo_id}?depth=all")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public String queryNFVODetail(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization,
+ @PathParam("nfvo_id") String nfvoId) throws ExtsysException;
+
+ @GET
+ @Path("/esr-nfvo-list")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public String queryNFVOList(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization)
+ throws ExtsysException;
+
+ @DELETE
+ @Path("/esr-nfvo-list/esr-nfvo/{nfvo_id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public void deleteNFVO(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization,
+ @PathParam("nfvo_id") String nfvoId, @QueryParam("resource-version") String resourceVersion)
+ throws ExtsysException;
+
+
+
+ @PUT
@Path("/esr-ems-list/esr-ems/{ems_id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java
new file mode 100644
index 0000000..119c8f4
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.EsrNfvoDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.gson.Gson;
+
+public class NfvoRegisterProvider implements MessageBodyWriter<EsrNfvoDetail> {
+
+ private static final Logger logger = LoggerFactory.getLogger(NfvoRegisterProvider.class);
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return EsrNfvoDetail.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(EsrNfvoDetail t, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(EsrNfvoDetail t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
+ throws IOException, WebApplicationException {
+ String json = new Gson().toJson(t, EsrNfvoDetail.class);
+ logger.info("the param to register NFVO input is:" + json);
+ entityStream.write(json.getBytes("UTF-8"));
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java
new file mode 100644
index 0000000..412cbf0
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java
@@ -0,0 +1,142 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.resource;
+
+import com.codahale.metrics.annotation.Timed;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
+import org.onap.aai.esr.util.ExtsysUtil;
+import org.onap.aai.esr.wrapper.NfvoManagerWrapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("/nfvos")
+@Api(tags = {" nfvo Management "})
+public class NfvoManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NfvoManager.class);
+
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
+
+ /**
+ * query all nfvo.
+ */
+ @GET
+ @ApiOperation(value = "get all nfvo ")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response queryNfvoList() {
+ LOGGER.info("start query all nfvo!");
+ return NfvoManagerWrapper.getInstance().queryNfvoList();
+ }
+
+ /**
+ * query nfvo by id.
+ */
+ @Path("/{nfvoId}")
+ @GET
+ @ApiOperation(value = "get nfvo by id")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response queryNfvoById(@ApiParam(value = "nfvo id") @PathParam("nfvoId") String nfvoId) {
+ LOGGER.info("start query nfvo by id." + nfvoId);
+ return NfvoManagerWrapper.getInstance().queryNfvoById(nfvoId);
+ }
+
+ /**
+ * delete nfvo by id.
+ */
+ @Path("/{nfvoId}")
+ @DELETE
+ @ApiOperation(value = "delete a nfvo")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response delNfvo(@ApiParam(value = "nfvo id") @PathParam("nfvoId") String nfvoId) {
+ LOGGER.info("start delete nfvo .id:" + nfvoId);
+ return NfvoManagerWrapper.getInstance().delNfvo(nfvoId);
+ }
+
+ /**
+ * update nfvo by id.
+ */
+ @PUT
+ @Path("/{nfvoId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "update a nfvo")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response updateNfvo(@ApiParam(value = "nfvo", required = true) NfvoRegisterInfo nfvo,
+ @ApiParam(value = "nfvo id", required = true) @PathParam("nfvoId") String nfvoId) {
+ LOGGER.info("start update nfvo .id:" + nfvoId + " info:" + extsysUtil.objectToString(nfvo));
+ return NfvoManagerWrapper.getInstance().updateNfvo(nfvo, nfvoId);
+ }
+
+ /**
+ * add nfvo .
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "create a nfvo")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response registerNfvo(@ApiParam(value = "nfvo", required = true) NfvoRegisterInfo nfvo) {
+ return NfvoManagerWrapper.getInstance().registerNfvo(nfvo);
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java
new file mode 100644
index 0000000..2768201
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.util;
+
+import org.onap.aai.esr.common.SystemType;
+import org.onap.aai.esr.entity.aai.EsrSystemInfo;
+import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
+import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
+
+public class NfvoManagerUtil {
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
+
+ public EsrNfvoDetail nfvoRegisterInfo2EsrNfvo(NfvoRegisterInfo nfvoRegisterInfo) {
+ EsrNfvoDetail esrNfvo = new EsrNfvoDetail();
+ esrNfvo.setNfvoId(extsysUtil.generateId());
+ esrNfvo.setApiroot(nfvoRegisterInfo.getApiroot());
+ EsrSystemInfo authInfo = getAuthInfoFromNfvoRegisterInfo(nfvoRegisterInfo);
+ EsrSystemInfoList esrSystemInfo = extsysUtil.getEsrSystemInfoListFromAuthInfo(authInfo);
+ esrNfvo.setEsrSystemInfoList(esrSystemInfo);
+ return esrNfvo;
+ }
+
+ /**
+ * @param nfvoRegisterInfo nfvo register informantion from portal
+ * @return
+ */
+ private EsrSystemInfo getAuthInfoFromNfvoRegisterInfo(NfvoRegisterInfo nfvoRegisterInfo) {
+ EsrSystemInfo authInfo = new EsrSystemInfo();
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
+ authInfo.setSystemName(nfvoRegisterInfo.getName());
+ authInfo.setVendor(nfvoRegisterInfo.getVendor());
+ authInfo.setVersion(nfvoRegisterInfo.getVersion());
+ authInfo.setServiceUrl(nfvoRegisterInfo.getUrl());
+ authInfo.setUserName(nfvoRegisterInfo.getUserName());
+ authInfo.setPassword(nfvoRegisterInfo.getPassword());
+ authInfo.setSystemType(SystemType.NFVO.toString());
+ return authInfo;
+ }
+
+ public NfvoRegisterInfo esrNfvo2NfvoRegisterInfo(EsrNfvoDetail esrNfvo) {
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setNfvoId(esrNfvo.getNfvoId());
+ nfvoRegisterInfo.setApiroot(esrNfvo.getApiroot());
+ EsrSystemInfo authInfo = esrNfvo.getEsrSystemInfoList().getEsrSystemInfo().get(0);
+ nfvoRegisterInfo.setName(authInfo.getSystemName());
+ nfvoRegisterInfo.setPassword(authInfo.getPassword());
+ nfvoRegisterInfo.setUrl(authInfo.getServiceUrl());
+ nfvoRegisterInfo.setUserName(authInfo.getUserName());
+ nfvoRegisterInfo.setVendor(authInfo.getVendor());
+ nfvoRegisterInfo.setVersion(authInfo.getVersion());
+ return nfvoRegisterInfo;
+ }
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java
new file mode 100644
index 0000000..f546320
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java
@@ -0,0 +1,175 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.wrapper;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.onap.aai.esr.entity.aai.EsrSystemInfo;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoList;
+import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
+import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
+import org.onap.aai.esr.exception.ExceptionUtil;
+import org.onap.aai.esr.exception.ExtsysException;
+import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
+import org.onap.aai.esr.util.NfvoManagerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.gson.Gson;
+
+public class NfvoManagerWrapper {
+ private static NfvoManagerWrapper NfvoManagerWrapper;
+ private static final Logger LOG = LoggerFactory.getLogger(NfvoManagerWrapper.class);
+
+ private static NfvoManagerUtil nfvoManagerUtil = new NfvoManagerUtil();
+ private static ExternalSystemProxy externalSystemProxy = new ExternalSystemProxy();
+
+ /**
+ * get NfvoManagerWrapper instance.
+ *
+ * @return nfvo manager wrapper instance
+ */
+ public static NfvoManagerWrapper getInstance() {
+ if (NfvoManagerWrapper == null) {
+ NfvoManagerWrapper = new NfvoManagerWrapper(externalSystemProxy);
+ }
+ return NfvoManagerWrapper;
+ }
+
+ public NfvoManagerWrapper(ExternalSystemProxy externalSystemProxy){
+ NfvoManagerWrapper.externalSystemProxy = externalSystemProxy;
+ }
+
+ public Response registerNfvo(NfvoRegisterInfo nfvo) {
+ CommonRegisterResponse result = new CommonRegisterResponse();
+ EsrNfvoDetail esrNfvoDetail = nfvoManagerUtil.nfvoRegisterInfo2EsrNfvo(nfvo);
+ String nfvoId = esrNfvoDetail.getNfvoId();
+ try {
+ externalSystemProxy.registerNfvo(nfvoId, esrNfvoDetail);
+ result.setId(nfvoId);
+ return Response.ok(result).build();
+ } catch (ExtsysException e) {
+ LOG.error("Register NFVO failed !", e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ }
+
+ public Response updateNfvo(NfvoRegisterInfo nfvo, String nfvoId) {
+ CommonRegisterResponse result = new CommonRegisterResponse();
+ EsrNfvoDetail originalEsrNfvoDetail = queryEsrNfvoDetail(nfvoId);
+ EsrNfvoDetail esrNfvoDetail = nfvoManagerUtil.nfvoRegisterInfo2EsrNfvo(nfvo);
+ String resourceVersion = getResourceVersion(nfvoId);
+ esrNfvoDetail.setResourceVersion(resourceVersion);
+ esrNfvoDetail.setNfvoId(nfvoId);
+ EsrSystemInfo originalEsrSystemInfo = originalEsrNfvoDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0);
+ esrNfvoDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0)
+ .setEsrSystemInfoId(originalEsrSystemInfo.getEsrSystemInfoId());
+ esrNfvoDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0)
+ .setResouceVersion(originalEsrSystemInfo.getResouceVersion());
+ try {
+ externalSystemProxy.registerNfvo(nfvoId, esrNfvoDetail);
+ result.setId(nfvoId);
+ return Response.ok(result).build();
+ } catch (ExtsysException e) {
+ LOG.error("Update NFVO failed !", e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ }
+
+ public Response queryNfvoList() {
+ List<NfvoRegisterInfo> nfvoList = new ArrayList<>();
+ EsrNfvoList esrNfvo = new EsrNfvoList();
+ try {
+ String esrNfvoStr = externalSystemProxy.queryNfvoList();
+ esrNfvo = new Gson().fromJson(esrNfvoStr, EsrNfvoList.class);
+ LOG.info("Response from AAI by query NFVO list: " + esrNfvo);
+ nfvoList = getNfvoDetailList(esrNfvo);
+ return Response.ok(nfvoList).build();
+ } catch (ExtsysException e) {
+ LOG.error("Query NFVO list failed !", e);
+ return Response.ok(nfvoList).build();
+ }
+ }
+
+ public Response queryNfvoById(String nfvoId) {
+ NfvoRegisterInfo nfvo = queryNfvoDetail(nfvoId);
+ if (nfvo != null) {
+ return Response.ok(nfvo).build();
+ } else {
+ return Response.ok(nfvo).build();
+ }
+ }
+
+ public Response delNfvo(String nfvoId) {
+ String resourceVersion = getResourceVersion(nfvoId);
+ try {
+ externalSystemProxy.deleteNfvo(nfvoId, resourceVersion);
+ return Response.noContent().build();
+ } catch (ExtsysException e) {
+ LOG.error("Delete NFVO from A&AI failed! NFVO ID: " + nfvoId + "resouce-version:" + resourceVersion, e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ }
+
+ private NfvoRegisterInfo queryNfvoDetail(String nfvoId) {
+ NfvoRegisterInfo nfvo = new NfvoRegisterInfo();
+ EsrNfvoDetail esrNfvoDetail = new EsrNfvoDetail();
+ try {
+ String esrNfvostr = externalSystemProxy.queryNfvoDetail(nfvoId);
+ LOG.info("Response from AAI by query NFVO: " + esrNfvostr);
+ esrNfvoDetail = new Gson().fromJson(esrNfvostr, EsrNfvoDetail.class);
+ nfvo = nfvoManagerUtil.esrNfvo2NfvoRegisterInfo(esrNfvoDetail);
+ } catch (ExtsysException e) {
+ LOG.error("Query NFVO detail failed! NFVO ID: " + nfvoId, e);
+ }
+ return nfvo;
+ }
+
+ private List<NfvoRegisterInfo> getNfvoDetailList(EsrNfvoList esrNfvo) {
+ List<NfvoRegisterInfo> nfvoInfoList = new ArrayList<>();
+ for (int i = 0; i < esrNfvo.getEsrNfvo().size(); i++) {
+ String nfvoId = esrNfvo.getEsrNfvo().get(i).getNfvoId();
+ NfvoRegisterInfo nfvoInfo = queryNfvoDetail(nfvoId);
+ if (nfvoInfo != null) {
+ nfvoInfoList.add(nfvoInfo);
+ }
+ }
+ return nfvoInfoList;
+ }
+
+ private String getResourceVersion(String nfvoId) {
+ String resourceVersion = null;
+ EsrNfvoDetail esrNfvoDetail = queryEsrNfvoDetail(nfvoId);
+ if (esrNfvoDetail != null && esrNfvoDetail.getResourceVersion() != null) {
+ resourceVersion = esrNfvoDetail.getResourceVersion();
+ }
+ return resourceVersion;
+ }
+
+ private EsrNfvoDetail queryEsrNfvoDetail(String nfvoId) {
+ EsrNfvoDetail esrNfvoDetail = new EsrNfvoDetail();
+ try {
+ String esrNfvostr = externalSystemProxy.queryNfvoDetail(nfvoId);
+ LOG.info("Response from AAI by query NFVO: " + esrNfvostr);
+ esrNfvoDetail = new Gson().fromJson(esrNfvostr, EsrNfvoDetail.class);
+ } catch (ExtsysException e) {
+ LOG.error("Query NFVO detail failed! NFVO ID: " + nfvoId, e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ return esrNfvoDetail;
+ }
+}