summaryrefslogtreecommitdiffstats
path: root/controlloop
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java14
-rw-r--r--controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml3
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java14
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java12
-rw-r--r--controlloop/common/guard/src/main/resources/operation_history.properties26
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java5
6 files changed, 34 insertions, 40 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index 4f879b67b..608d2c00d 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -47,6 +47,7 @@ import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.so.SOResponse;
import org.onap.policy.vfc.VFCResponse;
+import org.onap.policy.guard.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -555,12 +556,15 @@ public class ControlLoopOperationManager implements Serializable {
// DB Properties
Properties props = new Properties();
- try (InputStream is = org.onap.policy.guard.PIPEngineGetHistory.class.getResourceAsStream(org.onap.policy.guard.PIPEngineGetHistory.OPS_HIST_PROPS_LOC)){
- props.load(is);
- } catch (Exception ex) {
- logger.error("getCountFromDB threw: ", ex);
- return;
+ if(PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL) != null &&
+ PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER) != null &&
+ PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS) != null){
+ props.put(Util.ECLIPSE_LINK_KEY_URL, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL));
+ props.put(Util.ECLIPSE_LINK_KEY_USER, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER));
+ props.put(Util.ECLIPSE_LINK_KEY_PASS, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS));
}
+
+
String OpsHistPU = System.getProperty("OperationsHistoryPU");
if(OpsHistPU == null || !OpsHistPU.equals("TestOperationsHistoryPU")){
OpsHistPU = "OperationsHistoryPU";
diff --git a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
index 827e2562b..9af545592 100644
--- a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
+++ b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
@@ -9,10 +9,9 @@
<!-- <jar-file>packedEntity.jar</jar-file> -->
<class>org.onap.policy.controlloop.eventmanager.OperationsHistoryDbEntry</class>
<properties>
- <property name="eclipselink.ddl-generation" value="create-tables" />
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
<property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" />
<property name="eclipselink.logging.level" value="WARNING" />
- <!-- Credential and URL properties located in /guard/src/main/resources/operation_history.properties -->
</properties>
</persistence-unit>
</persistence>
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
index 57f520894..702edab1f 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
@@ -38,6 +38,7 @@ import javax.persistence.NonUniqueResultException;
import javax.persistence.Persistence;
import javax.persistence.Query;
+import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,7 +78,8 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
private static final Logger logger = LoggerFactory.getLogger(PIPEngineGetHistory.class);
public static final String DEFAULT_DESCRIPTION = "PIP for retrieving Operations History from DB";
- public static final String OPS_HIST_PROPS_LOC = "/operation_history.properties";
+
+
//
// Base issuer string. The issuer in the policy will also contain time window information
@@ -320,12 +322,10 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
// DB Properties
Properties props = new Properties();
- try (InputStream is = org.onap.policy.guard.PIPEngineGetHistory.class.getResourceAsStream(OPS_HIST_PROPS_LOC)){
- props.load(is);
- } catch (IOException ex) {
- logger.error("getCountFromDB threw: ", ex);
- return -1;
- }
+ props.put(Util.ECLIPSE_LINK_KEY_URL, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL));
+ props.put(Util.ECLIPSE_LINK_KEY_USER, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER));
+ props.put(Util.ECLIPSE_LINK_KEY_PASS, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS));
+
EntityManager em = null;
String OpsHistPU = System.getProperty("OperationsHistoryPU");
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
index f572cd7fa..ca62f6149 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
@@ -48,6 +48,18 @@ public final class Util {
public static final String PROP_GUARD_CLIENT_USER = "pdpx.client.username";
public static final String PROP_GUARD_CLIENT_PASS = "pdpx.client.password";
public static final String PROP_GUARD_ENV = "pdpx.environment";
+ public static final String PROP_GUARD_DISABLED = "guard.disabled";
+
+ /*
+ * Keys for eclipse link and ONAP properties
+ */
+ public static final String ECLIPSE_LINK_KEY_URL = "javax.persistence.jdbc.url";
+ public static final String ECLIPSE_LINK_KEY_USER = "javax.persistence.jdbc.user";
+ public static final String ECLIPSE_LINK_KEY_PASS = "javax.persistence.jdbc.password";
+
+ public static final String ONAP_KEY_URL = "guard.jdbc.url";
+ public static final String ONAP_KEY_USER = "sql.db.username";
+ public static final String ONAP_KEY_PASS = "sql.db.password";
/*
* Guard responses
diff --git a/controlloop/common/guard/src/main/resources/operation_history.properties b/controlloop/common/guard/src/main/resources/operation_history.properties
deleted file mode 100644
index 8c374a85b..000000000
--- a/controlloop/common/guard/src/main/resources/operation_history.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#/*-
-# * ============LICENSE_START=======================================================
-# * guard
-# * ================================================================================
-# * 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=========================================================
-# */
-
-#
-# Maria DB Operation History Credentials
-#
-javax.persistence.jdbc.user=root
-javax.persistence.jdbc.password=aaaa
-javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/policy
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
index 0c633c477..ab365af77 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
@@ -31,6 +31,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -260,12 +261,16 @@ public final class Util {
}
public static void setGuardProps(){
+ /*
+ * Guard PDP-x connection Properties
+ */
PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL, "http://localhost:6669/pdp/api/getDecision");
PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, "python");
PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, "test");
PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_USER, "python");
PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_PASS, "test");
PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_ENV, "TEST");
+ PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_DISABLED, "false");
}
public static void setVFCProps() {