Package and Create Docker Image for Xacml PDP 10/78410/1
authorMichael Mokry <michael.mokry@att.com>
Wed, 13 Feb 2019 16:34:48 +0000 (10:34 -0600)
committerMichael Mokry <michael.mokry@att.com>
Wed, 13 Feb 2019 16:38:31 +0000 (10:38 -0600)
- Creates docker image of policy xacml-pdp
- Creates zip package of policy xacml-pdp
- Also committed changes from Healthcheck/Statitics review that were
allowed to be deferred

Change-Id: Ia5fb72be05a30a341692453fe4ff32c7b112e861
Issue-ID: POLICY-1436
Signed-off-by: Michael Mokry <michael.mokry@att.com>
18 files changed:
main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java
main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestServer.java
main/src/main/java/org/onap/policy/pdpx/main/startstop/Main.java
main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java
main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java
main/src/test/java/org/onap/policy/pdpx/main/startstop/TestMain.java
packages/policy-xacmlpdp-docker/pom.xml [new file with mode: 0644]
packages/policy-xacmlpdp-docker/src/main/docker/Dockerfile [new file with mode: 0644]
packages/policy-xacmlpdp-docker/src/main/docker/policy-pdpx.sh [new file with mode: 0644]
packages/policy-xacmlpdp-tarball/pom.xml [new file with mode: 0644]
packages/policy-xacmlpdp-tarball/src/main/package/tarball/assembly.xml [new file with mode: 0644]
packages/policy-xacmlpdp-tarball/src/main/resources/etc/defaultConfig.json [new file with mode: 0644]
packages/policy-xacmlpdp-tarball/src/main/resources/etc/logback.xml [new file with mode: 0644]
packages/policy-xacmlpdp-tarball/src/main/resources/etc/s3pConfig.json [new file with mode: 0644]
packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-keystore [new file with mode: 0644]
packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-truststore [new file with mode: 0644]
packages/pom.xml [new file with mode: 0644]
pom.xml

index ae950fd..b061c96 100644 (file)
@@ -49,20 +49,16 @@ public class XacmlPdpRestController {
 
     @GET
     @Path("healthcheck")
-    @Produces(MediaType.APPLICATION_JSON)
     @ApiOperation(value = "Perform a system healthcheck",
-            notes = "Provides healthy status of the Policy Xacml PDP component",
-            response = HealthCheckReport.class)
+            notes = "Provides healthy status of the Policy Xacml PDP component", response = HealthCheckReport.class)
     public Response healthcheck() {
         return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
     }
 
     @GET
     @Path("statistics")
-    @Produces(MediaType.APPLICATION_JSON)
     @ApiOperation(value = "Fetch current statistics",
-            notes = "Provides current statistics of the Policy Xacml PDP component",
-            response = StatisticsReport.class)
+            notes = "Provides current statistics of the Policy Xacml PDP component", response = StatisticsReport.class)
     public Response statistics() {
         return Response.status(Response.Status.OK).entity(new StatisticsProvider().fetchCurrentStatistics()).build();
     }
