[SDNC-5] Split listeners 13/3613/3
authorDan Timoney <dtimoney@att.com>
Fri, 21 Apr 2017 21:36:30 +0000 (17:36 -0400)
committerDan Timoney <dtimoney@att.com>
Mon, 24 Apr 2017 16:19:33 +0000 (12:19 -0400)
Split dmaap-listener and ueb-listener to separate artifacts

Change-Id: I7b1d5b15c8ef850ace75d4da451143ba4062b817
Signed-off-by: Dan Timoney <dtimoney@att.com>
63 files changed:
.gitreview
asdcApi/installer/pom.xml
asdcApi/installer/src/assembly/assemble_installer_zip.xml
asdcApi/installer/src/assembly/assemble_mvnrepo_zip.xml
dataChange/installer/pom.xml
dataChange/installer/src/assembly/assemble_installer_zip.xml
dataChange/installer/src/assembly/assemble_mvnrepo_zip.xml
dmaap-listener/.gitignore [new file with mode: 0755]
dmaap-listener/.sonar/checkstyle.xml [new file with mode: 0755]
dmaap-listener/.sonar/pmd.xml [new file with mode: 0755]
dmaap-listener/pom.xml [new file with mode: 0755]
dmaap-listener/src/assembly/assemble_zip.xml [new file with mode: 0644]
dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DmaapListener.java [new file with mode: 0644]
dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DummyDmaapConsumer.java [new file with mode: 0644]
dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/InvalidMessageException.java [new file with mode: 0644]
dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncDmaapConsumer.java [new file with mode: 0644]
dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncFlatJsonDmaapConsumer.java [new file with mode: 0644]
dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncOdlConnection.java [new file with mode: 0644]
dmaap-listener/src/main/resources/edgeRouterStatusChange.map [new file with mode: 0644]
dmaap-listener/src/main/resources/log4j.properties [new file with mode: 0644]
dmaap-listener/src/main/resources/preferredRoute.txt [new file with mode: 0644]
dmaap-listener/src/main/scripts/start-dmaap-listener.sh [new file with mode: 0644]
dmaap-listener/src/main/scripts/stop-dmaap-listener.sh [new file with mode: 0644]
dmaap-listener/src/site/apt/index.apt [new file with mode: 0644]
dmaap-listener/src/site/site.xml [new file with mode: 0644]
pom.xml
ueb-listener/pom.xml
ueb-listener/src/assembly/assemble_zip.xml
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncARModel.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncArtifactMap.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncBaseModel.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncNodeModel.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncOdlConnection.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncServiceModel.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncUebCallback.java
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncUebClient.java
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncUebConfiguration.java
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFCModel.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFModel.java [new file with mode: 0644]
ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFModuleModel.java [new file with mode: 0644]
ueb-listener/src/main/resources/log4j.properties
ueb-listener/src/main/scripts/start-ueb-listener.sh [new file with mode: 0644]
ueb-listener/src/main/scripts/stop-ueb-listener.sh [new file with mode: 0644]
ueb-listener/src/site/apt/index.apt
ueb-listener/src/site/site.xml
vnfapi/features/src/main/resources/features.xml
vnfapi/installer/pom.xml
vnfapi/installer/src/assembly/assemble_installer_zip.xml
vnfapi/installer/src/assembly/assemble_mvnrepo_zip.xml
vnfapi/installer/src/main/resources/scripts/install-feature.sh
vnfapi/model/src/main/yang/VNF-API.yang
vnfapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/vnfapi/provider/impl/rev140523/VnfapiProviderModule.java
vnfapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/vnfapi/provider/impl/rev140523/VnfapiProviderModuleFactory.java
vnfapi/provider/src/main/java/org/openecomp/sdnc/vnfapi/VNFSDNSvcLogicServiceClient.java
vnfapi/provider/src/main/java/org/openecomp/sdnc/vnfapi/VnfSdnUtil.java
vnfapi/provider/src/main/java/org/openecomp/sdnc/vnfapi/vnfapiProvider.java
vnfapi/provider/src/main/resources/initial/vnfapi-provider.xml
vnfapi/provider/src/test/java/org/openecomp/sdnc/vnfapi/TestPropertyList.java
vnfapi/provider/src/test/resources/proplist.properties
vnfapi/provider/src/test/resources/simplelogger.properties
vnftools/installer/pom.xml
vnftools/installer/src/assembly/assemble_installer_zip.xml
vnftools/installer/src/assembly/assemble_mvnrepo_zip.xml

index de68d2e..ac3bf48 100644 (file)
@@ -1,4 +1,4 @@
 [gerrit]
-host=gerrit.onap.org
+host=gerrit.openecomp.org
 port=29418
 project=sdnc/northbound.git
index 764c866..f5c3771 100755 (executable)
@@ -60,7 +60,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                        <execution>
@@ -75,7 +74,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                </executions>
index 85e2e1e..728afca 100644 (file)
@@ -25,7 +25,6 @@
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
        <formats>
                <format>zip</format>
        </formats>
index 73afa1c..b4d2d61 100644 (file)
@@ -25,7 +25,6 @@
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
        <formats>
                <format>zip</format>
        </formats>
index 0eeea7a..7ab3209 100755 (executable)
@@ -60,7 +60,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                        <execution>
@@ -75,7 +74,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                </executions>
index 85e2e1e..728afca 100644 (file)
@@ -25,7 +25,6 @@
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
        <formats>
                <format>zip</format>
        </formats>
index 73afa1c..b4d2d61 100644 (file)
@@ -25,7 +25,6 @@
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
        <formats>
                <format>zip</format>
        </formats>
