aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controlloop/common/feature-controlloop-utils/pom.xml134
-rw-r--r--controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml75
-rw-r--r--controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment26
-rw-r--r--controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java64
-rw-r--r--controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI1
-rw-r--r--controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java46
-rw-r--r--controlloop/common/guard/pom.xml6
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java39
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java116
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java13
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java3
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java2
-rw-r--r--controlloop/common/pom.xml1
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java70
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java17
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java121
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java198
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java75
-rw-r--r--controlloop/packages/apps/pom.xml6
-rw-r--r--controlloop/packages/apps/src/files/apps-installer24
-rw-r--r--controlloop/packages/basex/src/files/bin/create-cl-amsterdam235
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.success.json22
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl5
-rw-r--r--controlloop/templates/template.demo/pom.xml6
-rw-r--r--controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl5
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java10
-rw-r--r--controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml2
-rw-r--r--pom.xml2
28 files changed, 1031 insertions, 293 deletions
diff --git a/controlloop/common/feature-controlloop-utils/pom.xml b/controlloop/common/feature-controlloop-utils/pom.xml
new file mode 100644
index 000000000..f0f95f26a
--- /dev/null
+++ b/controlloop/common/feature-controlloop-utils/pom.xml
@@ -0,0 +1,134 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP
+ ================================================================================
+ 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 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.drools-applications</groupId>
+ <artifactId>common</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>feature-controlloop-utils</artifactId>
+ <description>
+ Loadable PDP-D feature module to enable simulator usage in a non-junit
+ lab environments. In a pdp-d lab environment this capability can be
+ enabled with the "feature" mechanisms.
+ </description>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>zipfile</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>false</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <includeScope>runtime</includeScope>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>simulators</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>so</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml b/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml
new file mode 100644
index 000000000..26e6676b7
--- /dev/null
+++ b/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml
@@ -0,0 +1,75 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP
+ ================================================================================
+ 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">
+ <id>feature-controlloop-utils-package</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>lib/feature</outputDirectory>
+ <includes>
+ <include>feature-controlloop-utils-${project.version}.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/assembly/lib</directory>
+ <outputDirectory>lib/dependencies</outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/feature/config</directory>
+ <outputDirectory>config</outputDirectory>
+ <fileMode>0644</fileMode>
+ <excludes/>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/feature/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0744</fileMode>
+ <excludes/>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/feature/db</directory>
+ <outputDirectory>db</outputDirectory>
+ <fileMode>0744</fileMode>
+ <excludes/>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/feature/install</directory>
+ <outputDirectory>install</outputDirectory>
+ <fileMode>0744</fileMode>
+ <excludes/>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment b/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment
new file mode 100644
index 000000000..daa98799c
--- /dev/null
+++ b/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment
@@ -0,0 +1,26 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP
+# ================================================================================
+# 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=========================================================
+###
+
+# Environment file (.environment) for the simulator for control loop applications
+
+aai.url=http://localhost:6666
+so.url=http://localhost:6667
+vfc.url=http://localhost:6668
+
diff --git a/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java b/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java
new file mode 100644
index 000000000..50876311c
--- /dev/null
+++ b/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * 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.onap.policy.drools.apps.controlloop.feature.utils;
+
+import java.io.IOException;
+
+import org.onap.policy.drools.features.PolicyEngineFeatureAPI;
+import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.simulators.Util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * PDP-D feature for lab environments that provides Server simulation capabilities for AAI, SO, and
+ * VFC
+ *
+ */
+public class ControlLoopUtilsFeature implements PolicyEngineFeatureAPI {
+
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(ControlLoopUtilsFeature.class);
+
+ @Override
+ public boolean afterStart(PolicyEngine engine) {
+ try {
+ Util.buildAaiSim();
+ Util.buildSoSim();
+ Util.buildVfcSim();
+ } catch (final InterruptedException e) {
+ logger.error("{}: initialization aborted", ControlLoopUtilsFeature.class.getName(), e);
+ Thread.currentThread().interrupt();
+ } catch (final IOException e) {
+ logger.error("{}: a simulator cannot be built because of {}",
+ ControlLoopUtilsFeature.class.getName(), e.getMessage(), e);
+ }
+ return false;
+ }
+
+ @Override
+ public int getSequenceNumber() {
+ return 100000;
+ }
+
+}
diff --git a/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI b/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI
new file mode 100644
index 000000000..b5a71b8b2
--- /dev/null
+++ b/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI
@@ -0,0 +1 @@
+org.onap.policy.drools.apps.controlloop.feature.utils.ControlLoopUtilsFeature
diff --git a/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java
new file mode 100644
index 000000000..5ba375847
--- /dev/null
+++ b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * 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.onap.policy.drools.apps.controlloop.feature.utils;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.simulators.Util;
+
+/**
+ * ControlLoopUtilsFeature JUnit Tests
+ */
+public class ControlLoopUtilsFeatureTest {
+
+ @Test
+ public void simulate() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ final ControlLoopUtilsFeature feature = new ControlLoopUtilsFeature();
+ feature.afterStart(PolicyEngine.manager);
+ assertNotNull(HttpServletServer.factory.get(Util.AAISIM_SERVER_PORT));
+ assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT));
+ assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT));
+ }
+
+}
diff --git a/controlloop/common/guard/pom.xml b/controlloop/common/guard/pom.xml
index e0283589a..0fe442e43 100644
--- a/controlloop/common/guard/pom.xml
+++ b/controlloop/common/guard/pom.xml
@@ -48,5 +48,11 @@
<version>2.7.0</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
index 6b311bf45..8ea4ec1b3 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
@@ -20,22 +20,21 @@
package org.onap.policy.guard;
-import com.att.research.xacml.api.DataTypeException;
-import com.att.research.xacml.api.pdp.PDPEngine;
-import com.att.research.xacml.std.annotations.RequestParser;
-
import java.util.UUID;
import org.drools.core.WorkingMemory;
+import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.att.research.xacml.api.DataTypeException;
+import com.att.research.xacml.std.annotations.RequestParser;
+
public class CallGuardTask implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(CallGuardTask.class);
WorkingMemory workingMemory;
- PDPEngine embeddedPdpEngine;
String restfulPdpUrl;
String clname;
String actor;
@@ -43,10 +42,9 @@ public class CallGuardTask implements Runnable {
String target;
String requestId;
- public CallGuardTask(PDPEngine engine, String url, WorkingMemory wm, String cl, String act, String rec, String tar, String reqId) {
+ public CallGuardTask(String guardUrl, WorkingMemory wm, String cl, String act, String rec, String tar, String reqId) {
- embeddedPdpEngine = engine;
- restfulPdpUrl = url;
+ restfulPdpUrl = guardUrl;
workingMemory = wm;
clname = cl;
actor = act;
@@ -71,13 +69,30 @@ public class CallGuardTask implements Runnable {
logger.debug("{}", request);
logger.debug("********** XACML REQUEST END ********\n");
- com.att.research.xacml.api.Response xacmlResponse = PolicyGuardXacmlHelper.callPDP(embeddedPdpEngine, "", request, false);
+ String guardUrl = PolicyEngine.manager.getEnvironmentProperty("guard.url");
+ String guardDecision = null;
+ //
+ // Check if guard url property exists
+ //
+ if(guardUrl != null){
+ guardDecision = PolicyGuardXacmlHelper.callPDP(guardUrl, xacmlReq);
+ }
+
logger.debug("\n********** XACML RESPONSE START ********");
- logger.debug("{}", xacmlResponse);
+ logger.debug("{}", guardDecision);
logger.debug("********** XACML RESPONSE END ********\n");
-
- PolicyGuardResponse guardResponse = PolicyGuardXacmlHelper.ParseXacmlPdpResponse(xacmlResponse);
+
+ //
+ // Check if the restful call was unsuccessful or property doesn't exist
+ //
+ if(guardDecision == null){
+ logger.error("********** XACML FAILED TO CONNECT ********");
+ guardDecision = "Indeterminate";
+ }
+
+ PolicyGuardResponse guardResponse = new PolicyGuardResponse(guardDecision, UUID.fromString(this.requestId), this.recipe);
+
//
//Create an artificial Guard response in case we didn't get a clear Permit or Deny
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
index 5ecb44162..72c498d0e 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
@@ -20,8 +20,10 @@
package org.onap.policy.guard;
+import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -30,6 +32,7 @@ import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.http.entity.ContentType;
+import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,45 +40,40 @@ import com.att.research.xacml.api.Attribute;
import com.att.research.xacml.api.AttributeCategory;
import com.att.research.xacml.api.AttributeValue;
import com.att.research.xacml.api.Result;
-import com.att.research.xacml.api.pdp.PDPEngine;
-import com.att.research.xacml.api.pdp.PDPException;
-import com.att.research.xacml.std.dom.DOMResponse;
-import com.att.research.xacml.std.json.JSONRequest;
-import com.att.research.xacml.std.json.JSONResponse;
public class PolicyGuardXacmlHelper {
private static final Logger logger = LoggerFactory.getLogger(PolicyGuardXacmlHelper.class);
- public static com.att.research.xacml.api.Response callPDP(PDPEngine xacmlEmbeddedPdpEngine, String restfulPdpUrl, com.att.research.xacml.api.Request request, boolean isREST) {
+ public static String callPDP(String restfulPdpUrl, PolicyGuardXacmlRequestAttributes xacmlReq) {
//
// Send it to the PDP
//
- com.att.research.xacml.api.Response response = null;
- if (isREST) {
- try {
- String jsonString = JSONRequest.toString((com.att.research.xacml.api.Request) request, false);
- //
- // Call RESTful PDP
- //
- response = (com.att.research.xacml.api.Response) callRESTfulPDP(new ByteArrayInputStream(jsonString.getBytes()), new URL(restfulPdpUrl/*"https://localhost:8443/pdp/"*/));
- } catch (Exception e) {
- logger.error("Error in sending RESTful request: ", e);
- }
- } else if(xacmlEmbeddedPdpEngine != null){
+// com.att.research.xacml.api.Response response = null;
+ String response = null;
+
+ JSONObject attributes = new JSONObject();
+ attributes.put("actor", xacmlReq.getActor_id());
+ attributes.put("recipe", xacmlReq.getOperation_id());
+ attributes.put("target", xacmlReq.getTarget_id());
+ if (xacmlReq.getClname_id() != null){
+ attributes.put("clname", xacmlReq.getClname_id());
+ }
+ JSONObject jsonReq = new JSONObject();
+ jsonReq.put("decisionAttributes", attributes);
+ jsonReq.put("onapName", "PDPD");
+
+ try {
//
- // Embedded call to PDP
+ // Call RESTful PDP
//
- long lTimeStart = System.currentTimeMillis();
- try {
- response = (com.att.research.xacml.api.Response) xacmlEmbeddedPdpEngine.decide((com.att.research.xacml.api.Request) request);
- } catch (PDPException e) {
- logger.error(e.getMessage(), e);
- }
- long lTimeEnd = System.currentTimeMillis();
- logger.debug("Elapsed Time: {} ms", (lTimeEnd - lTimeStart));
+ response = callRESTfulPDP(new ByteArrayInputStream(jsonReq.toString().getBytes()), new URL(restfulPdpUrl/*"https://localhost:8443/pdp/"*/));
+ } catch (Exception e) {
+ logger.error("Error in sending RESTful request: ", e);
}
+
+
return response;
}
@@ -84,10 +82,12 @@ public class PolicyGuardXacmlHelper {
* This makes an HTTP POST call to a running PDP RESTful servlet to get a decision.
*
* @param file
- * @return
+ * @return response from guard which contains "Permit" or "Deny"
*/
- private static com.att.research.xacml.api.Response callRESTfulPDP(InputStream is, URL restURL) {
- com.att.research.xacml.api.Response response = null;
+ private static String callRESTfulPDP(InputStream is, URL restURL) {
+// com.att.research.xacml.api.Response response = null;
+ String response = null;
+ String rawDecision = null;
HttpURLConnection connection = null;
try {
@@ -130,28 +130,59 @@ public class PolicyGuardXacmlHelper {
contentType = ContentType.parse(connection.getContentType());
if (contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_JSON.getMimeType())) {
- response = (com.att.research.xacml.api.Response) JSONResponse.load(connection.getInputStream());
- } else if (contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_XML.getMimeType()) ||
- contentType.getMimeType().equalsIgnoreCase("application/xacml+xml") ) {
- response = (com.att.research.xacml.api.Response) DOMResponse.load(connection.getInputStream());
+ InputStream iStream = connection.getInputStream();
+ int contentLength = connection.getContentLength();
+
+ // if content length is -1, respose is chunked, and
+ // TCP connection will be dropped at the end
+ byte[] buf =
+ new byte[contentLength < 0 ? 1024 : contentLength];
+ int offset = 0;
+ for ( ; ; )
+ {
+ if (offset == contentLength)
+ {
+ // all expected bytes have been read
+ response = new String(buf);
+ break;
+ }
+ int size = iStream.read(buf, offset,
+ buf.length - offset);
+ if (size < 0)
+ {
+ if (contentLength > 0)
+ {
+ logger.error("partial input stream");
+ }
+ else
+ {
+ // chunked response --
+ // dropped connection is expected
+ response = new String(buf, 0, offset);
+ }
+ break;
+ }
+ offset += size;
+ }
} else {
- logger.error("{}: unknown content-type: ", contentType);
+ logger.error("unknown content-type: " + contentType);
}
} catch (Exception e) {
- String message = "Parsing Content-Type: " + connection.getContentType() + ", error=" + e.getMessage();
- logger.error("{}: callRESTfulPDP threw: ", message, e);
+ String message = "Parsing Content-Type: " + connection.getContentType();
+ logger.error(message, e);
}
} else {
- logger.error("unknown content-type: {} {}", connection.getResponseCode(), connection.getResponseMessage() );
+ logger.error(connection.getResponseCode() + " " + connection.getResponseMessage());
}
} catch (Exception e) {
-
- logger.error("callRESTfulPDP threw: ", e);
+ logger.error("Exception in 'PolicyGuardXacmlHelper.callRESTfulPDP'", e);
}
+
+ rawDecision = new JSONObject(response).getString("decision");
- return response;
+ return rawDecision;
}
@@ -191,9 +222,6 @@ public class PolicyGuardXacmlHelper {
}
-
-
-
return new PolicyGuardResponse(decision_from_xacml_response, req_id_from_xacml_response, operation_from_xacml_response);
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
index 4de0f81f9..7bd745936 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
@@ -33,25 +33,26 @@ public enum ResponseValue {
private ResponseValue(String value) {
this.value = value;
}
-
+
+ @Override
public String toString() {
return this.value;
}
public static ResponseValue toResponseValue(String value) {
- if (value.toString().equals(ACCEPT.toString())) {
+ if (value.equals(ACCEPT.toString())) {
return ACCEPT;
}
- if (value.toString().equals(ERROR.toString())) {
+ if (value.equals(ERROR.toString())) {
return ERROR;
}
- if (value.toString().equals(REJECT.toString())) {
+ if (value.equals(REJECT.toString())) {
return REJECT;
}
- if (value.toString().equals(SUCCESS.toString())) {
+ if (value.equals(SUCCESS.toString())) {
return SUCCESS;
}
- if (value.toString().equals(FAILURE.toString())) {
+ if (value.equals(FAILURE.toString())) {
return FAILURE;
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
index f74b626cb..5effa0c49 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
@@ -30,7 +30,8 @@ public enum ControlLoopEventStatus {
private ControlLoopEventStatus(String status) {
this.status = status;
}
-
+
+ @Override
public String toString() {
return this.status;
}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
index a225f2d71..4797ab906 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
@@ -41,7 +41,7 @@ public final class VFCManager implements Runnable {
vfcRequest = request;
// TODO: Get base URL, username and password from MSB?
// TODO: Following code is a placeholder, needs to be updated
- setVFCParams("https://", "vfc", "vfc");
+ setVFCParams("http://localhost:6668", "username", "password");
}
diff --git a/controlloop/common/pom.xml b/controlloop/common/pom.xml
index 083a19f0b..39f1b7038 100644
--- a/controlloop/common/pom.xml
+++ b/controlloop/common/pom.xml
@@ -39,6 +39,7 @@
<module>model-impl</module>
<module>policy-yaml</module>
<module>simulators</module>
+ <module>feature-controlloop-utils</module>
</modules>
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
index 9fbb2b50f..4a2bcf76e 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,35 +24,43 @@ import java.io.IOException;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.utils.NetworkUtil;
-import org.onap.policy.simulators.AaiSimulatorJaxRs;
-import org.onap.policy.simulators.SoSimulatorJaxRs;
-import org.onap.policy.simulators.VfcSimulatorJaxRs;
public class Util {
- public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6666, "/", false, true);
- testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
- return testServer;
- }
-
- public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true);
- testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
- return testServer;
- }
-
- public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6668, "/", false, true);
- testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
- return testServer;
- }
+ public static final String AAISIM_SERVER_NAME = "aaiSim";
+ public static final String SOSIM_SERVER_NAME = "soSim";
+ public static final String VFCSIM_SERVER_NAME = "vfcSim";
+
+ public static final int AAISIM_SERVER_PORT = 6666;
+ public static final int SOSIM_SERVER_PORT = 6667;
+ public static final int VFCSIM_SERVER_PORT = 6668;
+
+ public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
+ final HttpServletServer testServer = HttpServletServer.factory.build(AAISIM_SERVER_NAME,
+ "localhost", AAISIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+ throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ return testServer;
+ }
+
+ public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
+ final HttpServletServer testServer = HttpServletServer.factory.build(SOSIM_SERVER_NAME,
+ "localhost", SOSIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+ throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ return testServer;
+ }
+
+ public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
+ final HttpServletServer testServer = HttpServletServer.factory.build(VFCSIM_SERVER_NAME,
+ "localhost", VFCSIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+ throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ return testServer;
+ }
}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
index 51a85ce60..cd894825c 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
@@ -24,21 +24,30 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.Context;
@Path("/api/nslcm/v1")
public class VfcSimulatorJaxRs {
@POST
@Path("/ns/{nsInstanceId}/heal")
- public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId)
+ public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId,
+ @Context final HttpServletResponse response)
{
+ response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ try {
+ response.flushBuffer();
+ }catch(Exception e){}
+
return "{\"jobId\":\"1\"}";
}
@GET
- @Path("/jobs/{jobId}&responseId={responseId}")
- public String vfcGetQuery(@PathParam("jobId") String jobId, @PathParam("responseId") String responseId){
- return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": "+responseId+",\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
+ @Path("/jobs/{jobId}")
+ public String vfcGetQuery(@PathParam("jobId") String jobId) {
+ return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
}
}
+
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
index f5d42c9ce..121a889f7 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
@@ -40,67 +40,74 @@ import org.onap.policy.aai.AAINQQueryParameters;
import org.onap.policy.aai.AAINQRequest;
import org.onap.policy.aai.AAINQResponse;
import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
public class AaiSimulatorTest {
- @BeforeClass
- public static void setUpSimulator() {
- try {
- Util.buildAaiSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
+ @BeforeClass
+ public static void setUpSimulator() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ try {
+ Util.buildAaiSim();
+ } catch (final Exception e) {
+ fail(e.getMessage());
+ }
+ }
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
- @Test
- public void testGet() {
- AAIGETVnfResponse response = AAIManager.getQueryByVnfID("http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass", UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
- assertNotNull(response);
- assertNotNull(response.relationshipList);
- }
+ @Test
+ public void testGet() {
+ final AAIGETVnfResponse response = AAIManager.getQueryByVnfID(
+ "http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass",
+ UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
+ assertNotNull(response);
+ assertNotNull(response.relationshipList);
+ }
- @Test
- public void testPost() {
- AAINQRequest request = new AAINQRequest();
- AAINQQueryParameters tempQueryParameters = new AAINQQueryParameters();
- AAINQNamedQuery tempNamedQuery = new AAINQNamedQuery();
- tempNamedQuery.namedQueryUUID = UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469");
- tempQueryParameters.namedQuery = tempNamedQuery;
- request.queryParameters = tempQueryParameters;
- Map<String, String> tempInnerMap = new HashMap<>();
- tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- Map<String, Map<String, String>> tempOuterMap = new HashMap<>();
- tempOuterMap.put("vserver", tempInnerMap);
- List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>();
- tempInstanceFilter.add(tempOuterMap);
- AAINQInstanceFilters tempInstanceFilters = new AAINQInstanceFilters();
- tempInstanceFilters.instanceFilter = tempInstanceFilter;
- request.instanceFilters = tempInstanceFilters;
-
- AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.inventoryResponseItems);
-
- tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087");
- tempQueryParameters.namedQuery = tempNamedQuery;
- request.queryParameters = tempQueryParameters;
- tempInnerMap = new HashMap<>();
- tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb");
- tempOuterMap = new HashMap<>();
- tempOuterMap.put("generic-vnf", tempInnerMap);
- tempInstanceFilter = new LinkedList<>();
- tempInstanceFilter.add(tempOuterMap);
- tempInstanceFilters = new AAINQInstanceFilters();
- tempInstanceFilters.instanceFilter = tempInstanceFilter;
- request.instanceFilters = tempInstanceFilters;
-
- response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.inventoryResponseItems);
- }
+ @Test
+ public void testPost() {
+ final AAINQRequest request = new AAINQRequest();
+ final AAINQQueryParameters tempQueryParameters = new AAINQQueryParameters();
+ final AAINQNamedQuery tempNamedQuery = new AAINQNamedQuery();
+ tempNamedQuery.namedQueryUUID = UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469");
+ tempQueryParameters.namedQuery = tempNamedQuery;
+ request.queryParameters = tempQueryParameters;
+ Map<String, String> tempInnerMap = new HashMap<>();
+ tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ Map<String, Map<String, String>> tempOuterMap = new HashMap<>();
+ tempOuterMap.put("vserver", tempInnerMap);
+ List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>();
+ tempInstanceFilter.add(tempOuterMap);
+ AAINQInstanceFilters tempInstanceFilters = new AAINQInstanceFilters();
+ tempInstanceFilters.instanceFilter = tempInstanceFilter;
+ request.instanceFilters = tempInstanceFilters;
+
+ AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass",
+ request, UUID.randomUUID());
+ assertNotNull(response);
+ assertNotNull(response.inventoryResponseItems);
+
+ tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087");
+ tempQueryParameters.namedQuery = tempNamedQuery;
+ request.queryParameters = tempQueryParameters;
+ tempInnerMap = new HashMap<>();
+ tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb");
+ tempOuterMap = new HashMap<>();
+ tempOuterMap.put("generic-vnf", tempInnerMap);
+ tempInstanceFilter = new LinkedList<>();
+ tempInstanceFilter.add(tempOuterMap);
+ tempInstanceFilters = new AAINQInstanceFilters();
+ tempInstanceFilters.instanceFilter = tempInstanceFilter;
+ request.instanceFilters = tempInstanceFilters;
+
+ response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request,
+ UUID.randomUUID());
+ assertNotNull(response);
+ assertNotNull(response.inventoryResponseItems);
+ }
}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
index 2cf6b8e0c..683da86b7 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,7 +20,8 @@
package org.onap.policy.simulators;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.UUID;
@@ -29,6 +30,9 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.rest.RESTManager;
+import org.onap.policy.rest.RESTManager.Pair;
import org.onap.policy.so.SOCloudConfiguration;
import org.onap.policy.so.SOModelInfo;
import org.onap.policy.so.SORelatedInstance;
@@ -39,95 +43,105 @@ import org.onap.policy.so.SORequestInfo;
import org.onap.policy.so.SORequestParameters;
import org.onap.policy.so.SOResponse;
import org.onap.policy.so.util.Serialization;
-import org.onap.policy.rest.RESTManager;
-import org.onap.policy.rest.RESTManager.Pair;
public class SoSimulatorTest {
-
- @BeforeClass
- public static void setUpSimulator() {
- try {
- Util.buildSoSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- /**
- * Create dummy SO request for TestResponse() junit
- */
- private SORequest createTestRequest() {
-
- // Construct SO Request
- SORequest request = new SORequest();
- request.requestId = UUID.randomUUID();
- request.requestDetails = new SORequestDetails();
- request.requestDetails.modelInfo = new SOModelInfo();
- request.requestDetails.cloudConfiguration = new SOCloudConfiguration();
- request.requestDetails.requestInfo = new SORequestInfo();
- request.requestDetails.requestParameters = new SORequestParameters();
- request.requestDetails.requestParameters.userParams = null;
- //
- // cloudConfiguration
- //
- request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW";
- request.requestDetails.cloudConfiguration.tenantId = "1015548";
- //
- // modelInfo
- //
- request.requestDetails.modelInfo.modelType = "vfModule";
- request.requestDetails.modelInfo.modelInvariantId = "f32568ec-2f1c-458a-864b-0593d53d141a";
- request.requestDetails.modelInfo.modelNameVersionId = "69615025-879d-4f0d-afe3-b7d1a7eeed1f";
- request.requestDetails.modelInfo.modelName = "C15ce9e1E9144c8fB8bb..dnsscaling..module-1";
- request.requestDetails.modelInfo.modelVersion = "1.0";
- //
- // requestInfo
- //
- request.requestDetails.requestInfo.instanceName = "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
- request.requestDetails.requestInfo.source = "POLICY";
- request.requestDetails.requestInfo.suppressRollback = false;
- //
- // relatedInstanceList
- //
- SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement();
- SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement();
- relatedInstanceListElement1.relatedInstance = new SORelatedInstance();
- relatedInstanceListElement2.relatedInstance = new SORelatedInstance();
- //
- relatedInstanceListElement1.relatedInstance.instanceId = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5";
- relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
- relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = "5c996219-b2e2-4c76-9b43-7e8672a33c1d";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "8330e932-2a23-4943-8606";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "1.0";
- //
- relatedInstanceListElement2.relatedInstance.instanceId = "594e2fe0-48b8-41ff-82e2-3d4bab69b192";
- relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
- relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "033a32ed-aa65-4764-a736-36f2942f1aa0";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "d4d072dc-4e21-4a03-9524-628985819a8e";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "c15ce9e1-e914-4c8f-b8bb";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = "c15ce9e1-e914-4c8f-b8bb 1";
- //
- request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
- request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
-
- return request;
- }
-
- @Test
- public void testResponse(){
- String request = Serialization.gsonPretty.toJson(createTestRequest());
- Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username", "password", new HashMap<>(), "application/json", request);
- assertNotNull(httpDetails);
- SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
- assertNotNull(response);
- }
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ try {
+ Util.buildSoSim();
+ } catch (final Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
+ /**
+ * Create dummy SO request for TestResponse() junit
+ */
+ private SORequest createTestRequest() {
+
+ // Construct SO Request
+ final SORequest request = new SORequest();
+ request.requestId = UUID.randomUUID();
+ request.requestDetails = new SORequestDetails();
+ request.requestDetails.modelInfo = new SOModelInfo();
+ request.requestDetails.cloudConfiguration = new SOCloudConfiguration();
+ request.requestDetails.requestInfo = new SORequestInfo();
+ request.requestDetails.requestParameters = new SORequestParameters();
+ request.requestDetails.requestParameters.userParams = null;
+ //
+ // cloudConfiguration
+ //
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW";
+ request.requestDetails.cloudConfiguration.tenantId = "1015548";
+ //
+ // modelInfo
+ //
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = "f32568ec-2f1c-458a-864b-0593d53d141a";
+ request.requestDetails.modelInfo.modelNameVersionId = "69615025-879d-4f0d-afe3-b7d1a7eeed1f";
+ request.requestDetails.modelInfo.modelName = "C15ce9e1E9144c8fB8bb..dnsscaling..module-1";
+ request.requestDetails.modelInfo.modelVersion = "1.0";
+ //
+ // requestInfo
+ //
+ request.requestDetails.requestInfo.instanceName =
+ "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
+ request.requestDetails.requestInfo.source = "POLICY";
+ request.requestDetails.requestInfo.suppressRollback = false;
+ //
+ // relatedInstanceList
+ //
+ final SORelatedInstanceListElement relatedInstanceListElement1 =
+ new SORelatedInstanceListElement();
+ final SORelatedInstanceListElement relatedInstanceListElement2 =
+ new SORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new SORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new SORelatedInstance();
+ //
+ relatedInstanceListElement1.relatedInstance.instanceId = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5";
+ relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId =
+ "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId =
+ "5c996219-b2e2-4c76-9b43-7e8672a33c1d";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "8330e932-2a23-4943-8606";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "1.0";
+ //
+ relatedInstanceListElement2.relatedInstance.instanceId = "594e2fe0-48b8-41ff-82e2-3d4bab69b192";
+ relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId =
+ "033a32ed-aa65-4764-a736-36f2942f1aa0";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId =
+ "d4d072dc-4e21-4a03-9524-628985819a8e";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "c15ce9e1-e914-4c8f-b8bb";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName =
+ "c15ce9e1-e914-4c8f-b8bb 1";
+ //
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+
+ return request;
+ }
+
+ @Test
+ public void testResponse() {
+ final String request = Serialization.gsonPretty.toJson(this.createTestRequest());
+ final Pair<Integer, String> httpDetails = RESTManager.post(
+ "http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username",
+ "password", new HashMap<>(), "application/json", request);
+ assertNotNull(httpDetails);
+ final SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
+ assertNotNull(response);
+ }
}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
index 0fb41ab9b..a063277ed 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,6 +21,7 @@
package org.onap.policy.simulators;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
@@ -29,40 +30,50 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
import org.onap.policy.vfc.VFCResponse;
import org.onap.policy.vfc.util.Serialization;
public class VfcSimulatorTest {
-
- @BeforeClass
- public static void setUpSimulator() {
- try {
- Util.buildVfcSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- @Test
- public void testPost(){
- Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password", new HashMap<String, String>(), "application/json", "Some Request Here");
- assertNotNull(httpDetails);
- VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
- assertNotNull(response);
- }
-
- @Test
- public void testGet(){
- Pair<Integer, String> httpDetails = RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234&responseId=5678", "username", "password", new HashMap<String, String>());
- assertNotNull(httpDetails);
- VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
- assertNotNull(response);
- }
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ LoggerUtil.setLevel("ROOT", "INFO");
+ LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+ try {
+ Util.buildVfcSim();
+ } catch (final Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
+ @Test
+ public void testPost() {
+ final Pair<Integer, String> httpDetails =
+ RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username",
+ "password", new HashMap<String, String>(), "application/json", "Some Request Here");
+ assertNotNull(httpDetails);
+ assertTrue(httpDetails.a == 202);
+ final VFCResponse response =
+ Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
+ assertNotNull(response);
+ }
+
+ @Test
+ public void testGet() {
+ final Pair<Integer, String> httpDetails =
+ RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password",
+ new HashMap<String, String>());
+ assertNotNull(httpDetails);
+ final VFCResponse response =
+ Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
+ assertNotNull(response);
+ }
}
diff --git a/controlloop/packages/apps/pom.xml b/controlloop/packages/apps/pom.xml
index f591bdc38..8b3acdc66 100644
--- a/controlloop/packages/apps/pom.xml
+++ b/controlloop/packages/apps/pom.xml
@@ -71,6 +71,12 @@
<version>${project.version}</version>
<type>zip</type>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>feature-controlloop-utils</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/packages/apps/src/files/apps-installer b/controlloop/packages/apps/src/files/apps-installer
index f6b27abcf..f53a48b60 100644
--- a/controlloop/packages/apps/src/files/apps-installer
+++ b/controlloop/packages/apps/src/files/apps-installer
@@ -27,6 +27,28 @@
echo "APPS INSTALL"
-# cache in local maven repo
+source ${POLICY_HOME}/etc/build.info
+
+# caching in local maven repo all dependencies to make it
+# easier for drools kie-ci - aether to fetch them
mvn dependency:get -Dartifact=com.att.research.xacml:xacml-pdp:1.0.0:jar
+
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:archetype-cl-amsterdam:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:events:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:appc:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:appclcm:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:aai:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:so:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:trafficgenerator:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:eventmanager:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:guard:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:actorServiceProvider:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:actor.appc:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:actor.appclcm:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:actor.so:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:actor.vfc:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:policy-yaml:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:demo:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:template.demo:${version}:jar -Dtransitive=false
+mvn dependency:get -Dartifact=org.onap.policy.drools-applications:guard:${version}:jar -Dtransitive=false
diff --git a/controlloop/packages/basex/src/files/bin/create-cl-amsterdam b/controlloop/packages/basex/src/files/bin/create-cl-amsterdam
new file mode 100644
index 000000000..6aad8a33a
--- /dev/null
+++ b/controlloop/packages/basex/src/files/bin/create-cl-amsterdam
@@ -0,0 +1,235 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# PDP-D APPS Base Package
+# ================================================================================
+# 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=========================================================
+###
+
+# Interactive script to generate and install in a pdp-d control loops demo rules
+# for a standalone PDP-D usage
+
+source ${POLICY_HOME}/etc/build.info
+
+echo "Control Loop CLI Generator for R1 Amsterdam Release"
+echo "---------------------------------------------------"
+echo
+
+GROUP_ID="org.onap.policy.rules.amsterdam"
+ARTIFACT_ID="amsterdam"
+VERSION="1.1.0"
+PACKAGE="org.onap.policy.rules.amsterdam"
+CONTROL_LOOP_NAME="ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e"
+POLICY_SCOPE="amsterdam"
+POLICY_NAME="vcpe"
+POLICY_VERSION="v0.0.1"
+CONTROL_LOOP_YAML="controlLoop%3A%0A++version%3A+2.0.0%0A++controlLoopName%3A+ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A++trigger_policy%3A+unique-policy-id-1-restart%0A++timeout%3A+3600%0A+%0Apolicies%3A%0A+%0A++-+id%3A+unique-policy-id-1-restart%0A++++name%3A+Restart+the+VM%0A++++description%3A%0A++++actor%3A+APPC%0A++++recipe%3A+Restart%0A++++target%3A%0A++++++type%3A+VM%0A++++retry%3A+3%0A++++timeout%3A+1200%0A++++success%3A+final_success%0A++++failure%3A+final_failure%0A++++failure_timeout%3A+final_failure_timeout%0A++++failure_retries%3A+final_failure_retries%0A++++failure_exception%3A+final_failure_exception%0A++++failure_guard%3A"
+DMAAP_SERVERS="vm1.mr.simpledemo.openecomp.org"
+DCAE_TOPIC="unauthenticated.TCA_EVENT_OUTPUT"
+DCAE_SERVERS="10.0.4.102"
+
+read -e -i "${GROUP_ID}" -p "Target Rules Group Id> " GROUP_ID
+read -e -i "${ARTIFACT_ID}" -p "Target Rules Artifact Id> " ARTIFACT_ID
+read -e -i "${VERSION}" -p "Target Rules Version> " VERSION
+read -e -i "${PACKAGE}" -p "Target Rules Java Package> " PACKAGE
+
+read -e -i "${CONTROL_LOOP_NAME}" -p "Template Control Loop Name> " CONTROL_LOOP_NAME
+read -e -i "${POLICY_SCOPE}" -p "Template Policy Scope> " POLICY_SCOPE
+read -e -i "${POLICY_NAME}" -p "Template Policy Name> " POLICY_NAME
+read -e -i "${POLICY_VERSION}" -p "Template Policy Version> " POLICY_VERSION
+
+read -e -i "${CONTROL_LOOP_YAML}" -p "Control Loop Yaml> " CONTROL_LOOP_YAML
+
+read -e -i "${DCAE_SERVERS}" -p "Configuration DCAE DMaaP Servers> " DCAE_SERVERS
+read -e -i "${DMAAP_SERVERS}" -p "Configuration Open DMaaP Servers> " DMAAP_SERVERS
+read -e -i "${DCAE_TOPIC}" -p "Template DCAE Topic> " DCAE_TOPIC
+
+echo
+echo
+
+if [ -z "${GROUP_ID}" ]; then echo "Aborting: Rules Maven Group Id not provided"; exit 1; fi
+if [ -z "${ARTIFACT_ID}" ]; then echo "Aborting: Rules Maven Coordinates Artifact Id not provided"; exit 1; fi
+if [ -z "${VERSION}" ]; then echo "Aborting: Rules Maven Coordinates Version not provided"; exit 1; fi
+if [ -z "${PACKAGE}" ]; then echo "Aborting: Rules Package not provided"; exit 1; fi
+if [ -z "${CONTROL_LOOP_NAME}" ]; then echo "Aborting: Template Control Loop Name not provided"; exit 1; fi
+if [ -z "${POLICY_SCOPE}" ]; then echo "Aborting: Template Policy Scope not provided"; exit 1; fi
+if [ -z "${POLICY_NAME}" ]; then echo "Aborting: Template Policy Name not provided"; exit 1; fi
+if [ -z "${POLICY_VERSION}" ]; then echo "Aborting: Template Policy Version not provided"; exit 1; fi
+if [ -z "${CONTROL_LOOP_YAML}" ]; then echo "Aborting: Control Loop Yaml not provided"; exit 1; fi
+
+if [ -z "${DCAE_TOPIC}" ]; then echo "Aborting: Configuration DCAE DMaaP Topic not provided"; exit 1; fi
+if [ -z "${DMAAP_SERVERS}" ]; then echo "Aborting: Configuration Open DMaaP Servers not provided"; exit 1; fi
+if [ -z "${DCAE_SERVERS}" ]; then echo "Aborting: Configuration DCAE DMaaP Servers not provided"; exit 1; fi
+
+if [[ "${version}" == *-SNAPSHOT ]]; then
+ DEPENDENCIES_VERSION="1.1.0-SNAPSHOT"
+else
+ DEPENDENCIES_VERSION="${version}"
+fi
+
+read -e -i "${DEPENDENCIES_VERSION}" -p "Control Loop Jar Dependencies Version (ie: 1.1.0-SNAPSHOT, or 1.1.0) > " DEPENDENCIES_VERSION
+if [ -z "${DEPENDENCIES_VERSION}" ]; then echo "Aborting: Control Loop Jar Dependencies Version not provided"; exit 1; fi
+
+echo "---------------------------------------------------------------------------------------"
+echo "Please review the Control Loop Rules, Template, and Configuration Parameters:"
+echo
+echo "The generated rules jar will be installed in a local Maven Repository"
+echo
+echo "Rules Maven Artifact Generation: Group Id: ${GROUP_ID}"
+echo "Rules Maven Artifact Generation: Artifact Id: ${ARTIFACT_ID}"
+echo "Rules Maven Artifact Generation: Version: ${VERSION}"
+echo "Rules Maven Artifact Generation: Java Package: ${PACKAGE}"
+echo "Rules Maven Artifact Generation: pom: Java Libraries Dependencies Version: ${DEPENDENCIES_VERSION}"
+echo
+echo "Template Drools DRL Expansion: Control Loop Control Name: ${CONTROL_LOOP_NAME}"
+echo "Template Drools DRL Expansion: Control Loop Policy Scope: ${POLICY_SCOPE}"
+echo "Template Drools DRL Expansion: Control Loop Policy Name: ${POLICY_NAME}"
+echo "Template Drools DRL Expansion: Control Loop Policy Version: ${POLICY_VERSION}"
+echo "Template Drools DRL Expansion: Control Loop Yaml: ${CONTROL_LOOP_YAML}"
+echo
+echo "Configuration Policy Controller: Rules: Group Id: ${GROUP_ID}"
+echo "Configuration Policy Controller: Rules: Artifact Id: ${ARTIFACT_ID}"
+echo "Configuration Policy Controller: Rules: Version: ${VERSION}"
+echo
+echo "Configuration Policy Controller: DCAE DMaaP Topic: ${DCAE_TOPIC}"
+echo "Configuration Policy Controller: DCAE DMaaP Servers: ${DCAE_SERVERS}"
+echo
+echo "Configuration Policy Controller: Open DMaaP Servers: ${DMAAP_SERVERS}"
+echo "---------------------------------------------------------------------------------------"
+echo
+
+HAPPY="Y"
+read -e -i "${HAPPY}" -p "Are the previous parameters correct (Y/N)? " HAPPY
+if [[ ${HAPPY} != "Y" ]]; then
+ exit 1
+fi
+
+echo
+DIR_TMP="/tmp"
+echo "The Control Loop Rules Maven Project Source Rules will be installed at ${DIR_TMP}"
+read -e -i "${DIR_TMP}" -p "Do you want to change the Rules Source Project install directory? " DIR_TMP
+
+if [ ! -w "${DIR_TMP}" ]; then
+ echo "Aborting. ${DIR_TMP} is not writable"
+ exit 1
+fi
+
+ARCHETYPE_GROUP_ID="org.onap.policy.drools-applications"
+ARCHETYPE_ARTIFACT_ID="archetype-cl-amsterdam"
+ARCHETYPE_VERSION="${VERSION}"
+
+if [ -d "${DIR_TMP}/${ARTIFACT_ID}/" ]; then
+ if [ "$(ls -A "${DIR_TMP}/${ARTIFACT_ID}"/)" ]; then
+ echo "${DIR_TMP} already contains a ${ARTIFACT_ID}/ directory, saving it to ${DIR_TMP}/${ARTIFACT_ID}.arch.bak/"
+ if [ -d "${DIR_TMP}/${ARTIFACT_ID}.arch.bak"/ ]; then
+ (
+ echo "${DIR_TMP}/${ARTIFACT_ID}.arch.bak/ also exists, deleting it .."
+ cd "${DIR_TMP}"/
+ rm -fr "${ARTIFACT_ID}.arch.bak"
+ )
+ fi
+ /bin/mv --force "${DIR_TMP}/${ARTIFACT_ID}/" "${DIR_TMP}/${ARTIFACT_ID}.arch.bak"
+ if [ "${?}" -ne 0 ]; then
+ echo
+ echo
+ echo "Aborting: ${DIR_TMP}/${ARTIFACT_ID}/ cannot be moved"
+ exit 1
+ fi
+ else
+ ( cd "${DIR_TMP}/" ; rmdir "${DIR_TMP}/${ARTIFACT_ID}/" )
+ fi
+fi
+
+CREATEARTIFACT="Y"
+read -e -i "${CREATEARTIFACT}" -p "Create Maven Artifact (Y/N)? " CREATEARTIFACT
+if [[ ${CREATEARTIFACT} != "Y" ]]; then
+ exit 1
+fi
+
+(
+cd "${DIR_TMP}"
+
+mvn archetype:generate \
+ -B \
+ -DarchetypeCatalog=local \
+ -DarchetypeGroupId="${ARCHETYPE_GROUP_ID}" \
+ -DarchetypeArtifactId="${ARCHETYPE_ARTIFACT_ID}" \
+ -DarchetypeVersion="${ARCHETYPE_VERSION}" \
+ -Dpackage="${PACKAGE}" \
+ -DgroupId="${GROUP_ID}" \
+ -DartifactId="${ARTIFACT_ID}" \
+ -Dversion="${VERSION}" \
+ -DclosedLoopControlName="${CONTROL_LOOP_NAME}" \
+ -DcontrolLoopYaml="${CONTROL_LOOP_YAML}" \
+ -DpolicyScope="${POLICY_SCOPE}" \
+ -DpolicyName="${POLICY_NAME}" \
+ -DpolicyVersion="${POLICY_VERSION}" \
+ -DdmaapServers="${DMAAP_SERVERS}" \
+ -DdcaeTopic="${DCAE_TOPIC}" \
+ -DdcaeServers="${DCAE_SERVERS}" \
+ -DdependenciesVersion="${DEPENDENCIES_VERSION}"
+
+if [ "${?}" -ne 0 ]; then
+ echo
+ echo
+ echo "Aborting: ${ARTIFACT_ID} has not been successfully generated"
+ exit 1
+fi
+
+echo
+
+cd "${DIR_TMP}/${ARTIFACT_ID}"/
+
+mv src/main/config/* .
+
+echo
+echo "Control Loop Rules from templates have been successfully created under ${DIR_TMP}/${ARTIFACT_ID}/"
+echo "You have to option to further tweak this project or deploy it as is to the local maven repository."
+echo "If you decide to customize the source rules project, please enter 'N' below,"
+echo "and when finished type 'mvn install' at ${DIR_TMP}/${ARTIFACT_ID}/ to install the Control Loop."
+
+INSTALLREPO="Y"
+read -e -i "${INSTALLREPO}" -p "Do you want to deploy ${ARTIFACT_ID} rules into maven repository (Y/N)? " INSTALLREPO
+if [[ ${INSTALLREPO} != "Y" ]]; then
+ exit 1
+fi
+
+echo
+echo "installing the rules ${ARTIFACT_ID} maven artifact .."
+
+mvn install
+
+if [ "${?}" -ne 0 ]; then
+ echo
+ echo
+ echo "Aborting: ${ARTIFACT_ID} deployable jar cannot be installed"
+ echo "Fix the source rules project issues, and issue 'mvn install'"
+ echo "at ${DIR_TMP}/${ARTIFACT_ID}/ when done to install it."
+ exit 1
+fi
+
+
+echo
+echo "${ARTIFACT_ID} has been successfully installed in user's (${USER}) local repository"
+echo "Find configuration files at ${DIR_TMP}/${ARTIFACT_ID}/"
+echo
+echo "To deploy this Control Loop into the PDP-D, follow one of these methods: "
+echo "1. copy ${DIR_TMP}/${ARTIFACT_ID}/${ARTIFACT_ID}-controller.properties under '${POLICY_HOME}/config'"
+echo " and restart the pdp-d (policy stop; policy start)"
+echo "2. rest-add-controller ${ARTIFACT_ID}"
+echo
+)
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.success.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.success.json
new file mode 100644
index 000000000..6f8af9b64
--- /dev/null
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.success.json
@@ -0,0 +1,22 @@
+{
+ "body": {
+ "output": {
+ "common-header": {
+ "timestamp": "2017-08-25T21:06:23.037Z",
+ "api-ver": "5.00",
+ "originator-id": "a20e2073-30b1-4357-893b-f5ed57b66ef0",
+ "request-id": "664be3d2-6c12-4f4b-a3e7-c349acced200",
+ "sub-request-id": "1",
+ "flags": {}
+ },
+ "status": {
+ "code": 400,
+ "message": "Restart Successful"
+ }
+ }
+ },
+ "version": "2.0",
+ "rpc-name": "restart",
+ "correlation-id": "a20e2073-30b1-4357-893b-f5ed57b66ef0-1",
+ "type": "response"
+} \ No newline at end of file
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 5e90f052d..a2939a0bf 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -627,7 +627,6 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
if(guardEnabled){
Thread t = new Thread(new org.onap.policy.guard.CallGuardTask(
- null,
PolicyEngine.manager.getEnvironmentProperty("guard.url"),
drools.getWorkingMemory(),
$event.closedLoopControlName,
@@ -667,7 +666,7 @@ rule "${policyName}.GUARD.RESPONSE"
//we will permit the operation if there was no Guard for it
- if($guardResponse.result == "Indeterminate"){
+ if("Indeterminate".equals($guardResponse.result)){
$guardResponse.result = "Permit";
}
@@ -685,7 +684,7 @@ rule "${policyName}.GUARD.RESPONSE"
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
- if($guardResponse.result == "Permit"){
+ if("Permit".equals($guardResponse.result)){
modify($operation){setGuardApprovalStatus($guardResponse.result)};
}
diff --git a/controlloop/templates/template.demo/pom.xml b/controlloop/templates/template.demo/pom.xml
index d3d3ef0ab..69c2da80e 100644
--- a/controlloop/templates/template.demo/pom.xml
+++ b/controlloop/templates/template.demo/pom.xml
@@ -203,5 +203,11 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
index 82899f08b..ff184b385 100644
--- a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
+++ b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
@@ -589,7 +589,6 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
if(guardEnabled){
Thread t = new Thread(new org.onap.policy.guard.CallGuardTask(
- XacmlPdpEngine,
"",
drools.getWorkingMemory(),
$event.closedLoopControlName,
@@ -636,7 +635,7 @@ rule "${policyName}.GUARD.RESPONSE"
//we will permit the operation if there was no Guard for it
- if($guardResponse.result == "Indeterminate"){
+ if("Indeterminate".equals($guardResponse.result)){
$guardResponse.result = "Permit";
}
@@ -655,7 +654,7 @@ rule "${policyName}.GUARD.RESPONSE"
- if($guardResponse.result == "Permit"){
+ if("Permit".equals($guardResponse.result)){
modify($operation){setGuardApprovalStatus($guardResponse.result)};
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
index 64ad490b2..5fe2f6222 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
@@ -47,6 +47,7 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.TargetType;
+import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.guard.PolicyGuard;
@@ -75,6 +76,7 @@ public class ControlLoopXacmlGuardTest {
@BeforeClass
public static void setPUProp(){
System.setProperty(OPSHISTPUPROP, "TestOperationsHistoryPU");
+ PolicyEngine.manager.setEnvironmentProperty("guard.url", "http://127.0.0.1:8443/pdp");
}
@AfterClass
public static void restorePUProp(){
@@ -171,7 +173,7 @@ public class ControlLoopXacmlGuardTest {
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
- Thread.sleep(4000);
+ Thread.sleep(2*4000);
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
@@ -210,7 +212,7 @@ public class ControlLoopXacmlGuardTest {
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
- Thread.sleep(4000);
+ Thread.sleep(2*4000);
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
@@ -238,7 +240,7 @@ public class ControlLoopXacmlGuardTest {
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
- Thread.sleep(1000);
+ Thread.sleep(2*1000);
obj = engine.subscribe("UEB", "APPC-CL");
assertNotNull(obj);
@@ -277,7 +279,7 @@ public class ControlLoopXacmlGuardTest {
//
// now wait for it to finish
//
- Thread.sleep(15000);
+ Thread.sleep(2*15000);
//
// Ensure they released the lock
//
diff --git a/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml b/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml
index c3740d0b2..820874105 100644
--- a/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml
+++ b/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml
@@ -14,7 +14,7 @@
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
- <property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level" value="CONFIG" />
</properties>
</persistence-unit>
diff --git a/pom.xml b/pom.xml
index 73769ad61..0c25498b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>0.1.1</version>
<relativePath/>
</parent>