summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java12
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java24
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java102
-rw-r--r--controlloop/packages/basex-controlloop/src/files/config/controlloop.properties.environment8
4 files changed, 100 insertions, 46 deletions
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java
index 123fe2fa1..3c43756c3 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java
@@ -177,20 +177,12 @@ public interface ControlLoopPolicyBuilder {
/**
* Creates a policy that is chained to the result of another Policy.
*
- * @param name name
- * @param description description
- * @param actor actor
- * @param target target
- * @param recipe recipe
- * @param retries retries
- * @param timeout timeout
- * @param policyId id
+ * @param policyParam policy parameters object
* @param results results
* @return Policy that was set
* @throws BuilderException builder exception
*/
- public Policy setPolicyForPolicyResult(String name, String description, String actor, Target target, String recipe,
- Map<String, String> payload, Integer retries, Integer timeout, String policyId, PolicyResult... results)
+ public Policy setPolicyForPolicyResult(PolicyParam policyParam, PolicyResult... results)
throws BuilderException;
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
index 6950523cb..bd3939886 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
@@ -228,30 +228,28 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
}
@Override
- public Policy setPolicyForPolicyResult(String name, String description, String actor, Target target, String recipe,
- Map<String, String> payload, Integer retries, Integer timeout,
- String policyId, PolicyResult... results)
+ public Policy setPolicyForPolicyResult(PolicyParam policyParam, PolicyResult... results)
throws BuilderException {
//
// Find the existing policy
//
- Policy existingPolicy = this.findPolicy(policyId);
+ Policy existingPolicy = this.findPolicy(policyParam.getId());
if (existingPolicy == null) {
- throw new BuilderException(UNKNOWN_POLICY + policyId);
+ throw new BuilderException(UNKNOWN_POLICY + policyParam.getId());
}
//
// Create the new Policy
//
Policy newPolicy = new Policy(
PolicyParam.builder().id(UUID.randomUUID().toString())
- .name(name)
- .description(description)
- .actor(actor)
- .payload(payload)
- .target(target)
- .recipe(recipe)
- .retries(retries)
- .timeout(timeout)
+ .name(policyParam.getName())
+ .description(policyParam.getDescription())
+ .actor(policyParam.getActor())
+ .payload(policyParam.getPayload())
+ .target(policyParam.getTarget())
+ .recipe(policyParam.getRecipe())
+ .retries(policyParam.getRetries())
+ .timeout(policyParam.getTimeout())
.build());
//
// Connect the results
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java
index ac36603a1..be5e488d0 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java
@@ -339,9 +339,20 @@ public class ControlLoopPolicyBuilderTest {
.retries(2)
.timeout(300).build());
@SuppressWarnings("unused")
- Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult("Rebuild VM",
- "If the restart fails, rebuild it", "APPC", new Target(TargetType.VM), "Rebuild", null, 1, 600,
- trigger.getId(), PolicyResult.FAILURE, PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT);
+ Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult(
+ PolicyParam.builder()
+ .name("Rebuild VM")
+ .description("If the restart fails, rebuild it")
+ .actor("APPC")
+ .target(new Target(TargetType.VM))
+ .recipe("Rebuild")
+ .payload(null)
+ .retries(1)
+ .timeout(600)
+ .id(trigger.getId()).build(),
+ PolicyResult.FAILURE,
+ PolicyResult.FAILURE_RETRIES,
+ PolicyResult.FAILURE_TIMEOUT);
assertTrue(builder.calculateTimeout().equals(new Integer(300 + 600)));
//
} catch (BuilderException e) {
@@ -466,10 +477,22 @@ public class ControlLoopPolicyBuilderTest {
//
// Test create a policy and chain it to the results of trigger policy
//
- Policy onRestartFailurePolicy1 = builder.setPolicyForPolicyResult("Rebuild VM",
- "If the restart fails, rebuild it.", "APPC", new Target(TargetType.VM), "Rebuild", null, 1, 600,
- triggerPolicy.getId(), PolicyResult.FAILURE, PolicyResult.FAILURE_EXCEPTION,
- PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT, PolicyResult.FAILURE_GUARD);
+ Policy onRestartFailurePolicy1 = builder.setPolicyForPolicyResult(
+ PolicyParam.builder()
+ .name("Rebuild VM")
+ .description("If the restart fails, rebuild it.")
+ .actor("APPC")
+ .target(new Target(TargetType.VM))
+ .recipe("Rebuild")
+ .payload(null)
+ .retries(1)
+ .timeout(600)
+ .id(triggerPolicy.getId()).build(),
+ PolicyResult.FAILURE,
+ PolicyResult.FAILURE_EXCEPTION,
+ PolicyResult.FAILURE_RETRIES,
+ PolicyResult.FAILURE_TIMEOUT,
+ PolicyResult.FAILURE_GUARD);
//
assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy1.getId()));
assertTrue(builder.getTriggerPolicy().getFailure_exception().equals(onRestartFailurePolicy1.getId()));
@@ -480,9 +503,18 @@ public class ControlLoopPolicyBuilderTest {
//
// Test create a policy and chain it to the results of trigger policy success
//
- Policy onSuccessPolicy1 = builder.setPolicyForPolicyResult("Do something",
- "If the restart succeeds, do something else.", "APPC", new Target(TargetType.VM), "SomethingElse",
- null, 1, 600, triggerPolicy.getId(), PolicyResult.SUCCESS);
+ Policy onSuccessPolicy1 = builder.setPolicyForPolicyResult(
+ PolicyParam.builder()
+ .name("Do something")
+ .description("If the restart succeeds, do something else.")
+ .actor("APPC")
+ .target(new Target(TargetType.VM))
+ .recipe("SomethingElse")
+ .payload(null)
+ .retries(1)
+ .timeout(600)
+ .id(triggerPolicy.getId()).build(),
+ PolicyResult.SUCCESS);
//
assertTrue(builder.getTriggerPolicy().getSuccess().equals(onSuccessPolicy1.getId()));
@@ -502,9 +534,20 @@ public class ControlLoopPolicyBuilderTest {
// Create another policy and chain it to the results of trigger policy
//
final Policy onRestartFailurePolicy2 =
- builder.setPolicyForPolicyResult("Rebuild VM", "If the restart fails, rebuild it.", "APPC",
- new Target(TargetType.VM), "Rebuild", null, 2, 600, triggerPolicy.getId(),
- PolicyResult.FAILURE, PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT);
+ builder.setPolicyForPolicyResult(
+ PolicyParam.builder()
+ .name("Rebuild VM")
+ .description("If the restart fails, rebuild it.")
+ .actor("APPC")
+ .target(new Target(TargetType.VM))
+ .recipe("Rebuild")
+ .payload(null)
+ .retries(2)
+ .timeout(600)
+ .id(triggerPolicy.getId()).build(),
+ PolicyResult.FAILURE,
+ PolicyResult.FAILURE_RETRIES,
+ PolicyResult.FAILURE_TIMEOUT);
//
// Test reset policy results
//
@@ -556,9 +599,21 @@ public class ControlLoopPolicyBuilderTest {
expectedException.expect(BuilderException.class);
expectedException.expectMessage("Unknown policy " + policyId);
- builder.setPolicyForPolicyResult("Rebuild VM", "If the restart fails, rebuild it.", "APPC",
- new Target(TargetType.VM), "Rebuild", null, 1, 600, policyId, PolicyResult.FAILURE,
- PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT, PolicyResult.FAILURE_GUARD);
+ builder.setPolicyForPolicyResult(
+ PolicyParam.builder()
+ .name("Rebuild VM")
+ .description("If the restart fails, rebuild it.")
+ .actor("APPC")
+ .target(new Target(TargetType.VM))
+ .recipe("Rebuild")
+ .payload(null)
+ .retries(1)
+ .timeout(600)
+ .id(policyId).build(),
+ PolicyResult.FAILURE,
+ PolicyResult.FAILURE_RETRIES,
+ PolicyResult.FAILURE_TIMEOUT,
+ PolicyResult.FAILURE_GUARD);
}
@Test
@@ -579,9 +634,18 @@ public class ControlLoopPolicyBuilderTest {
.timeout(300).build());
- Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult("Rebuild VM",
- "If the restart fails, rebuild it.", "APPC", new Target(TargetType.VM), "Rebuild", null, 1, 600,
- triggerPolicy.getId(), PolicyResult.FAILURE);
+ Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult(
+ PolicyParam.builder()
+ .name("Rebuild VM")
+ .description("If the restart fails, rebuild it.")
+ .actor("APPC")
+ .target(new Target(TargetType.VM))
+ .recipe("Rebuild")
+ .payload(null)
+ .retries(1)
+ .timeout(600)
+ .id(triggerPolicy.getId()).build(),
+ PolicyResult.FAILURE);
final String unknownPolicyId = "100";
expectedException.expect(BuilderException.class);
diff --git a/controlloop/packages/basex-controlloop/src/files/config/controlloop.properties.environment b/controlloop/packages/basex-controlloop/src/files/config/controlloop.properties.environment
index 5f813c204..4e53b3ed6 100644
--- a/controlloop/packages/basex-controlloop/src/files/config/controlloop.properties.environment
+++ b/controlloop/packages/basex-controlloop/src/files/config/controlloop.properties.environment
@@ -45,10 +45,10 @@ pdpx.environment=${{PDP_ENVIRONMENT}}
pdpx.client.username=${{PDP_CLIENT_USERNAME}}
pdpx.client.password=${{PDP_CLIENT_PASSWORD}}
-guard.url=http://${{PDP_HOST}}:8081/pdp/api/getDecision
-guard.jdbc.url=mariadb://${{SQL_HOST}}:3306/operationshistory10
-guard.disabled=true
+guard.url=https://${{PDP_HOST}}:8081/pdp/api/getDecision
+guard.jdbc.url=jdbc:mariadb://${{SQL_HOST}}:3306/onap_sdk
+guard.disabled=false
sdnc.url=${{SDNC_URL}}
sdnc.username=${{SDNC_USERNAME}}
-sdnc.password=${{SDNC_PASSWORD}} \ No newline at end of file
+sdnc.password=${{SDNC_PASSWORD}}