diff --git a/dmaap-listener/.gitignore b/dmaap-listener/.gitignore
new file mode 100755 (executable)
index 0000000..1b8a6ba
--- /dev/null
@@ -0,0 +1,12 @@
+org.eclipse.core.resources.prefs
+.classpath\r
+.project\r
+.settings\r
+.idea\r
+.externalToolBuilders\r
+maven-eclipse.xml\r
+*.class\r
+target/\r
+MANIFEST.MF\r
+.DS_STORE\r
+.metadata\r
diff --git a/dmaap-listener/.sonar/checkstyle.xml b/dmaap-listener/.sonar/checkstyle.xml
new file mode 100755 (executable)
index 0000000..3fa2315
--- /dev/null
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"><!-- Generated by Sonar --><module name="Checker"><module name="SuppressionCommentFilter"/><module name="TreeWalker"><module name="FileContentsHolder"/> <module name="ClassFanOutComplexity"><property name="severity" value="warning"/></module><module name="NestedForDepth"><property name="severity" value="warning"/><property name="max" value="1"/></module><module name="ClassDataAbstractionCoupling"><property name="severity" value="warning"/></module></module></module>
\ No newline at end of file
diff --git a/dmaap-listener/.sonar/pmd.xml b/dmaap-listener/.sonar/pmd.xml
new file mode 100755 (executable)
index 0000000..80343b3
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ruleset>\r
+  <rule ref="rulesets/java/naming.xml/BooleanGetMethodName">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/j2ee.xml/StaticEJBFieldShouldBeFinal">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/coupling.xml/CouplingBetweenObjects">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/codesize.xml/TooManyMethods">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/naming.xml/AvoidFieldNameMatchingTypeName">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/basic.xml/DoubleCheckedLocking">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/naming.xml/AvoidFieldNameMatchingMethodName">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/coupling.xml/ExcessiveImports">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/basic.xml/OverrideBothEqualsAndHashcode">\r
+    <priority>2</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/naming.xml/ShortMethodName">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/basic.xml/BooleanInstantiation">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/codesize.xml/TooManyFields">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/controversial.xml/AvoidUsingNativeCode">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/optimizations.xml/UseStringBufferForStringAppends">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/coupling.xml/LooseCoupling">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/design.xml/NonThreadSafeSingleton">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/j2ee.xml/DoNotUseThreads">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/sunsecure.xml/ArrayIsStoredDirectly">\r
+    <priority>5</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/sunsecure.xml/MethodReturnsInternalArray">\r
+    <priority>2</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/design.xml/AssignmentToNonFinalStatic">\r
+    <priority>3</priority>\r
+  </rule>\r
+  <rule ref="rulesets/java/strictexception.xml/AvoidCatchingGenericException">\r
+    <priority>3</priority>\r
+  </rule>\r
+</ruleset>\r
+\r
diff --git a/dmaap-listener/pom.xml b/dmaap-listener/pom.xml
new file mode 100755 (executable)
index 0000000..a46d7ca
--- /dev/null
@@ -0,0 +1,113 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+        <groupId>org.openecomp.sdnc.northbound</groupId>
+       <packaging>jar</packaging>
+       <artifactId>dmaap-listener</artifactId>
+       <version>1.1.0-SNAPSHOT</version>
+
+       <name>DMAAP Listener</name>
+       <description>DMAAP Listener</description>
+       <parent>
+               <groupId>org.openecomp.sdnc.northbound</groupId>
+               <artifactId>sdnc-northbound</artifactId>
+               <version>1.1.0-SNAPSHOT</version>
+       </parent>
+       <properties>
+               <sdc.client.version>1.1.7-SNAPSHOT</sdc.client.version>
+               <fasterxml.jackson.version>2.9.0.pr1</fasterxml.jackson.version>
+               <skip.SWM>true</skip.SWM>
+               <dmaap.listener.base>/opt/app/dmaap-listener</dmaap.listener.base>
+               <dmaap.listener.version>0.2.12</dmaap.listener.version>
+               <maven.build.timestamp.format>yyMMdd-HHmmss</maven.build.timestamp.format>
+               <build.number>${maven.build.timestamp}</build.number>
+               <SWM_VERSION>${project.version}-${build.number}</SWM_VERSION>
+       </properties>
+
+       <dependencies>
+
+               <dependency>
+                       <groupId>com.att.nsa</groupId>
+                       <artifactId>dmaapClient</artifactId>
+                       <version>${dmaap.listener.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-api</artifactId>
+                       <version>1.7.10</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-log4j12</artifactId>
+                       <version>1.6.1</version>
+                       <scope>compile</scope>
+               </dependency>
+               <dependency>
+                       <groupId>log4j</groupId>
+                       <artifactId>log4j</artifactId>
+                       <version>1.2.17</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-core</artifactId>
+                       <version>${fasterxml.jackson.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-databind</artifactId>
+                       <version>${fasterxml.jackson.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>${junit.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.openecomp.sdnc.core</groupId>
+                       <artifactId>dblib-provider</artifactId>
+                       <version>1.1.0-SNAPSHOT</version>
+               </dependency>
+       </dependencies>
+       <build>
+               <plugins>
+
+                       <!-- ================================================== -->
+                       <!-- Set the JDK compiler version. -->
+                       <!-- ================================================== -->
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>2.5.1</version>
+                               <inherited>true</inherited>
+                               <configuration>
+                                       <source>1.7</source>
+                                       <target>1.7</target>
+                               </configuration>
+                       </plugin>
+
+
+                       <plugin>
+                               <artifactId>maven-assembly-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <id>create-zip</id>
+                                               <goals>
+                                                       <goal>single</goal>
+                                               </goals>
+                                               <phase>package</phase>
+                                               <configuration>
+                                                       <attach>true</attach>
+                                                       <finalName>${project.artifactId}.${project.version}</finalName>
+                                                       <attach>true</attach>
+                                                       <descriptors>
+                                                               <descriptor>src/assembly/assemble_zip.xml</descriptor>
+                                                       </descriptors>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
+               </plugins>
+       </build>
+
+</project>
diff --git a/dmaap-listener/src/assembly/assemble_zip.xml b/dmaap-listener/src/assembly/assemble_zip.xml
new file mode 100644 (file)
index 0000000..b8c44c7
--- /dev/null
@@ -0,0 +1,59 @@
+<!--
+  ============LICENSE_START=======================================================
+  openECOMP : SDN-C
+  ================================================================================
+  Copyright (C) 2017 AT&T Intellectual Property. 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.
+  ============LICENSE_END=========================================================
+  -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+       xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+       <formats>
+               <format>zip</format>
+       </formats>
+
+       <includeBaseDirectory>false</includeBaseDirectory>
+
+       <fileSets>
+               <fileSet>
+                       <directory>src/main/scripts</directory>
+                       <outputDirectory>bin</outputDirectory>
+               </fileSet>
+               <fileSet>
+                       <directory>target</directory>
+                       <outputDirectory>lib</outputDirectory>
+                       <includes>
+                               <include>*.jar</include>
+                       </includes>
+               </fileSet>
+               <fileSet>
+                       <directory>src/main/resources</directory>
+                       <outputDirectory>lib</outputDirectory>
+                       <includes>
+                               <include>*.properties</include>
+                       </includes>
+               </fileSet>
+       </fileSets>
+       <dependencySets>
+               <dependencySet>
+                       <outputDirectory>lib</outputDirectory>
+                       <useProjectArtifact>true</useProjectArtifact>
+                       <scope>runtime</scope>
+               </dependencySet>
+       </dependencySets>
+</assembly>
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DmaapListener.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DmaapListener.java
new file mode 100644 (file)
index 0000000..bfc342c
--- /dev/null
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DmaapListener {
+       
+       private static final String DMAAP_LISTENER_PROPERTIES = "dmaap-listener.properties";
+       private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(DmaapListener.class);
+       
+       public static void main(String[] args) {
+               
+               Properties properties = new Properties();
+               
+
+               String propFileName = DMAAP_LISTENER_PROPERTIES;
+               
+               if (args.length > 0) {
+                       propFileName = args[0];
+               }
+               
+               String propPath = null;
+               String propDir = System.getenv(SDNC_CONFIG_DIR);
+               
+               List<SdncDmaapConsumer> consumers = new LinkedList();
+               
+               if (propDir == null) {
+                       
+                       propDir = "/opt/sdnc/data/properties";
+               }
+               
+               if (!propFileName.startsWith("/")) {
+                       propPath = propDir + "/" + propFileName;
+               }
+               
+               File propFile = new File(propPath);
+               
+               if (!propFile.canRead()) {
+                       LOG.error("Cannot read properties file "+propPath);
+                       System.exit(1);
+               }
+               
+               try {
+                       properties.load(new FileInputStream(propFile));
+               } catch (Exception e) {
+                       LOG.error("Caught exception loading properties from "+propPath, e);
+                       System.exit(1);
+               }
+               
+               String subscriptionStr = properties.getProperty("subscriptions");
+               
+               boolean threadsRunning = false;
+               
+               LOG.debug("Dmaap subscriptions : "+subscriptionStr);
+               
+               if (subscriptionStr != null) {
+                       String[] subscriptions = subscriptionStr.split(";");
+                       
+                       for (int i = 0; i < subscriptions.length; i++) {
+                               String[] subscription = subscriptions[i].split(":");
+                               String consumerClassName = subscription[0];
+                               String propertyPath = subscription[1];
+
+                               LOG.debug("Handling subscription [" + consumerClassName + "," + propertyPath + "]");
+
+                               if (propertyPath == null) {
+                                       LOG.error("Invalid subscription (" + subscriptions[i] + ") property file missing");
+                                       continue;
+                               }
+
+                               if (!propertyPath.startsWith("/")) {
+                                       propertyPath = propDir + "/" + propertyPath;
+                               }
+
+                               Class<?> consumerClass = null;
+
+                               try {
+                                       consumerClass = Class.forName(consumerClassName);
+                               } catch (Exception e) {
+                                       LOG.error("Could not find DMaap consumer class " + consumerClassName);
+                               }
+
+                               if (consumerClass != null) {
+
+                                       SdncDmaapConsumer consumer = null;
+
+                                       try {
+                                               consumer = (SdncDmaapConsumer) consumerClass.newInstance();
+                                       } catch (Exception e) {
+                                               LOG.error("Could not create consumer from class " + consumerClassName, e);
+                                       }
+
+                                       if (consumer != null) {
+                                               LOG.debug("Initializing consumer " + consumerClassName + "(" + propertyPath + ")");
+                                               consumer.init(properties, propertyPath);
+
+                                               if (consumer.isReady()) {
+                                                       Thread consumerThread = new Thread(consumer);
+                                                       consumerThread.start();
+                                                       consumers.add(consumer);
+                                                       threadsRunning = true;
+                                                       LOG.info("Started consumer thread (" + consumerClassName + " : " + propertyPath + ")");
+                                               } else {
+                                                       LOG.debug("Consumer " + consumerClassName + " is not ready");
+                                               }
+                                       }
+
+                               }
+
+                       }
+               }
+               
+               while (threadsRunning) {
+                       
+                       threadsRunning = false;
+                       for (SdncDmaapConsumer consumer : consumers) {
+                               if (consumer.isRunning()) {
+                                       threadsRunning = true;
+                               }
+                       }
+                       
+                       if (!threadsRunning) {
+                               break;
+                       }
+                       
+                       try {
+                               Thread.sleep(10000);
+                       } catch (InterruptedException e) {
+                               
+                       }
+               }
+               
+               LOG.info("No listener threads running - exitting");
+
+       }
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DummyDmaapConsumer.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DummyDmaapConsumer.java
new file mode 100644 (file)
index 0000000..b948d4a
--- /dev/null
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DummyDmaapConsumer extends SdncDmaapConsumer {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(DummyDmaapConsumer.class);
+       
+       @Override
+       public void processMsg(String msg) {
+               LOG.info("Consumed message: \n"+msg);
+       }
+
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/InvalidMessageException.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/InvalidMessageException.java
new file mode 100644 (file)
index 0000000..cff4edb
--- /dev/null
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+public class InvalidMessageException extends Exception {
+
+       public InvalidMessageException() {
+               super();
+       }
+       
+       public InvalidMessageException(String msg) {
+               super(msg);
+       }
+       
+       public InvalidMessageException(String msg, Throwable t) {
+               super(msg, t);
+       }
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncDmaapConsumer.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncDmaapConsumer.java
new file mode 100644 (file)
index 0000000..42ae1a2
--- /dev/null
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.att.nsa.mr.client.MRClientFactory;
+import com.att.nsa.mr.client.MRConsumer;
+import com.att.nsa.mr.client.response.MRConsumerResponse;
+
+public abstract class SdncDmaapConsumer implements Runnable {
+
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncDmaapConsumer.class);
+
+       private String propertiesPath = "";
+       private Properties properties = null;
+       MRConsumer consumer = null;
+       MRConsumerResponse consumerResponse = null;
+       boolean running = false;
+       boolean ready = false;
+       int fetchPause = 5000; // Default pause between fetchs - 5 seconds
+
+       public boolean isReady() {
+               return ready;
+       }
+
+       int timeout = 15000; // Default timeout - 15 seconds
+
+       public boolean isRunning() {
+               return running;
+       }
+
+       public SdncDmaapConsumer() {
+
+       }
+
+       public SdncDmaapConsumer(Properties properties, String propertiesPath) {
+               init(properties, propertiesPath);
+       }
+
+       public String getProperty(String name) {
+               return(properties.getProperty(name, ""));
+       }
+
+       public void init(Properties properties, String propertiesPath) {
+
+               this.propertiesPath = propertiesPath;
+
+               try {
+
+                       this.properties = (Properties) properties.clone();
+
+                       this.properties.load(new FileInputStream(new File(propertiesPath)));
+
+                       String timeoutStr = properties.getProperty("timeout");
+
+                       if ((timeoutStr != null) && (timeoutStr.length() > 0)) {
+                               try {
+                                       timeout = Integer.parseInt(timeoutStr);
+                               } catch (NumberFormatException e) {
+                                       LOG.error("Non-numeric value specified for timeout ("+timeoutStr+")");
+                               }
+                       }
+
+                       String fetchPauseStr = properties.getProperty("fetchPause");
+                       if ((fetchPauseStr != null) && (fetchPauseStr.length() > 0)) {
+                               try {
+                                       fetchPause = Integer.parseInt(fetchPauseStr);
+                               } catch (NumberFormatException e) {
+                                       LOG.error("Non-numeric valud specified for fetchPause ("+fetchPauseStr+")");
+                               }
+                       }
+
+                       this.consumer = MRClientFactory.createConsumer(propertiesPath);
+                       ready = true;
+               } catch (Exception e) {
+                       LOG.error("Error initializing DMaaP consumer from file "+propertiesPath, e);
+               }
+       }
+
+
+       @Override
+       public void run() {
+               if (ready) {
+
+                       running = true;
+
+                       while (running) {
+
+                               try {
+                                       boolean noData = true;
+                                       consumerResponse = consumer.fetchWithReturnConsumerResponse(timeout, -1);
+                                       for (String msg : consumerResponse.getActualMessages()) {
+                                               noData = false;
+                                               LOG.info("Received message from DMaaP:\n"+msg);
+                                               processMsg(msg);
+                                       }
+
+                                       if (noData) {
+                                               if (fetchPause > 0) {
+
+                                                       LOG.info("No data received from fetch.  Pausing "+fetchPause+" ms before retry");
+                                                       Thread.sleep(fetchPause);
+                                               } else {
+
+                                                       LOG.info("No data received from fetch.  No fetch pause specified - retrying immediately");
+                                               }
+                                       }
+                               } catch (Exception e) {
+                                       LOG.error("Caught exception reading from DMaaP", e);
+                                       running = false;
+                               }
+
+
+                       }
+               }
+
+       }
+
+       abstract public void processMsg(String msg) throws InvalidMessageException;
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncFlatJsonDmaapConsumer.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncFlatJsonDmaapConsumer.java
new file mode 100644 (file)
index 0000000..1cc5d14
--- /dev/null
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+
+public class SdncFlatJsonDmaapConsumer extends SdncDmaapConsumer {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncFlatJsonDmaapConsumer.class);
+       
+       private static final String UEBLISTENERROOT = "UEBLISTENERROOT";
+       private static final String SDNC_ENDPOINT = "SDNC.endpoint";
+       
+
+       
+       @Override
+       public void processMsg(String msg) throws InvalidMessageException {
+               
+               processMsg(msg, null);
+       }
+       
+       public void processMsg(String msg, String mapDirName) throws InvalidMessageException {
+               
+               if (msg == null) {
+                       throw new InvalidMessageException("Null message");
+               }
+               
+               ObjectMapper oMapper = new ObjectMapper();
+               JsonNode instarRootNode = null;
+               ObjectNode sdncRootNode = null;
+
+               String instarMsgName = null;
+               
+               try {
+                        instarRootNode = oMapper.readTree(msg);
+               } catch (Exception e) {
+                       throw new InvalidMessageException("Cannot parse json object", e);
+               }
+               
+               Iterator<Map.Entry<String, JsonNode>> instarFields = instarRootNode.fields();
+               
+               while (instarFields.hasNext()) {
+                       Map.Entry<String, JsonNode> entry = instarFields.next();
+                       
+                       instarMsgName = entry.getKey();
+                       instarRootNode = entry.getValue();
+                       break;
+               }
+
+               Map<String,String> fieldMap = loadMap(instarMsgName, mapDirName);
+               
+               if (fieldMap == null) {
+                       throw new InvalidMessageException("Unable to process message - cannot load field mappings");
+               }
+               
+               if (!fieldMap.containsKey(SDNC_ENDPOINT)) {
+                       throw new InvalidMessageException("No SDNC endpoint known for message "+instarMsgName);
+               }
+               
+               String sdncEndpoint = fieldMap.get(SDNC_ENDPOINT);
+               
+               sdncRootNode = oMapper.createObjectNode();
+               ObjectNode inputNode = oMapper.createObjectNode();
+               
+               
+               for (String fromField : fieldMap.keySet()) {
+                       
+                       if (!SDNC_ENDPOINT.equals(fromField)) {
+                               JsonNode curNode = instarRootNode.get(fromField);
+                               if (curNode != null) {
+                                       String fromValue = curNode.textValue();
+
+                                       inputNode.put(fieldMap.get(fromField), fromValue);
+                               }
+                       }
+               }
+               sdncRootNode.put("input", inputNode);
+               
+               try {
+                       String rpcMsgbody = oMapper.writeValueAsString(sdncRootNode);
+                       String odlUrlBase = getProperty("sdnc.odl.url-base");
+                       String odlUser = getProperty("sdnc.odl.user");
+                       String odlPassword = getProperty("sdnc.odl.password");
+                       
+                       if ((odlUrlBase != null) && (odlUrlBase.length() > 0)) {
+                               SdncOdlConnection conn = SdncOdlConnection.newInstance(odlUrlBase + sdncEndpoint, odlUser, odlPassword);
+                       
+                               conn.send("POST", "application/json", rpcMsgbody);
+                       } else {
+                               LOG.info("POST message body would be:\n"+rpcMsgbody);
+                       }
+               } catch (Exception e) {
+                       
+               }
+               
+       }
+
+       private Map<String,String> loadMap(String msgType, String mapDirName) {
+               Map<String, String> results = new HashMap<String, String>();
+               
+               
+               if (mapDirName == null) {
+                       String rootdir = System.getenv(UEBLISTENERROOT);
+               
+                       if ((rootdir == null) || (rootdir.length() == 0)) {
+                               rootdir = "/opt/app/ueb-listener";
+                       }
+               
+                       mapDirName = rootdir + "/lib";
+
+               }
+               
+               String mapFilename = mapDirName + "/" + msgType + ".map";
+               
+               File mapFile = new File(mapFilename);
+               
+               if (!mapFile.canRead()) {
+                       LOG.error("Cannot read map file ("+mapFilename+")");
+                       return(null);
+               }
+               
+               try {
+                       BufferedReader mapReader = new BufferedReader(new FileReader(mapFile));
+                       
+                       String curLine = null;
+                       
+                       while ((curLine = mapReader.readLine()) != null) {
+                               curLine = curLine.trim();
+                               
+                               if ((curLine.length() > 0) && (!curLine.startsWith("#"))) {
+                                       
+                                       if (curLine.contains("=>")) {
+                                               String[] entry = curLine.split("=>");
+                                               if (entry.length == 2) {
+                                                       results.put(entry[0].trim(), entry[1].trim());
+                                               }
+                                       }
+                               }
+                       }
+                       mapReader.close();
+               } catch (Exception e) {
+                       LOG.error("Caught exception reading map "+mapFilename, e);
+                       return(null);
+               }
+               
+               return(results);
+       }
+       
+       
+
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncOdlConnection.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncOdlConnection.java
new file mode 100644 (file)
index 0000000..94596e6
--- /dev/null
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.ProtocolException;
+import java.net.URL;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SdncOdlConnection {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncOdlConnection.class);
+       
+       private HttpURLConnection httpConn = null;
+       
+       private String url = null;
+       private String user = null;
+       private String password = null;
+       
+       private class SdncAuthenticator extends Authenticator {
+               
+               private String user;
+               private String passwd;
+
+               SdncAuthenticator(String user, String passwd) {
+                       this.user = user;
+                       this.passwd = passwd;
+               }
+               @Override
+               protected PasswordAuthentication getPasswordAuthentication() {
+                       return new PasswordAuthentication(user, passwd.toCharArray());
+               }
+               
+       }
+       
+       private SdncOdlConnection() {
+               
+       }
+       
+       private SdncOdlConnection(String url, String user, String password) {
+               this.url = url;
+               this.user = user;
+               this.password = password;
+               
+               try {
+                       URL sdncUrl = new URL(url);
+                       Authenticator.setDefault(new SdncAuthenticator(user, password));
+               
+                       this.httpConn = (HttpURLConnection) sdncUrl.openConnection();
+               } catch (Exception e) {
+                       LOG.error("Unable to create http connection", e);
+               }
+       }
+       
+       public static  SdncOdlConnection newInstance(String url, String user, String password) throws IOException
+       {
+               return (new SdncOdlConnection(url, user, password));
+       }
+               
+
+       
+       public String send(String method, String contentType, String msg) throws IOException {
+
+               LOG.info("Sending REST " + method + " to " + url);
+               LOG.info("Message body:\n" + msg);
+               String authStr = user + ":" + password;
+               String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes()));
+
+               httpConn.addRequestProperty("Authentication", "Basic " + encodedAuthStr);
+
+               httpConn.setRequestMethod(method);
+               httpConn.setRequestProperty("Content-Type", contentType);
+               httpConn.setRequestProperty("Accept", contentType);
+
+               httpConn.setDoInput(true);
+               httpConn.setDoOutput(true);
+               httpConn.setUseCaches(false);
+
+               if (httpConn instanceof HttpsURLConnection) {
+                       HostnameVerifier hostnameVerifier = new HostnameVerifier() {
+                               @Override
+                               public boolean verify(String hostname, SSLSession session) {
+                                       return true;
+                               }
+                       };
+                       ((HttpsURLConnection) httpConn).setHostnameVerifier(hostnameVerifier);
+               }
+
+               // Write message
+               httpConn.setRequestProperty("Content-Length", "" + msg.length());
+               DataOutputStream outStr = new DataOutputStream(httpConn.getOutputStream());
+               outStr.write(msg.getBytes());
+               outStr.close();
+
+               // Read response
+               BufferedReader respRdr;
+
+               LOG.info("Response: " + httpConn.getResponseCode() + " " + httpConn.getResponseMessage());
+
+               if (httpConn.getResponseCode() < 300) {
+
+                       respRdr = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
+               } else {
+                       respRdr = new BufferedReader(new InputStreamReader(httpConn.getErrorStream()));
+               }
+
+               StringBuffer respBuff = new StringBuffer();
+
+               String respLn;
+
+               while ((respLn = respRdr.readLine()) != null) {
+                       respBuff.append(respLn + "\n");
+               }
+               respRdr.close();
+
+               String respString = respBuff.toString();
+
+               LOG.info("Response body :\n" + respString);
+
+               return (respString);
+
+       }
+               
+
+}
diff --git a/dmaap-listener/src/main/resources/edgeRouterStatusChange.map b/dmaap-listener/src/main/resources/edgeRouterStatusChange.map
new file mode 100644 (file)
index 0000000..57644bb
--- /dev/null
@@ -0,0 +1,23 @@
+# SDN-C URL
+SDNC.endpoint => FLOWRED-API:process-edge-router-status-change
+
+# Field mapping 
+equip_id => equip_id
+ptnii_equip_name => equip-name
+equip_type.equip_type => equip-type
+ip_addr => loopback0
+router_prov_status => prov-status
+country.region => region
+country_abbr => country
+equip_name_code => equip-name-code
+as_number => as-number
+loopback1 => loopback1
+loopback2 => loopback2
+loopback3 => loopback3
+loopback40 => loopback40
+loopback65535 => loopback65535
+inms_list => inms-list
+encrypted_access_flag => encrypted-access-flag
+sw_name => sw-name
+nmipaddr => nm-addr
+function_code => function-code
\ No newline at end of file
diff --git a/dmaap-listener/src/main/resources/log4j.properties b/dmaap-listener/src/main/resources/log4j.properties
new file mode 100644 (file)
index 0000000..b6960a7
--- /dev/null
@@ -0,0 +1,37 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. 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.
+# ============LICENSE_END=========================================================
+###
+
+log4j.rootLogger=DEBUG,CONSOLE,LOGFILE
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=ERROR
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
+log4j.appender.LOGFILE.File=/opt/app/dmaap-listener/logs/dmaap-listener.log
+log4j.appender.LOGFILE.Append=true
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
+log4j.appender.LOGFILE.MaxFileSize=10MB
+log4j.appender.LOGFILE.MaxBackupIndex=10
diff --git a/dmaap-listener/src/main/resources/preferredRoute.txt b/dmaap-listener/src/main/resources/preferredRoute.txt
new file mode 100644 (file)
index 0000000..662b0aa
--- /dev/null
@@ -0,0 +1 @@
+preferredRouteKey=MR1
\ No newline at end of file
diff --git a/dmaap-listener/src/main/scripts/start-dmaap-listener.sh b/dmaap-listener/src/main/scripts/start-dmaap-listener.sh
new file mode 100644 (file)
index 0000000..cee16fc
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. 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.
+# ============LICENSE_END=========================================================
+###
+
+PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
+
+LISTENER=dmaap-listener
+
+
+
+PIDFILE=/tmp/.${LISTENER}-pid
+UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/dmaap-listener}
+JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-oracle}
+JAVA_OPTS=${JAVA_OPTS:--Dhttps.protocols=TLSv1.1,TLSv1.2}
+JAVA=${JAVA:-${JAVA_HOME}/bin/java}
+
+# Redirect output from script to $LISTENER.out
+exec >> ${UEBLISTENERROOT}/logs/$LISTENER.out
+exec 2>&1
+
+if [ -f $PIDFILE ]
+then
+  pid=$(cat $PIDFILE)
+  if [ "$pid" != "" ]
+  then
+    if kill -0 $pid
+    then
+      echo "$LISTENER already running"
+      exit 0
+    fi
+  fi
+fi
+
+if [ ! -d ${UEBLISTENERROOT}/logs ]
+then
+  mkdir ${UEBLISTENERROOT}/logs
+fi
+
+for file in ${UEBLISTENERROOT}/lib/*.jar
+do
+  LISTENERCLASSPATH=$LISTENERCLASSPATH:$file
+done
+
+${JAVA} ${JAVA_OPTS} -Dlog4j.configuration=file:${UEBLISTENERROOT}/lib/log4j.properties -cp ${LISTENERCLASSPATH} com.att.sdnctl.dmaapclient.DmaapListener &
+
+
+echo $! > $PIDFILE
+
+echo "$LISTENER started!"
+exit 0
diff --git a/dmaap-listener/src/main/scripts/stop-dmaap-listener.sh b/dmaap-listener/src/main/scripts/stop-dmaap-listener.sh
new file mode 100644 (file)
index 0000000..0193f15
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. 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.
+# ============LICENSE_END=========================================================
+###
+
+PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
+
+LISTENER=dmaap-listener
+
+
+PIDFILE=/tmp/.${LISTENER}-pid
+UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/dmaap-listener}
+
+if [ -f $PIDFILE ]
+then
+  pid=$(cat $PIDFILE)
+  if [ "$pid" != "" ]
+  then
+    if kill -0 $pid
+      then
+       echo "Stopping $LISTENER"
+        kill $pid && rm $PIDFILE
+        exit 0
+      else
+        echo "$LISTENER not running"
+        exit 1
+      fi
+  else
+      echo "$LISTENER not running"
+      exit 1
+  fi
+fi
+
+
diff --git a/dmaap-listener/src/site/apt/index.apt b/dmaap-listener/src/site/apt/index.apt
new file mode 100644 (file)
index 0000000..19ff8bd
--- /dev/null
@@ -0,0 +1,46 @@
+~~~
+~~ ============LICENSE_START=======================================================
+~~ openECOMP : SDN-C
+~~ ================================================================================
+~~ Copyright (C) 2017 AT&T Intellectual Property. 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.
+~~ ============LICENSE_END=========================================================
+~~~
+
+      ---
+      UEB Listener
+      ---
+
+
+UEB Listener
+
+    The UEB Listener is a daemon that listens for notifications from SDC, posted to UEB (Universal Event Bus).
+    On receipt of an event, the UEB listener downloads any artifacts posted and examines them to determine if
+    the format (the outer XML tag) matches a supported format.  If so, it posts the file to the ASDC-API REST
+    API in order to update the SDN-C database.
+
+File Locations
+
+    * Root directory : /opt/app/ueb-listener
+
+    * Log files : /opt/app/ueb-listener/logs
+
+    * Incoming files to be processed : /opt/app/ueb-listener/spool/asdc/incoming
+
+    * Files already processed : /opt/app/ueb-listener/spool/asdc/archive
+
+
+
+
diff --git a/dmaap-listener/src/site/site.xml b/dmaap-listener/src/site/site.xml
new file mode 100644 (file)
index 0000000..4118c7b
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ============LICENSE_START=======================================================
+  openECOMP : SDN-C
+  ================================================================================
+  Copyright (C) 2017 AT&T Intellectual Property. 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.
+  ============LICENSE_END=========================================================
+  -->
+
+<project>
+
+  <body>
+    <menu ref="modules"/>
+
+    <menu ref="reports"/>
+
+  </body>
+</project>
diff --git a/pom.xml b/pom.xml
index f642ab0..c348597 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
        <parent>
                <groupId>org.openecomp.sdnc.core</groupId>
                <artifactId>root</artifactId>
-               <version>1.1.1-SNAPSHOT</version>
+               <version>1.1.0</version>
        </parent>
 
        <modelVersion>4.0.0</modelVersion>
        <artifactId>sdnc-northbound</artifactId>
 
        <name>SDN-C Northbound APIs</name>
-       <url>https://wiki.onap.org</url>
+       <url>https://wiki.openecomp.org</url>
        <description>The SDN-C Northbound APIs repo contains code for northbound API adaptors, typically MD-SAL applications</description>
 
 
        <issueManagement>
                <system>JIRA</system>
-               <url>https://jira.onap.org/</url>
+               <url>https://jira.openecomp.org/</url>
        </issueManagement>
 
 
 
        <ciManagement>
                <system>Jenkins</system>
-               <url>https://jenkins.onap.org/</url>
+               <url>https://jenkins.openecomp.org/</url>
        </ciManagement>
 
        <distributionManagement>
                <site>
-                       <id>ecomp-site</id>
-                       <url>dav:https://${openecomp.nexus.host}/content/sites/site/org/onap/sdnc/${project.artifactId}/${project.version}</url>
+                       <id>sdnc-javadoc</id>
+                       <url>dav:https://${openecomp.nexus.host}:${openecomp.nexus.port}/repository/sdn-c-javadoc/${project.artifactId}/${project.version}</url>
                </site>
        </distributionManagement>
        <profiles>
        <modules>
                <module>asdcApi</module>
                <module>dataChange</module>
-               <!-- <module>ueb-listener</module> -->
+               <module>dmaap-listener</module>
+               <module>ueb-listener</module>
                <module>vnfapi</module>
                <module>vnftools</module>
        </modules>
index 91ef89f..48c47a8 100755 (executable)
@@ -1,19 +1,20 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
-    <groupId>org.openecomp.sdnc.northbound</groupId>
+        <groupId>org.openecomp.sdnc.northbound</groupId>
        <packaging>jar</packaging>
        <artifactId>ueb-listener</artifactId>
-       <version>1.0.0-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
 
        <name>UEB Listener</name>
        <description>UEB Listener</description>
        <parent>
                <groupId>org.openecomp.sdnc.northbound</groupId>
                <artifactId>sdnc-northbound</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
        </parent>
        <properties>
-               <sdc.client.version>1.1.0</sdc.client.version>
+               <sdc.client.version>1.1.7-SNAPSHOT</sdc.client.version>
+               <fasterxml.jackson.version>2.9.0.pr1</fasterxml.jackson.version>
                <skip.SWM>true</skip.SWM>
                <ueb.listener.base>/opt/app/ueb-listener</ueb.listener.base>
                <maven.build.timestamp.format>yyMMdd-HHmmss</maven.build.timestamp.format>
        <dependencies>
 
                <dependency>
-                       <groupId>org.openecomp.sdc</groupId>
+                       <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
                        <artifactId>sdc-distribution-client</artifactId>
                        <version>${sdc.client.version}</version>
                        <scope>compile</scope>
                </dependency>
-
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                        <version>1.2.17</version>
                </dependency>
                <dependency>
-               <groupId>commons-codec</groupId>
-               <artifactId>commons-codec</artifactId>
-               <version>${commons.codec.version}</version>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-core</artifactId>
+                       <version>${fasterxml.jackson.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-databind</artifactId>
+                       <version>${fasterxml.jackson.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>${junit.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.openecomp.sdnc.core</groupId>
+                       <artifactId>dblib-provider</artifactId>
+                       <version>1.1.0-SNAPSHOT</version>
                </dependency>
        </dependencies>
        <build>
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                </executions>
index 48aafa5..29e3b41 100644 (file)
@@ -3,7 +3,7 @@
   openECOMP : SDN-C
   ================================================================================
   Copyright (C) 2017 AT&T Intellectual Property. All rights
-              reserved.
+                                               reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
        <formats>
                <format>zip</format>
        </formats>
@@ -49,6 +48,7 @@
                        <outputDirectory>lib</outputDirectory>
                        <includes>
                                <include>*.xslt</include>
+                               <include>*.properties</include>
                        </includes>
                </fileSet>
        </fileSets>
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncARModel.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncARModel.java
new file mode 100644 (file)
index 0000000..0bb7a85
--- /dev/null
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.Metadata;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncARModel extends SdncBaseModel {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncARModel.class);
+
+       public SdncARModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
+
+               super(sdcCsarHelper, nodeTemplate);
+               
+               // extract metadata
+               Metadata metadata = nodeTemplate.getMetadata();
+               addParameter("type", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_TYPE));
+               
+               // extract properties
+               //addParameter("role", extractValue (sdcCsarHelper, nodeTemplate, SdcPropertyNames.PROPERTY_NAME_ROLE));
+               //addParameter("type", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_TYPE)); - wrong location, get from metadata
+               addParameter("ecomp_generated_naming", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VFCNAMING_ECOMPGENERATEDNAMING));
+               addParameter("naming_policy", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VFCNAMING_NAMINGPOLICY));
+               //addParameter("depending_service", extractValue (sdcCsarHelper, nodeTemplate, SdcPropertyNames.PROPERTY_NAME_DEPENDINGSERVICE));
+               //addParameter("service_dependency", extractValue (sdcCsarHelper, nodeTemplate, SdcPropertyNames.PROPERTY_NAME_SERVICEDEPENDENCY));
+       }
+
+}
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncArtifactMap.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncArtifactMap.java
new file mode 100644 (file)
index 0000000..5b00418
--- /dev/null
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncArtifactMap {
+
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncArtifactMap.class);
+
+       public class SdncArtifactType {
+               private String tag;
+               private String artifactType;
+               private String rpc;
+               private int pass;
+
+               public String getTag() {
+                       return tag;
+               }
+               public String getArtifactType() {
+                       return artifactType;
+               }
+               public String getRpc() {
+                       return rpc;
+               }
+
+               public int getPass() {
+                       return pass;
+               }
+
+        public String getRpcUrl(String base) {
+                       return(base+rpc);
+        }
+
+               private SdncArtifactType(String tag, String rpc, String pass) {
+                       this.tag = tag;
+                       this.rpc = rpc;
+                       try {
+                               this.pass = Integer.parseInt(pass);
+                       } catch (Exception e) {
+                               LOG.error("Invalid pass value for artifact map entry ("+tag+","+rpc+","+pass+")");
+                       }
+               }
+       }
+
+
+
+       private Map<String, SdncArtifactType> mapItems = new HashMap<String, SdncArtifactType>();
+
+       private int NumPasses = 1;
+
+       public int getNumPasses() {
+               return NumPasses;
+       }
+
+       public void load(String fileName) {
+
+               File mapFile = new File(fileName);
+
+               if (mapFile.exists() && mapFile.canRead()) {
+
+                       BufferedReader rdr = null;
+                       try {
+
+                               rdr = new BufferedReader(new FileReader(mapFile));
+
+                               for (String ln ; (ln = rdr.readLine()) != null ; ) {
+                                       String[] lnFields = ln.split(",");
+                                       if (lnFields.length == 3) {
+                                               SdncArtifactType entry = new SdncArtifactType(lnFields[0], lnFields[1], lnFields[2]);
+                                               mapItems.put(entry.getTag(), entry);
+                                               if (entry.getPass() + 1 > NumPasses ) {
+                                                       NumPasses = entry.getPass() + 1;
+                                               }
+                                       }
+                               }
+
+
+                       } catch (Exception e) {
+                               LOG.error("Caught exception reading artifact map", e);
+                               return;
+                       } finally {
+                               if (rdr != null) {
+                                       try {
+                                               rdr.close();
+                                       } catch (IOException e) {
+
+                                       }
+                               }
+                       }
+               }
+       }
+
+       public SdncArtifactType getMapping(String tag) {
+               if (mapItems.containsKey(tag)) {
+                       return(mapItems.get(tag));
+               } else {
+                       return(null);
+               }
+       }
+
+       public static SdncArtifactMap getInstance() {
+               return new SdncArtifactMap();
+       }
+
+}
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncBaseModel.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncBaseModel.java
new file mode 100644 (file)
index 0000000..6eb9dcc
--- /dev/null
@@ -0,0 +1,297 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.Group;
+import org.openecomp.sdc.toscaparser.api.Metadata;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncBaseModel {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncBaseModel.class);
+       
+       protected String customizationUUID = null;
+       protected String invariantUUID = null;
+       protected String model_yaml = null;     
+       protected String version = null;        
+       
+       protected Map<String, String> params = null;
+       protected ISdcCsarHelper sdcCsarHelper = null;
+
+       public SdncBaseModel() {
+               
+       }
+       
+       public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, Metadata metadata) {
+
+               params = new HashMap<String, String>();
+               this.sdcCsarHelper = sdcCsarHelper;
+               
+               // extract service metadata
+               invariantUUID = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
+               addParameter("invariant_uuid",invariantUUID);
+               addParameter("version",extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_VERSION));
+               addParameter("name",extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_NAME));
+               addParameter("description",extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+               addParameter("type",extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_TYPE));
+               addParameter("category",extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+       }
+
+       public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
+
+               params = new HashMap<String, String>();
+               this.sdcCsarHelper = sdcCsarHelper;
+
+               // extract nodeTemplate metadata
+               Metadata metadata = nodeTemplate.getMetadata();
+               customizationUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+               addParameter("invariant_uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+               addParameter("uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_UUID));
+               addParameter("version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VERSION)); 
+       }
+
+       public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, Group group) {
+
+               params = new HashMap<String, String>();
+               this.sdcCsarHelper = sdcCsarHelper;
+
+               // extract group metadata
+               Metadata metadata = group.getMetadata();
+               //customizationUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULECUSTOMIZATIONUUID); - returning null
+               customizationUUID = extractValue (metadata, "vfModuleModelCustomizationUUID");
+               addParameter("invariant_uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID));                     
+               addParameter("uuid", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));                        
+               addParameter("version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION));                  
+       }
+
+       protected void addParameter (String name, String value) {
+               if (value != null && !value.isEmpty()) {
+                       params.put(name, "\"" + value + "\"");
+               }
+       }
+
+       protected void addIntParameter (String name, String value) {
+               if (value != null && !value.isEmpty()) {
+                       params.put(name, value);
+               }
+       }
+       
+       public static void addIntParameter (String name, String value, Map<String, String> params) {
+               if (value != null && !value.isEmpty()) {
+                       params.put(name, value);
+               }
+       }
+       
+       public static void addParameter (String name, String value, Map<String, String> params) {
+               if (value != null && !value.isEmpty()) {
+                       params.put(name, "\"" + value + "\"");
+               }
+       }
+       
+       protected String extractValue (Metadata metadata, String name) {
+               String value = sdcCsarHelper.getMetadataPropertyValue(metadata, name);
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }       
+       }
+
+       public static String extractValue (ISdcCsarHelper sdcCsarHelper, Metadata metadata, String name) {
+               String value = sdcCsarHelper.getMetadataPropertyValue(metadata, name);
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }       
+       }
+
+       protected String extractValue (NodeTemplate nodeTemplate, String name) {
+               String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, name);
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }
+       }
+
+       public static String extractValue (ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate, String name) {
+               String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, name);
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }
+       }
+
+       protected String extractBooleanValue (NodeTemplate nodeTemplate, String name) {
+               String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, name);
+               if (value != null && !value.isEmpty()) {
+                       return value.contains("true") ? "Y" : "N";
+               } else {
+                       return "";
+               }
+       }
+
+       public static String extractBooleanValue (ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate, String name) {
+               String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, name);
+               if (value != null && !value.isEmpty()) {
+                       return value.contains("true") ? "Y" : "N";
+               } else {
+                       return "";
+               }
+       }
+
+       protected String extractValue (Group group, String name) {
+               String value = sdcCsarHelper.getGroupPropertyLeafValue(group, name);
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }
+       }
+
+       protected String extractBooleanValue (Group group, String name) {
+               String value = sdcCsarHelper.getGroupPropertyLeafValue(group, name);
+               if (value != null && !value.isEmpty()) {
+                       return value.contains("true") ? "Y" : "N";
+               } else {
+                       return "";
+               }
+       }
+
+       protected String extractInputDefaultValue (String name) {
+               String value = sdcCsarHelper.getServiceInputLeafValueOfDefault(name);
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }
+       }
+
+       protected String extractBooleanInputDefaultValue (String name) {
+               String value = sdcCsarHelper.getServiceInputLeafValueOfDefault(name);
+               if (value != null && !value.isEmpty()) {
+                       return value.contains("true") ? "Y" : "N";
+               } else {
+                       return "";
+               }
+       }
+
+       public static String extractInputDefaultValue (ISdcCsarHelper sdcCsarHelper, String name) {
+               String value = sdcCsarHelper.getServiceInputLeafValueOfDefault(name);
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }
+       }
+
+       public static String extractBooleanInputDefaultValue (ISdcCsarHelper sdcCsarHelper, String name) {
+               String value = sdcCsarHelper.getServiceInputLeafValueOfDefault(name);
+               if (value != null && !value.isEmpty()) {
+                       return value.contains("true") ? "Y" : "N";
+               } else {
+                       return "";
+               }
+       }
+
+       public static String extractSubstitutionMappingTypeName (ISdcCsarHelper sdcCsarHelper) {
+               String value = sdcCsarHelper.getServiceSubstitutionMappingsTypeName();
+               if (value != null) {
+                       return value;
+               } else {
+                       return "";
+               }
+       }
+
+       public String getCustomizationUUID() {
+               return ("\"" + customizationUUID + "\"");
+       }
+       public String getCustomizationUUIDNoQuotes() {
+               return (customizationUUID);
+       }
+       public void setCustomizationUUID(String customizationUUID) {
+               this.customizationUUID = customizationUUID;
+       }
+       
+       public String getSql(String tableName, String model_yaml) {
+               
+               StringBuilder sb = new StringBuilder();
+               sb.append("INSERT into " + tableName + " (customization_uuid, model_yaml, ");
+               
+               int paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                   sb.append(paramKey);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+               
+               sb.append(") values (" + getCustomizationUUID() + ", \"" + model_yaml + "\", ");
+
+               paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                       String paramValue = params.get(paramKey);
+                   sb.append(paramValue);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+
+               sb.append(");");
+               return sb.toString();
+       }
+       
+       public static String getSql(String tableName, String keyName, String keyValue, String model_yaml, Map<String, String> params) {
+               
+               StringBuilder sb = new StringBuilder();
+               sb.append("INSERT into " + tableName + " (" + keyName + ", ");
+               
+               int paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                   sb.append(paramKey);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+               
+               sb.append(") values (" + keyValue + ", ");
+
+               paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                       String paramValue = params.get(paramKey);
+                   sb.append(paramValue);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+
+               sb.append(");");
+               return sb.toString();
+       }
+       
+}
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncNodeModel.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncNodeModel.java
new file mode 100644 (file)
index 0000000..b0fdc5e
--- /dev/null
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncNodeModel extends SdncBaseModel {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncNodeModel.class);
+       
+       private String serviceUUID = null;
+       private String ecompGeneratedNaming = null;
+       private String [] bindingUuids = null; 
+       
+       // Using ASDC TOSCA Parser 17.07
+       public SdncNodeModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
+               
+               super(sdcCsarHelper, nodeTemplate);
+
+               // extract inputs
+               String ecompGeneratedNaming = extractBooleanInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_ECOMPGENERATEDNAMING);
+               addParameter("ecomp_generated_naming",ecompGeneratedNaming);
+               addParameter("naming_policy", extractInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_NAMINGPOLICY));
+               
+               // extract properties
+               addParameter("network_type", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+               addParameter("network_role", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+               addParameter("network_scope", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+               addParameter("network_technology", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+
+               // extract properties - network_assignments
+               addParameter("is_shared_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_ISSHAREDNETWORK));
+               addParameter("is_external_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_ISEXTERNALNETWORK));
+
+               // extract properties - network_assignments - ipv4_subnet_default_assignment
+               String useIpv4 = extractBooleanValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#use_ipv4");
+               addParameter("use_ipv4", useIpv4);
+               addParameter("ipv4_dhcp_enabled", extractBooleanValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#dhcp_enabled"));
+               if (useIpv4.contains("Y")) {
+                       addParameter("ipv4_ip_version", "ipv4");
+               }
+               addParameter("ipv4_cidr_mask", extractValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask"));
+               addParameter("eipam_v4_address_plan", extractValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#ip_network_address_plan"));
+               
+               // extract properties - network_assignments - ipv6_subnet_default_assignment
+               String useIpv6 = extractBooleanValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#use_ipv6");
+               addParameter("use_ipv6", useIpv6);
+               addParameter("ipv6_dhcp_enabled", extractBooleanValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#dhcp_enabled"));
+               if (useIpv6.contains("Y")) {
+                       addParameter("ipv6_ip_version", "ipv6");
+               }
+               addParameter("ipv6_cidr_mask", extractValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#cidr_mask"));
+               addParameter("eipam_v6_address_plan", extractValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#ip_network_address_plan"));
+               
+               // extract properties - provider_network
+               addParameter("is_provider_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK));
+               addParameter("physical_network_name", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_PHYSICALNETWORKNAME));
+
+               // extract properties - network_flows
+               addParameter("is_bound_to_vpn", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKFLOWS_ISBOUNDTOVPN));
+
+               // extract properties - network_flows - vpn_bindings
+               String vpnBindingString = extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKFLOWS_VPNBINDING);
+               bindingUuids = vpnBindingString.split(",");
+
+}
+
+       public String getServiceUUID() {
+               return serviceUUID;
+       }
+       public void setServiceUUID(String serviceUUID) {
+               this.serviceUUID = serviceUUID;
+       }
+
+       public String getEcompGeneratedNaming() {
+               return ecompGeneratedNaming;
+       }
+       public void setEcompGeneratedNaming(String ecompGeneratedNaming) {
+               this.ecompGeneratedNaming = ecompGeneratedNaming;
+               if (ecompGeneratedNaming != null && !ecompGeneratedNaming.isEmpty()) {
+                       params.put("ecomp_generated_naming", "\"" + ecompGeneratedNaming + "\"");                       
+               }
+       }
+
+       public String getSql(String model_yaml) {
+               
+               StringBuilder sb = new StringBuilder();
+               sb.append("INSERT into NETWORK_MODEL (service_uuid, customization_uuid, model_yaml, ");
+               
+               int paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                   sb.append(paramKey);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+               
+               sb.append(") values (" + serviceUUID + ", " + getCustomizationUUID() + ", \"" + model_yaml + "\", ");
+
+               paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                       String paramValue = params.get(paramKey);
+                   sb.append(paramValue);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+
+               sb.append(");");
+               return sb.toString();
+       }
+
+       public String getVpnBindingsSql() {
+               
+               StringBuilder sb = new StringBuilder();
+               for (int i=0; i < bindingUuids.length; i++) {
+                       sb.append("INSERT into VPN_BINDINGS (network_customization_uuid, binding_uuid) values (" + getCustomizationUUID() + ", \"" + bindingUuids[i] + "\"); ");
+               }
+
+               return sb.toString();
+       }
+       
+}
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncOdlConnection.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncOdlConnection.java
new file mode 100644 (file)
index 0000000..a277def
--- /dev/null
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.ProtocolException;
+import java.net.URL;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SdncOdlConnection {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncOdlConnection.class);
+       
+       private HttpURLConnection httpConn = null;
+       
+       private String url = null;
+       private String user = null;
+       private String password = null;
+       
+       private class SdncAuthenticator extends Authenticator {
+               
+               private String user;
+               private String passwd;
+
+               SdncAuthenticator(String user, String passwd) {
+                       this.user = user;
+                       this.passwd = passwd;
+               }
+               @Override
+               protected PasswordAuthentication getPasswordAuthentication() {
+                       return new PasswordAuthentication(user, passwd.toCharArray());
+               }
+               
+       }
+       
+       private SdncOdlConnection() {
+               
+       }
+       
+       private SdncOdlConnection(String url, String user, String password) {
+               this.url = url;
+               this.user = user;
+               this.password = password;
+               
+               try {
+                       URL sdncUrl = new URL(url);
+                       Authenticator.setDefault(new SdncAuthenticator(user, password));
+               
+                       this.httpConn = (HttpURLConnection) sdncUrl.openConnection();
+               } catch (Exception e) {
+                       LOG.error("Unable to create http connection", e);
+               }
+       }
+       
+       public static  SdncOdlConnection newInstance(String url, String user, String password) throws IOException
+       {
+               return (new SdncOdlConnection(url, user, password));
+       }
+               
+
+       
+       public String send(String method, String contentType, String msg) throws IOException {
+
+               LOG.info("Sending REST " + method + " to " + url);
+               LOG.info("Message body:\n" + msg);
+               String authStr = user + ":" + password;
+               String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes()));
+
+               httpConn.addRequestProperty("Authentication", "Basic " + encodedAuthStr);
+
+               httpConn.setRequestMethod(method);
+               httpConn.setRequestProperty("Content-Type", contentType);
+               httpConn.setRequestProperty("Accept", contentType);
+
+               httpConn.setDoInput(true);
+               httpConn.setDoOutput(true);
+               httpConn.setUseCaches(false);
+
+               if (httpConn instanceof HttpsURLConnection) {
+                       HostnameVerifier hostnameVerifier = new HostnameVerifier() {
+                               @Override
+                               public boolean verify(String hostname, SSLSession session) {
+                                       return true;
+                               }
+                       };
+                       ((HttpsURLConnection) httpConn).setHostnameVerifier(hostnameVerifier);
+               }
+
+               // Write message
+               httpConn.setRequestProperty("Content-Length", "" + msg.length());
+               DataOutputStream outStr = new DataOutputStream(httpConn.getOutputStream());
+               outStr.write(msg.getBytes());
+               outStr.close();
+
+               // Read response
+               BufferedReader respRdr;
+
+               LOG.info("Response: " + httpConn.getResponseCode() + " " + httpConn.getResponseMessage());
+
+               if (httpConn.getResponseCode() < 300) {
+
+                       respRdr = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
+               } else {
+                       respRdr = new BufferedReader(new InputStreamReader(httpConn.getErrorStream()));
+               }
+
+               StringBuffer respBuff = new StringBuffer();
+
+               String respLn;
+
+               while ((respLn = respRdr.readLine()) != null) {
+                       respBuff.append(respLn + "\n");
+               }
+               respRdr.close();
+
+               String respString = respBuff.toString();
+
+               LOG.info("Response body :\n" + respString);
+
+               return (respString);
+
+       }
+               
+
+}
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncServiceModel.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncServiceModel.java
new file mode 100644 (file)
index 0000000..7e95c8f
--- /dev/null
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.Metadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncServiceModel extends SdncBaseModel {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncServiceModel.class);
+       
+       private String UUID = null;
+       private String serviceInstanceNamePrefix = null;
+       private String filename = null;
+       
+       public SdncServiceModel(ISdcCsarHelper sdcCsarHelper, Metadata metadata) {
+               
+               super(sdcCsarHelper, metadata);
+       
+               UUID = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_UUID);
+               
+               // extract service topology template input data 
+               addParameter("ecomp_naming",extractBooleanInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_ECOMPGENERATEDNAMING));
+               addParameter("naming_policy",extractInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_NAMINGPOLICY));
+       }
+
+       public String getServiceUUID() {
+               return ("\"" + UUID + "\"");
+       }
+       public void setServiceUUID(String serviceUUID) {
+               this.UUID = serviceUUID;
+       }
+       public String getServiceInstanceNamePrefix() {
+               return serviceInstanceNamePrefix;
+       }
+       public void setServiceInstanceNamePrefix(String serviceInstanceNamePrefix) {
+               if (serviceInstanceNamePrefix != null && !serviceInstanceNamePrefix.isEmpty()) {
+                       this.serviceInstanceNamePrefix = serviceInstanceNamePrefix;
+                       params.put("service_instance_name_prefix", "\"" + serviceInstanceNamePrefix + "\"");
+               }
+       }
+       public String getFilename() {
+               return filename;
+       }
+       public void setFilename(String filename) {
+               this.filename = filename;
+       }
+       
+       public String getSql(String model_yaml) {
+               
+               StringBuilder sb = new StringBuilder();
+               sb.append("INSERT into SERVICE_MODEL (service_uuid, model_yaml, filename, ");
+               
+               int paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                   sb.append(paramKey);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+               
+               sb.append(") values (" + getServiceUUID() + ", \"" + model_yaml + "\", \"" + filename + "\", ");
+
+               paramCount = 0;
+               for (String paramKey :  params.keySet()) {
+                       paramCount++;
+                       String paramValue = params.get(paramKey);
+                   sb.append(paramValue);
+                   if (paramCount < params.size()) sb.append(", ");
+               }
+
+               sb.append(");");
+               return sb.toString();
+       }
+       
+}
index 3fa752b..0393397 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *             reserved.
+ *                                             reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,9 +25,12 @@ import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.DataOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.Authenticator;
 import java.net.HttpURLConnection;
@@ -37,14 +40,20 @@ import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLSession;
+import javax.sql.rowset.CachedRowSet;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Source;
@@ -56,6 +65,7 @@ import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathFactory;
 
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.tuple.Pair;
 import org.openecomp.sdc.api.IDistributionClient;
 import org.openecomp.sdc.api.consumer.IDistributionStatusMessage;
 import org.openecomp.sdc.api.consumer.INotificationCallback;
@@ -64,60 +74,33 @@ import org.openecomp.sdc.api.notification.INotificationData;
 import org.openecomp.sdc.api.notification.IResourceInstance;
 import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
 import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.openecomp.sdc.toscaparser.api.Group;
+import org.openecomp.sdc.toscaparser.api.Metadata;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
 import org.openecomp.sdc.utils.ArtifactTypeEnum;
 import org.openecomp.sdc.utils.DistributionActionResultEnum;
 import org.openecomp.sdc.utils.DistributionStatusEnum;
+import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager;
+import org.openecomp.sdnc.uebclient.SdncArtifactMap.SdncArtifactType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
 
 public class SdncUebCallback implements INotificationCallback {
 
     private static final Logger LOG = LoggerFactory
             .getLogger(SdncUebCallback.class);
 
-    private static final int NUM_PASSES = 2;
+       private static DBResourceManager jdbcDataSource = null;
+       private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
 
-    private enum SdncArtifactType {
-        VF_LICENSE_MODEL("vf-license-model", "vf-license-model-update",0),
-        UNKNOWN("","",0);
-
-
-        private String tag;
-        private String rpcName;
-        private int pass;
-
-        public int getPass() {
-            return pass;
-        }
-
-        private SdncArtifactType(String tag, String rpcName, int pass) {
-            this.tag = tag;
-            this.rpcName = rpcName;
-            this.pass = pass;
-        }
-
-        public String getTag() {
-            return tag;
-        }
-
-        public String getRpcUrl(String base) {
-            return base+rpcName;
-        }
-
-        public static SdncArtifactType fromTag(String tag) {
-            if (tag != null) {
-                for (SdncArtifactType artifact: SdncArtifactType.values()) {
-                    if (artifact.getTag().equalsIgnoreCase(tag)) {
-                        return artifact;
-                    }
-                }
-            }
-
-            return UNKNOWN;
-        }
-    }
 
     private class SdncAuthenticator extends Authenticator {
 
@@ -176,6 +159,8 @@ public class SdncUebCallback implements INotificationCallback {
         public DeployableArtifact(SdncArtifactType type, String svcName, String resourceName, IArtifactInfo artifactInfo, File file) {
             this.type = type;
             this.artifactInfo = artifactInfo;
+                       this.svcName = svcName;
+                       this.resourceName = resourceName;
             this.artifactName = artifactInfo.getArtifactName();
             this.artifactVersion = artifactInfo.getArtifactVersion();
             this.file = file;
@@ -185,6 +170,8 @@ public class SdncUebCallback implements INotificationCallback {
         public DeployableArtifact(SdncArtifactType type, String svcName, String resourceName, String artifactName, String artifactVersion, File file) {
             this.type = type;
             this.artifactInfo = null;
+                       this.svcName = svcName;
+                       this.resourceName = resourceName;
             this.artifactName = artifactName;
             this.artifactVersion = artifactVersion;
             this.file = file;
@@ -207,24 +194,57 @@ public class SdncUebCallback implements INotificationCallback {
     private final IDistributionClient client;
     private final SdncUebConfiguration config;
 
-    private final LinkedList<DeployableArtifact> deployList[];
+    private LinkedList<DeployableArtifact> deployList[];
 
+       private static void setJdbcDataSource() throws IOException {
+
+               String propPath = null;
+               String propDir = System.getenv(SDNC_CONFIG_DIR);
+               if (propDir == null) {
+
+                       propDir = "/opt/sdnc/data/properties";
+               }
+               propPath = propDir + "/dblib.properties";
+               File propFile = new File(propPath);
+
+               if (!propFile.exists()) {
+
+                       throw new FileNotFoundException(
+                                       "Missing configuration properties file : "
+                                                       + propFile);
+               }
+
+               Properties props = new Properties();
+               props.load(new FileInputStream(propFile));
+
+               try {
+                       jdbcDataSource = DBResourceManager.create(props);
+               } catch(Throwable exc) {
+                       LOG.error("", exc);
+               }
+
+               if(((DBResourceManager)jdbcDataSource).isActive()){
+                       LOG.warn( "DBLIB: JDBC DataSource has been initialized.");
+               } else {
+                       LOG.warn( "DBLIB: JDBC DataSource did not initialize successfully.");
+               }
+       }
+
+       private static void loadArtifactMap() {
+
+       }
 
     public SdncUebCallback(IDistributionClient client, SdncUebConfiguration config) {
         this.client = client;
         this.config = config;
-        this.deployList = new LinkedList[NUM_PASSES];
 
-        for (int i = 0 ; i < NUM_PASSES ; i++) {
-            this.deployList[i] = new LinkedList<>();
-        }
     }
 
     @Override
        public void activateCallback(INotificationData data) {
 
         LOG.info("Received notification : ("+data.getDistributionID()+","+data.getServiceName()+","+data.getServiceVersion()+
-                ","+data.getServiceDescription());
+                               ","+data.getServiceDescription() +  ")");
 
         String incomingDirName = config.getIncomingDir();
         String archiveDirName = config.getArchiveDir();
@@ -260,7 +280,7 @@ public class SdncUebCallback implements INotificationCallback {
 
                 LOG.info("Received artifact " + curArtifact.getArtifactName());
 
-                handleArtifact(data, data.getServiceName(), null, curArtifact, incomingDir, archiveDir);
+                               handleArtifact(data, data.getServiceName(), null, null, curArtifact, incomingDir, archiveDir);
             }
         }
 
@@ -287,7 +307,7 @@ public class SdncUebCallback implements INotificationCallback {
 
                     LOG.info("Received artifact " + curArtifact.getArtifactName());
 
-                    handleArtifact(data, data.getServiceName(), curResource.getResourceName(), curArtifact, incomingDir, archiveDir);
+                                       handleArtifact(data, data.getServiceName(), curResource.getResourceName(), curResource.getResourceType(), curArtifact, incomingDir, archiveDir);
                 }
             }
         }
@@ -330,8 +350,14 @@ public class SdncUebCallback implements INotificationCallback {
         }
 
         // Deploy scheduled deployments
+        int numPasses = config.getMaxPasses();
+
+        deployList = new LinkedList[numPasses];
 
-        for (int pass = 0 ; pass < NUM_PASSES ; pass++) {
+        for (int i = 0 ; i < numPasses ; i++) {
+                       deployList[i] = new LinkedList<DeployableArtifact>();
+        }
+        for (int pass = 0 ; pass < config.getMaxPasses() ; pass++) {
 
             if (deployList[pass] != null) {
                 while (! deployList[pass].isEmpty()) {
@@ -350,7 +376,7 @@ public class SdncUebCallback implements INotificationCallback {
 
                     IArtifactInfo artifactInfo = artifact.getArtifactInfo();
 
-                    if (artifactInfo != null && data != null) {
+                                       if ((artifactInfo != null) && (data != null)) {
                         IDistributionClientResult deploymentStatus;
                             deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(
                                     client, data, artifactInfo,
@@ -362,13 +388,26 @@ public class SdncUebCallback implements INotificationCallback {
         }
     }
 
-    private void handleArtifact(INotificationData data, String svcName, String resourceName, IArtifactInfo artifact, File incomingDir, File archiveDir) {
+       private void handleArtifact(INotificationData data, String svcName, String resourceName, String resourceType, IArtifactInfo artifact, File incomingDir, File archiveDir) {
 
         // Download Artifact
         IDistributionClientDownloadResult downloadResult = client
                 .download(artifact);
 
-        String payload = new String(downloadResult.getArtifactPayload());
+               if (downloadResult == null) {
+
+                       handleFailedDownload(data, artifact);
+                       return;
+               }
+
+               byte[] payloadBytes = downloadResult.getArtifactPayload();
+
+               if (payloadBytes == null) {
+                       handleFailedDownload(data, artifact);
+                       return;
+               }
+
+               String payload = new String(payloadBytes);
 
 
         File spoolFile = new File(incomingDir.getAbsolutePath() + "/" + artifact.getArtifactName());
@@ -385,7 +424,7 @@ public class SdncUebCallback implements INotificationCallback {
         }
 
 
-        if (writeSucceeded && downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) {
+               if (writeSucceeded && (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS)) {
             handleSuccessfulDownload(data, svcName, resourceName, artifact, spoolFile, archiveDir);
 
 
@@ -406,7 +445,7 @@ public class SdncUebCallback implements INotificationCallback {
     private void handleSuccessfulDownload(INotificationData data, String svcName, String resourceName,
             IArtifactInfo artifact, File spoolFile, File archiveDir) {
 
-        if (data != null && artifact != null) {
+               if ((data != null) && (artifact != null)) {
             // Send Download Status
             IDistributionClientResult sendDownloadStatus = client
                     .sendDownloadStatus(buildStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK));
@@ -415,11 +454,19 @@ public class SdncUebCallback implements INotificationCallback {
         // If an override file exists, read that instead of the file we just downloaded
         ArtifactTypeEnum artifactEnum = ArtifactTypeEnum.YANG_XML;
 
+               boolean toscaYamlType = false;
         if (artifact != null) {
-                artifact.getArtifactType();
+                       String artifactTypeString = artifact.getArtifactType();
+                       if (artifactTypeString.contains("TOSCA_TEMPLATE")) {
+                               toscaYamlType = true;
+                       }
+               } else {
+                       if (spoolFile.toString().contains(".yml") || spoolFile.toString().contains(".csar")) {
+                               toscaYamlType = true;
+                       }
         }
         String overrideFileName = config.getOverrideFile();
-        if (overrideFileName != null && overrideFileName.length() > 0) {
+               if ((overrideFileName != null) && (overrideFileName.length() > 0)) {
             File overrideFile = new File(overrideFileName);
 
             if (overrideFile.exists()) {
@@ -429,13 +476,30 @@ public class SdncUebCallback implements INotificationCallback {
 
         }
 
+               if (toscaYamlType == true) {
+                       processToscaYaml (data, svcName, resourceName, artifact, spoolFile, archiveDir);
+
+                       try {
+                               Path source = spoolFile.toPath();
+                               Path targetDir = archiveDir.toPath();
+
+                               Files.move(source, targetDir.resolve(source.getFileName()), StandardCopyOption.REPLACE_EXISTING);
+                       } catch (IOException e) {
+                               LOG.warn("Could not move "+spoolFile.getAbsolutePath()+" to "+archiveDir.getAbsolutePath(), e);
+                       }
+
+                       return;
+               }
+
         // Process spool file
         Document spoolDoc = null;
         File transformedFile = null;
 
         // Apply XSLTs and get Doc object
         try {
+                       if (!spoolFile.isDirectory()) {
             transformedFile = applyXslts(spoolFile);
+                       }
         } catch (Exception e) {
             LOG.error("Caught exception trying to parse XML file", e);
         }
@@ -467,7 +531,7 @@ public class SdncUebCallback implements INotificationCallback {
             SdncArtifactType artifactType = analyzeFileType(artifactEnum,
                     spoolFile, spoolDoc);
 
-            if (artifactType != SdncArtifactType.UNKNOWN) {
+            if (artifactType != null) {
 
                 scheduleDeployment(artifactType, svcName, resourceName, artifact, spoolFile.getName(), transformedFile);
 
@@ -489,11 +553,285 @@ public class SdncUebCallback implements INotificationCallback {
     }
 
 
+       private void processToscaYaml(INotificationData data, String svcName, String resourceName,
+                       IArtifactInfo artifact, File spoolFile, File archiveDir) {
+               
+               // Use ASDC Dist Client 1.1.5 with TOSCA parsing APIs to extract relevant TOSCA model data
+               
+               // TOSCA data extraction flow 1707:
+               // Use ASDC dist-client to get yaml string - not yet available
+               String model_yaml = null;
+               LOG.info("Process TOSCA YAML file: "+spoolFile.toString());
+               
+               SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+               ISdcCsarHelper sdcCsarHelper = null;
+               try {
+                       sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath());
+               } catch (SdcToscaParserException e) {
+                       LOG.error("Could not create SDC TOSCA Parser ", e);
+                       factory.close();
+                       return;
+               }
+
+               // Ingest Service Data - 1707
+               Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata();
+               SdncServiceModel serviceModel = new SdncServiceModel(sdcCsarHelper, serviceMetadata);
+               serviceModel.setFilename(spoolFile.toString().substring(spoolFile.toString().lastIndexOf("/")+1));  // will be csar file name
+               serviceModel.setServiceInstanceNamePrefix(SdncBaseModel.extractSubstitutionMappingTypeName(sdcCsarHelper).substring(SdncBaseModel.extractSubstitutionMappingTypeName(sdcCsarHelper).lastIndexOf(".")+1));
+
+               try {
+                       cleanUpExistingToscaServiceData(serviceModel.getServiceUUID());
+                       LOG.info("Call insertToscaData for SERVICE_MODEL serviceUUID = " + serviceModel.getServiceUUID());
+                       insertToscaData(serviceModel.getSql(model_yaml));
+               } catch (IOException e) {
+                       LOG.error("Could not insert Tosca YAML data into the SERVICE_MODEL table ", e);
+                       factory.close();
+                       return;
+               }       
+
+               // Ingest Network (VL) Data - 1707
+               //List<NodeTemplate> vlNodeTemplatesList = sdcCsarHelper.getServiceNodeTemplatesByType("VL");
+               List<NodeTemplate> vlNodeTemplatesList = sdcCsarHelper.getServiceVlList();
+
+               for (NodeTemplate nodeTemplate :  vlNodeTemplatesList) {
+                       SdncNodeModel nodeModel = new SdncNodeModel (sdcCsarHelper, nodeTemplate);
+                       nodeModel.setServiceUUID(serviceModel.getServiceUUID());
+                       nodeModel.setEcompGeneratedNaming(SdncBaseModel.extractBooleanInputDefaultValue(sdcCsarHelper, SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_ECOMPGENERATEDNAMING));//service_naming#default#ecomp_generated_naming
+                       
+                       try {
+                               cleanUpExistingToscaData("NETWORK_MODEL", "customization_uuid", nodeModel.getCustomizationUUID());
+                               cleanUpExistingToscaData("VPN_BINDINGS", "network_customization_uuid", nodeModel.getCustomizationUUID());
+                               LOG.info("Call insertToscaData for NETWORK_MODEL customizationUUID = " + nodeModel.getCustomizationUUID());
+                               // using ASDC dist-client use method for get yaml string
+                               insertToscaData(nodeModel.getSql(model_yaml));
+                               insertToscaData(nodeModel.getVpnBindingsSql());
+                       } catch (IOException e) {
+                               LOG.error("Could not insert Tosca YAML data into the NETWORK_MODEL table ", e);
+                       }
+               }
+               
+               // Ingest Allotted Resource Data - 1707
+               List<NodeTemplate> arNodeTemplatesList = sdcCsarHelper.getAllottedResources();
+
+               for (NodeTemplate nodeTemplate :  arNodeTemplatesList) {
+                       SdncARModel nodeModel = new SdncARModel (sdcCsarHelper, nodeTemplate);
+                       
+                       try {
+                               cleanUpExistingToscaData("ALLOTTED_RESOURCE_MODEL", "customization_uuid", nodeModel.getCustomizationUUID());
+                               LOG.info("Call insertToscaData for ALLOTTED_RESOURCE_MODEL customizationUUID = " + nodeModel.getCustomizationUUID());
+                               // using ASDC dist-client use method for get yaml string
+                               insertToscaData(nodeModel.getSql("ALLOTTED_RESOURCE_MODEL", model_yaml));
+                       } catch (IOException e) {
+                               LOG.error("Could not insert Tosca YAML data into the NETWORK_MODEL table ", e);
+                       }
+               }
+               
+               // Ingest Network (VF) Data - 1707
+               //List<NodeTemplate> nodeTemplatesList = sdcCsarHelper.getServiceNodeTemplatesByType("VF");
+               List<NodeTemplate> vfNodeTemplatesList = sdcCsarHelper.getServiceVfList();
+
+               for (NodeTemplate nodeTemplate :  vfNodeTemplatesList) {
+                       SdncVFModel vfNodeModel = new SdncVFModel (sdcCsarHelper, nodeTemplate);
+                       
+                       try {
+                               cleanUpExistingToscaData("VF_MODEL", "customization_uuid", vfNodeModel.getCustomizationUUID()) ;
+                               LOG.info("Call insertToscaData for VF_MODEL customizationUUID = " + vfNodeModel.getCustomizationUUID());
+                               insertToscaData(vfNodeModel.getSql("VF_MODEL", model_yaml));
+                       } catch (IOException e) {
+                               LOG.error("Could not insert Tosca YAML data into the VF_MODEL table ", e);
+                       }
+                       
+                       // For each VF, insert VF_MODULE_MODEL data
+                       List<Group> vfModules = sdcCsarHelper.getVfModulesByVf(vfNodeModel.getCustomizationUUIDNoQuotes());
+                       for (Group group : vfModules){
+                               SdncVFModuleModel vfModuleModel = new SdncVFModuleModel(sdcCsarHelper, group);
+                       
+                               try {
+                                       cleanUpExistingToscaData("VF_MODULE_MODEL", "customization_uuid", vfModuleModel.getCustomizationUUID());
+                                       LOG.info("Call insertToscaData for VF_MODULE_MODEL customizationUUID = " + vfModuleModel.getCustomizationUUID());
+                                       insertToscaData(vfModuleModel.getSql("VF_MODULE_MODEL", model_yaml));
+                               } catch (IOException e) {
+                                       LOG.error("Could not insert Tosca YAML data into the VF_MODULE_MODEL table ", e);
+                               }
+                       
+                               // For each VF Module, get the VFC list, insert VF_MODULE_TO_VFC_MAPPING data
+                               // List<NodeTemplate> groupMembers = sdcCsarHelper.getMembersOfGroup(group); - old version
+                               // For each vfcNode (group member) in the groupMembers list, extract vm_type and vm_count.  
+                               // Insert vf_module.customizationUUID, vfcNode.customizationUUID and vm_type and vm_count into VF_MODULE_TO_VFC_MAPPING
+                               List<NodeTemplate> groupMembers = sdcCsarHelper.getMembersOfVfModule(nodeTemplate, group); // not yet available
+                               for (NodeTemplate vfcNode : groupMembers){
+                                       SdncVFCModel vfcModel = new SdncVFCModel(sdcCsarHelper, vfcNode);
+                               
+                                       try {
+                                               cleanUpExistingToscaData("VF_MODULE_TO_VFC_MAPPING", "vf_module_customization_uuid", vfModuleModel.getCustomizationUUID());
+                                               LOG.info("Call insertToscaData for VF_MODULE_TO_VFC_MAPPING customizationUUID = " + vfModuleModel.getCustomizationUUID());
+                                               insertToscaData("insert into VF_MODULE_TO_VFC_MAPPING (vf_module_customization_uuid, vfc_customization_uuid, vm_type, vm_count) values (" + 
+                                                               vfModuleModel.getCustomizationUUID() + ", " + vfcModel.getCustomizationUUID() + ", \"" + vfcModel.getVmType() + "\", \"" + vfcModel.getVmCount() + "\")");
+                                       } catch (IOException e) {
+                                               LOG.error("Could not insert Tosca YAML data into the VF_MODULE_TO_VFC_MAPPING table ", e);
+                                       }
+
+                               }
+
+                       }
+                       
+                       // For each VF, insert VFC_MODEL data
+                       List<NodeTemplate> vfcNodes = sdcCsarHelper.getVfcListByVf(vfNodeModel.getCustomizationUUIDNoQuotes());
+                       for (NodeTemplate vfcNode : vfcNodes){
+                               SdncVFCModel vfcModel = new SdncVFCModel(sdcCsarHelper, vfcNode);
+                       
+                               try {
+                                       cleanUpExistingToscaData("VFC_MODEL", "customization_uuid", vfcModel.getCustomizationUUID());
+                                       LOG.info("Call insertToscaData for VFC_MODEL customizationUUID = " + vfcModel.getCustomizationUUID());
+                                       insertToscaData(vfcModel.getSql("VFC_MODEL", model_yaml));
+                               } catch (IOException e) {
+                                       LOG.error("Could not insert Tosca YAML data into the VFC_MODEL table ", e);
+                               }
+
+                       }
+                       
+                       // For each VF, insert VF_TO_NETWORK_ROLE_MAPPING data
+                       List<NodeTemplate> cpNodes = sdcCsarHelper.getCpListByVf(vfNodeModel.getCustomizationUUIDNoQuotes());
+                       for (NodeTemplate cpNode : cpNodes){
+               
+                               // Insert into VF_TO_NETWORK_ROLE_MAPPING vf_customization_uuid and network_role
+                               String cpNetworkRole = sdcCsarHelper.getNodeTemplatePropertyLeafValue(cpNode, "network_role_tag");
+                       
+                               try {
+                                       cleanUpExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", "vf_customization_uuid", vfNodeModel.getCustomizationUUID());
+                                       LOG.info("Call insertToscaData for VF_TO_NETWORK_ROLE_MAPPING vfCustomizationUUID = " + vfNodeModel.getCustomizationUUID());
+                                       insertToscaData("insert into VF_TO_NETWORK_ROLE_MAPPING (vf_customization_uuid, network_role) values (" + 
+                                       vfNodeModel.getCustomizationUUID() + ", \"" + cpNetworkRole + "\")");
+                               } catch (IOException e) {
+                                       LOG.error("Could not insert Tosca YAML data into the VF_TO_NETWORK_ROLE_MAPPING table ", e);
+                               }
+                               
+                               // Insert VFC_TO_NETWORK_ROLE_MAPPING data
+                               Map<String, String> mappingParams = new HashMap<String, String>();
+                               //String cpNetworkRoleTag = "\"" + sdcCsarHelper.getNodeTemplatePropertyLeafValue(cpNode, SdcPropertyNames.PROPERTY_NAME_NETWORKROLETAG) + "\"";
+                               // extract network_role, network_role_tag and virtual_binding from this cpNode
+                               SdncBaseModel.addParameter("network_role", SdncBaseModel.extractValue(sdcCsarHelper, cpNode, "network_role"), mappingParams);
+                               SdncBaseModel.addParameter("network_role_tag", SdncBaseModel.extractValue(sdcCsarHelper, cpNode, "network_role_tag"), mappingParams);
+                               String virtualBinding = "\"" + SdncBaseModel.extractValue(sdcCsarHelper, cpNode, "requirements#virtualBinding") + "\""; 
+
+                               // get list of cpNodes and vfcNodes with matching virtualBinding
+                               List<Pair<NodeTemplate, NodeTemplate>> matchList = sdcCsarHelper.getNodeTemplatePairsByReqName(sdcCsarHelper.getCpListByVf(vfNodeModel.getCustomizationUUIDNoQuotes()), sdcCsarHelper.getVfcListByVf(vfNodeModel.getCustomizationUUIDNoQuotes()), virtualBinding);                              
+                               for (Pair<NodeTemplate, NodeTemplate> match : matchList) {  // should be 1 match?
+                                       
+                                       // extract values from the left "CP" Node
+                                       SdncBaseModel.addParameter("ipv4_use_dhcp", SdncBaseModel.extractBooleanValue(sdcCsarHelper, match.getLeft(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_DHCPENABLED), mappingParams);
+                                       //SdncBaseModel.addParameter("ipv4_ip_version", SdncBaseModel.extractValue(sdcCsarHelper, match.getLeft(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_IPVERSION), mappingParams);
+                                       SdncBaseModel.addParameter("ipv4_ip_version", "dummy_ipv4_vers", mappingParams);
+                                       SdncBaseModel.addParameter("ipv6_use_dhcp", SdncBaseModel.extractBooleanValue(sdcCsarHelper, match.getLeft(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_DHCPENABLED), mappingParams);
+                                       //SdncBaseModel.addParameter("ipv6_ip_version", SdncBaseModel.extractValue(sdcCsarHelper, match.getLeft(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_IPVERSION), mappingParams);
+                                       SdncBaseModel.addParameter("ipv6_ip_version", "dummy_ipv6_vers", mappingParams);
+                                       //String extcp_subnetpool_id = "\"" + SdncBaseModel.extractValue(sdcCsarHelper, match.getLeft(), SdcPropertyNames.PROPERTY_NAME_SUBNETPOOLID) + "\""; // need path to subnetpoolid 
+                                       
+                                       // extract values from the right "VFC" Node
+                                       String vfcCustomizationUuid = "\"" + SdncBaseModel.extractValue(sdcCsarHelper, match.getRight().getMetadata(), "customization_uuid") + "\"";
+                                       SdncBaseModel.addParameter("vm_type", SdncBaseModel.extractValue(sdcCsarHelper, match.getRight(), SdcPropertyNames.PROPERTY_NAME_VMTYPE), mappingParams);
+                                       SdncBaseModel.addIntParameter("ipv4_count", SdncBaseModel.extractValue(sdcCsarHelper, match.getRight(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_MINSUBNETSCOUNT), mappingParams);
+                                       SdncBaseModel.addIntParameter("ipv6_count", SdncBaseModel.extractValue(sdcCsarHelper, match.getRight(), SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_MINSUBNETSCOUNT), mappingParams);
+                               
+                                       try {
+                                               cleanUpExistingToscaData("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", vfcCustomizationUuid);
+                                               LOG.info("Call insertToscaData for VFC_TO_NETWORK_ROLE_MAPPING vfcCustomizationUUID = " + vfcCustomizationUuid);
+                                               insertToscaData(SdncBaseModel.getSql("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", vfcCustomizationUuid, "", mappingParams));
+                                       } catch (IOException e) {
+                                               LOG.error("Could not insert Tosca YAML data into the VFC_TO_NETWORK_ROLE_MAPPING table ", e);
+                                       }
+                               
+                               }       
+                               
+                       } // CP loop    
+                       
+               } // VF loop
+               
+               // Close ASDC TOSCA Parser factory - we are done processing this distribution
+               factory.close();
+               
+               if ((artifact != null) && (data != null)) {
+                       LOG.info("Update to SDN-C succeeded");
+                       IDistributionClientResult deploymentStatus;
+                               deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(
+                                               client, data, artifact,
+                                               DistributionStatusEnum.DEPLOY_OK));
+               }
+       
+       }
+       
+        private void cleanUpExistingToscaData(String tableName, String keyName, String keyValue) throws IOException
+     {
+         
+            if (jdbcDataSource == null) {
+                setJdbcDataSource();
+            }
+             try {
+               int rowCount = 0;
+               CachedRowSet data = jdbcDataSource.getData("SELECT * from " + tableName + " where " + keyName + " = " + keyValue + ";", null, "");
+               while(data.next()) { 
+                               rowCount ++; 
+               }
+               if (rowCount != 0) {
+                    LOG.info("cleanUpExistingToscaData: " + keyValue);
+                               jdbcDataSource.writeData("DELETE from " + tableName + " where " + keyName + " = " + keyValue + ";", null, null);
+               }
+                
+                       } catch (SQLException e) {                              
+                               LOG.error("Could not clean up existing " + tableName  + " for " + keyValue, e);
+                       }    
+                       
+     }
+
+       
+        private void cleanUpExistingToscaServiceData(String serviceUUID) throws IOException
+     {
+         
+            if (jdbcDataSource == null) {
+                setJdbcDataSource();
+            }
+             try {
+               int rowCount = 0;
+               CachedRowSet data = jdbcDataSource.getData("SELECT * from SERVICE_MODEL where service_uuid = " + serviceUUID + ";", null, "");
+               while(data.next()) { 
+                               rowCount ++; 
+               }
+               if (rowCount != 0) {
+                    LOG.info("cleanUpExistingToscaData: " + serviceUUID);
+                               jdbcDataSource.writeData("DELETE from NETWORK_MODEL where service_uuid = " + serviceUUID + ";", null, null);
+                               jdbcDataSource.writeData("DELETE from SERVICE_MODEL where service_uuid = " + serviceUUID + ";", null, null);
+               }
+                
+                       } catch (SQLException e) {                              
+                               LOG.error("Could not clean up existing NETWORK_MODEL and SERVICE_MODEL for service_UUID " + serviceUUID, e);
+                       }    
+                       
+     }
+
+       
+        private void insertToscaData(String toscaDataString) throws IOException
+     {
+            LOG.debug("insertToscaData: " + toscaDataString);
+
+            if (jdbcDataSource == null) {
+                setJdbcDataSource();
+            }
+             try {
+
+                               jdbcDataSource.writeData(toscaDataString, null, null);
+
+                       } catch (SQLException e) {
+                               LOG.error("Could not insert Tosca YAML data into the database ", e);
+                       }
+
+     }
+
+
     private SdncArtifactType analyzeFileType(ArtifactTypeEnum artifactType, File spoolFile, Document spoolDoc) {
 
         if (artifactType != ArtifactTypeEnum.YANG_XML) {
             LOG.error("Unexpected artifact type - expecting YANG_XML, got "+artifactType);
-            return SdncArtifactType.UNKNOWN;
+                       return (null);
         }
 
         // Examine outer tag
@@ -511,21 +849,22 @@ public class SdncUebCallback implements INotificationCallback {
             }
 
             if (rootName != null) {
-                SdncArtifactType retValue = SdncArtifactType.fromTag(rootName);
+               SdncArtifactType mapEntry = config.getMapping(rootName);
 
-                if (retValue == SdncArtifactType.UNKNOWN) {
+
+                if (mapEntry == null) {
 
                     LOG.error("Unexpected file contents - root tag is "+rootName);
                 }
-                return retValue;
+                               return(mapEntry);
             } else {
                 LOG.error("Cannot get root tag from file");
-                return SdncArtifactType.UNKNOWN;
+                               return(null);
             }
 
         } catch (Exception e) {
             LOG.error("Could not parse YANG_XML file "+spoolFile.getName(), e);
-            return SdncArtifactType.UNKNOWN;
+                       return(null);
         }
     }
 
@@ -562,7 +901,7 @@ public class SdncUebCallback implements INotificationCallback {
 
 
         String namespace = config.getAsdcApiNamespace();
-        if (namespace == null || namespace.length() == 0) {
+               if ((namespace == null) || (namespace.length() == 0)) {
             namespace="com:att:sdnctl:asdcapi";
         }
 
@@ -602,7 +941,7 @@ public class SdncUebCallback implements INotificationCallback {
 
         } catch (Exception e) {
             LOG.error("Could not process spool file "+artifact.getFile().getName(), e);
-            return DistributionStatusEnum.DEPLOY_ERROR;
+                       return(DistributionStatusEnum.DEPLOY_ERROR);
         }
 
         msgBuffer.append("</input>\n");
@@ -646,7 +985,7 @@ public class SdncUebCallback implements INotificationCallback {
 
 
 
-        return deployResult;
+               return(deployResult);
     }
 
 
@@ -709,74 +1048,29 @@ public class SdncUebCallback implements INotificationCallback {
         conn.setDoOutput(true);
         conn.setUseCaches(false);
 
-        return conn;
+               return(conn);
 
     }
 
     private Document postRestXml(String urlString, byte[] msgBytes) {
         Document response = null;
 
-        LOG.info("Sending REST POST to "+urlString);
-        LOG.info("Message body:\n"+new String(msgBytes));
-
         try {
-            HttpURLConnection conn = getRestXmlConnection(urlString, "POST");
-
-            if (conn instanceof HttpsURLConnection) {
-                HostnameVerifier hostnameVerifier = new HostnameVerifier() {
-                    @Override
-                    public boolean verify(String hostname, SSLSession session) {
-                        return true;
-                    }
-                };
-                ((HttpsURLConnection)conn).setHostnameVerifier(hostnameVerifier);
-            }
-
-            // Write message
-            conn.setRequestProperty("Content-Length", ""+msgBytes.length);
-            DataOutputStream outStr = new DataOutputStream(conn.getOutputStream());
-            outStr.write(msgBytes);
-            outStr.close();
+                       SdncOdlConnection odlConn = SdncOdlConnection.newInstance(urlString, config.getSdncUser(), config.getSdncPasswd());
 
-
-            // Read response
-            BufferedReader respRdr;
-
-            LOG.info("Response: "+conn.getResponseCode()+" "+conn.getResponseMessage());
-
-
-            if (conn.getResponseCode() < 300) {
-
-                respRdr = new BufferedReader(new InputStreamReader(conn.getInputStream()));
-            } else {
-                respRdr = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
-            }
-
-            StringBuffer respBuff = new StringBuffer();
-
-            String respLn;
-
-            while ((respLn = respRdr.readLine()) != null) {
-                respBuff.append(respLn+"\n");
-            }
-            respRdr.close();
-
-            String respString = respBuff.toString();
-
-            LOG.info("Response body :\n"+respString);
+                       String sdncResp = odlConn.send("POST", "application/xml", new String(msgBytes));
 
             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
             DocumentBuilder db = dbf.newDocumentBuilder();
 
 
-            response = db.parse(new ByteArrayInputStream(respString.getBytes()));
-
+                       response = db.parse(new ByteArrayInputStream(sdncResp.getBytes()));
         } catch (Exception e) {
-
-            LOG.error("Caught exception in postRestXml", e);
+                       LOG.error("Caught exception posting to ODL tier", e);
         }
 
-        return response;
+               return(response);
+
     }
 
     private File applyXslts(File srcFile) {
@@ -789,7 +1083,7 @@ public class SdncUebCallback implements INotificationCallback {
 
         String xsltPathList = config.getXsltPathList();
 
-        if (xsltPathList == null || xsltPathList.length() == 0) {
+               if ((xsltPathList == null) || (xsltPathList.length() == 0)) {
             outFile = inFile;
         } else {
 
@@ -820,7 +1114,7 @@ public class SdncUebCallback implements INotificationCallback {
         // After transformations, parse transformed XML
 
 
-        return outFile;
+               return(outFile);
     }
 
     private String escapeFilename(String str) {
@@ -833,7 +1127,7 @@ public class SdncUebCallback implements INotificationCallback {
             }
         }
 
-        return retval.toString();
+               return(retval.toString());
 
     }
 
index dd6c514..bf4446f 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *             reserved.
+ *                                             reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index b7d9b98..6abc6f6 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *             reserved.
+ *                                             reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -55,6 +55,8 @@ public class SdncUebConfiguration implements IConfiguration{
        private String asdcApiBaseUrl = null;
        private String asdcApiNamespace = null;
 
+       private SdncArtifactMap artifactMap = SdncArtifactMap.getInstance();
+
        public String getAsdcApiNamespace() {
                return asdcApiNamespace;
        }
@@ -172,6 +174,10 @@ public class SdncUebConfiguration implements IConfiguration{
                xsltPathList = props.getProperty("org.openecomp.sdnc.uebclient.xslt-path-list");
 
 
+               String artifactMapFile = props.getProperty("org.openecomp.sdnc.uebclient.artifact-map");
+               if (artifactMapFile != null) {
+                       artifactMap.load(artifactMapFile);
+               }
 
        }
 
@@ -256,5 +262,19 @@ public class SdncUebConfiguration implements IConfiguration{
                return archiveDir;
        }
 
+       public int getMaxPasses() {
+               return(artifactMap.getNumPasses());
+       }
+
+       public SdncArtifactMap.SdncArtifactType getMapping(String tag) {
+               return(artifactMap.getMapping(tag));
+       }
+
+       @Override
+       public boolean isFilterInEmptyResources() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
 
 }
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFCModel.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFCModel.java
new file mode 100644 (file)
index 0000000..cf47fb5
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncVFCModel extends SdncBaseModel {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncVFCModel.class);
+       
+       private String vmType = null;
+       private String vmCount = null;
+
+       public SdncVFCModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
+
+               super(sdcCsarHelper, nodeTemplate);
+               
+               // extract properties
+               vmType = extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VMTYPE);
+               //vmCount = extractValue (sdcCsarHelper, nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VMCOUNT); - need path to vm_count
+               vmCount = "1";
+               addParameter("vm_type", vmType);
+               addParameter("vm_type_tag", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG));
+               addParameter("ecomp_generated_naming", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VFCNAMING_ECOMPGENERATEDNAMING));
+               addParameter("naming_policy", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VFCNAMING_NAMINGPOLICY));
+               addParameter("nfc_naming_code", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFCCODE));
+       }
+
+       public String getVmType() {
+               return vmType;
+       }
+
+       public void setVmType(String vmType) {
+               this.vmType = vmType;
+       }
+
+       public String getVmCount() {
+               return vmCount;
+       }
+
+       public void setVmCount(String vmCount) {
+               this.vmCount = vmCount;
+       }
+
+}
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFModel.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFModel.java
new file mode 100644 (file)
index 0000000..8793cf8
--- /dev/null
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.Metadata;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncVFModel extends SdncBaseModel {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncVFModel.class);
+
+       public SdncVFModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
+
+               super(sdcCsarHelper, nodeTemplate);
+
+               // extract metadata
+               Metadata metadata = nodeTemplate.getMetadata();
+               addParameter("name", extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_NAME));
+               addParameter("vendor", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDOR)); 
+               addParameter("vendor_version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDORRELEASE)); 
+               
+               // extract properties
+               addParameter("ecomp_generated_naming", extractBooleanValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VNFECOMPNAMING_ECOMPGENERATEDNAMING));
+               addParameter("naming_policy", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VNFECOMPNAMING_NAMINGPOLICY));
+               addParameter("nf_type", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+               addParameter("nf_role", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+               addParameter("nf_code", extractValue( nodeTemplate, "nf_naming_code"));
+               addParameter("nf_function", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+               addParameter("avail_zone_max_count", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONEMAXCOUNT));
+       }
+
+}
diff --git a/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFModuleModel.java b/ueb-listener/src/main/java/org/openecomp/sdnc/uebclient/SdncVFModuleModel.java
new file mode 100644 (file)
index 0000000..20165a1
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.uebclient;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.Group;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdncVFModuleModel extends SdncBaseModel {
+       
+       private static final Logger LOG = LoggerFactory
+                       .getLogger(SdncVFModuleModel.class);
+       
+       public SdncVFModuleModel(ISdcCsarHelper sdcCsarHelper, Group group) {
+
+               super(sdcCsarHelper, group);
+               
+               // extract properties
+               addParameter("vf_module_type", extractValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE));
+               addIntParameter("availability_zone_count", extractValue(group, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT));
+               addParameter("ecomp_generated_vm_assignments", extractBooleanValue(group, SdcPropertyNames.PROPERTY_NAME_ECOMPGENERATEDVMASSIGNMENTS));
+       }
+
+}
index 274f2d4..dbfe694 100644 (file)
@@ -3,7 +3,7 @@
 # openECOMP : SDN-C
 # ================================================================================
 # Copyright (C) 2017 AT&T Intellectual Property. All rights
-#             reserved.
+#                                              reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
 # ============LICENSE_END=========================================================
 ###
 
-log4j.rootCategory=INFO,CONSOLE,LOGFILE
+log4j.rootLogger=DEBUG,CONSOLE,LOGFILE
 
 # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
diff --git a/ueb-listener/src/main/scripts/start-ueb-listener.sh b/ueb-listener/src/main/scripts/start-ueb-listener.sh
new file mode 100644 (file)
index 0000000..d59eea7
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. 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.
+# ============LICENSE_END=========================================================
+###
+
+PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
+
+
+LISTENER=ueb-listener
+
+PIDFILE=/tmp/.${LISTENER}-pid
+UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/ueb-listener}
+JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-oracle}
+JAVA_OPTS=${JAVA_OPTS:--Dhttps.protocols=TLSv1.1,TLSv1.2}
+JAVA=${JAVA:-${JAVA_HOME}/bin/java}
+
+# Redirect output from script to $LISTENER.out
+exec >> ${UEBLISTENERROOT}/logs/$LISTENER.out
+exec 2>&1
+
+if [ -f $PIDFILE ]
+then
+  pid=$(cat $PIDFILE)
+  if [ "$pid" != "" ]
+  then
+    if kill -0 $pid
+    then
+      echo "$LISTENER already running"
+      exit 0
+    fi
+  fi
+fi
+
+if [ ! -d ${UEBLISTENERROOT}/logs ]
+then
+  mkdir ${UEBLISTENERROOT}/logs
+fi
+
+for file in ${UEBLISTENERROOT}/lib/*.jar
+do
+  LISTENERCLASSPATH=$LISTENERCLASSPATH:$file
+done
+
+${JAVA} ${JAVA_OPTS} -jar ${UEBLISTENERROOT}/lib/ueb-listener*.jar -Dlog4j.configuration=file:${UEBLISTENERROOT}/lib/log4j.properties -cp ${LISTENERCLASSPATH} &
+
+
+echo $! > $PIDFILE
+
+echo "$LISTENER started!"
+exit 0
diff --git a/ueb-listener/src/main/scripts/stop-ueb-listener.sh b/ueb-listener/src/main/scripts/stop-ueb-listener.sh
new file mode 100644 (file)
index 0000000..381266d
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. 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.
+# ============LICENSE_END=========================================================
+###
+
+PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
+
+if [ -f ${PROPERTY_DIR}/dmaap-listener.properties ]
+then
+       LISTENER=dmaap-listener
+else
+       LISTENER=ueb-listener
+fi
+
+PIDFILE=/tmp/.${LISTENER}-pid
+UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/ueb-listener}
+
+if [ -f $PIDFILE ]
+then
+  pid=$(cat $PIDFILE)
+  if [ "$pid" != "" ]
+  then
+    if kill -0 $pid
+      then
+       echo "Stopping $LISTENER"
+        kill $pid && rm $PIDFILE
+        exit 0
+      else
+        echo "$LISTENER not running"
+        exit 1
+      fi
+  else
+      echo "$LISTENER not running"
+      exit 1
+  fi
+fi
+
+
index fb2cb29..19ff8bd 100644 (file)
@@ -3,7 +3,7 @@
 ~~ openECOMP : SDN-C
 ~~ ================================================================================
 ~~ Copyright (C) 2017 AT&T Intellectual Property. All rights
-~~             reserved.
+~~                                             reserved.
 ~~ ================================================================================
 ~~ Licensed under the Apache License, Version 2.0 (the "License");
 ~~ you may not use this file except in compliance with the License.
index 1d4e73f..4118c7b 100644 (file)
@@ -4,7 +4,7 @@
   openECOMP : SDN-C
   ================================================================================
   Copyright (C) 2017 AT&T Intellectual Property. All rights
-              reserved.
+                                               reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
index 2758a48..813459d 100644 (file)
@@ -4,7 +4,7 @@
   openECOMP : SDN-C
   ================================================================================
   Copyright (C) 2017 AT&T Intellectual Property. All rights
-                                               reserved.
+                                                       reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
index ee68113..88b38e9 100755 (executable)
@@ -60,7 +60,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                        <execution>
@@ -75,7 +74,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                </executions>
index f8bf5a2..c7fb0c1 100644 (file)
@@ -3,7 +3,7 @@
   openECOMP : SDN-C
   ================================================================================
   Copyright (C) 2017 AT&T Intellectual Property. All rights
-                                               reserved.
+                                                       reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
     xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
     <formats>
         <format>zip</format>
     </formats>
index c2b3ecc..b37b3f1 100644 (file)
@@ -3,7 +3,7 @@
   openECOMP : SDN-C
   ================================================================================
   Copyright (C) 2017 AT&T Intellectual Property. All rights
-                                               reserved.
+                                                       reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
     xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
     <formats>
         <format>zip</format>
     </formats>
index 93236c5..6e8620e 100644 (file)
@@ -5,7 +5,7 @@
 # openECOMP : SDN-C
 # ================================================================================
 # Copyright (C) 2017 AT&T Intellectual Property. All rights
-#                                              reserved.
+#                                                      reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
index f61b3e7..83e3e4c 100755 (executable)
@@ -122,6 +122,17 @@ module VNF-API {
             leaf vnf-request-version {\r
                 type string; \r
             }\r
+            leaf model-customization-uuid {\r
+                type string; \r
+                description "customized resource, i.e. vf-module, for use within a given service";\r
+            }\r
+            leaf use-preload {\r
+                type enumeration { \r
+                    enum "Y";\r
+                    enum "N";\r
+                }\r
+                description "orchestrate vf-module with full preload data or TOSCA lookup plus EIPAM automation";\r
+            }\r
             leaf vnf-id {\r
                 type string; \r
                 description "vf-module-id";\r
index 56a1b18..4302a17 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                                             reserved.
+ *                                                     reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 2df2bfa..4b07aab 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                                             reserved.
+ *                                                     reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index e15a986..e356baa 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                                             reserved.
+ *                                                     reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 7435963..4a41aac 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                                             reserved.
+ *                                                     reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 0d31c07..92ba08d 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                                             reserved.
+ *                                                     reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -797,7 +797,37 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                                }
                        }
                }
+
        }
+    private void DeleteVnfList (final VnfList entry, LogicalDatastoreType storeType) throws IllegalStateException {
+        // Each entry will be identifiable by a unique key, we have to create that identifier
+               InstanceIdentifier.InstanceIdentifierBuilder<VnfList> vnfListIdBuilder =
+                               InstanceIdentifier.<Vnfs>builder(Vnfs.class)
+                               .child(VnfList.class, entry.getKey());
+               InstanceIdentifier<VnfList> path = vnfListIdBuilder.toInstance();
+
+        int tries = 2;
+        while (true) {
+            try {
+                WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+                tx.delete(storeType, path);
+                tx.submit().checkedGet();
+                log.debug("DataStore delete succeeded");
+                break;
+            } catch (final TransactionCommitFailedException e) {
+                if (e instanceof OptimisticLockFailedException) {
+                    if (--tries <= 0) {
+                        log.debug("Got OptimisticLockFailedException on last try - failing ");
+                        throw new IllegalStateException(e);
+                    }
+                    log.debug("Got OptimisticLockFailedException - trying again ");
+                } else {
+                    log.debug("Delete DataStore failed");
+                    throw new IllegalStateException(e);
+                }
+            }
+        }
+    }
 
        //1610 vnf-instance
        private void SaveVnfInstanceList (final VnfInstanceList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException {
@@ -1630,12 +1660,16 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                        if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
                        {
                                // Only update operational tree on Delete or Activate
-                               if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) ||
-                                   input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
-                               {
+                               if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
                                        log.info("Updating OPERATIONAL tree.");
                                        SaveVnfList (vnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
                                }
+                               else if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) ||
+                                   input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Rollback)) {
+                                           log.info("Delete OPERATIONAL tree.");
+                                           DeleteVnfList (vnfListBuilder.build(), LogicalDatastoreType.CONFIGURATION);
+                                           DeleteVnfList (vnfListBuilder.build(), LogicalDatastoreType.OPERATIONAL);
+                }
                        }
                        VnfInformationBuilder vnfInformationBuilder = new VnfInformationBuilder();
                        vnfInformationBuilder.setVnfId(siid);
index eebba0c..01f156d 100644 (file)
@@ -4,7 +4,7 @@
   openECOMP : SDN-C
   ================================================================================
   Copyright (C) 2017 AT&T Intellectual Property. All rights
-                                               reserved.
+                                                       reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
index b131f83..320f30d 100644 (file)
@@ -3,7 +3,7 @@
  * openECOMP : SDN-C
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                                             reserved.
+ *                                                     reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 203d565..556de91 100644 (file)
@@ -3,7 +3,7 @@
 # openECOMP : SDN-C
 # ================================================================================
 # Copyright (C) 2017 AT&T Intellectual Property. All rights
-#                                              reserved.
+#                                                      reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
index 9b10afd..96a105c 100644 (file)
@@ -3,7 +3,7 @@
 # openECOMP : SDN-C
 # ================================================================================
 # Copyright (C) 2017 AT&T Intellectual Property. All rights
-#                                              reserved.
+#                                                      reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
index 796b159..d08e313 100755 (executable)
@@ -60,7 +60,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                        <execution>
@@ -75,7 +74,6 @@
                                                        <descriptors>
                                                                <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
                                                        </descriptors>
-                                                       <appendAssemblyId>false</appendAssemblyId>
                                                </configuration>
                                        </execution>
                                </executions>
index 85e2e1e..728afca 100644 (file)
@@ -25,7 +25,6 @@
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
        <formats>
                <format>zip</format>
        </formats>
index bf7805f..c14f8ae 100644 (file)
@@ -25,7 +25,6 @@
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>bin</id>
        <formats>
                <format>zip</format>
        </formats>