aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramshegokar <AS00500801@techmahindra.com>2018-10-10 16:58:13 +0530
committeramshegokar <AS00500801@techmahindra.com>2018-10-10 16:58:13 +0530
commit8db67259b2b682c403da0cfda8875037e94c60f5 (patch)
tree2d245a3cc95106db7d585c3ff43636a769561b7e
parent135b49e2dcce3b817e174fdcec3f92aec2422f74 (diff)
Readme file and Docker env changes
added readme file and change 1 docker env and also added healthcheck endpoint Change-Id: I7f737c036f44d749d885cdb49fc63710ae0aefc7 Issue-ID: DCAEGEN2-335 Signed-off-by: amshegokar <AS00500801@techmahindra.com>
-rw-r--r--UniversalVesAdapter/.classpath6
-rw-r--r--UniversalVesAdapter/README.md89
-rw-r--r--UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java7
-rw-r--r--UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VESAdapterInitializer.java11
-rw-r--r--UniversalVesAdapter/src/main/resources/application.properties4
-rw-r--r--snmpmapper/Dockerfile20
-rw-r--r--snmpmapper/README.md68
-rw-r--r--snmpmapper/src/main/resources/application.properties4
8 files changed, 169 insertions, 40 deletions
diff --git a/UniversalVesAdapter/.classpath b/UniversalVesAdapter/.classpath
index 3eba719..1301883 100644
--- a/UniversalVesAdapter/.classpath
+++ b/UniversalVesAdapter/.classpath
@@ -32,5 +32,11 @@
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
+ <classpathentry kind="src" output="target/classes" path="src/gen/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/UniversalVesAdapter/README.md b/UniversalVesAdapter/README.md
index e3d30fe..33d41c8 100644
--- a/UniversalVesAdapter/README.md
+++ b/UniversalVesAdapter/README.md
@@ -1,26 +1,101 @@
-# DCAE Universal VES Adapter
+# DCAE VES Adapter (Mapper)
-DCAE Universal VES Adapter is a micro-service consume snmp trap from dmaap topic and reads uploaded mapper file of the specific vendor, using SNMP mapper. After reading mapper file, converts snmp trap (JSON format) to VES format and publish on dmaap topic.
+# Summary
+Different VNF vendors generates event and telemetry data in different formats. Out of the box all VNF vendors may not support ONAP VES format. The aim of this solution is to provide generic adapter(mapper) to VES which can convert different formats of event and telemetry data to VES format which is needed by ONAP. Currently supporting SNMP events JSON to VES
+
+This release supports only SNMP format. DCAE existing SNMP traps receiver are pushing SNMP traps (converted to json format) to DMaaP. DCAE Universal VES Adapter (mapper) micro-service consumes snmp trap from dmaap topic and reads uploaded mapper file (for the specific vendor). After reading mapper file, converts snmp trap (JSON format) to VES format and publish on dmaap topic.
+
+ONAP DCAE VES Adapter (Mapper) is delivered with **2 Docker container** having spring boot mocroservices, UniversalVesAdapter and snmpmapper. UniversalVesAdapter converts SNMP trap JSON to VES and snmpmapper is just helper application for uploading the mapping file to DB.
+### Build Instructions
+
+This project is organized as a mvn project and has "org.onap.dcaegen2" as parent project. The build generate a jar and package into docker container.
+
+```
+git clone https://gerrit.onap.org/r/p/dcaegen2/services/mapper.git
+mvn clean install
+```
### Build Docker image
-The following Maven command will build the mapper JAR, build the Docker image to the local machine registry and then push the same image to the specified remote registry.
+The following Maven command will build the JAR, build the Docker image to the local machine registry and then push the same image to the specified remote registry.
```
mvn clean package docker:build -DpushImageTag
```
-The image will be tagged with the project version found in the `pom.xml`.
### Run via Docker
Execute this to run.
+####UniversalVesAdapter
+
```
-docker run -p 8082:8080 <image_name>
+ sudo docker run -d -p 8085:8085/tcp -e URL_JDBC=jdbc:postgresql://10.53.172.138:5432/postgres -e JDBC_USERNAME=postgres -e JDBC_PASSWORD=root -e DMAAPHOST=10.53.172.156 -e CONSUL_HOST=10.53.172.109 -e HOSTNAME=static-dcaegen2-services-mua -e MR_DEFAULT_PORT_NUMBER=3904 -e CONFIG_BINDING_SERVICE=config_binding_service nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor:latest
+```
+
+### Environment variables in Docker Container
+Most of the configuration of how UniversalVesAdapter should be started and managed is done through environment variables.
+Some of them are set during the image build process and some of them are defined manually or by
+a particular deployment system.
+
+Variables set manually / coming from deployment system:
+- DMAAPHOST-should contain an address to DMaaP, so that event publishing can work
+- MR_PORT - DMaaP Exposed Port
+- URL_JDBC- JDBC URL
+- JDBC_USERNAME- Username for DB user
+- JDBC_PASSWORD-Password for DB user
+- CONSUL_HOST -
+- CONFIG_BINDING_SERVICE -
+- HOSTNAME -
+
+
+### Docker file system layout
+The main directory where all code resides in docker container
+looks like this and is located in /opt/app/VESAdapter
+```
+<host>:/opt/app/VESAdapter# ls
+Dockerfile bin conf lib logs
```
+- bin contains startup script for running the application
+- conf contains default mapping file inserted to DB (defaultSnmpMappingFile.xml)
+- lib contains all libraries that are pulled into the app during maven build
+- logs contains application logs, DroppedEvents.log file contains invalid events which are drop during publishing events.
+
+
+## How the application starts inside container
+General flow goes like this
+- Docker image is build, and it points run.sh as the entrypoint.
+- run.sh calls the spring boot starter class which in turns calls VESAdapterInitializer
+- Here entry point will be depending on the deployment type, Getting configuration from docker env var or from CBS
+ configures a bunch of things and starts the application in a separate process
+
+### Release images
+For R1 - image/version pushed to nexus3
+
+```
+nexus3.onap.org:10003/snapshots/onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor latest
+```
+
+
+### Deployment
+For testing purpose, the docker image includes preset configuration which can be ran without DCAEGEN2 platform.
+
+
+### Testing
+
- ### Access
- <host>:<expose port>/start \ No newline at end of file
+```
+STEPS FOR SETUP/TEST
+1) Get the VESAdapter image from Nexus
+ docker pull nexus3.onap.org:10003/snapshots/onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor:latest
+2) Start the container (change the DMAAPHOST and MR_DEFAULT_PORT_NUMBER environment value to running DMAAP instance host as well DB Details as mention in Running locally part)
+
+ sudo docker run -d -p 8085:8085/tcp -e URL_JDBC=jdbc:postgresql://10.53.172.138:5432/postgres -e JDBC_USERNAME=postgres -e JDBC_PASSWORD=root -e DMAAPHOST=10.53.172.156 -e CONSUL_HOST=10.53.172.109 -e HOSTNAME=static-dcaegen2-services-mua -e MR_DEFAULT_PORT_NUMBER=3904 -e CONFIG_BINDING_SERVICE=config_binding_service nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor:latest
+
+3) Go inside container and tail /opt/app/VESCollector/logs/vesadaper.log
+4) Post SNMP event JSON to DMaaP Topic ONAP-COLLECTOR-SNMPTRAP
+5) Subscribe to DMaaP topic unauthenticated.SEC_FAULT_OUTPUT you will get process VES JSON to this topic.
+```
diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java
index dfddfde..be49587 100644
--- a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java
+++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java
@@ -70,7 +70,12 @@ public class VesController {
LOGGER.debug("Reload of Mapping File is completed");
}
-
+ @RequestMapping("/healthcheck")
+ public String healthcheck() {
+
+ LOGGER.debug("UniversalVesAdapter Application is up & running...");
+ return "UniversalVesAdapter Application is up & running...";
+ }
/**
* @return message that application stop process is triggered
diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VESAdapterInitializer.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VESAdapterInitializer.java
index 424d40e..82cee66 100644
--- a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VESAdapterInitializer.java
+++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VESAdapterInitializer.java
@@ -42,7 +42,6 @@ import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
-import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
//AdapterInitializer
@@ -68,9 +67,6 @@ public class VESAdapterInitializer implements CommandLineRunner, Ordered {
String defaultEnterpriseId;
@Value("${server.port}")
String serverPort;
- @Autowired
- private JdbcTemplate jdbcTemplate;
-
private static Map<String, String> mappingFiles = new HashMap<String, String>();
private static Map<String, String> env;
@@ -93,12 +89,11 @@ public class VESAdapterInitializer implements CommandLineRunner, Ordered {
LOGGER.info(">>>Dynamic configuration to be used");
- if( (env.get("MR_DMAAPHOST")==null ||
- (env.get("MR_DMAAPHOST")==null ||
+ if( (env.get("DMAAPHOST")==null ||
(env.get("MR_DEFAULT_PORT_NUMBER")==null ||
(env.get("URL_JDBC")==null ||
(env.get("JDBC_USERNAME")==null ||
- (env.get("JDBC_PASSWORD")==null ))))))) {
+ (env.get("JDBC_PASSWORD")==null )))))) {
LOGGER.error("Some docker environment parameter is missing. Sample Usage is -\n sudo docker run -d -p 8085:8085/tcp --env URL_JDBC=jdbc:postgresql://10.53.172.129:5432/dummy --env JDBC_USERNAME=ngpuser --env JDBC_PASSWORD=root --env MR_DMAAPHOST=10.10.10.10 --env MR_DEFAULT_PORT_NUMBER=3904 --env CONSUL_HOST=10.53.172.109 --env HOSTNAME=mvp-dcaegen2-collectors-ves --env CONFIG_BINDING_SERVICE=config_binding_service -e DMAAPHOST='10.53.172.156' onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor:latest");
@@ -108,7 +103,7 @@ public class VESAdapterInitializer implements CommandLineRunner, Ordered {
- dmaapConfig.setDmaaphost(env.get("MR_DMAAPHOST"));
+ dmaapConfig.setDmaaphost(env.get("DMAAPHOST"));
dmaapConfig.setDEFAULT_PORT_NUMBER(Integer.parseInt(env.get("MR_DEFAULT_PORT_NUMBER")));
creator.setDmaapConfig(dmaapConfig);
diff --git a/UniversalVesAdapter/src/main/resources/application.properties b/UniversalVesAdapter/src/main/resources/application.properties
index abbfab7..8d83595 100644
--- a/UniversalVesAdapter/src/main/resources/application.properties
+++ b/UniversalVesAdapter/src/main/resources/application.properties
@@ -3,8 +3,8 @@ logging.level.org.springframework.web=ERROR
dmaap.mr_props=DMaapMR.properties
#Lab Details
-spring.datasource.url=jdbc:postgresql://10.53.172.129:5432/dummy
-spring.datasource.username=ngpuser
+spring.datasource.url=jdbc:postgresql://10.53.172.138:5432/postgres
+spring.datasource.username=postgres
spring.datasource.password=root
#MappingFileDetails
diff --git a/snmpmapper/Dockerfile b/snmpmapper/Dockerfile
deleted file mode 100644
index 9483baf..0000000
--- a/snmpmapper/Dockerfile
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM ubuntu:16.04
-
-WORKDIR /opt/app/SnmpMapper
-
-ENV HOME /opt/app/SnmpMapper
-
-ENV JAVA_HOME /usr
-
-RUN apt-get update && apt-get install -y \
- curl \
- vim \
- openjdk-8-jdk
-
-
-COPY snmpmapper.jar /opt/snmpmapper.jar
-
-RUN bash -c 'touch /opt/snmpmapper.jar'
-
-ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/opt/snmpmapper.jar"]
-
diff --git a/snmpmapper/README.md b/snmpmapper/README.md
new file mode 100644
index 0000000..f5ab564
--- /dev/null
+++ b/snmpmapper/README.md
@@ -0,0 +1,68 @@
+# SNMP Mapper
+
+# Summary
+snmpmapper is just helper application for uploading the mapping file to DB. Here simple web page is given to upload file in DB
+
+### Build Instructions
+
+This project is organized as a mvn project and has "org.onap.dcaegen2" as parent project. The build generate a jar and package into docker container.
+
+```
+git clone https://gerrit.onap.org/r/p/dcaegen2/services/mapper.git
+mvn clean install
+```
+
+### Build Docker image
+
+The following Maven command will build the JAR, build the Docker image to the local machine registry and then push the same image to the specified remote registry.
+
+```
+mvn clean package docker:build -DpushImageTag
+```
+
+
+### Run via Docker
+
+Execute this to run.
+
+####snmpmapper
+
+```
+ sudo docker run -d -p 8084:8080/tcp -e URL_JDBC=jdbc:postgresql://10.53.172.138:5432/postgres -e JDBC_USERNAME=postgres -e JDBC_PASSWORD=root -e DMAAPHOST=10.53.172.156 -e CONSUL_HOST=10.53.172.109 -e HOSTNAME=static-dcaegen2-services-msnmp -e MR_DEFAULT_PORT_NUMBER=3904 -e CONFIG_BINDING_SERVICE=config_binding_service nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.mapper.snmpmapper:latest
+```
+
+### Environment variables in Docker Container
+Most of the configuration of how UniversalVesAdapter should be started and managed is done through environment variables.
+Some of them are set during the image build process and some of them are defined manually or by
+a particular deployment system.
+
+Variables set manually / coming from deployment system:
+- DMAAPHOST-should contain an address to DMaaP, so that event publishing can work
+- MR_PORT - DMaaP Exposed Port
+- URL_JDBC- JDBC URL
+- JDBC_USERNAME- Username for DB user
+- JDBC_PASSWORD-Password for DB user
+- CONSUL_HOST -
+- CBS_PROTOCOL - Config Binding Service protocol by default set to **http**, if it is need to change it then that can be set to different value
+- CONFIG_BINDING_SERVICE -
+- HOSTNAME -
+
+
+
+### Docker file system layout
+The main directory where all code resides in docker container
+looks like this and is located in /opt/app/VESAdapter
+```
+<host>:/opt/app/SnmpMapper# ls
+Dockerfile bin lib logs
+```
+- bin contains startup script for running the application
+- lib contains all libraries that are pulled into the app during maven build
+- logs contains application logs
+
+
+### Release images
+For R1 - image/version pushed to nexus3
+
+```nexus3.onap.org:10003/snapshots/onap/org.onap.dcaegen2.services.mapper.vesadapter.snmpmapper:latest
+```
diff --git a/snmpmapper/src/main/resources/application.properties b/snmpmapper/src/main/resources/application.properties
index c9d1255..fb923aa 100644
--- a/snmpmapper/src/main/resources/application.properties
+++ b/snmpmapper/src/main/resources/application.properties
@@ -3,8 +3,8 @@ server.port=8080
#spring.datasource.username=postgres
#spring.datasource.password=root
-spring.datasource.url=jdbc:postgresql://10.53.172.129:5432/dummy
-spring.datasource.username=ngpuser
+spring.datasource.url=jdbc:postgresql://10.53.172.138:5432/postgres
+spring.datasource.username=postgres
spring.datasource.password=root
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true