index 3a3992f..90f0bfa 100644 (file)
@@ -99,7 +99,7 @@ public class XacmlPdpRestServer implements Startable {
     public boolean stop() {
         for (final HttpServletServer server : servers) {
             try {
-                server.stop();
+                server.shutdown();
             } catch (final Exception exp) {
                 LOGGER.error("Failed to stop xacml pdp http server", exp);
             }
index 2e3c446..91b38f9 100644 (file)
@@ -41,6 +41,9 @@ public class Main {
     // The parameters read in from JSON
     private XacmlPdpParameterGroup parameterGroup;
 
+    // The argument message for some args that return a message
+    private String argumentMessage = null;
+
     /**
      * Instantiates the policy xacml pdp service.
      *
@@ -54,7 +57,7 @@ public class Main {
         final XacmlPdpCommandLineArguments arguments = new XacmlPdpCommandLineArguments();
         try {
             // The arguments return a string if there is a message to print and we should exit
-            final String argumentMessage = arguments.parse(args);
+            argumentMessage = arguments.parse(args);
             if (argumentMessage != null) {
                 LOGGER.info(argumentMessage);
                 return;
@@ -100,6 +103,15 @@ public class Main {
         return parameterGroup;
     }
 
+    /**
+     * Get the argumentMessage string.
+     *
+     * @return the argumentMessage
+     */
+    public String getArgumentMessage() {
+        return argumentMessage;
+    }
+
     /**
      * Shut down Execution.
      *
index ce0671a..d9a0e9b 100644 (file)
@@ -23,7 +23,9 @@ package org.onap.policy.pdpx.main.rest;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.Invocation;
@@ -33,6 +35,7 @@ import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 import org.junit.Test;
 import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
 import org.onap.policy.pdpx.main.parameters.CommonTestData;
 import org.onap.policy.pdpx.main.parameters.RestServerParameters;
@@ -56,10 +59,16 @@ public class TestXacmlPdpRestServer {
     @Test
     public void testHealthCheckSuccess() throws PolicyXacmlPdpException, InterruptedException {
         final String reportString = "Report [name=Policy Xacml PDP, url=self, healthy=true, code=200, message=alive]";
-        final Main main = startXacmlPdpService();
-        final HealthCheckReport report = performHealthCheck();
-        validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
-        stopXacmlPdpService(main);
+        try {
+            final Main main = startXacmlPdpService();
+            final HealthCheckReport report = performHealthCheck();
+            validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+            stopXacmlPdpService(main);
+        } catch (final Exception e) {
+            LOGGER.error("testHealthCheckSuccess failed", e);
+            fail("Test should not throw an exception");
+        }
+
     }
 
     @Test
@@ -69,12 +78,18 @@ public class TestXacmlPdpRestServer {
         final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
         restServerParams.setName(CommonTestData.PDPX_GROUP_NAME);
         final XacmlPdpRestServer restServer = new XacmlPdpRestServer(restServerParams);
-        restServer.start();
-        final HealthCheckReport report = performHealthCheck();
-        validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
-        assertTrue(restServer.isAlive());
-        assertTrue(restServer.toString().startsWith("XacmlPdpRestServer [servers="));
-        restServer.shutdown();
+
+        try {
+            restServer.start();
+            final HealthCheckReport report = performHealthCheck();
+            validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
+            assertTrue(restServer.isAlive());
+            assertTrue(restServer.toString().startsWith("XacmlPdpRestServer [servers="));
+            restServer.shutdown();
+        } catch (final Exception e) {
+            LOGGER.error("testHealthCheckSuccess failed", e);
+            fail("Test should not throw an exception");
+        }
     }
 
     private Main startXacmlPdpService() {
@@ -86,8 +101,8 @@ public class TestXacmlPdpRestServer {
         main.shutdown();
     }
 
-    private HealthCheckReport performHealthCheck() throws InterruptedException {
-        HealthCheckReport response = null;
+    private HealthCheckReport performHealthCheck() throws InterruptedException, IOException {
+
         final ClientConfig clientConfig = new ClientConfig();
 
         final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -98,15 +113,11 @@ public class TestXacmlPdpRestServer {
 
         final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
 
-        final long startTime = System.currentTimeMillis();
-        while (response == null && (System.currentTimeMillis() - startTime) < 120000) {
-            try {
-                response = invocationBuilder.get(HealthCheckReport.class);
-            } catch (final Exception exp) {
-                LOGGER.info("the server is not started yet. We will retry again");
-            }
+        if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+            throw new IllegalStateException("Cannot connect to port 6969");
         }
-        return response;
+
+        return invocationBuilder.get(HealthCheckReport.class);
     }
 
     private void validateReport(final String name, final String url, final boolean healthy, final int code,
index 303a3cf..b38e92d 100644 (file)
 package org.onap.policy.pdpx.main.rest;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
-
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 import org.junit.Test;
-
+import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
 import org.onap.policy.pdpx.main.parameters.CommonTestData;
 import org.onap.policy.pdpx.main.parameters.RestServerParameters;
@@ -49,38 +50,44 @@ public class TestXacmlPdpStatistics {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TestXacmlPdpStatistics.class);
 
-
     @Test
     public void testXacmlPdpStatistics_200() throws PolicyXacmlPdpException, InterruptedException {
-        final Main main = startXacmlPdpService();
-        StatisticsReport report = getXacmlPdpStatistics();
-
-        validateReport(report, 0, 200);
-        updateXacmlPdpStatistics();
-        report = getXacmlPdpStatistics();
-        validateReport(report, 1, 200);
-        stopXacmlPdpService(main);
-        XacmlPdpStatisticsManager.resetAllStatistics();
+        try {
+            final Main main = startXacmlPdpService();
+            StatisticsReport report = getXacmlPdpStatistics();
+            validateReport(report, 0, 200);
+            updateXacmlPdpStatistics();
+            report = getXacmlPdpStatistics();
+            validateReport(report, 1, 200);
+            stopXacmlPdpService(main);
+            XacmlPdpStatisticsManager.resetAllStatistics();
+        } catch (final Exception e) {
+            LOGGER.error("testApiStatistics_200 failed", e);
+            fail("Test should not throw an exception");
+        }
     }
 
     @Test
     public void testXacmlPdpStatistics_500() throws InterruptedException {
         final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
         restServerParams.setName(CommonTestData.PDPX_GROUP_NAME);
-
         final XacmlPdpRestServer restServer = new XacmlPdpRestServer(restServerParams);
-        restServer.start();
-        final StatisticsReport report = getXacmlPdpStatistics();
 
-        validateReport(report, 0, 500);
-        restServer.shutdown();
-        XacmlPdpStatisticsManager.resetAllStatistics();
+        try {
+            restServer.start();
+            final StatisticsReport report = getXacmlPdpStatistics();
+            validateReport(report, 0, 500);
+            restServer.shutdown();
+            XacmlPdpStatisticsManager.resetAllStatistics();
+        } catch (final Exception e) {
+            LOGGER.error("testApiStatistics_500 failed", e);
+            fail("Test should not throw an exception");
+        }
     }
 
 
     private Main startXacmlPdpService() {
-        final String[] XacmlPdpConfigParameters =
-            { "-c", "parameters/XacmlPdpConfigParameters.json" };
+        final String[] XacmlPdpConfigParameters = {"-c", "parameters/XacmlPdpConfigParameters.json"};
         return new Main(XacmlPdpConfigParameters);
     }
 
@@ -88,8 +95,8 @@ public class TestXacmlPdpStatistics {
         main.shutdown();
     }
 
-    private StatisticsReport getXacmlPdpStatistics() throws InterruptedException {
-        StatisticsReport response = null;
+    private StatisticsReport getXacmlPdpStatistics() throws InterruptedException, IOException {
+
         final ClientConfig clientConfig = new ClientConfig();
 
         final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -99,15 +106,12 @@ public class TestXacmlPdpStatistics {
         final WebTarget webTarget = client.target("http://localhost:6969/statistics");
 
         final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
-        final long startTime = System.currentTimeMillis();
-        while (response == null && (System.currentTimeMillis() - startTime) < 120000) {
-            try {
-                response = invocationBuilder.get(StatisticsReport.class);
-            } catch (final Exception exp) {
-                LOGGER.info("the server is not started yet. We will retry again");
-            }
+
+        if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+            throw new IllegalStateException("Cannot connect to port 6969");
         }
-        return response;
+
+        return invocationBuilder.get(StatisticsReport.class);
     }
 
     private void updateXacmlPdpStatistics() {
index 8178343..bfc8a2a 100644 (file)
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
 import org.onap.policy.pdpx.main.parameters.CommonTestData;
@@ -44,10 +45,11 @@ public class TestMain {
     }
 
     @Test
-    public void testMain_NoArguments() {
+    public void testMain_NoArguments() throws PolicyXacmlPdpException {
         final String[] xacmlPdpConfigParameters = {};
         final Main main = new Main(xacmlPdpConfigParameters);
         assertNull(main.getParameters());
+        main.shutdown();
     }
 
     @Test
@@ -60,7 +62,10 @@ public class TestMain {
     @Test
     public void testMain_Help() {
         final String[] xacmlPdpConfigParameters = {"-h"};
-        Main.main(xacmlPdpConfigParameters);
+        final Main main = new Main(xacmlPdpConfigParameters);
+        final String message = "-h,--help                     outputs the usage of this command";
+        Assert.assertTrue(main.getArgumentMessage().contains(message));
+
     }
 
     @Test
diff --git a/packages/policy-xacmlpdp-docker/pom.xml b/packages/policy-xacmlpdp-docker/pom.xml
new file mode 100644 (file)
index 0000000..bc45b3f
--- /dev/null
@@ -0,0 +1,176 @@
+<!--
+  ============LICENSE_START=======================================================
+   Copyright (C) 2019 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.
+
+  SPDX-License-Identifier: Apache-2.0
+  ============LICENSE_END=========================================================
+-->
+
+<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>
+    <parent>
+        <groupId>org.onap.policy.xacml-pdp</groupId>
+        <artifactId>packages</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+
+    <packaging>pom</packaging>
+    <artifactId>policy-xacmlpdp-docker</artifactId>
+    
+    <name>${project.artifactId}</name>
+    <description>Creates Policy Xacml PDP docker images</description>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <pdpx.project.version>${project.version}</pdpx.project.version>
+        <docker.skip>false</docker.skip>
+        <docker.skip.build>false</docker.skip.build>
+        <docker.skip.push>false</docker.skip.push>
+        <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
+        <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+        <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
+    </properties>
+
+    <build>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.groovy.maven</groupId>
+                <artifactId>gmaven-plugin</artifactId>
+                <version>1.0</version>
+                <executions>
+                    <execution>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                            <source>
+                                println 'Project version: ' + project.properties['pdpx.project.version'];
+                                def versionArray;
+                                if ( project.properties['pdpx.project.version'] != null ) {
+                                    versionArray = project.properties['pdpx.project.version'].split('-');
+                                }
+
+                                if ( project.properties['pdpx.project.version'].endsWith("-SNAPSHOT") ) {
+                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-SNAPSHOT-latest";
+                                } else {
+                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-STAGING-latest";
+                                }
+
+                                println 'New tag for docker: ' + project.properties['project.docker.latesttag.version'];
+                            </source>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>io.fabric8</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>0.19.1</version>
+
+                <configuration>
+                    <verbose>true</verbose>
+                    <apiVersion>1.23</apiVersion>
+                    <pullRegistry>${docker.pull.registry}</pullRegistry>
+                    <pushRegistry>${docker.push.registry}</pushRegistry>
+
+                    <images>
+                        <image>
+                            <name>onap/policy-xacml-pdp</name>
+                            <build>
+                                <cleanup>try</cleanup>
+                                <dockerFile>Dockerfile</dockerFile>
+                                <tags>
+                                    <tag>${project.version}</tag>
+                                    <tag>${project.version}-${maven.build.timestamp}</tag>
+                                    <tag>${project.docker.latesttag.version}</tag>
+                                </tags>
+                                <assembly>
+                                    <inline>
+                                        <dependencySets>
+                                            <dependencySet>
+                                                <includes>
+                                                    <include>org.onap.policy.xacmlpdp:policy-xacmlpdp-tarball</include>
+                                                </includes>
+                                                <outputDirectory>/lib</outputDirectory>
+                                                <outputFileNameMapping>policy-xacmlpdp.tar.gz</outputFileNameMapping>
+                                            </dependencySet>
+                                        </dependencySets>
+                                    </inline>
+                                </assembly>
+                            </build>
+                        </image>
+                    </images>
+                </configuration>
+
+                <executions>
+                    <execution>
+                        <id>clean-images</id>
+                        <phase>pre-clean</phase>
+                        <goals>
+                            <goal>remove</goal>
+                        </goals>
+                        <configuration>
+                            <removeAll>true</removeAll>
+                        </configuration>
+                    </execution>
+
+                    <execution>
+                        <id>generate-images</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+
+                    <execution>
+                        <id>push-images</id>
+                        <phase>deploy</phase>
+                        <goals>
+                            <goal>build</goal>
+                            <goal>push</goal>
+                        </goals>
+                        <configuration>
+                            <image>onap/policy-xacmp-pdp</image>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.policy.xacml-pdp</groupId>
+            <artifactId>policy-xacmlpdp-tarball</artifactId>
+            <version>${project.version}</version>
+            <classifier>tarball</classifier>
+            <type>tar.gz</type>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/packages/policy-xacmlpdp-docker/src/main/docker/Dockerfile b/packages/policy-xacmlpdp-docker/src/main/docker/Dockerfile
new file mode 100644 (file)
index 0000000..b5f8af3
--- /dev/null
@@ -0,0 +1,46 @@
+FROM ubuntu:16.04
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+ARG BUILD_VERSION=${BUILD_VERSION}
+ARG POLICY_LOGS=/var/log/onap/policy/pdpx
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+ENV BUILD_VERSION ${BUILD_VERSION}
+ENV POLICY_LOGS ${POLICY_LOGS}
+
+ENV POLICY_HOME=/opt/app/policy
+ENV POLICY_PDPX_HOME=${POLICY_HOME}/pdpx
+
+RUN \
+        apt-get clean && \
+        apt-get update && \
+        apt-get install -y zip unzip curl wget ssh telnet maven && \
+        apt-get install -y software-properties-common && \
+        apt-get install -y jq httpie && \
+        apt-get install -y python-pip && \
+        add-apt-repository ppa:openjdk-r/ppa && \
+        apt-get clean && \
+        apt-get update && \
+        apt-get install -y openjdk-8-jdk
+
+RUN groupadd policy 
+RUN useradd --create-home --shell /bin/bash -g policy policy
+
+RUN mkdir -p ${POLICY_PDPX_HOME} ${POLICY_LOGS} ${POLICY_HOME}/etc/ssl ${POLICY_PDPX_HOME}/bin && \
+    chown  -R policy:policy ${POLICY_HOME} ${POLICY_PDPX_HOME} ${POLICY_LOGS}
+
+RUN mkdir /packages
+COPY /maven/* /packages
+RUN tar xvfz /packages/policy-xacml-pdp.tar.gz --directory ${POLICY_PDPX_HOME}
+RUN rm /packages/policy-xacml-pdp.tar.gz
+
+WORKDIR ${POLICY_PDPX_HOME}
+COPY policy-pdpx.sh  bin/.
+RUN chown -R policy:policy * && chmod +x bin/*.sh
+RUN cp ${POLICY_PDPX_HOME}/etc/ssl/* ${POLICY_HOME}/etc/ssl && chown policy:policy ${POLICY_HOME}/etc/ssl/*
+
+USER policy
+WORKDIR ${POLICY_PDPX_HOME}/bin
+ENTRYPOINT [ "bash", "./policy-pdpx.sh" ]
diff --git a/packages/policy-xacmlpdp-docker/src/main/docker/policy-pdpx.sh b/packages/policy-xacmlpdp-docker/src/main/docker/policy-pdpx.sh
new file mode 100644 (file)
index 0000000..aff8d8e
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#
+
+JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
+POLICY_PDPX_HOME=/opt/app/policy/pdpx
+KEYSTORE="${POLICY_HOME}/etc/ssl/policy-keystore"
+KEYSTORE_PASSWD="Pol1cy_0nap"
+TRUSTSTORE="${POLICY_HOME}/etc/ssl/policy-truststore"
+TRUSTSTORE_PASSWD="Pol1cy_0nap"
+
+
+if [ "$#" -eq 1 ]; then
+    CONFIG_FILE=$1
+else
+    CONFIG_FILE=${CONFIG_FILE}
+fi
+
+if [ -z "$CONFIG_FILE" ]
+  then
+    CONFIG_FILE="$POLICY_PDPX_HOME/etc/defaultConfig.json"
+fi
+
+echo "Policy Xacml PDP config file: $CONFIG_FILE"
+
+$JAVA_HOME/bin/java -cp "$POLICY_PDPX_HOME/etc:$POLICY_PDPX_HOME/lib/*" -Djavax.net.ssl.keyStore="$KEYSTORE" -Djavax.net.ssl.keyStorePassword="$KEYSTORE_PASSWD" -Djavax.net.ssl.trustStore="$TRUSTSTORE" -Djavax.net.ssl.trustStorePassword="$TRUSTSTORE_PASSWD" org.onap.policy.xacmlpdp.main.startstop.Main -c $CONFIG_FILE
diff --git a/packages/policy-xacmlpdp-tarball/pom.xml b/packages/policy-xacmlpdp-tarball/pom.xml
new file mode 100644 (file)
index 0000000..2605d94
--- /dev/null
@@ -0,0 +1,65 @@
+<!--
+  ============LICENSE_START=======================================================
+   Copyright (C) 2019 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.
+
+  SPDX-License-Identifier: Apache-2.0
+  ============LICENSE_END=========================================================
+-->
+
+<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>
+    <parent>
+        <groupId>org.onap.policy.xacml-pdp</groupId>
+        <artifactId>packages</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>policy-xacmlpdp-tarball</artifactId>
+    <name>${project.artifactId}</name>
+    <description>Creates the zip pacakge of entire Xacml PDP component</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.policy.xacml-pdp</groupId>
+            <artifactId>main</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-complete-tar</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                <descriptor>src/main/package/tarball/assembly.xml</descriptor>
+                            </descriptors>
+                            <finalName>${project.artifactId}-${project.version}</finalName>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/packages/policy-xacmlpdp-tarball/src/main/package/tarball/assembly.xml b/packages/policy-xacmlpdp-tarball/src/main/package/tarball/assembly.xml
new file mode 100644 (file)
index 0000000..4c76c5a
--- /dev/null
@@ -0,0 +1,70 @@
+<!--
+  ============LICENSE_START=======================================================
+   Copyright (C) 2019 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.
+
+  SPDX-License-Identifier: Apache-2.0
+  ============LICENSE_END=========================================================
+-->
+
+<assembly>
+    <id>tarball</id>
+    <formats>
+        <format>tar.gz</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <dependencySets>
+        <dependencySet>
+            <useProjectArtifact>true</useProjectArtifact>
+            <outputDirectory>/lib</outputDirectory>
+            <unpack>false</unpack>
+            <scope>runtime</scope>
+            <includes>
+                <include>*:jar</include>
+            </includes>
+        </dependencySet>
+    </dependencySets>
+    <fileSets>
+        <fileSet>
+            <directory>${project.basedir}/src/main/resources</directory>
+            <includes>
+                <include>policyLogger.properties</include>
+            </includes>
+            <outputDirectory>/bin/config</outputDirectory>
+            <lineEnding>unix</lineEnding>
+        </fileSet>
+        <fileSet>
+            <directory>${project.basedir}/src/main/resources/etc
+            </directory>
+            <includes>
+                <include>*.json</include>
+                <include>*.xml</include>
+            </includes>
+            <outputDirectory>/etc</outputDirectory>
+            <lineEnding>unix</lineEnding>
+            <excludes>
+                <exclude>*.formatted</exclude>
+            </excludes>
+        </fileSet>
+        <fileSet>
+            <directory>${project.basedir}/src/main/resources/etc/ssl
+            </directory>
+            <includes>
+                <include>policy*</include>
+            </includes>
+            <outputDirectory>/etc/ssl</outputDirectory>
+            <lineEnding>keep</lineEnding>
+        </fileSet>
+    </fileSets>
+</assembly>
diff --git a/packages/policy-xacmlpdp-tarball/src/main/resources/etc/defaultConfig.json b/packages/policy-xacmlpdp-tarball/src/main/resources/etc/defaultConfig.json
new file mode 100644 (file)
index 0000000..561574a
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "name": "XacmlPdpGroup",
+    "restServerParameters": {
+        "host": "0.0.0.0",
+        "port": 6969,
+        "userName": "healthcheck",
+        "password": "zb!XztG34",
+        "https": true,
+        "aaf": false
+    }
+}
diff --git a/packages/policy-xacmlpdp-tarball/src/main/resources/etc/logback.xml b/packages/policy-xacmlpdp-tarball/src/main/resources/etc/logback.xml
new file mode 100644 (file)
index 0000000..6f82561
--- /dev/null
@@ -0,0 +1,163 @@
+<!--
+  ============LICENSE_START=======================================================
+   Copyright (C) 2019 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.
+
+  SPDX-License-Identifier: Apache-2.0
+  ============LICENSE_END=========================================================
+-->
+<configuration scan="true" scanPeriod="3 seconds" debug="true">
+
+    <property name="logDir" value="${POLICY_LOGS}" />
+
+    <property name="errorLog" value="error" />
+    <property name="debugLog" value="debug" />
+    <property name="networkLog" value="network" />
+    <property name="metricLog" value="metric" />
+    <property name="transactionLog" value="audit" />
+
+    <property name="debugPattern" value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%level|%logger{0}|%thread] %msg%n" />
+    <property name="errorPattern" value="${debugPattern}" />
+    <property name="networkPattern" value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%t]%m%n" />
+    <property name="metricPattern"
+        value="%X{RequestID}|%X{InvocationID}|%X{ServiceName}|%X{PartnerName}|%X{BeginTimestamp}|%X{EndTimestamp}|%X{ElapsedTime}|%X{ServiceInstanceID}|%X{VirtualServerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%X{Severity}|%X{TargetEntity}|%X{TargetServiceName}|%X{Server}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ProcessKey}|%X{RemoteHost}|%X{AlertSeverity}|%X{TargetVirtualEntity}|%level|%thread| %msg%n" />
+    <property name="transactionPattern" value="${metricPattern}" />
+
+    <appender name="errorOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${logDir}/${errorLog}.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${logDir}/${errorLog}.%d{yyyy-MM-dd}.%i.log.zip
+            </fileNamePattern>
+            <maxFileSize>50MB</maxFileSize>
+            <maxHistory>30</maxHistory>
+            <totalSizeCap>10GB</totalSizeCap>
+        </rollingPolicy>
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>WARN</level>
+        </filter>
+        <encoder>
+            <pattern>${errorPattern}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="asyncErrorOut" class="ch.qos.logback.classic.AsyncAppender">
+        <appender-ref ref="errorOut" />
+    </appender>
+
+    <appender name="debugOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${logDir}/${debuLog}.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${logDir}/${debugLog}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+            <maxFileSize>50MB</maxFileSize>
+            <maxHistory>30</maxHistory>
+            <totalSizeCap>10GB</totalSizeCap>
+        </rollingPolicy>
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>DEBUG</level>
+        </filter>
+        <encoder>
+            <pattern>${debugPattern}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="asyncDebugOut" class="ch.qos.logback.classic.AsyncAppender">
+        <appender-ref ref="debugOut" />
+    </appender>
+
+    <appender name="metricOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${logDir}/${metricsLog}.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${logDir}/${metricsLog}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+            <maxFileSize>50MB</maxFileSize>
+            <maxHistory>30</maxHistory>
+            <totalSizeCap>10GB</totalSizeCap>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${metricPattern}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="asyncMetricOut" class="ch.qos.logback.classic.AsyncAppender">
+        <appender-ref ref="metricOut" />
+    </appender>
+
+    <appender name="networkOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${logDir}/${networkLog}.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${logDir}/${networkLog}.%d{yyyy-MM-dd}.%i.log.zip
+            </fileNamePattern>
+            <maxFileSize>50MB</maxFileSize>
+            <maxHistory>30</maxHistory>
+            <totalSizeCap>10GB</totalSizeCap>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${networkPattern}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="asyncNetworkOut" class="ch.qos.logback.classic.AsyncAppender">
+        <appender-ref ref="networkOut" />
+    </appender>
+
+    <appender name="transactionOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${logDir}/${transactionLog}.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${logDir}/${transactionLog}.%d{yyyy-MM-dd}.%i.log.zip
+            </fileNamePattern>
+            <maxFileSize>50MB</maxFileSize>
+            <maxHistory>30</maxHistory>
+            <totalSizeCap>10GB</totalSizeCap>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${transactionPattern}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="asyncTransactionOut" class="ch.qos.logback.classic.AsyncAppender">
+        <appender-ref ref="transactionOut" />
+    </appender>
+
+    <logger name="metrics" level="info" additivity="false">
+        <appender-ref ref="asyncMetricsOut" />
+    </logger>
+
+    <logger name="error" level="error" additivity="false">
+        <appender-ref ref="asyncErrorOut" />
+    </logger>
+
+    <logger name="debug" level="debug" additivity="false">
+        <appender-ref ref="asyncDebugOut" />
+    </logger>
+
+    <logger name="network" level=info" additivity="false">
+        <appender-ref ref="asyncNetworkOut" />
+    </logger>
+    
+    <logger name="org.eclipse.jetty.server.RequestLog" level="info" additivity="false">
+        <appender-ref ref="asyncNetworkOut" />
+    </logger>
+    
+    <logger name="transactionOut" level="info" additivity="false">
+        <appender-ref ref="asyncTransactionOut" />
+    </logger>
+
+    <root level="INFO">
+        <appender-ref ref="asyncDebugOut" />
+        <appender-ref ref="asyncErrorOut" />
+        <appender-ref ref="asyncMetricOut" />
+        <appender-ref ref="asyncTransactionOut" />
+        <appender-ref ref="asyncNetworkOut" />
+    </root>
+
+</configuration>
diff --git a/packages/policy-xacmlpdp-tarball/src/main/resources/etc/s3pConfig.json b/packages/policy-xacmlpdp-tarball/src/main/resources/etc/s3pConfig.json
new file mode 100644 (file)
index 0000000..54be41a
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "name":"XacmlPdpGroup",
+    "restServerParameters":{
+        "host":"0.0.0.0",
+        "port":6969,
+        "userName":"healthcheck",
+        "password":"zb!XztG34",
+        "https": true,
+        "aaf": false
+    }
+}
diff --git a/packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-keystore b/packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-keystore
new file mode 100644 (file)
index 0000000..7d2b1ec
Binary files /dev/null and b/packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-keystore differ
diff --git a/packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-truststore b/packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-truststore
new file mode 100644 (file)
index 0000000..8834ac2
Binary files /dev/null and b/packages/policy-xacmlpdp-tarball/src/main/resources/etc/ssl/policy-truststore differ
diff --git a/packages/pom.xml b/packages/pom.xml
new file mode 100644 (file)
index 0000000..34bdbe8
--- /dev/null
@@ -0,0 +1,54 @@
+<!--
+  ============LICENSE_START=======================================================
+  ONAP Policy Engine - XACML PDP
+  ================================================================================
+  Copyright (C) 2019 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 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>
+    <parent>
+        <groupId>org.onap.policy.xacml-pdp</groupId>
+        <artifactId>policy-xacml-pdp</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>packages</artifactId>
+    <packaging>pom</packaging>
+
+    <name>${project.artifactId}</name>
+    <description>The module for packaging the Xacml PDP component</description>
+    
+    <profiles>
+        <profile>
+            <id>default</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+        </profile>
+        <profile>
+            <id>docker</id>
+            <modules>
+                <module>policy-xacmlpdp-tarball</module>
+                <module>policy-xacmlpdp-docker</module>
+            </modules>
+            <properties>
+                <docker.skip.push>false</docker.skip.push>
+            </properties>
+        </profile>
+    </profiles>
+</project>
diff --git a/pom.xml b/pom.xml
index 8c4c6a5..03d633f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.onap.policy.parent</groupId>
         <artifactId>integration</artifactId>
-        <version>2.0.0</version>
+        <version>2.1.0-SNAPSHOT</version>
         <relativePath />
     </parent>
 
@@ -50,6 +50,7 @@
 
     <modules>
         <module>main</module>
+        <module>packages</module>
     </modules>
     
     <dependencies>
@@ -61,7 +62,6 @@
         <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
-             <version>3.11.1</version>
             <scope>test</scope>
         </dependency>
         <dependency>