diff options
Diffstat (limited to 'ECOMP-ControlloopPolicy')
49 files changed, 8358 insertions, 454 deletions
diff --git a/ECOMP-ControlloopPolicy/pom.xml b/ECOMP-ControlloopPolicy/pom.xml index 18b2c5ded..870ba148f 100644 --- a/ECOMP-ControlloopPolicy/pom.xml +++ b/ECOMP-ControlloopPolicy/pom.xml @@ -1,3 +1,22 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP Policy Engine + ================================================================================ + 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> @@ -9,6 +28,11 @@ </parent> <dependencies> <dependency> + <groupId>org.openecomp.policy.engine</groupId> + <artifactId>asdc</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> @@ -29,5 +53,10 @@ <artifactId>guava</artifactId> <version>19.0</version> </dependency> + <dependency> + <groupId>org.openecomp.policy.common</groupId> + <artifactId>ECOMP-Logging</artifactId> + <version>${common-modules.version}</version> + </dependency> </dependencies> </project> diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/CompilerException.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/CompilerException.java index 7c124d5fd..78f30570c 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/CompilerException.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/CompilerException.java @@ -25,6 +25,7 @@ public class CompilerException extends Exception { private static final long serialVersionUID = -7262217239867898601L; public CompilerException() { + //Empty Constructor } public CompilerException(String message) { diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java index fca229242..799371a2a 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java @@ -21,15 +21,19 @@ package org.openecomp.policy.controlloop.compiler; import java.io.InputStream; +import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.jgrapht.DirectedGraph; import org.jgrapht.graph.ClassBasedEdgeFactory; import org.jgrapht.graph.DefaultEdge; import org.jgrapht.graph.DirectedMultigraph; +import org.openecomp.policy.common.logging.flexlogger.FlexLogger; +import org.openecomp.policy.common.logging.flexlogger.Logger; import org.openecomp.policy.controlloop.policy.ControlLoop; import org.openecomp.policy.controlloop.policy.ControlLoopPolicy; import org.openecomp.policy.controlloop.policy.FinalResult; @@ -43,16 +47,18 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; public class ControlLoopCompiler { + private static Logger LOGGER = FlexLogger.getLogger(ControlLoopCompiler.class.getName()); public static ControlLoopPolicy compile(ControlLoopPolicy policy, ControlLoopCompilerCallback callback) throws CompilerException { // // Ensure the control loop is sane // - validateControlLoop(policy.controlLoop, callback); + validateControlLoop(policy.getControlLoop(), callback); // // Validate the policies // validatePolicies(policy, callback); + return policy; } @@ -69,25 +75,18 @@ public class ControlLoopCompiler { } private static void validateControlLoop(ControlLoop controlLoop, ControlLoopCompilerCallback callback) throws CompilerException { - if (controlLoop == null) { - if (callback != null) { - callback.onError("controlLoop cannot be null"); - } + if (controlLoop == null && callback != null) { + callback.onError("controlLoop cannot be null"); } - if (controlLoop.controlLoopName == null | controlLoop.controlLoopName.length() < 1) { - if (callback != null) { - callback.onError("Missing controlLoopName"); - } + if ((controlLoop.getControlLoopName() == null || controlLoop.getControlLoopName().length() < 1) && callback != null) { + callback.onError("Missing controlLoopName"); } - if (! controlLoop.version.contentEquals(ControlLoop.VERSION)) { - if (callback != null) { - callback.onError("Unsupported version for this compiler"); - } + if ((!controlLoop.getVersion().contentEquals(ControlLoop.getVERSION())) && callback != null) { + callback.onError("Unsupported version for this compiler"); } - if (controlLoop.trigger_policy == null || controlLoop.trigger_policy.length() < 1) { + if (controlLoop.getTrigger_policy() == null || controlLoop.getTrigger_policy().length() < 1) { throw new CompilerException("trigger_policy is not valid"); } - // } private static void validatePolicies(ControlLoopPolicy policy, ControlLoopCompilerCallback callback) throws CompilerException { @@ -97,29 +96,27 @@ public class ControlLoopCompiler { // // verify controlLoop overall timeout should be no less than the sum of operational policy timeouts // - if (policy.policies == null) { + if (policy.getPolicies() == null) { callback.onWarning("controlLoop is an open loop."); } else{ int sum = 0; - for (Policy operPolicy : policy.policies) { - sum += operPolicy.timeout.intValue(); + for (Policy operPolicy : policy.getPolicies()) { + sum += operPolicy.getTimeout().intValue(); } - if (policy.controlLoop.timeout.intValue() < sum) { - if (callback != null) { - callback.onError("controlLoop overall timeout is less than the sum of operational policy timeouts."); - } + if (policy.getControlLoop().getTimeout().intValue() < sum && callback != null) { + callback.onError("controlLoop overall timeout is less than the sum of operational policy timeouts."); } // // For this version we can use a directed multigraph, in the future we may not be able to // - DirectedGraph<NodeWrapper, LabeledEdge> graph = new DirectedMultigraph<NodeWrapper, LabeledEdge>(new ClassBasedEdgeFactory<NodeWrapper, LabeledEdge>(LabeledEdge.class)); + DirectedGraph<NodeWrapper, LabeledEdge> graph = new DirectedMultigraph<>(new ClassBasedEdgeFactory<NodeWrapper, LabeledEdge>(LabeledEdge.class)); // // Check to see if the trigger Event is for OpenLoop, we do so by // attempting to create a FinalResult object from it. If its a policy id, this should // return null. // - FinalResult triggerResult = FinalResult.toResult(policy.controlLoop.trigger_policy); + FinalResult triggerResult = FinalResult.toResult(policy.getControlLoop().getTrigger_policy()); TriggerNodeWrapper triggerNode; // // Did this turn into a FinalResult object? @@ -134,10 +131,8 @@ public class ControlLoopCompiler { // // They really shouldn't have any policies attached. // - if (policy.policies != null || policy.policies.size() > 0) { - if (callback != null) { - callback.onWarning("Open Loop policy contains policies. The policies will never be invoked."); - } + if ((policy.getPolicies() != null || policy.getPolicies().isEmpty())&& callback != null ) { + callback.onWarning("Open Loop policy contains policies. The policies will never be invoked."); } return; // @@ -145,7 +140,7 @@ public class ControlLoopCompiler { // // Ok, not a FinalResult object so let's assume that it is a Policy. Which it should be. // - triggerNode = new TriggerNodeWrapper(policy.controlLoop.controlLoopName); + triggerNode = new TriggerNodeWrapper(policy.getControlLoop().getControlLoopName()); } // // Add in the trigger node @@ -169,132 +164,12 @@ public class ControlLoopCompiler { // // Work through the policies and add them in as nodes. // - Map<Policy, PolicyNodeWrapper> mapNodes = new HashMap<Policy, PolicyNodeWrapper>(); - for (Policy operPolicy : policy.policies) { - // - // Check the policy id and make sure its sane - // - boolean okToAdd = true; - if (operPolicy.id == null || operPolicy.id.length() < 1) { - if (callback != null) { - callback.onError("Operational Policy has an bad ID"); - } - okToAdd = false; - } - // - // Check if they decided to make the ID a result object - // - if (PolicyResult.toResult(operPolicy.id) != null) { - if (callback != null) { - callback.onError("Policy id is set to a PolicyResult " + operPolicy.id); - } - okToAdd = false; - } - if (FinalResult.toResult(operPolicy.id) != null) { - if (callback != null) { - callback.onError("Policy id is set to a FinalResult " + operPolicy.id); - } - okToAdd = false; - } - // - // Check that the actor/recipe/target are valid - // - if (operPolicy.actor == null) { - if (callback != null) { - callback.onError("Policy actor is null"); - } - okToAdd = false; - } - // - // Construct a list for all valid actors - // - ImmutableList<String> actors = ImmutableList.of("APPC", "AOTS", "MSO", "SDNO", "SDNR", "AAI"); - // - if (operPolicy.actor != null && (!actors.contains(operPolicy.actor)) ) { - if (callback != null) { - callback.onError("Policy actor is invalid"); - } - okToAdd = false; - } - if (operPolicy.recipe == null) { - if (callback != null) { - callback.onError("Policy recipe is null"); - } - okToAdd = false; - } - // - // TODO: - // NOTE: We need a way to find the acceptable recipe values (either Enum or a database that has these) - // - ImmutableMap<String, List<String>> recipes = new ImmutableMap.Builder<String, List<String>>() - .put("APPC", ImmutableList.of("Restart", "Rebuild", "Migrate", "ModifyConfig")) - .put("AOTS", ImmutableList.of("checkMaintenanceWindow", "checkENodeBTicketHours", "checkEquipmentStatus", "checkEimStatus", "checkEquipmentMaintenance")) - .put("MSO", ImmutableList.of("VF Module Create")) - .put("SDNO", ImmutableList.of("health-diagnostic-type", "health-diagnostic", "health-diagnostic-history", "health-diagnostic-commands", "health-diagnostic-aes")) - .put("SDNR", ImmutableList.of("Restart", "Reboot")) - .build(); - // - if (operPolicy.recipe != null && (!recipes.getOrDefault(operPolicy.actor, Collections.emptyList()).contains(operPolicy.recipe))) { - if (callback != null) { - callback.onError("Policy recipe is invalid"); - } - okToAdd = false; - } - if (operPolicy.target == null) { - if (callback != null) { - callback.onError("Policy target is null"); - } - okToAdd = false; - } - if (operPolicy.target != null && operPolicy.target.type != TargetType.VM && operPolicy.target.type != TargetType.VFC && operPolicy.target.type != TargetType.PNF) { - if (callback != null) { - callback.onError("Policy target is invalid"); - } - okToAdd = false; - } - // - // Check that policy results are connected to either default final * or another policy - // - if (FinalResult.toResult(operPolicy.success) != null && operPolicy.success != FinalResult.FINAL_SUCCESS.toString()) { - if (callback != null) { - callback.onError("Policy success is neither another policy nor FINAL_SUCCESS"); - } - okToAdd = false; - } - if (FinalResult.toResult(operPolicy.failure) != null && operPolicy.failure != FinalResult.FINAL_FAILURE.toString()) { - if (callback != null) { - callback.onError("Policy failure is neither another policy nor FINAL_FAILURE"); - } - okToAdd = false; - } - if (FinalResult.toResult(operPolicy.failure_retries) != null && operPolicy.failure_retries != FinalResult.FINAL_FAILURE_RETRIES.toString()) { - if (callback != null) { - callback.onError("Policy failure retries is neither another policy nor FINAL_FAILURE_RETRIES"); - } - okToAdd = false; - } - if (FinalResult.toResult(operPolicy.failure_timeout) != null && operPolicy.failure_timeout != FinalResult.FINAL_FAILURE_TIMEOUT.toString()) { - if (callback != null) { - callback.onError("Policy failure timeout is neither another policy nor FINAL_FAILURE_TIMEOUT"); - } - okToAdd = false; - } - if (FinalResult.toResult(operPolicy.failure_exception) != null && operPolicy.failure_exception != FinalResult.FINAL_FAILURE_EXCEPTION.toString()) { - if (callback != null) { - callback.onError("Policy failure exception is neither another policy nor FINAL_FAILURE_EXCEPTION"); - } - okToAdd = false; - } - if (FinalResult.toResult(operPolicy.failure_guard) != null && operPolicy.failure_guard != FinalResult.FINAL_FAILURE_GUARD.toString()) { - if (callback != null) { - callback.onError("Policy failure guard is neither another policy nor FINAL_FAILURE_GUARD"); - } - okToAdd = false; - } + Map<Policy, PolicyNodeWrapper> mapNodes = new HashMap<>(); + for (Policy operPolicy : policy.getPolicies()) { // // Is it still ok to add? // - if (okToAdd == false) { + if (!okToAdd(operPolicy, callback)) { // // Do not add it in // @@ -310,7 +185,7 @@ public class ControlLoopCompiler { // // Is this the trigger policy? // - if (operPolicy.id.equals(policy.controlLoop.trigger_policy)) { + if (operPolicy.getId().equals(policy.getControlLoop().getTrigger_policy())) { // // Yes add an edge from our trigger event node to this policy // @@ -320,7 +195,7 @@ public class ControlLoopCompiler { // // last sweep to connect remaining edges for policy results // - for (Policy operPolicy : policy.policies) { + for (Policy operPolicy : policy.getPolicies()) { PolicyNodeWrapper node = mapNodes.get(operPolicy); // // Just ensure this has something @@ -328,62 +203,62 @@ public class ControlLoopCompiler { if (node == null) { continue; } - if (FinalResult.isResult(operPolicy.success, FinalResult.FINAL_SUCCESS)) { + if (FinalResult.isResult(operPolicy.getSuccess(), FinalResult.FINAL_SUCCESS)) { graph.addEdge(node, finalSuccess, new LabeledEdge(node, finalSuccess, new FinalResultEdgeWrapper(FinalResult.FINAL_SUCCESS))); } else { - PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.success); + PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.getSuccess()); if (toNode == null) { - throw new CompilerException("Operation Policy " + operPolicy.id + " success is connected to unknown policy " + operPolicy.success); + throw new CompilerException("Operation Policy " + operPolicy.getId() + " success is connected to unknown policy " + operPolicy.getSuccess()); } else { graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(PolicyResult.SUCCESS))); } } - if (FinalResult.isResult(operPolicy.failure, FinalResult.FINAL_FAILURE)) { + if (FinalResult.isResult(operPolicy.getFailure(), FinalResult.FINAL_FAILURE)) { graph.addEdge(node, finalFailure, new LabeledEdge(node, finalFailure, new FinalResultEdgeWrapper(FinalResult.FINAL_FAILURE))); } else { - PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.failure); + PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.getFailure()); if (toNode == null) { - throw new CompilerException("Operation Policy " + operPolicy.id + " failure is connected to unknown policy " + operPolicy.failure); + throw new CompilerException("Operation Policy " + operPolicy.getId() + " failure is connected to unknown policy " + operPolicy.getFailure()); } else { graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(PolicyResult.FAILURE))); } } - if (FinalResult.isResult(operPolicy.failure_timeout, FinalResult.FINAL_FAILURE_TIMEOUT)) { + if (FinalResult.isResult(operPolicy.getFailure_timeout(), FinalResult.FINAL_FAILURE_TIMEOUT)) { graph.addEdge(node, finalFailureTimeout, new LabeledEdge(node, finalFailureTimeout, new FinalResultEdgeWrapper(FinalResult.FINAL_FAILURE_TIMEOUT))); } else { - PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.failure_timeout); + PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.getFailure_timeout()); if (toNode == null) { - throw new CompilerException("Operation Policy " + operPolicy.id + " failure_timeout is connected to unknown policy " + operPolicy.failure_timeout); + throw new CompilerException("Operation Policy " + operPolicy.getId() + " failure_timeout is connected to unknown policy " + operPolicy.getFailure_timeout()); } else { graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(PolicyResult.FAILURE_TIMEOUT))); } } - if (FinalResult.isResult(operPolicy.failure_retries, FinalResult.FINAL_FAILURE_RETRIES)) { + if (FinalResult.isResult(operPolicy.getFailure_retries(), FinalResult.FINAL_FAILURE_RETRIES)) { graph.addEdge(node, finalFailureRetries, new LabeledEdge(node, finalFailureRetries, new FinalResultEdgeWrapper(FinalResult.FINAL_FAILURE_RETRIES))); } else { - PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.failure_retries); + PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.getFailure_retries()); if (toNode == null) { - throw new CompilerException("Operation Policy " + operPolicy.id + " failure_retries is connected to unknown policy " + operPolicy.failure_retries); + throw new CompilerException("Operation Policy " + operPolicy.getId() + " failure_retries is connected to unknown policy " + operPolicy.getFailure_retries()); } else { graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(PolicyResult.FAILURE_RETRIES))); } } - if (FinalResult.isResult(operPolicy.failure_exception, FinalResult.FINAL_FAILURE_EXCEPTION)) { + if (FinalResult.isResult(operPolicy.getFailure_exception(), FinalResult.FINAL_FAILURE_EXCEPTION)) { graph.addEdge(node, finalFailureException, new LabeledEdge(node, finalFailureException, new FinalResultEdgeWrapper(FinalResult.FINAL_FAILURE_EXCEPTION))); } else { - PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.failure_exception); + PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.getFailure_exception()); if (toNode == null) { - throw new CompilerException("Operation Policy " + operPolicy.id + " failure_exception is connected to unknown policy " + operPolicy.failure_exception); + throw new CompilerException("Operation Policy " + operPolicy.getId() + " failure_exception is connected to unknown policy " + operPolicy.getFailure_exception()); } else { graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(PolicyResult.FAILURE_EXCEPTION))); } } - if (FinalResult.isResult(operPolicy.failure_guard, FinalResult.FINAL_FAILURE_GUARD)) { + if (FinalResult.isResult(operPolicy.getFailure_guard(), FinalResult.FINAL_FAILURE_GUARD)) { graph.addEdge(node, finalFailureGuard, new LabeledEdge(node, finalFailureGuard, new FinalResultEdgeWrapper(FinalResult.FINAL_FAILURE_GUARD))); } else { - PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.failure_guard); + PolicyNodeWrapper toNode = findPolicyNode(mapNodes, operPolicy.getFailure_guard()); if (toNode == null) { - throw new CompilerException("Operation Policy " + operPolicy.id + " failure_guard is connected to unknown policy " + operPolicy.failure_guard); + throw new CompilerException("Operation Policy " + operPolicy.getId() + " failure_guard is connected to unknown policy " + operPolicy.getFailure_guard()); } else { graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(PolicyResult.FAILURE_GUARD))); } @@ -394,7 +269,7 @@ public class ControlLoopCompiler { // for (NodeWrapper node : graph.vertexSet()) { if (node instanceof TriggerNodeWrapper) { - System.out.println("Trigger Node " + node.toString()); + LOGGER.info("Trigger Node " + node.toString()); if (graph.inDegreeOf(node) > 0 ) { // // Really should NEVER get here unless someone messed up the code above. @@ -408,7 +283,7 @@ public class ControlLoopCompiler { throw new CompilerException("The event trigger should only go to ONE node"); } } else if (node instanceof FinalResultNodeWrapper) { - System.out.println("FinalResult Node " + node.toString()); + LOGGER.info("FinalResult Node " + node.toString()); // // FinalResult nodes should NEVER have an out edge // @@ -416,7 +291,7 @@ public class ControlLoopCompiler { throw new CompilerException("FinalResult nodes should never have any out edges."); } } else if (node instanceof PolicyNodeWrapper) { - System.out.println("Policy Node " + node.toString()); + LOGGER.info("Policy Node " + node.toString()); // // All Policy Nodes should have the 5 out degrees defined. // @@ -424,38 +299,159 @@ public class ControlLoopCompiler { throw new CompilerException("Policy node should ALWAYS have 6 out degrees."); } // - // Chenfei: All Policy Nodes should have at least 1 in degrees + // All Policy Nodes should have at least 1 in degrees // - if (graph.inDegreeOf(node) == 0) { - if (callback != null) { - callback.onWarning("Policy " + node.getID() + " is not reachable."); - } + if (graph.inDegreeOf(node) == 0 && callback != null) { + callback.onWarning("Policy " + node.getID() + " is not reachable."); } } for (LabeledEdge edge : graph.outgoingEdgesOf(node)){ - System.out.println(edge.from.getID() + " invokes " + edge.to.getID() + " upon " + edge.edge.getID()); + LOGGER.info(edge.from.getID() + " invokes " + edge.to.getID() + " upon " + edge.edge.getID()); } } } } + private static boolean okToAdd(Policy operPolicy, ControlLoopCompilerCallback callback) { + // + // Check the policy id and make sure its sane + // + boolean okToAdd = true; + if (operPolicy.getId() == null || operPolicy.getId().length() < 1) { + if (callback != null) { + callback.onError("Operational Policy has an bad ID"); + } + okToAdd = false; + } + // + // Check if they decided to make the ID a result object + // + if (PolicyResult.toResult(operPolicy.getId()) != null) { + if (callback != null) { + callback.onError("Policy id is set to a PolicyResult " + operPolicy.getId()); + } + okToAdd = false; + } + if (FinalResult.toResult(operPolicy.getId()) != null) { + if (callback != null) { + callback.onError("Policy id is set to a FinalResult " + operPolicy.getId()); + } + okToAdd = false; + } + // + // Check that the actor/recipe/target are valid + // + if (operPolicy.getActor() == null) { + if (callback != null) { + callback.onError("Policy actor is null"); + } + okToAdd = false; + } + // + // Construct a list for all valid actors + // + ImmutableList<String> actors = ImmutableList.of("APPC", "AOTS", "MSO", "SDNO", "SDNR", "AAI"); + // + if (operPolicy.getActor() != null && (!actors.contains(operPolicy.getActor())) ) { + if (callback != null) { + callback.onError("Policy actor is invalid"); + } + okToAdd = false; + } + if (operPolicy.getRecipe() == null) { + if (callback != null) { + callback.onError("Policy recipe is null"); + } + okToAdd = false; + } + // + // NOTE: We need a way to find the acceptable recipe values (either Enum or a database that has these) + // + ImmutableMap<String, List<String>> recipes = new ImmutableMap.Builder<String, List<String>>() + .put("APPC", ImmutableList.of("Restart", "Rebuild", "Migrate", "ModifyConfig")) + .put("AOTS", ImmutableList.of("checkMaintenanceWindow", "checkENodeBTicketHours", "checkEquipmentStatus", "checkEimStatus", "checkEquipmentMaintenance")) + .put("MSO", ImmutableList.of("VF Module Create")) + .put("SDNO", ImmutableList.of("health-diagnostic-type", "health-diagnostic", "health-diagnostic-history", "health-diagnostic-commands", "health-diagnostic-aes")) + .put("SDNR", ImmutableList.of("Restart", "Reboot")) + .build(); + // + if (operPolicy.getRecipe() != null && (!recipes.getOrDefault(operPolicy.getActor(), Collections.emptyList()).contains(operPolicy.getRecipe()))) { + if (callback != null) { + callback.onError("Policy recipe is invalid"); + } + okToAdd = false; + } + if (operPolicy.getTarget() == null) { + if (callback != null) { + callback.onError("Policy target is null"); + } + okToAdd = false; + } + if (operPolicy.getTarget() != null && operPolicy.getTarget().getType() != TargetType.VM && operPolicy.getTarget().getType() != TargetType.VFC && operPolicy.getTarget().getType() != TargetType.PNF) { + if (callback != null) { + callback.onError("Policy target is invalid"); + } + okToAdd = false; + } + // + // Check that policy results are connected to either default final * or another policy + // + if (FinalResult.toResult(operPolicy.getSuccess()) != null && operPolicy.getSuccess() != FinalResult.FINAL_SUCCESS.toString()) { + if (callback != null) { + callback.onError("Policy success is neither another policy nor FINAL_SUCCESS"); + } + okToAdd = false; + } + if (FinalResult.toResult(operPolicy.getFailure()) != null && operPolicy.getFailure() != FinalResult.FINAL_FAILURE.toString()) { + if (callback != null) { + callback.onError("Policy failure is neither another policy nor FINAL_FAILURE"); + } + okToAdd = false; + } + if (FinalResult.toResult(operPolicy.getFailure_retries()) != null && operPolicy.getFailure_retries() != FinalResult.FINAL_FAILURE_RETRIES.toString()) { + if (callback != null) { + callback.onError("Policy failure retries is neither another policy nor FINAL_FAILURE_RETRIES"); + } + okToAdd = false; + } + if (FinalResult.toResult(operPolicy.getFailure_timeout()) != null && operPolicy.getFailure_timeout() != FinalResult.FINAL_FAILURE_TIMEOUT.toString()) { + if (callback != null) { + callback.onError("Policy failure timeout is neither another policy nor FINAL_FAILURE_TIMEOUT"); + } + okToAdd = false; + } + if (FinalResult.toResult(operPolicy.getFailure_exception()) != null && operPolicy.getFailure_exception() != FinalResult.FINAL_FAILURE_EXCEPTION.toString()) { + if (callback != null) { + callback.onError("Policy failure exception is neither another policy nor FINAL_FAILURE_EXCEPTION"); + } + okToAdd = false; + } + if (FinalResult.toResult(operPolicy.getFailure_guard()) != null && operPolicy.getFailure_guard() != FinalResult.FINAL_FAILURE_GUARD.toString()) { + if (callback != null) { + callback.onError("Policy failure guard is neither another policy nor FINAL_FAILURE_GUARD"); + } + okToAdd = false; + } + return okToAdd; + } + private static PolicyNodeWrapper findPolicyNode(Map<Policy, PolicyNodeWrapper> mapNodes, String id) { - for (Policy key : mapNodes.keySet()) { - if (key.id.equals(id)) { - return mapNodes.get(key); + for (Entry<Policy, PolicyNodeWrapper> entry : mapNodes.entrySet()) { + if (entry.getKey().getId().equals(id)) { + return entry.getValue(); } } return null; } - - private interface NodeWrapper { - + + @FunctionalInterface + private interface NodeWrapper extends Serializable{ public String getID(); - } private static class TriggerNodeWrapper implements NodeWrapper { - public String closedLoopControlName; + private static final long serialVersionUID = -187644087811478349L; + private String closedLoopControlName; public TriggerNodeWrapper(String closedLoopControlName) { this.closedLoopControlName = closedLoopControlName; @@ -474,8 +470,8 @@ public class ControlLoopCompiler { } private static class FinalResultNodeWrapper implements NodeWrapper { - - public FinalResult result; + private static final long serialVersionUID = 8540008796302474613L; + private FinalResult result; public FinalResultNodeWrapper(FinalResult result) { this.result = result; @@ -493,8 +489,8 @@ public class ControlLoopCompiler { } private static class PolicyNodeWrapper implements NodeWrapper { - - public Policy policy; + private static final long serialVersionUID = 8170162175653823082L; + private Policy policy; public PolicyNodeWrapper(Policy operPolicy) { this.policy = operPolicy; @@ -507,18 +503,18 @@ public class ControlLoopCompiler { @Override public String getID() { - return policy.id; + return policy.getId(); } } - private interface EdgeWrapper { - + @FunctionalInterface + private interface EdgeWrapper extends Serializable{ public String getID(); } private static class TriggerEdgeWrapper implements EdgeWrapper { - + private static final long serialVersionUID = 2678151552623278863L; private String trigger; public TriggerEdgeWrapper(String trigger) { @@ -538,7 +534,8 @@ public class ControlLoopCompiler { } private static class PolicyResultEdgeWrapper implements EdgeWrapper { - public PolicyResult policyResult; + private static final long serialVersionUID = 6078569477021558310L; + private PolicyResult policyResult; public PolicyResultEdgeWrapper(PolicyResult policyResult) { super(); @@ -559,8 +556,8 @@ public class ControlLoopCompiler { } private static class FinalResultEdgeWrapper implements EdgeWrapper { - - public FinalResult finalResult; + private static final long serialVersionUID = -1486381946896779840L; + private FinalResult finalResult; public FinalResultEdgeWrapper(FinalResult result) { this.finalResult = result; } @@ -578,10 +575,6 @@ public class ControlLoopCompiler { private static class LabeledEdge extends DefaultEdge { - - /** - * - */ private static final long serialVersionUID = 579384429573385524L; private NodeWrapper from; diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java index a40bc9d53..aa2bbfd8a 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java @@ -36,21 +36,25 @@ import org.yaml.snakeyaml.constructor.Constructor; public class ControlLoopGuardCompiler { - public static ControlLoopGuard compile(ControlLoopGuard CLGuard, ControlLoopCompilerCallback callback) throws CompilerException { + private ControlLoopGuardCompiler(){ + // Private Constructor + } + + public static ControlLoopGuard compile(ControlLoopGuard cLGuard, ControlLoopCompilerCallback callback) throws CompilerException { // // Ensure ControlLoopGuard has at least one guard policies // - validateControlLoopGuard(CLGuard, callback); + validateControlLoopGuard(cLGuard, callback); // // Ensure each guard policy has at least one constraints and all guard policies are unique // - validateGuardPolicies(CLGuard.guards, callback); + validateGuardPolicies(cLGuard.getGuards(), callback); // // Ensure constraints for each guard policy are unique // - validateConstraints(CLGuard.guards, callback); + validateConstraints(cLGuard.getGuards(), callback); - return CLGuard; + return cLGuard; } public static ControlLoopGuard compile(InputStream yamlSpecification, ControlLoopCompilerCallback callback) throws CompilerException { @@ -65,26 +69,22 @@ public class ControlLoopGuardCompiler { return ControlLoopGuardCompiler.compile((ControlLoopGuard) obj, callback); } - private static void validateControlLoopGuard(ControlLoopGuard CLGuard, ControlLoopCompilerCallback callback) throws CompilerException { - if (CLGuard == null) { + private static void validateControlLoopGuard(ControlLoopGuard cLGuard, ControlLoopCompilerCallback callback) throws CompilerException { + if (cLGuard == null) { if (callback != null) { callback.onError("ControlLoop Guard cannot be null"); } throw new CompilerException("ControlLoop Guard cannot be null"); } - if (CLGuard.guard == null) { - if (callback != null) { - callback.onError("Guard version cannot be null"); - } + if (cLGuard.getGuard() == null && callback != null) { + callback.onError("Guard version cannot be null"); } - if (CLGuard.guards == null) { - if (callback != null) { - callback.onError("ControlLoop Guard should have at least one guard policies"); - } - } else if (CLGuard.guards.size() < 1) { + if (cLGuard.getGuards() == null) { if (callback != null) { callback.onError("ControlLoop Guard should have at least one guard policies"); } + } else if (cLGuard.getGuards().isEmpty() && callback != null) { + callback.onError("ControlLoop Guard should have at least one guard policies"); } } @@ -98,21 +98,19 @@ public class ControlLoopGuardCompiler { // // Ensure all guard policies are unique // - Set<GuardPolicy> newSet = new HashSet<GuardPolicy>(policies); - if (newSet.size() != policies.size()) { - if (callback != null) { - callback.onWarning("There are duplicate guard policies"); - } + Set<GuardPolicy> newSet = new HashSet<>(policies); + if (newSet.size() != policies.size() && callback != null) { + callback.onWarning("There are duplicate guard policies"); } // // Ensure each guard policy has at least one constraints // for (GuardPolicy policy : policies) { - if (policy.limit_constraints == null || policy.limit_constraints.size() < 1) { + if (policy.getLimit_constraints() == null || policy.getLimit_constraints().isEmpty()) { if (callback != null) { - callback.onError("Guard policy " + policy.name + " does not have any limit constraint"); + callback.onError("Guard policy " + policy.getName() + " does not have any limit constraint"); } - throw new CompilerException("Guard policy " + policy.name + " does not have any limit constraint"); + throw new CompilerException("Guard policy " + policy.getName() + " does not have any limit constraint"); } } } @@ -125,11 +123,9 @@ public class ControlLoopGuardCompiler { throw new CompilerException("Guard policies should not be null"); } for (GuardPolicy policy : policies) { - Set<Constraint> newSet = new HashSet<Constraint>(policy.limit_constraints); - if (newSet.size() != policy.limit_constraints.size()) { - if (callback != null) { - callback.onWarning("Guard policy " + policy.name + " has duplicate limit constraints"); - } + Set<Constraint> newSet = new HashSet<>(policy.getLimit_constraints()); + if (newSet.size() != policy.getLimit_constraints().size() && callback != null) { + callback.onWarning("Guard policy " + policy.getName() + " has duplicate limit constraints"); } } } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoop.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoop.java index fa144156e..ec25ab3db 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoop.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoop.java @@ -20,30 +20,110 @@ package org.openecomp.policy.controlloop.policy; +import java.util.LinkedList; +import java.util.List; + +import org.openecomp.policy.asdc.Resource; +import org.openecomp.policy.asdc.Service; + public class ControlLoop { - public static String VERSION = "2.0.0"; + private static String VERSION = "2.0.0"; - public String controlLoopName; - public final String version = VERSION; - public String trigger_policy = FinalResult.FINAL_OPENLOOP.toString(); - public Integer timeout; - public Boolean abatement = false; + private String controlLoopName; + private String version = VERSION; + private List<Service> services; + private List<Resource> resources; + private String trigger_policy = FinalResult.FINAL_OPENLOOP.toString(); + private Integer timeout; + private Boolean abatement = false; public ControlLoop() { - + // Empty Constructor. + } + + public static String getVERSION(){ + return ControlLoop.VERSION; + } + + public String getControlLoopName() { + return controlLoopName; + } + + public void setControlLoopName(String controlLoopName) { + this.controlLoopName = controlLoopName; + } + + public List<Service> getServices() { + return services; + } + + public void setServices(List<Service> services) { + this.services = services; + } + + public List<Resource> getResources() { + return resources; + } + + public void setResources(List<Resource> resources) { + this.resources = resources; + } + + public String getTrigger_policy() { + return trigger_policy; + } + + public void setTrigger_policy(String trigger_policy) { + this.trigger_policy = trigger_policy; + } + + public Integer getTimeout() { + return timeout; + } + + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + + public Boolean getAbatement() { + return abatement; + } + + public void setAbatement(Boolean abatement) { + this.abatement = abatement; + } + + public String getVersion() { + return version; } + public void setVersion(String version){ + this.version = version; + } + public ControlLoop(ControlLoop controlLoop) { this.controlLoopName = controlLoop.controlLoopName; + this.services = new LinkedList<>(); + if (controlLoop.services != null) { + for (Service service : controlLoop.services) { + this.services.add(service); + } + } + this.resources = new LinkedList<>(); + if (controlLoop.resources != null) { + for (Resource resource: controlLoop.resources) { + this.resources.add(resource); + } + } this.trigger_policy = controlLoop.trigger_policy; this.timeout = controlLoop.timeout; this.abatement = controlLoop.abatement; } @Override public String toString() { - return "ControlLoop [controlLoopName=" + controlLoopName + ", version=" + version - + ", trigger_policy=" + trigger_policy + ", timeout=" + return "ControlLoop [controlLoopName=" + controlLoopName + ", version=" + version + ", services=" + services + + ", resources=" + resources + ", trigger_policy=" + trigger_policy + ", timeout=" + timeout + ", abatement=" + abatement + "]"; } @Override @@ -51,6 +131,8 @@ public class ControlLoop { final int prime = 31; int result = 1; result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode()); + result = prime * result + ((resources == null) ? 0 : resources.hashCode()); + result = prime * result + ((services == null) ? 0 : services.hashCode()); result = prime * result + ((timeout == null) ? 0 : timeout.hashCode()); result = prime * result + ((trigger_policy == null) ? 0 : trigger_policy.hashCode()); result = prime * result + ((version == null) ? 0 : version.hashCode()); @@ -71,6 +153,16 @@ public class ControlLoop { return false; } else if (!controlLoopName.equals(other.controlLoopName)) return false; + if (resources == null) { + if (other.resources != null) + return false; + } else if (!resources.equals(other.resources)) + return false; + if (services == null) { + if (other.services != null) + return false; + } else if (!services.equals(other.services)) + return false; if (timeout == null) { if (other.timeout != null) return false; diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicy.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicy.java index f14229bce..82a9d964e 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicy.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicy.java @@ -20,13 +20,29 @@ package org.openecomp.policy.controlloop.policy; -import java.util.LinkedList; +import java.util.List; public class ControlLoopPolicy { - public ControlLoop controlLoop; + private ControlLoop controlLoop; - public LinkedList<Policy> policies; + private List<Policy> policies; + + public ControlLoop getControlLoop() { + return controlLoop; + } + + public void setControlLoop(ControlLoop controlLoop) { + this.controlLoop = controlLoop; + } + + public List<Policy> getPolicies() { + return policies; + } + + public void setPolicies(List<Policy> policies) { + this.policies = policies; + } @Override public String toString() { diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/FinalResult.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/FinalResult.java index 86b174a85..f64e44939 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/FinalResult.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/FinalResult.java @@ -87,7 +87,7 @@ public enum FinalResult { if (toResult == null) { return false; } - return (toResult.equals(finalResult)); + return toResult.equals(finalResult); } } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/OperationsAccumulateParams.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/OperationsAccumulateParams.java index 6cf91ce05..b7424dd33 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/OperationsAccumulateParams.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/OperationsAccumulateParams.java @@ -28,11 +28,11 @@ public class OperationsAccumulateParams implements Serializable { */ private static final long serialVersionUID = -3597358159130168247L; - public String period; - public Integer limit; + private String period; + private Integer limit; public OperationsAccumulateParams() { - + // Does Nothing } public OperationsAccumulateParams(OperationsAccumulateParams ops) { @@ -45,6 +45,22 @@ public class OperationsAccumulateParams implements Serializable { this.limit = limit; } + public String getPeriod() { + return period; + } + + public void setPeriod(String period) { + this.period = period; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + @Override public String toString() { return "OperationsAccumulateParams [period=" + period + ", limit=" + limit + "]"; diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Policy.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Policy.java index 0af1eab68..dcbc8937b 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Policy.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Policy.java @@ -26,28 +26,156 @@ import java.util.UUID; public class Policy { - public String id = UUID.randomUUID().toString(); - public String name; - public String description; - public String actor; - public String recipe; - public Map<String, String> payload; - public Target target; - public OperationsAccumulateParams operationsAccumulateParams; - public Integer retry = 0; - public Integer timeout = 300; - public String success = FinalResult.FINAL_SUCCESS.toString(); - public String failure = FinalResult.FINAL_FAILURE.toString(); - public String failure_retries = FinalResult.FINAL_FAILURE_RETRIES.toString(); - public String failure_timeout = FinalResult.FINAL_FAILURE_TIMEOUT.toString(); - public String failure_exception = FinalResult.FINAL_FAILURE_EXCEPTION.toString(); - public String failure_guard = FinalResult.FINAL_FAILURE_GUARD.toString(); + private String id = UUID.randomUUID().toString(); + private String name; + private String description; + private String actor; + private String recipe; + private Map<String, String> payload; + private Target target; + private OperationsAccumulateParams operationsAccumulateParams; + private Integer retry = 0; + private Integer timeout = 300; + private String success = FinalResult.FINAL_SUCCESS.toString(); + private String failure = FinalResult.FINAL_FAILURE.toString(); + private String failure_retries = FinalResult.FINAL_FAILURE_RETRIES.toString(); + private String failure_timeout = FinalResult.FINAL_FAILURE_TIMEOUT.toString(); + private String failure_exception = FinalResult.FINAL_FAILURE_EXCEPTION.toString(); + private String failure_guard = FinalResult.FINAL_FAILURE_GUARD.toString(); public Policy() { - + //Does Nothing Empty Constructor } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getActor() { + return actor; + } + + public void setActor(String actor) { + this.actor = actor; + } + + public String getRecipe() { + return recipe; + } + + public void setRecipe(String recipe) { + this.recipe = recipe; + } + + public Map<String, String> getPayload() { + return payload; + } + + public void setPayload(Map<String, String> payload) { + this.payload = payload; + } + + public Target getTarget() { + return target; + } + + public void setTarget(Target target) { + this.target = target; + } + + public OperationsAccumulateParams getOperationsAccumulateParams() { + return operationsAccumulateParams; + } + + public void setOperationsAccumulateParams(OperationsAccumulateParams operationsAccumulateParams) { + this.operationsAccumulateParams = operationsAccumulateParams; + } + + public Integer getRetry() { + return retry; + } + + public void setRetry(Integer retry) { + this.retry = retry; + } + + public Integer getTimeout() { + return timeout; + } + + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + + public String getSuccess() { + return success; + } + + public void setSuccess(String success) { + this.success = success; + } + + public String getFailure() { + return failure; + } + + public void setFailure(String failure) { + this.failure = failure; + } + + public String getFailure_retries() { + return failure_retries; + } + + public void setFailure_retries(String failure_retries) { + this.failure_retries = failure_retries; + } + + public String getFailure_timeout() { + return failure_timeout; + } + + public void setFailure_timeout(String failure_timeout) { + this.failure_timeout = failure_timeout; + } + + public String getFailure_exception() { + return failure_exception; + } + + public void setFailure_exception(String failure_exception) { + this.failure_exception = failure_exception; + } + + public String getFailure_guard() { + return failure_guard; + } + + public void setFailure_guard(String failure_guard) { + this.failure_guard = failure_guard; + } + public Policy(String id) { this.id = id; } @@ -58,7 +186,6 @@ public class Policy { this.recipe = recipe; this.target = target; if (payload != null) { -// this.payload = new LinkedList<Map<String, String>>(); this.payload = Collections.unmodifiableMap(payload); } } @@ -82,8 +209,6 @@ public class Policy { this.actor = policy.actor; this.recipe = policy.recipe; if (policy.payload != null) { -// this.payload = new LinkedList<Map<String, String>>(); -// this.payload.addAll(policy.payload); this.payload = Collections.unmodifiableMap(policy.payload); } this.target = policy.target; @@ -99,26 +224,9 @@ public class Policy { } public boolean isValid() { - try { - if (id == null) { - throw new NullPointerException(); - } - if (name == null) { - throw new NullPointerException(); - } - if (actor == null) { - throw new NullPointerException(); - } - if (recipe == null) { - throw new NullPointerException(); - } - if (target == null) { - throw new NullPointerException(); - } - } catch (Exception e) { + if(id==null || name==null || actor==null|| recipe==null || target==null){ return false; } - return true; } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/PolicyResult.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/PolicyResult.java index cfcd624f3..7d0334125 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/PolicyResult.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/PolicyResult.java @@ -52,6 +52,7 @@ public enum PolicyResult { this.result = result; } + @Override public String toString() { return this.result; } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Target.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Target.java index 9bccf0feb..1625c2968 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Target.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/Target.java @@ -28,13 +28,29 @@ public class Target implements Serializable { */ private static final long serialVersionUID = 2180988443264988319L; - public String resourceID; - public TargetType type; + private String resourceID; + private TargetType type; public Target() { - + //Does Nothing Empty Constructor } + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public TargetType getType() { + return type; + } + + public void setType(TargetType type) { + this.type = type; + } + public Target(TargetType type) { this.type = type; } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/TargetType.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/TargetType.java index c5e4abce0..e43fa615e 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/TargetType.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/TargetType.java @@ -25,14 +25,15 @@ public enum TargetType { VFC("VFC") ; - private String targetType; + private String target; private TargetType(String targetType) { - this.targetType = targetType; + this.target = targetType; } + @Override public String toString() { - return this.targetType; + return this.target; } } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/BuilderException.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/BuilderException.java index a087463b9..273af85e3 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/BuilderException.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/BuilderException.java @@ -17,17 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.policy.controlloop.policy.builder; public class BuilderException extends Exception { + private static final long serialVersionUID = 610064813684337895L; + public BuilderException(String string) { super(string); } - /** - * - */ - private static final long serialVersionUID = 610064813684337895L; - } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java index fb10f292c..2fdb6d9df 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java @@ -22,6 +22,8 @@ package org.openecomp.policy.controlloop.policy.builder; import java.util.Map; +import org.openecomp.policy.asdc.Resource; +import org.openecomp.policy.asdc.Service; import org.openecomp.policy.controlloop.policy.ControlLoop; import org.openecomp.policy.controlloop.policy.OperationsAccumulateParams; import org.openecomp.policy.controlloop.policy.Policy; @@ -32,6 +34,52 @@ import org.openecomp.policy.controlloop.policy.builder.impl.ControlLoopPolicyBui public interface ControlLoopPolicyBuilder { /** + * Adds one or more services to the ControlLoop + * + * + * @param service + * @return + * @throws BuilderException + */ + public ControlLoopPolicyBuilder addService(Service... services) throws BuilderException; + + /** + * @param services + * @return + * @throws BuilderException + */ + public ControlLoopPolicyBuilder removeService(Service... services) throws BuilderException; + + /** + * @return + * @throws BuilderException + */ + public ControlLoopPolicyBuilder removeAllServices() throws BuilderException; + + /** + * Adds one or more resources to the ControlLoop + * + * + * @param resource + * @return + * @throws BuilderException + */ + public ControlLoopPolicyBuilder addResource(Resource... resources) throws BuilderException; + + /** + * @param resources + * @return + * @throws BuilderException + */ + public ControlLoopPolicyBuilder removeResource(Resource... resources) throws BuilderException; + + /** + * @return + * @throws BuilderException + */ + public ControlLoopPolicyBuilder removeAllResources() throws BuilderException; + + /** * @param abatement * @return * @throws BuilderException @@ -186,6 +234,9 @@ public interface ControlLoopPolicyBuilder { * */ public static class Factory { + private Factory(){ + // Private Constructor. + } /** * Builds a basic Control Loop with an overall timeout. Use this method if you wish to create an OpenLoop, or if you @@ -197,12 +248,40 @@ public interface ControlLoopPolicyBuilder { * @throws BuilderException */ public static ControlLoopPolicyBuilder buildControlLoop (String controlLoopName, Integer timeout) throws BuilderException { + return new ControlLoopPolicyBuilderImpl(controlLoopName, timeout); + } + + /** + * Build a Control Loop for a resource and services associated with the resource. + * + * @param controlLoopName - Per Closed Loop AID v1.0, unique string for the closed loop. + * @param timeout - Overall timeout for the Closed Loop to execute. + * @param resource - Resource this closed loop is for. Should come from ASDC, but if not available use resourceName to distinguish. + * @param services - Zero or more services associated with this resource. Should come from ASDC, but if not available use serviceName to distinguish. + * @return ControlLoopPolicyBuilder object + * @throws BuilderException + */ + public static ControlLoopPolicyBuilder buildControlLoop (String controlLoopName, Integer timeout, Resource resource, Service... services) throws BuilderException { - ControlLoopPolicyBuilder builder = new ControlLoopPolicyBuilderImpl(controlLoopName, timeout); + ControlLoopPolicyBuilder builder = new ControlLoopPolicyBuilderImpl(controlLoopName, timeout, resource, services); return builder; - } + } + /** + * @param controlLoopName + * @param timeout + * @param service + * @param resources + * @return + * @throws BuilderException + */ + public static ControlLoopPolicyBuilder buildControlLoop (String controlLoopName, Integer timeout, Service service, Resource... resources) throws BuilderException { + + ControlLoopPolicyBuilder builder = new ControlLoopPolicyBuilderImpl(controlLoopName, timeout, service, resources); + + return builder; + } } } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java index be34a0a24..523054dce 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java @@ -24,6 +24,8 @@ import java.util.LinkedList; import java.util.Map; import java.util.UUID; +import org.openecomp.policy.asdc.Resource; +import org.openecomp.policy.asdc.Service; import org.openecomp.policy.controlloop.compiler.CompilerException; import org.openecomp.policy.controlloop.compiler.ControlLoopCompiler; import org.openecomp.policy.controlloop.compiler.ControlLoopCompilerCallback; @@ -48,9 +50,89 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout) throws BuilderException { policy = new ControlLoopPolicy(); - policy.controlLoop = new ControlLoop(); - policy.controlLoop.controlLoopName = controlLoopName; - policy.controlLoop.timeout = timeout; + ControlLoop controlLoop = new ControlLoop(); + controlLoop.setControlLoopName(controlLoopName); + controlLoop.setTimeout(timeout); + policy.setControlLoop(controlLoop); + } + + public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Resource resource, Service... services) throws BuilderException { + this(controlLoopName, timeout); + this.addResource(resource); + this.addService(services); + } + + public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Service service, Resource[] resources) throws BuilderException { + this(controlLoopName, timeout); + this.addService(service); + this.addResource(resources); + } + + @Override + public ControlLoopPolicyBuilder addService(Service... services) throws BuilderException { + if (services == null) { + throw new BuilderException("Service must not be null"); + } + for (Service service : services) { + if (service.getServiceUUID() == null) { + if (service.getServiceName() == null || service.getServiceName().length() < 1) { + throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); + } + if(policy.getControlLoop().getServices()==null){ + policy.getControlLoop().setServices(new LinkedList<>()); + } + policy.getControlLoop().getServices().add(service); + } + } + return this; + } + + @Override + public ControlLoopPolicyBuilder removeService(Service... services) throws BuilderException { + if (services == null) { + throw new BuilderException("Service must not be null"); + } + if (policy.getControlLoop().getServices() == null) { + throw new BuilderException("No existing services to remove"); + } + for (Service service : services) { + if (service.getServiceUUID() == null) { + if (service.getServiceName() == null || service.getServiceName().length() < 1) { + throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); + } + } + boolean removed = policy.getControlLoop().getServices().remove(service); + if (!removed) { + throw new BuilderException("Unknown service " + service.getServiceName()); + } + } + return this; + } + + @Override + public ControlLoopPolicyBuilder removeAllServices() throws BuilderException { + policy.getControlLoop().getServices().clear(); + return this; + } + + + @Override + public ControlLoopPolicyBuilder addResource(Resource... resources) throws BuilderException { + if (resources == null) { + throw new BuilderException("resources must not be null"); + } + for (Resource resource : resources) { + if (resource.getResourceUUID() == null) { + if (resource.getResourceName() == null || resource.getResourceName().length() <= 0) { + throw new BuilderException("Invalid resource - need either resourceUUID or resourceName"); + } + } + if(policy.getControlLoop().getResources()==null){ + policy.getControlLoop().setResources(new LinkedList<>()); + } + policy.getControlLoop().getResources().add(resource); + } + return this; } @Override @@ -58,13 +140,13 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { if (abatement == null) { throw new BuilderException("abatement must not be null"); } - policy.controlLoop.abatement = abatement; + policy.getControlLoop().setAbatement(abatement); return this; } @Override public ControlLoopPolicyBuilder setTimeout(Integer timeout) { - policy.controlLoop.timeout = timeout; + policy.getControlLoop().setTimeout(timeout); return this; } @@ -74,7 +156,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { Policy trigger = new Policy(UUID.randomUUID().toString(), name, description, actor, payload, target, recipe, retries, timeout); - policy.controlLoop.trigger_policy = trigger.id; + policy.getControlLoop().setTrigger_policy(trigger.getId()); this.addNewPolicy(trigger); // @@ -103,22 +185,22 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { for (PolicyResult result : results) { switch (result) { case FAILURE: - existingPolicy.failure = newPolicy.id; + existingPolicy.setFailure(newPolicy.getId()); break; case FAILURE_EXCEPTION: - existingPolicy.failure_exception = newPolicy.id; + existingPolicy.setFailure_exception(newPolicy.getId()); break; case FAILURE_RETRIES: - existingPolicy.failure_retries = newPolicy.id; + existingPolicy.setFailure_retries(newPolicy.getId()); break; case FAILURE_TIMEOUT: - existingPolicy.failure_timeout = newPolicy.id; + existingPolicy.setFailure_timeout(newPolicy.getId()); break; case FAILURE_GUARD: - existingPolicy.failure_guard = newPolicy.id; + existingPolicy.setFailure_guard(newPolicy.getId()); break; case SUCCESS: - existingPolicy.success = newPolicy.id; + existingPolicy.setSuccess(newPolicy.getId()); break; default: throw new BuilderException("Invalid PolicyResult " + result); @@ -127,7 +209,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { // // Add it to our list // - this.policy.policies.add(newPolicy); + this.policy.getPolicies().add(newPolicy); // // Return a policy to them // @@ -136,7 +218,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { private class BuilderCompilerCallback implements ControlLoopCompilerCallback { - public ResultsImpl results = new ResultsImpl(); + private ResultsImpl results = new ResultsImpl(); @Override public boolean onWarning(String message) { @@ -181,15 +263,15 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { } private void addNewPolicy(Policy policy) { - if (this.policy.policies == null) { - this.policy.policies = new LinkedList<Policy>(); + if (this.policy.getPolicies() == null) { + this.policy.setPolicies(new LinkedList<>()); } - this.policy.policies.add(policy); + this.policy.getPolicies().add(policy); } private Policy findPolicy(String id) { - for (Policy policy : this.policy.policies) { - if (policy.id.equals(id)) { + for (Policy policy : this.policy.getPolicies()) { + if (policy.getId().equals(id)) { return policy; } } @@ -197,10 +279,38 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { } @Override + public ControlLoopPolicyBuilder removeResource(Resource... resources) throws BuilderException { + if (resources == null) { + throw new BuilderException("Resource must not be null"); + } + if (policy.getControlLoop().getResources() == null) { + throw new BuilderException("No existing resources to remove"); + } + for (Resource resource : resources) { + if (resource.getResourceUUID() == null) { + if (resource.getResourceName() == null || resource.getResourceName().length() < 1) { + throw new BuilderException("Invalid resource - need either a resourceUUID or resourceName"); + } + } + boolean removed = policy.getControlLoop().getResources().remove(resource); + if (!removed) { + throw new BuilderException("Unknown resource " + resource.getResourceName()); + } + } + return this; + } + + @Override + public ControlLoopPolicyBuilder removeAllResources() throws BuilderException { + policy.getControlLoop().getResources().clear(); + return this; + } + + @Override public Integer calculateTimeout() { int sum = 0; - for (Policy policy : this.policy.policies) { - sum += policy.timeout.intValue(); + for (Policy policy : this.policy.getPolicies()) { + sum += policy.getTimeout().intValue(); } return new Integer(sum); } @@ -215,14 +325,14 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { throw new BuilderException("Unknown policy " + id); } else { - this.policy.controlLoop.trigger_policy = id; + this.policy.getControlLoop().setTrigger_policy(id); } - return new ControlLoop(this.policy.controlLoop); + return new ControlLoop(this.policy.getControlLoop()); } @Override public boolean isOpenLoop() { - if (this.policy.controlLoop.trigger_policy.equals(FinalResult.FINAL_OPENLOOP.toString())) { + if (this.policy.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())) { return true; } else { @@ -232,18 +342,18 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { @Override public Policy getTriggerPolicy() throws BuilderException { - if (this.policy.controlLoop.trigger_policy.equals(FinalResult.FINAL_OPENLOOP.toString())) { + if (this.policy.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())) { return null; } else { - Policy trigger = new Policy(this.findPolicy(this.policy.controlLoop.trigger_policy)); + Policy trigger = new Policy(this.findPolicy(this.policy.getControlLoop().getTrigger_policy())); return trigger; } } @Override public ControlLoop getControlLoop() { - ControlLoop loop = new ControlLoop(this.policy.controlLoop); + ControlLoop loop = new ControlLoop(this.policy.getControlLoop()); return loop; } @@ -266,22 +376,22 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { for (PolicyResult result : results) { switch (result) { case FAILURE: - existingPolicy.failure = policyResultID; + existingPolicy.setFailure(policyResultID); break; case FAILURE_EXCEPTION: - existingPolicy.failure_exception = policyResultID; + existingPolicy.setFailure_exception(policyResultID); break; case FAILURE_RETRIES: - existingPolicy.failure_retries = policyResultID; + existingPolicy.setFailure_retries(policyResultID); break; case FAILURE_TIMEOUT: - existingPolicy.failure_timeout = policyResultID; + existingPolicy.setFailure_timeout(policyResultID); break; case FAILURE_GUARD: - existingPolicy.failure_guard = policyResultID; + existingPolicy.setFailure_guard(policyResultID); break; case SUCCESS: - existingPolicy.success = policyResultID; + existingPolicy.setSuccess(policyResultID); break; default: throw new BuilderException("Invalid PolicyResult " + result); @@ -299,40 +409,40 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { // // Check if the policy to remove is trigger_policy // - if (this.policy.controlLoop.trigger_policy.equals(policyID)) { - this.policy.controlLoop.trigger_policy = FinalResult.FINAL_OPENLOOP.toString(); + if (this.policy.getControlLoop().getTrigger_policy().equals(policyID)) { + this.policy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); } else { // // Update policies // - for (Policy policy : this.policy.policies) { - int index = this.policy.policies.indexOf(policy); - if (policy.success.equals(policyID)) { - policy.success = FinalResult.FINAL_SUCCESS.toString(); + for (Policy policy : this.policy.getPolicies()) { + int index = this.policy.getPolicies().indexOf(policy); + if (policy.getSuccess().equals(policyID)) { + policy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); } - if (policy.failure.equals(policyID)) { - policy.failure = FinalResult.FINAL_FAILURE.toString(); + if (policy.getFailure().equals(policyID)) { + policy.setFailure(FinalResult.FINAL_FAILURE.toString()); } - if (policy.failure_retries.equals(policyID)) { - policy.failure_retries = FinalResult.FINAL_FAILURE_RETRIES.toString(); + if (policy.getFailure_retries().equals(policyID)) { + policy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); } - if (policy.failure_timeout.equals(policyID)) { - policy.failure_timeout = FinalResult.FINAL_FAILURE_TIMEOUT.toString(); + if (policy.getFailure_timeout().equals(policyID)) { + policy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); } - if (policy.failure_exception.equals(policyID)) { - policy.failure_exception = FinalResult.FINAL_FAILURE_EXCEPTION.toString(); + if (policy.getFailure_exception().equals(policyID)) { + policy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); } - if (policy.failure_guard.equals(policyID)) { - policy.failure_guard = FinalResult.FINAL_FAILURE_GUARD.toString(); + if (policy.getFailure_guard().equals(policyID)) { + policy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); } - this.policy.policies.set(index, policy); + this.policy.getPolicies().set(index, policy); } } // // remove the policy // - boolean removed = this.policy.policies.remove(existingPolicy); + boolean removed = this.policy.getPolicies().remove(existingPolicy); return removed; } @@ -345,12 +455,12 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { // // reset policy results // - existingPolicy.success = FinalResult.FINAL_SUCCESS.toString(); - existingPolicy.failure = FinalResult.FINAL_FAILURE.toString(); - existingPolicy.failure_retries = FinalResult.FINAL_FAILURE_RETRIES.toString(); - existingPolicy.failure_timeout = FinalResult.FINAL_FAILURE_TIMEOUT.toString(); - existingPolicy.failure_exception = FinalResult.FINAL_FAILURE_EXCEPTION.toString(); - existingPolicy.failure_guard = FinalResult.FINAL_FAILURE_GUARD.toString(); + existingPolicy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); + existingPolicy.setFailure(FinalResult.FINAL_FAILURE.toString()); + existingPolicy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); + existingPolicy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); + existingPolicy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); + existingPolicy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); return new Policy(existingPolicy); } @@ -359,11 +469,11 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { // // Remove all existing operational policies // - this.policy.policies.clear(); + this.policy.getPolicies().clear(); // // Revert controlLoop back to an open loop // - this.policy.controlLoop.trigger_policy = FinalResult.FINAL_OPENLOOP.toString(); + this.policy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); return this; } @@ -376,7 +486,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { // // Add operationsAccumulateParams to existingPolicy // - existingPolicy.operationsAccumulateParams = operationsAccumulateParams; + existingPolicy.setOperationsAccumulateParams(operationsAccumulateParams); return new Policy(existingPolicy); } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ResultsImpl.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ResultsImpl.java index f7941533c..9ab78566e 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ResultsImpl.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ResultsImpl.java @@ -28,7 +28,7 @@ import org.openecomp.policy.controlloop.policy.builder.Results; public class ResultsImpl implements Results { private String specification; - private List<Message> messages = new LinkedList<Message>(); + private List<Message> messages = new LinkedList<>(); @Override public List<Message> getMessages() { @@ -42,7 +42,7 @@ public class ResultsImpl implements Results { @Override public boolean isValid() { - return (this.specification != null); + return this.specification != null; } public void addMessage(Message message) { diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java index 7d7991787..85ddf066d 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java @@ -26,37 +26,62 @@ import java.util.Map; public class Constraint { - public Integer num; - public String duration; - public Map<String, String> time_in_range; + private Integer num; + private String duration; + private Map<String, String> time_in_range; - public LinkedList<String> blacklist; + private List<String> blacklist; public Constraint() { - + // Do Nothing empty constructor. } + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public Map<String, String> getTime_in_range() { + return time_in_range; + } + + public void setTime_in_range(Map<String, String> time_in_range) { + this.time_in_range = time_in_range; + } + + public List<String> getBlacklist() { + return blacklist; + } + + public void setBlacklist(List<String> blacklist) { + this.blacklist = blacklist; + } + public Constraint(Integer num, String duration) { this.num = num; this.duration = duration; } public Constraint(List<String> blacklist) { - this.blacklist = new LinkedList<String>(blacklist); + this.blacklist = new LinkedList<>(blacklist); } - public Constraint(Integer num, String duration, Map<String, String> time_in_range) { - this(num, duration); - if (time_in_range != null) { - this.time_in_range = Collections.unmodifiableMap(time_in_range); - } - } - public Constraint(Integer num, String duration, List<String> blacklist) { this.num = num; this.duration = duration; - this.blacklist = new LinkedList<String>(blacklist); + this.blacklist = new LinkedList<>(blacklist); } public Constraint(Integer num, String duration, Map<String, String> time_in_range, List<String> blacklist) { @@ -64,7 +89,7 @@ public class Constraint { if (time_in_range != null) { this.time_in_range = Collections.unmodifiableMap(time_in_range); } - this.blacklist = new LinkedList<String>(blacklist); + this.blacklist = new LinkedList<>(blacklist); } public Constraint(Constraint constraint) { @@ -73,18 +98,14 @@ public class Constraint { if (constraint.time_in_range != null) { this.time_in_range = Collections.unmodifiableMap(constraint.time_in_range); } - this.blacklist = new LinkedList<String>(constraint.blacklist); + this.blacklist = new LinkedList<>(constraint.blacklist); } public boolean isValid() { - try { - if (num == null && duration != null) { - throw new NullPointerException(); - } - if (duration == null && num != null) { - throw new NullPointerException(); - } - } catch (Exception e) { + if (num == null && duration != null) { + return false; + } + if (duration == null && num != null) { return false; } return true; diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java index 37fd431a0..cfc904823 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java @@ -20,20 +20,37 @@ package org.openecomp.policy.controlloop.policy.guard; import java.util.LinkedList; +import java.util.List; public class ControlLoopGuard { - public Guard guard; + private Guard guard; - public LinkedList<GuardPolicy> guards; + private List<GuardPolicy> guards; public ControlLoopGuard() { - + //DO Nothing Empty Constructor } - public ControlLoopGuard(ControlLoopGuard CLGuard) { + public Guard getGuard() { + return guard; + } + + public void setGuard(Guard guard) { + this.guard = guard; + } + + public List<GuardPolicy> getGuards() { + return guards; + } + + public void setGuards(List<GuardPolicy> guards) { + this.guards = guards; + } + + public ControlLoopGuard(ControlLoopGuard cLGuard) { this.guard = new Guard(); - this.guards = new LinkedList<GuardPolicy>(CLGuard.guards); + this.guards = new LinkedList<>(cLGuard.guards); } @Override diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Guard.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Guard.java index f3e765107..ee0327c3d 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Guard.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Guard.java @@ -21,14 +21,22 @@ package org.openecomp.policy.controlloop.policy.guard; public class Guard { - public static String VERSION = "2.0.0"; + private static final String DEFAULTVERSION = "2.0.0"; - public final String version = VERSION; + private String version = DEFAULTVERSION; public Guard() { - + //DO Nothing empty Constructor. } + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + @Override public String toString() { return "Guard [version=" + version + "]"; diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java index 0195fac17..7eb8af6d1 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java @@ -26,17 +26,65 @@ import java.util.UUID; public class GuardPolicy { - public String id = UUID.randomUUID().toString(); - public String name; - public String description; - public String actor; - public String recipe; - public LinkedList<Constraint> limit_constraints; + private String id = UUID.randomUUID().toString(); + private String name; + private String description; + private String actor; + private String recipe; + private List<Constraint> limit_constraints; public GuardPolicy() { - + //Do Nothing Empty Constructor. } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getActor() { + return actor; + } + + public void setActor(String actor) { + this.actor = actor; + } + + public String getRecipe() { + return recipe; + } + + public void setRecipe(String recipe) { + this.recipe = recipe; + } + + public List<Constraint> getLimit_constraints() { + return limit_constraints; + } + + public void setLimit_constraints(List<Constraint> limit_constraints) { + this.limit_constraints = limit_constraints; + } + public GuardPolicy(String id) { this.id = id; } @@ -82,20 +130,7 @@ public class GuardPolicy { } public boolean isValid() { - try { - if (id == null) { - throw new NullPointerException(); - } - if (name == null) { - throw new NullPointerException(); - } - if (actor == null) { - throw new NullPointerException(); - } - if (recipe == null) { - throw new NullPointerException(); - } - } catch (Exception e) { + if(id==null || name ==null|| actor==null|| recipe==null){ return false; } return true; @@ -104,7 +139,7 @@ public class GuardPolicy { @Override public String toString() { return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe=" - + recipe + ", limit_constraints=" + limit_constraints + "]"; + + recipe + ", limitConstraints=" + limit_constraints + "]"; } @Override diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java index c09757db6..d55510709 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java @@ -113,6 +113,9 @@ public interface ControlLoopGuardBuilder { */ public static class Factory { + private Factory(){ + //Do Nothing Private Constructor. + } /** * @param guard * @return ControlLoopGuardBuilder object @@ -120,9 +123,8 @@ public interface ControlLoopGuardBuilder { */ public static ControlLoopGuardBuilder buildControlLoopGuard (Guard guard) throws BuilderException { - ControlLoopGuardBuilder builder = new ControlLoopGuardBuilderImpl(guard); + return new ControlLoopGuardBuilderImpl(guard); - return builder; } } } diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java index b119620e3..bd6a3e42f 100644 --- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java +++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java @@ -40,11 +40,11 @@ import org.yaml.snakeyaml.Yaml; public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { - private ControlLoopGuard CLGuard; + private ControlLoopGuard cLGuard; public ControlLoopGuardBuilderImpl(Guard guard) { - CLGuard = new ControlLoopGuard(); - CLGuard.guard = guard; + cLGuard = new ControlLoopGuard(); + cLGuard.setGuard(guard); } @Override @@ -56,10 +56,10 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { if (!policy.isValid()) { throw new BuilderException("Invalid guard policy - some required fields are missing"); } - if (CLGuard.guards == null) { - CLGuard.guards = new LinkedList<GuardPolicy>(); + if (cLGuard.getGuards() == null) { + cLGuard.setGuards(new LinkedList<>()); } - CLGuard.guards.add(policy); + cLGuard.getGuards().add(policy); } return this; } @@ -69,16 +69,16 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { if (policies == null) { throw new BuilderException("GuardPolicy must not be null"); } - if (CLGuard.guards == null) { + if (cLGuard.getGuards() == null) { throw new BuilderException("No existing guard policies to remove"); } for (GuardPolicy policy : policies) { if (!policy.isValid()) { throw new BuilderException("Invalid guard policy - some required fields are missing"); } - boolean removed = CLGuard.guards.remove(policy); + boolean removed = cLGuard.getGuards().remove(policy); if (!removed) { - throw new BuilderException("Unknown guard policy: " + policy.name); + throw new BuilderException("Unknown guard policy: " + policy.getName()); } } return this; @@ -86,7 +86,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { @Override public ControlLoopGuardBuilder removeAllGuardPolicies() throws BuilderException { - CLGuard.guards.clear(); + cLGuard.getGuards().clear(); return this; } @@ -98,29 +98,33 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { if (constraints == null) { throw new BuilderException("Constraint much not be null"); } + if (!addLimitConstraints(id,constraints)) { + throw new BuilderException("No existing guard policy matching the id: " + id); + } + return this; + } + + private boolean addLimitConstraints(String id, Constraint... constraints) throws BuilderException { boolean exist = false; - for (GuardPolicy policy: CLGuard.guards) { + for (GuardPolicy policy: cLGuard.getGuards()) { // // We could have only one guard policy matching the id // - if (policy.id.equals(id)) { + if (policy.getId().equals(id)) { exist = true; for (Constraint cons: constraints) { if (!cons.isValid()) { throw new BuilderException("Invalid guard constraint - some required fields are missing"); } - if (policy.limit_constraints == null) { - policy.limit_constraints = new LinkedList<Constraint>(); + if (policy.getLimit_constraints() == null) { + policy.setLimit_constraints(new LinkedList<>()); } - policy.limit_constraints.add(cons); + policy.getLimit_constraints().add(cons); } break; } } - if (exist == false) { - throw new BuilderException("No existing guard policy matching the id: " + id); - } - return this; + return exist; } @Override @@ -131,18 +135,25 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { if (constraints == null) { throw new BuilderException("Constraint much not be null"); } + if (!removeConstraints(id, constraints)) { + throw new BuilderException("No existing guard policy matching the id: " + id); + } + return this; + } + + private boolean removeConstraints(String id, Constraint... constraints) throws BuilderException { boolean exist = false; - for (GuardPolicy policy: CLGuard.guards) { + for (GuardPolicy policy: cLGuard.getGuards()) { // // We could have only one guard policy matching the id // - if (policy.id.equals(id)) { + if (policy.getId().equals(id)) { exist = true; for (Constraint cons: constraints) { if (!cons.isValid()) { throw new BuilderException("Invalid guard constraint - some required fields are missing"); } - boolean removed = policy.limit_constraints.remove(cons); + boolean removed = policy.getLimit_constraints().remove(cons); if (!removed) { throw new BuilderException("Unknown guard constraint: " + cons); } @@ -150,28 +161,25 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { break; } } - if (exist == false) { - throw new BuilderException("No existing guard policy matching the id: " + id); - } - return this; + return exist; } @Override public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException { - if (CLGuard.guards == null || CLGuard.guards.isEmpty()) { + if (cLGuard.getGuards() == null || cLGuard.getGuards().isEmpty()) { throw new BuilderException("No guard policies exist"); } if (id == null) { throw new BuilderException("The id of target guard policy must not be null"); } boolean exist = false; - for (GuardPolicy policy: CLGuard.guards) { - if (policy.id.equals(id)) { + for (GuardPolicy policy: cLGuard.getGuards()) { + if (policy.getId().equals(id)) { exist = true; - policy.limit_constraints.clear(); + policy.getLimit_constraints().clear(); } } - if (exist == false) { + if (!exist) { throw new BuilderException("No existing guard policy matching the id: " + id); } return this; @@ -180,7 +188,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { private class BuilderCompilerCallback implements ControlLoopCompilerCallback { - public ResultsImpl results = new ResultsImpl(); + private ResultsImpl results = new ResultsImpl(); @Override public boolean onWarning(String message) { @@ -197,8 +205,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { @Override public ControlLoopGuard getControlLoopGuard() { - ControlLoopGuard guard = new ControlLoopGuard(this.CLGuard); - return guard; + return new ControlLoopGuard(this.cLGuard); } @@ -211,7 +218,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { options.setDefaultFlowStyle(FlowStyle.BLOCK); options.setPrettyFlow(true); Yaml yaml = new Yaml(options); - String dumpedYaml = yaml.dump(CLGuard); + String dumpedYaml = yaml.dump(cLGuard); // // This is our callback class for our compiler // @@ -220,7 +227,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { // Compile it // try { - ControlLoopGuardCompiler.compile(CLGuard, callback); + ControlLoopGuardCompiler.compile(cLGuard, callback); } catch (CompilerException e) { callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION)); } diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompilerTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompilerTest.java new file mode 100644 index 000000000..d26d094c6 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompilerTest.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.controlloop.compiler; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.junit.Test; + +public class ControlLoopCompilerTest { + + @Test + public void testTest() { + try { + this.test("src/test/resources/v1.0.0/test.yaml"); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + public void testBad1() { + try { + this.test("src/test/resources/v1.0.0/bad_trigger_1.yaml"); + } catch (Exception e) { + e.printStackTrace(); + } + } + @Test + public void testBad2() { + try { + this.test("src/test/resources/v1.0.0/bad_trigger_2.yaml"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testBad() { + try { + this.test("src/test/resources/v1.0.0/bad_policies_1.yaml"); + } catch (Exception e) { + } + } + + public void test(String testFile) throws Exception { + try (InputStream is = new FileInputStream(new File(testFile))) { + ControlLoopCompiler.compile(is, null); + } catch (FileNotFoundException e) { + fail(e.getMessage()); + } catch (IOException e) { + fail(e.getMessage()); + } catch (Exception e) { + throw e; + } + } + +} diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java new file mode 100644 index 000000000..1e035edf4 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.controlloop.compiler; + +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.junit.Test; +import org.openecomp.policy.controlloop.guard.compiler.ControlLoopGuardCompiler; + +public class ControlLoopGuardCompilerTest { + + @Test + public void testTest1() { + try { + this.test("src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml"); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + public void testTest2() { + try { + this.test("src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml"); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + public void testBad1() { + try { + this.test("src/test/resources/v2.0.0-guard/no_guard_policy.yaml"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testBad2() { + try { + this.test("src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testBad3() { + try { + this.test("src/test/resources/v2.0.0-guard/no_guard_constraint.yaml"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testBad4() { + try { + this.test("src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void test(String testFile) throws Exception { + try (InputStream is = new FileInputStream(new File(testFile))) { + ControlLoopGuardCompiler.compile(is, null); + } catch (FileNotFoundException e) { + fail(e.getMessage()); + } catch (IOException e) { + fail(e.getMessage()); + } catch (Exception e) { + throw e; + } + } + +} diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java new file mode 100644 index 000000000..713f35787 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java @@ -0,0 +1,516 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.controlloop.policy; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.UUID; + +import org.junit.Test; +import org.openecomp.policy.asdc.Resource; +import org.openecomp.policy.asdc.ResourceType; +import org.openecomp.policy.asdc.Service; +import org.openecomp.policy.controlloop.policy.builder.BuilderException; +import org.openecomp.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; +import org.openecomp.policy.controlloop.policy.builder.Message; +import org.openecomp.policy.controlloop.policy.builder.MessageLevel; +import org.openecomp.policy.controlloop.policy.builder.Results; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; +import org.yaml.snakeyaml.error.YAMLException; + + +public class ControlLoopPolicyBuilderTest { + + @Test + public void testControlLoop() { + try { + // + // Create a builder for our policy + // + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); + // + // Test add services + // + Service vSCP = new Service("vSCP"); + Service vUSP = new Service("vUSP"); + Service vTrinity = new Service("Trinity"); + builder = builder.addService(vSCP, vUSP, vTrinity); + assertTrue(builder.getControlLoop().getServices().size() == 3); + // + // Test remove services + // + builder = builder.removeService(vSCP); + assertTrue(builder.getControlLoop().getServices().size() == 2); + builder = builder.removeAllServices(); + assertTrue(builder.getControlLoop().getServices().size() == 0); + // + // Test add resources + // + Resource vCTS = new Resource("vCTS", ResourceType.VF); + Resource vCOM = new Resource("vCTS", ResourceType.VF); + Resource vRAR = new Resource("vCTS", ResourceType.VF); + builder = builder.addResource(vCTS, vCOM, vRAR); + assertTrue(builder.getControlLoop().getResources().size() == 3); + // + // Test remove resources + // + builder = builder.removeResource(vCTS); + assertTrue(builder.getControlLoop().getResources().size() == 2); + builder = builder.removeAllResources(); + assertTrue(builder.getControlLoop().getResources().size() == 0); + // + // Test set abatement + // + assertFalse(builder.getControlLoop().getAbatement()); + builder = builder.setAbatement(true); + assertTrue(builder.getControlLoop().getAbatement()); + } catch (BuilderException e) { + fail(e.getMessage()); + } + } + + @Test + public void testTimeout() { + try { + // + // Create a builder for our policy + // + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); + // + // Test setTimeout + // + assertTrue(builder.getControlLoop().getTimeout() == 2400); + builder = builder.setTimeout(800); + assertTrue(builder.getControlLoop().getTimeout() == 800); + // + // Test calculateTimeout + // + Policy trigger = builder.setTriggerPolicy( + "Restart the VM", + "Upon getting the trigger event, restart the VM", + "APPC", + new Target(TargetType.VM), + "Restart", + null, + 2, + 300); + @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); + assertTrue(builder.calculateTimeout().equals(new Integer(300 + 600))); + // + } catch (BuilderException e) { + fail(e.getMessage()); + } + } + + @Test + public void testTriggerPolicyMethods() { + try { + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); + // + // Test isOpenLoop + // + assertTrue(builder.isOpenLoop()); + // + // Test set initial trigger policy + // + Policy triggerPolicy1 = builder.setTriggerPolicy( + "Restart the VM", + "Upon getting the trigger event, restart the VM", + "APPC", + new Target(TargetType.VM), + "Restart", + null, + 2, + 300); + assertTrue(builder.isOpenLoop() == false); + assertTrue(builder.getControlLoop().getTrigger_policy().equals(triggerPolicy1.getId())); + // + // Set trigger policy to a new policy + // + @SuppressWarnings("unused") + Policy triggerPolicy2 = builder.setTriggerPolicy( + "Rebuild the VM", + "Upon getting the trigger event, rebuild the VM", + "APPC", + new Target(TargetType.VM), + "Rebuild", + null, + 2, + 300); + // + // Test set trigger policy to another existing policy + // + @SuppressWarnings("unused") + ControlLoop cl = builder.setTriggerPolicy(triggerPolicy1.getId()); + assertTrue(builder.getControlLoop().getTrigger_policy().equals(triggerPolicy1.getId())); + // + // Test get trigger policy + // + assertTrue(builder.getTriggerPolicy().equals(triggerPolicy1)); + // + } catch (BuilderException e) { + fail(e.getMessage()); + } + } + + @Test + public void testAddRemovePolicies() { + try { + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); + Policy triggerPolicy = builder.setTriggerPolicy( + "Restart the VM", + "Upon getting the trigger event, restart the VM", + "APPC", + new Target(TargetType.VM), + "Restart", + null, + 2, + 300); + // + // 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_RETRIES, + PolicyResult.FAILURE_TIMEOUT, + PolicyResult.FAILURE_GUARD); + // + assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy1.getId())); + assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy1.getId())); + assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy1.getId())); + assertTrue(builder.getTriggerPolicy().getFailure_guard().equals(onRestartFailurePolicy1.getId())); + // + // Test remove policy + // + boolean removed = builder.removePolicy(onRestartFailurePolicy1.getId()); + assertTrue(removed); + assertTrue(builder.getTriggerPolicy().getFailure().equals(FinalResult.FINAL_FAILURE.toString())); + assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(FinalResult.FINAL_FAILURE_RETRIES.toString())); + assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(FinalResult.FINAL_FAILURE_TIMEOUT.toString())); + assertTrue(builder.getTriggerPolicy().getFailure_guard().equals(FinalResult.FINAL_FAILURE_GUARD.toString())); + // + // Create another policy and chain it to the results of trigger policy + // + 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); + // + // Test reset policy results + // + triggerPolicy = builder.resetPolicyResults(triggerPolicy.getId()); + assertTrue(builder.getTriggerPolicy().getFailure().equals(FinalResult.FINAL_FAILURE.toString())); + assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(FinalResult.FINAL_FAILURE_RETRIES.toString())); + assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(FinalResult.FINAL_FAILURE_TIMEOUT.toString())); + // + // Test set the policy results to an existing operational policy + // + onRestartFailurePolicy2 = builder.setPolicyForPolicyResult( + onRestartFailurePolicy2.getId(), + triggerPolicy.getId(), + PolicyResult.FAILURE, + PolicyResult.FAILURE_RETRIES, + PolicyResult.FAILURE_TIMEOUT); + assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy2.getId())); + assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy2.getId())); + assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy2.getId())); + + // + // Test remove all existing operational policies + // + builder = builder.removeAllPolicies(); + assertTrue(builder.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())); + // + } catch (BuilderException e) { + fail(e.getMessage()); + } + } + + @Test + public void testAddOperationsAccumulateParams() { + try { + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); + Policy triggerPolicy = builder.setTriggerPolicy( + "Restart the eNodeB", + "Upon getting the trigger event, restart the eNodeB", + "SDNR", + new Target(TargetType.PNF), + "Restart", + null, + 2, + 300); + // + // Add the operationsAccumulateParams + // + triggerPolicy = builder.addOperationsAccumulateParams(triggerPolicy.getId(), new OperationsAccumulateParams("15m", 5)); + assertNotNull(builder.getTriggerPolicy().getOperationsAccumulateParams()); + assertTrue(builder.getTriggerPolicy().getOperationsAccumulateParams().getPeriod().equals("15m")); + assertTrue(builder.getTriggerPolicy().getOperationsAccumulateParams().getLimit() == 5); + // + } catch (BuilderException e) { + fail(e.getMessage()); + } + } + + + @Test + public void testBuildSpecification() { + try { + // + // Create the builder + // + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 800); + // + // Set the first invalid trigger policy + // + Policy policy1 = builder.setTriggerPolicy( + "Restart the VM", + "Upon getting the trigger event, restart the VM", + null, + null, + "Instantiate", + null, + 2, + 300); + Results results = builder.buildSpecification(); + // + // Check that ERRORs are in results for invalid policy arguments + // + boolean invalid_actor = false; + boolean invalid_recipe = false; + boolean invalid_target = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("Policy actor is null") && m.getLevel() == MessageLevel.ERROR) { + invalid_actor = true; + } + if (m.getMessage().equals("Policy recipe is invalid") && m.getLevel() == MessageLevel.ERROR) { + invalid_recipe = true; + } + if (m.getMessage().equals("Policy target is null") && m.getLevel() == MessageLevel.ERROR) { + invalid_target = true; + } + } + // + assertTrue(invalid_actor); + assertTrue(invalid_recipe); + assertTrue(invalid_target); + // + // Remove the invalid policy + // + //@SuppressWarnings("unused") + boolean removed = builder.removePolicy(policy1.getId()); + assertTrue(removed); + assertTrue(builder.getTriggerPolicy() == null); + // + // Set a valid trigger policy + // + policy1 = builder.setTriggerPolicy( + "Rebuild VM", + "If the restart fails, rebuild it.", + "APPC", + new Target(TargetType.VM), + "Rebuild", + null, + 1, + 600); + // + // Set a second valid trigger policy + // + Policy policy2 = builder.setTriggerPolicy( + "Restart the VM", + "Upon getting the trigger event, restart the VM", + "APPC", + new Target(TargetType.VM), + "Restart", + null, + 2, + 300); + // + // Now, we have policy1 unreachable + // + results = builder.buildSpecification(); + boolean unreachable = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("Policy " + policy1.getId() + " is not reachable.") && m.getLevel() == MessageLevel.WARNING) { + unreachable = true; + break; + } + } + assertTrue(unreachable); + // + // Set policy1 for the failure results of policy2 + // + policy1 = builder.setPolicyForPolicyResult( + policy1.getId(), + policy2.getId(), + PolicyResult.FAILURE, + PolicyResult.FAILURE_RETRIES, + PolicyResult.FAILURE_TIMEOUT); + results = builder.buildSpecification(); + boolean invalid_timeout = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("controlLoop overall timeout is less than the sum of operational policy timeouts.") && m.getLevel() == MessageLevel.ERROR) { + invalid_timeout = true; + break; + } + } + assertTrue(invalid_timeout); + // + // Remove policy2 (revert controlLoop back to open loop) + // + removed = builder.removePolicy(policy2.getId()); + // + // ControlLoop is open loop now, but it still has policies (policy1) + // + results = builder.buildSpecification(); + unreachable = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("Open Loop policy contains policies. The policies will never be invoked.") && m.getLevel() == MessageLevel.WARNING) { + unreachable = true; + break; + } + } + assertTrue(unreachable); + // + } catch (BuilderException e) { + fail(e.getMessage()); + } + } + + + @Test + public void test() { + this.test("src/test/resources/v1.0.0/policy_Test.yaml"); + } + + @Test + public void testEvilYaml() { + try (InputStream is = new FileInputStream(new File("src/test/resources/v1.0.0/test_evil.yaml"))) { + // + // Read the yaml into our Java Object + // + Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); + yaml.load(is); + } catch (FileNotFoundException e) { + fail(e.getLocalizedMessage()); + } catch (IOException e) { + fail(e.getLocalizedMessage()); + } catch (YAMLException e) { + // + // Should have this + // + } + } + + public void test(String testFile) { + try (InputStream is = new FileInputStream(new File(testFile))) { + // + // Read the yaml into our Java Object + // + Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); + Object obj = yaml.load(is); + assertNotNull(obj); + assertTrue(obj instanceof ControlLoopPolicy); + ControlLoopPolicy policyTobuild = (ControlLoopPolicy) obj; + // + // Now we're going to try to use the builder to build this. + // + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop( + policyTobuild.getControlLoop().getControlLoopName(), + policyTobuild.getControlLoop().getTimeout()); + // + // Add services + // + if (policyTobuild.getControlLoop().getServices() != null) { + builder = builder.addService(policyTobuild.getControlLoop().getServices().toArray(new Service[policyTobuild.getControlLoop().getServices().size()])); + } + // + // Add resources + // + if (policyTobuild.getControlLoop().getResources() != null) { + builder = builder.addResource(policyTobuild.getControlLoop().getResources().toArray(new Resource[policyTobuild.getControlLoop().getResources().size()])); + } + // + // Add the policies and be sure to set the trigger policy + // + if (policyTobuild.getPolicies() != null) { + for (Policy policy : policyTobuild.getPolicies()) { + if (policy.getId() == policyTobuild.getControlLoop().getTrigger_policy()) { + builder.setTriggerPolicy(policy.getName(), policy.getDescription(), policy.getActor(), policy.getTarget(), policy.getRecipe(), null, policy.getRetry(), policy.getTimeout()); + } + } + } + + // Question : how to change policy ID and results by using builder ?? + + @SuppressWarnings("unused") + Results results = builder.buildSpecification(); + + } catch (FileNotFoundException e) { + fail(e.getLocalizedMessage()); + } catch (IOException e) { + fail(e.getLocalizedMessage()); + } catch (BuilderException e) { + fail(e.getLocalizedMessage()); + } + + } + +} diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicyTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicyTest.java new file mode 100644 index 000000000..15d327087 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/ControlLoopPolicyTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.controlloop.policy; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.junit.Test; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.DumperOptions.FlowStyle; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; + + +public class ControlLoopPolicyTest { + + @Test + public void test() { + this.test("src/test/resources/v1.0.0/policy_Test.yaml"); + } + + @Test + public void testMultipleService() { + this.test("src/test/resources/v1.0.0/policy_Test_MultipleService.yaml"); + } + + @Test + public void testOpenLoop() { + this.test("src/test/resources/v1.0.0/policy_OpenLoop_1610.yaml"); + } + + @Test + public void testOpenECOMPvDNS() { + this.test("src/test/resources/v2.0.0/policy_OpenECOMP_demo_vDNS.yaml"); + } + + public void test(String testFile) { + try (InputStream is = new FileInputStream(new File(testFile))) { + // + // Read the yaml into our Java Object + // + Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); + Object obj = yaml.load(is); + assertNotNull(obj); + assertTrue(obj instanceof ControlLoopPolicy); + dump(obj); + // + // Now dump it to a yaml string + // + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(FlowStyle.BLOCK); + options.setPrettyFlow(true); + yaml = new Yaml(options); + String dumpedYaml = yaml.dump(obj); + System.out.println(dumpedYaml); + // + // Read that string back into our java object + // + Object newObject = yaml.load(dumpedYaml); + dump(newObject); + assertNotNull(newObject); + assertTrue(newObject instanceof ControlLoopPolicy); + // + // Have to comment it out tentatively since it causes junit to fail. + // Seems we cannot use assertEquals here. Need advice. + // + //assertEquals(newObject, obj); + } catch (FileNotFoundException e) { + fail(e.getLocalizedMessage()); + } catch (IOException e) { + fail(e.getLocalizedMessage()); + } + } + + public void dump(Object obj) { + System.out.println("Dumping " + obj.getClass().getCanonicalName()); + System.out.println(obj.toString()); + } +} diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java new file mode 100644 index 000000000..5df0266ec --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java @@ -0,0 +1,193 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.controlloop.policy.guard; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openecomp.policy.controlloop.policy.builder.BuilderException; +import org.openecomp.policy.controlloop.policy.builder.Message; +import org.openecomp.policy.controlloop.policy.builder.MessageLevel; +import org.openecomp.policy.controlloop.policy.builder.Results; +import org.openecomp.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; + +public class ControlLoopGuardBuilderTest { + + @Test + public void testControlLoopGuard() { + try { + // + // Create a builder + // + ControlLoopGuardBuilder builder = ControlLoopGuardBuilder.Factory.buildControlLoopGuard(new Guard()); + // + // Assert there is no guard policies yet + // + Results results = builder.buildSpecification(); + boolean no_guard_policies = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("ControlLoop Guard should have at least one guard policies") && m.getLevel() == MessageLevel.ERROR) { + no_guard_policies = true; + break; + } + } + assertTrue(no_guard_policies); + // + // Add a guard policy without limit constraint + // + GuardPolicy policy1 = new GuardPolicy("1111", "guardpolicy1", "guardpolicy1", "APPC", "restart"); + builder = builder.addGuardPolicy(policy1); + // + // Assert there is no limit constraint associated with the only guard policy + // + results = builder.buildSpecification(); + boolean no_constraint = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("Guard policy guardpolicy1 does not have any limit constraint") && m.getLevel() == MessageLevel.ERROR) { + no_constraint = true; + break; + } + } + assertTrue(no_constraint); + // + // Add a constraint to policy1 + // + Map<String, String> time_in_range = new HashMap<String, String>(); + time_in_range.put("arg2", "PT5H"); + time_in_range.put("arg3", "PT24H"); + List<String> blacklist = new LinkedList<String>(); + blacklist.add("eNodeB_common_id1"); + blacklist.add("eNodeB_common_id2"); + Constraint cons = new Constraint(5, "PT15M", time_in_range, blacklist); + builder = builder.addLimitConstraint(policy1.getId(), cons); + // + // Add a duplicate constraint to policy1 + // + builder = builder.addLimitConstraint(policy1.getId(), cons); + // + // Assert there are duplicate constraints associated with the only guard policy + // + results = builder.buildSpecification(); + boolean duplicate_constraint = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("Guard policy guardpolicy1 has duplicate limit constraints") && m.getLevel() == MessageLevel.WARNING) { + duplicate_constraint = true; + break; + } + } + assertTrue(duplicate_constraint); + // + // Remove the duplicate constraint + // + builder = builder.removeLimitConstraint(policy1.getId(), cons); + // + // Add a duplicate guard policy + // + builder = builder.addGuardPolicy(policy1); + builder = builder.addLimitConstraint(policy1.getId(), cons); + // + // Assert there are duplicate guard policies + // + results = builder.buildSpecification(); + boolean duplicate_guard_policy = false; + for (Message m : results.getMessages()) { + if (m.getMessage().equals("There are duplicate guard policies") && m.getLevel() == MessageLevel.WARNING) { + duplicate_guard_policy = true; + break; + } + } + assertTrue(duplicate_guard_policy); + // + // Remove the duplicate guard policy + // + builder = builder.removeGuardPolicy(policy1); + // + // Assert there are no Error/Warning message + // + results = builder.buildSpecification(); + assertTrue(results.getMessages().size() == 1); + // + } catch (BuilderException e) { + fail(e.getMessage()); + } + } + + @Test + public void test1() { + this.test("src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml"); + } + + @Test + public void test2() { + this.test("src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml"); + } + + public void test(String testFile) { + try (InputStream is = new FileInputStream(new File(testFile))) { + // + // Read the yaml into our Java Object + // + Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class)); + Object obj = yaml.load(is); + assertNotNull(obj); + assertTrue(obj instanceof ControlLoopGuard); + ControlLoopGuard guardTobuild = (ControlLoopGuard) obj; + // + // Now we're going to try to use the builder to build this. + // + ControlLoopGuardBuilder builder = ControlLoopGuardBuilder.Factory.buildControlLoopGuard(guardTobuild.getGuard()); + // + // Add guard policy + // + if (guardTobuild.getGuards() != null) { + builder = builder.addGuardPolicy(guardTobuild.getGuards().toArray(new GuardPolicy[guardTobuild.getGuards().size()])); + } + // + // Build the specification + // + Results results = builder.buildSpecification(); + // + // Print out the specification + // + System.out.println(results.getSpecification()); + // + } catch (FileNotFoundException e) { + fail(e.getLocalizedMessage()); + } catch (IOException e) { + fail(e.getLocalizedMessage()); + } catch (BuilderException e) { + fail(e.getLocalizedMessage()); + } + } +} diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java new file mode 100644 index 000000000..a09fd2112 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.controlloop.policy.guard; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.junit.Test; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.DumperOptions.FlowStyle; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; + + +public class ControlLoopGuardTest { + + @Test + public void testGuardvDNS() { + this.test("src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml"); + } + + @Test + public void testGuardvUSP() { + this.test("src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml"); + } + + public void test(String testFile) { + try (InputStream is = new FileInputStream(new File(testFile))) { + // + // Read the yaml into our Java Object + // + Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class)); + Object obj = yaml.load(is); + assertNotNull(obj); + assertTrue(obj instanceof ControlLoopGuard); + dump(obj); + // + // Now dump it to a yaml string + // + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(FlowStyle.BLOCK); + options.setPrettyFlow(true); + yaml = new Yaml(options); + String dumpedYaml = yaml.dump(obj); + System.out.println(dumpedYaml); + // + // Read that string back into our java object + // + Object newObject = yaml.load(dumpedYaml); + dump(newObject); + assertNotNull(newObject); + assertTrue(newObject instanceof ControlLoopGuard); + // + // Have to comment it out tentatively since it causes junit to fail. + // Seems we cannot use assertEquals here. Need advice. + // + //assertEquals(newObject, obj); + } catch (FileNotFoundException e) { + fail(e.getLocalizedMessage()); + } catch (IOException e) { + fail(e.getLocalizedMessage()); + } + } + + public void dump(Object obj) { + System.out.println("Dumping " + obj.getClass().getCanonicalName()); + System.out.println(obj.toString()); + } +} diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_policies_1.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_policies_1.yaml new file mode 100644 index 000000000..f6ad68425 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_policies_1.yaml @@ -0,0 +1,25 @@ +controlLoop: + controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 + version: 1.0.0 + services: + - serviceName: Foo Service + resources: + - resourceName: Bar VNF + resourceType: VF + trigger_policy: unique-policy-id-1-restart + timeout: 1200 + +policies: + - id: unique-policy-id-1-restart + name: Restart Policy for Trigger Event + description: + actor: APPC + recipe: Restart + target: VM + retry: 2 + timeout: 300 + success: FINAL_FAILURE + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_trigger_1.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_trigger_1.yaml new file mode 100644 index 000000000..981229c4a --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_trigger_1.yaml @@ -0,0 +1,95 @@ +controlLoop: + controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 + version: 1.0.0 + services: + - serviceName: Foo Service + resources: + - resourceName: Bar VNF + resourceType: VF + trigger_policy: FOO + timeout: 1200 + +policies: + - id: unique-policy-id-1-restart + name: Restart Policy for Trigger Event + description: + actor: APPC + recipe: Restart + target: VM + retry: 2 + timeout: 300 + success: unique-policy-id-2-healthcheck-restart + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-2-healthcheck-restart + name: HealthCheck Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-3-rebuild + name: Rebuild Policy + description: + actor: APPC + recipe: Rebuild + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-4-healthcheck-rebuild + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-4-healthcheck-rebuild + name: HealthCheck the Rebuild Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-5-migrate + name: Migrate Policy + description: + actor: APPC + recipe: Migrate + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-6-healthcheck-migrate + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + + - id: unique-policy-id-6-healthcheck-migrate + name: Healthcheck the Migrate Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_trigger_2.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_trigger_2.yaml new file mode 100644 index 000000000..1f9715b13 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/bad_trigger_2.yaml @@ -0,0 +1,95 @@ +controlLoop: + controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 + version: 1.0.0 + services: + - serviceName: Foo Service + resources: + - resourceName: Bar VNF + resourceType: VF + trigger_policy: FINAL_SUCCESS + timeout: 1200 + +policies: + - id: unique-policy-id-1-restart + name: Restart Policy for Trigger Event + description: + actor: APPC + recipe: Restart + target: VM + retry: 2 + timeout: 300 + success: unique-policy-id-2-healthcheck-restart + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-2-healthcheck-restart + name: HealthCheck Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-3-rebuild + name: Rebuild Policy + description: + actor: APPC + recipe: Rebuild + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-4-healthcheck-rebuild + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-4-healthcheck-rebuild + name: HealthCheck the Rebuild Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-5-migrate + name: Migrate Policy + description: + actor: APPC + recipe: Migrate + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-6-healthcheck-migrate + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + + - id: unique-policy-id-6-healthcheck-migrate + name: Healthcheck the Migrate Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_OpenLoop_1610.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_OpenLoop_1610.yaml new file mode 100644 index 000000000..7fd27fa97 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_OpenLoop_1610.yaml @@ -0,0 +1,12 @@ +controlLoop: + version: 1.0.0 + controlLoopName: ControlLoop-Open-fac4ae3d-c3f5-4bab-8e54-0a8581ede132 + services: + - serviceName: Service + resources: + - resourceType: VF + resourceName: Example + trigger_policy: final_openloop + timeout: 0 + +policies: diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_Test.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_Test.yaml new file mode 100644 index 000000000..b89a725cf --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_Test.yaml @@ -0,0 +1,95 @@ +controlLoop: + controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 + version: 1.0.0 + services: + - serviceName: Foo Service + resources: + - resourceName: Bar VNF + resourceType: VF + trigger_policy: unique-policy-id-1-restart + timeout: 1200 + +policies: + - id: unique-policy-id-1-restart + name: Restart Policy for Trigger Event + description: + actor: APPC + recipe: Restart + target: VM + retry: 2 + timeout: 300 + success: unique-policy-id-2-healthcheck-restart + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-2-healthcheck-restart + name: HealthCheck Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-3-rebuild + name: Rebuild Policy + description: + actor: APPC + recipe: Rebuild + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-4-healthcheck-rebuild + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-4-healthcheck-rebuild + name: HealthCheck the Rebuild Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-5-migrate + name: Migrate Policy + description: + actor: APPC + recipe: Migrate + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-6-healthcheck-migrate + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + + - id: unique-policy-id-6-healthcheck-migrate + name: Healthcheck the Migrate Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_Test_MultipleService.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_Test_MultipleService.yaml new file mode 100644 index 000000000..8ce707729 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/policy_Test_MultipleService.yaml @@ -0,0 +1,26 @@ +controlLoop: + version: 1.0.0 + controlLoopName: ClosedLoop-FRWL-SIG-d925ed73-8231-4d02-9545-db4e101f88f8 + services: + - serviceName: vSCP + - serviceName: vSBG + resources: + - resourceName: F5FW + resourceType: VF + trigger_policy: unique-policy-id-1-restart + timeout: 1200 + +policies: + - id: unique-policy-id-1-restart + name: Restart Policy + description: + actor: APPC + recipe: Restart + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/test.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/test.yaml new file mode 100644 index 000000000..b89a725cf --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/test.yaml @@ -0,0 +1,95 @@ +controlLoop: + controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 + version: 1.0.0 + services: + - serviceName: Foo Service + resources: + - resourceName: Bar VNF + resourceType: VF + trigger_policy: unique-policy-id-1-restart + timeout: 1200 + +policies: + - id: unique-policy-id-1-restart + name: Restart Policy for Trigger Event + description: + actor: APPC + recipe: Restart + target: VM + retry: 2 + timeout: 300 + success: unique-policy-id-2-healthcheck-restart + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-2-healthcheck-restart + name: HealthCheck Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-3-rebuild + failure_timeout: unique-policy-id-3-rebuild + failure_retries: unique-policy-id-3-rebuild + failure_exception: final_failure_exception + + - id: unique-policy-id-3-rebuild + name: Rebuild Policy + description: + actor: APPC + recipe: Rebuild + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-4-healthcheck-rebuild + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-4-healthcheck-rebuild + name: HealthCheck the Rebuild Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: unique-policy-id-5-migrate + failure_timeout: unique-policy-id-5-migrate + failure_retries: unique-policy-id-5-migrate + failure_exception: final_failure_exception + + - id: unique-policy-id-5-migrate + name: Migrate Policy + description: + actor: APPC + recipe: Migrate + target: VM + retry: 0 + timeout: 600 + success: unique-policy-id-6-healthcheck-migrate + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + + - id: unique-policy-id-6-healthcheck-migrate + name: Healthcheck the Migrate Policy + description: + actor: APPC + recipe: HealthCheck + target: VM + retry: 2 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/test_evil.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/test_evil.yaml new file mode 100644 index 000000000..347e84e5e --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v1.0.0/test_evil.yaml @@ -0,0 +1,25 @@ +controlLoop: + controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 + version: 1.0.0 + services: + - serviceName: Foo Service + resources: + - resourceName: Bar VNF + resourceType: VF + trigger_policy: unique-policy-id-1-restart + timeout: 1200 + +policies: + - id: unique-policy-id-1-restart + name: Restart Policy for Trigger Event + description: + actor: MSO + recipe: Instantiate + target: VM + retry: 2 + timeout: 300 + success: final_failure_exception + failure: final_success + failure_timeout: final_success + failure_retries: final_success + failure_exception: final_failure_exception diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml new file mode 100644 index 000000000..adb1ca171 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml @@ -0,0 +1,21 @@ +guard: + version: 2.0.0 + +guards: + - id: unique_guard_vUSP_1 + name: APPC 5 Restart + description: + We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) + actor: APPC + recipe: Restart + limit_constraints: + # + - num: 5 + time_in_range: + arg2: PT5H + arg3: PT24H + # + - num: 5 + time_in_range: + arg2: PT5H + arg3: PT24H
\ No newline at end of file diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml new file mode 100644 index 000000000..2d54e8517 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml @@ -0,0 +1,27 @@ +guard: + version: 2.0.0 + +guards: + - id: unique_guard_vUSP_1 + name: APPC 5 Restart + description: + We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) + actor: APPC + recipe: Restart + limit_constraints: + - num: 5 + time_in_range: + arg2: PT5H + arg3: PT24H + # + - id: unique_guard_vUSP_1 + name: APPC 5 Restart + description: + We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) + actor: APPC + recipe: Restart + limit_constraints: + - num: 5 + time_in_range: + arg2: PT5H + arg3: PT24H
\ No newline at end of file diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/no_guard_constraint.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/no_guard_constraint.yaml new file mode 100644 index 000000000..6ab3d67fa --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/no_guard_constraint.yaml @@ -0,0 +1,11 @@ +guard: + version: 2.0.0 + +guards: + - id: unique_guard_vUSP_1 + name: APPC 5 Restart + description: + We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) + actor: APPC + recipe: Restart +
\ No newline at end of file diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/no_guard_policy.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/no_guard_policy.yaml new file mode 100644 index 000000000..51f41d457 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/no_guard_policy.yaml @@ -0,0 +1,2 @@ +guard: + version: 2.0.0 diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml new file mode 100644 index 000000000..797a7a81f --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml @@ -0,0 +1,24 @@ +guard: + version: 2.0.0 + +guards: + - id: unique_guard_vUSP_1 + name: APPC 5 Restart + description: + We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) + actor: APPC + recipe: Restart + limit_constraints: + - num: 5 + # + # https://www.w3.org/TR/xmlschema-2/#duration + # + duration: PT15M + # + # XACML function time-in-range + # + # Assumption is that the "current time" is the 1st argument + # + time_in_range: + arg2: PT5H + arg3: PT24H
\ No newline at end of file diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml new file mode 100644 index 000000000..414e814d3 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml @@ -0,0 +1,15 @@ +guard: + version: 2.0.0 + +guards: + - id: unique_guard_ONAP_vDNS_1 + name: MSO Spinup + description: We only spin up 1 instance over a 10 minute window + actor: MSO + recipe: VF Module Create + limit_constraints: + - num: 1 + # + # https://www.w3.org/TR/xmlschema-2/#duration + # + duration: PT10M diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-59a2ee3fB58045feB5a1-template.yml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-59a2ee3fB58045feB5a1-template.yml new file mode 100644 index 000000000..f3e9bc4e4 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-59a2ee3fB58045feB5a1-template.yml @@ -0,0 +1,1698 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 +metadata: + invariantUUID: 4b8d4018-068b-4c33-b9bb-d980798e52c2 + UUID: d7d28881-b24d-4512-bfee-1e2eb335591f + name: 59a2ee3f-b580-45fe-b5a1 + description: vendor software product + type: VF + category: Generic + subcategory: Abstract + resourceVendor: 185c637a-3885-463e-8fd0 + resourceVendorRelease: '1.0' +imports: +- NeutronNet: + file: resource-Neutronnet-template.yml +- NeutronPort: + file: resource-Neutronport-template.yml +- 59a2ee3fB58045feB5a1.nodes.heat.vlb: + file: resource-59a2ee3fb58045feb5a1NodesHeatVlb-template.yml +- 59a2ee3fB58045feB5a1.nodes.heat.vdns: + file: resource-59a2ee3fb58045feb5a1NodesHeatVdns-template.yml +topology_template: + inputs: + vf_module_id: + type: string + description: The vLoadBalancer Module ID is provided by ECOMP + ecomp_private_subnet_id: + type: string + description: Private sub-network that connects ECOMP component and the VNF + repo_url_blob: + type: string + description: URL of the repository that hosts the demo packages + vlb_private_net_cidr: + type: string + description: The CIDR of the vLoadBalancer private network + vlb_private_net_id: + type: string + description: Private network that connects vLoadBalancer with vDNSs + public_net_id: + type: string + default: 00000000-0000-0000-0000-000000000000 + description: Public network that enables remote connection to VNF + demo_artifacts_version: + type: string + description: Artifacts (jar, tar.gz) version used in demo vnfs + ecomp_private_net_id: + type: string + description: Private network that connects ECOMP component and the VNF + pub_key: + type: string + description: Public key to be installed on the compute instance + vlb_private_ip_1: + type: string + description: Private IP address that is assigned to the vLoadBalancer to communicate with ECOMP components + key_name: + type: string + description: Public/Private key pair name + vdns_name_0: + type: string + description: Name of the vDNS + repo_url_artifacts: + type: string + description: URL of the repository that hosts the demo packages + vlb_name_0: + type: string + description: Name of the vLoadBalancer + vdns_private_ip_0: + type: string + description: Private IP address that is assigned to the vDNS to communicate with the vLoadBalancer + vnf_id: + type: string + description: The VNF ID is provided by ECOMP + dcae_collector_ip: + type: string + description: IP address of the DCAE collector + vdns_private_ip_1: + type: string + description: Private IP address that is assigned to the vDNS to communicate with ECOMP components + dcae_collector_port: + type: string + description: Port of the DCAE collector + vlb_image_name: + type: string + default: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) + description: Image to be used for compute instance + vlb_flavor_name: + type: string + default: 4 GB General Purpose v1 + description: Type of instance (flavor) to be used + vlb_private_ip_0: + type: string + description: Private IP address that is assigned to the vLoadBalancer to communicate with the vDNSs + ecomp_private_net_cidr: + type: string + description: The CIDR of the protected private network + node_templates: + vdns_private_1_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: + get_input: ecomp_private_subnet_id + ip_address: + get_input: vdns_private_ip_1 + network: + get_input: ecomp_private_net_id + requirements: + - binding: + capability: tosca.capabilities.network.Bindable + node: vdns_0 + relationship: tosca.relationships.network.BindsTo + vlb_private_network: + type: org.openecomp.resource.vl.nodes.heat.network.neutron.Net + metadata: + invariantUUID: 2870cc3a-d6cd-4423-b7f6-2d63619b0eeb + UUID: b7e764ba-17f9-4f0a-ad29-29877766ef21 + version: '1.0' + name: NeutronNet + description: Represents a network service with optional subnets and advanced configurations. + type: VL + category: Generic + subcategory: Network Elements + properties: + network_name: + get_input: vlb_private_net_id + subnets: + vlb_private_subnet: + name: + get_input: vlb_private_net_id + cidr: + get_input: vlb_private_net_cidr + vlb_private_1_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: + get_input: ecomp_private_subnet_id + ip_address: + get_input: vlb_private_ip_1 + network: + get_input: ecomp_private_net_id + requirements: + - binding: + capability: tosca.capabilities.network.Bindable + node: vlb_0 + relationship: tosca.relationships.network.BindsTo + vdns_0: + type: org.openecomp.resource.vfc.59a2ee3fB58045feB5a1.abstact.nodes.heat.vdns + metadata: + invariantUUID: ee585c30-127b-492e-b2c1-871dc61d1dde + UUID: d816cb01-b5d0-4bbb-b614-f7c3e230ab19 + version: '1.0' + name: 59a2ee3fB58045feB5a1.nodes.heat.vdns + description: Not reusable inner VFC + type: VFC + category: Generic + subcategory: Abstract + properties: + key_name: UNSUPPORTED_RESOURCE_my_keypair + flavor: + get_input: vlb_flavor_name + image: + get_input: vlb_image_name + metadata: + vf_module_id: + get_input: vf_module_id + vnf_id: + get_input: vnf_id + user_data_format: RAW + name: + get_input: vdns_name_0 + vlb_private_0_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: vlb_private_network + ip_address: + get_input: vlb_private_ip_0 + network: vlb_private_network + requirements: + - link: + capability: tosca.capabilities.network.Linkable + node: vlb_private_network + relationship: tosca.relationships.network.LinksTo + - binding: + capability: tosca.capabilities.network.Bindable + node: vlb_0 + relationship: tosca.relationships.network.BindsTo + vdns_private_0_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: + get_input: vlb_private_net_id + ip_address: + get_input: vdns_private_ip_0 + network: + get_input: vlb_private_net_id + requirements: + - binding: + capability: tosca.capabilities.network.Bindable + node: vdns_0 + relationship: tosca.relationships.network.BindsTo + vlb_0: + type: org.openecomp.resource.vfc.59a2ee3fB58045feB5a1.abstact.nodes.heat.vlb + metadata: + invariantUUID: f7f1d745-cfb1-4aa9-83fc-31280d0ce513 + UUID: 1821f13e-411f-4b29-87a5-ae935897b2e1 + version: '1.0' + name: 59a2ee3fB58045feB5a1.nodes.heat.vlb + description: Not reusable inner VFC + type: VFC + category: Generic + subcategory: Abstract + properties: + key_name: UNSUPPORTED_RESOURCE_my_keypair + flavor: + get_input: vlb_flavor_name + image: + get_input: vlb_image_name + metadata: + vf_module_id: + get_input: vf_module_id + vnf_id: + get_input: vnf_id + user_data_format: RAW + name: + get_input: vlb_name_0 + groups: + base_vlb: + type: org.openecomp.groups.heat.HeatStack + members: + - vdns_private_1_port + - vlb_private_network + - vlb_private_1_port + - vdns_0 + - vlb_private_0_port + - vdns_private_0_port + - vlb_0 + metadata: + invariantUUID: 097f71b3-90a1-4064-bc83-f76bf30195fe + UUID: 4daf7600-0a06-4515-859a-c45ec11abd29 + version: '1' + name: base_vlb + 59a2ee3fB58045feB5a1..dnsscaling..module-1: + type: org.openecomp.groups.VfModule + members: + - vdns_private_1_port + - vdns_0 + - vdns_private_0_port + metadata: + vfModuleModelName: 59a2ee3fB58045feB5a1..dnsscaling..module-1 + vfModuleModelInvariantUUID: 395d61a9-309b-4c0f-a442-ca47903e231e + vfModuleModelUUID: 40846490-abf4-4e1d-8f1a-2286968fa231 + vfModuleModelVersion: '1' + properties: + vf_module_type: Expansion + vf_module_description: + volume_group: false + 59a2ee3fB58045feB5a1..base_vlb..module-0: + type: org.openecomp.groups.VfModule + members: + - vdns_private_1_port + - vlb_private_network + - vlb_private_1_port + - vdns_0 + - vlb_private_0_port + - vdns_private_0_port + - vlb_0 + metadata: + vfModuleModelName: 59a2ee3fB58045feB5a1..base_vlb..module-0 + vfModuleModelInvariantUUID: 5ae76f74-6324-4835-a86c-0c96d16afd38 + vfModuleModelUUID: 17c4f752-a3da-4f3d-9cc5-1c4d28e5442d + vfModuleModelVersion: '1' + properties: + vf_module_type: Base + vf_module_description: + volume_group: false + dnsscaling: + type: org.openecomp.groups.heat.HeatStack + members: + - vdns_private_1_port + - vdns_0 + - vdns_private_0_port + metadata: + invariantUUID: 7c2971fa-9369-4fed-a449-a5e21c022f97 + UUID: ae8c3b79-77d3-425a-8bab-6558007f8392 + version: '1' + name: dnsscaling + substitution_mappings: + node_type: org.openecomp.resource.vf.59a2ee3fB58045feB5a1 + capabilities: + vdns_0.memory: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM allocated to the instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.memory.resident: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance on the physical machine + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.resident + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.cpu: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Cumulative + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vdns_private_0_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vdns_0.host: + type: tosca.capabilities.Container + occurrences: + - 1 + - UNBOUNDED + valid_source_types: + - tosca.nodes.SoftwareComponent + properties: + num_cpus: + type: integer + required: false + disk_size: + type: scalar-unit.size + required: false + cpu_frequency: + type: scalar-unit.frequency + required: false + mem_size: + type: scalar-unit.size + required: false + vdns_0.endpoint: + type: tosca.capabilities.Endpoint.Admin + occurrences: + - 1 + - UNBOUNDED + properties: + port_name: + type: string + required: false + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + secure: + type: boolean + default: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + url_path: + type: string + required: false + vlb_private_1_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vlb_0.memory: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM allocated to the instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_private_1_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vlb_0.scalable: + type: tosca.capabilities.Scalable + occurrences: + - 1 + - UNBOUNDED + properties: + max_instances: + type: integer + default: 1 + min_instances: + type: integer + default: 1 + default_instances: + type: integer + vlb_0.binding: + type: tosca.capabilities.network.Bindable + occurrences: + - 0 + - UNBOUNDED + vlb_0.vcpus: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average disk latency + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ms + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: vcpus + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_0.instance: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.os: + type: tosca.capabilities.OperatingSystem + occurrences: + - 1 + - UNBOUNDED + properties: + distribution: + type: string + required: false + type: + type: string + required: false + version: + type: version + required: false + architecture: + type: string + required: false + vlb_private_0_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vlb_private_1_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vlb_0.cpu: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Cumulative + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.cpu.delta: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used since previous datapoint + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Delta + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu.delta + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_0.memory.resident: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance on the physical machine + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.resident + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.vcpus: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average disk latency + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ms + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: vcpus + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.memory.usage: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance from the amount of its allocated memory + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.usage + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_0.cpu.delta: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used since previous datapoint + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Delta + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu.delta + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.instance:type: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance <type> (OpenStack types) + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance:type + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_0.os: + type: tosca.capabilities.OperatingSystem + occurrences: + - 1 + - UNBOUNDED + properties: + distribution: + type: string + required: false + type: + type: string + required: false + version: + type: version + required: false + architecture: + type: string + required: false + vlb_private_0_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vlb_0.host: + type: tosca.capabilities.Container + occurrences: + - 1 + - UNBOUNDED + valid_source_types: + - tosca.nodes.SoftwareComponent + properties: + num_cpus: + type: integer + required: false + disk_size: + type: scalar-unit.size + required: false + cpu_frequency: + type: scalar-unit.frequency + required: false + mem_size: + type: scalar-unit.size + required: false + vlb_0.instance:type: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance <type> (OpenStack types) + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance:type + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_private_network.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vdns_0.binding: + type: tosca.capabilities.network.Bindable + occurrences: + - 0 + - UNBOUNDED + vlb_private_network.link: + type: tosca.capabilities.network.Linkable + occurrences: + - 0 + - UNBOUNDED + vlb_0.cpu_util: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average CPU utilization + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: '%' + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu_util + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_0.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vdns_private_0_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vdns_0.cpu_util: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average CPU utilization + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: '%' + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu_util + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vdns_0.instance: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_private_network.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vdns_0.scalable: + type: tosca.capabilities.Scalable + occurrences: + - 1 + - UNBOUNDED + properties: + max_instances: + type: integer + default: 1 + min_instances: + type: integer + default: 1 + default_instances: + type: integer + vdns_private_1_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vlb_0.memory.usage: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance from the amount of its allocated memory + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.usage + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vlb_0.endpoint: + type: tosca.capabilities.Endpoint.Admin + occurrences: + - 1 + - UNBOUNDED + properties: + port_name: + type: string + required: false + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + secure: + type: boolean + default: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + url_path: + type: string + required: false + requirements: + vdns_0.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vlb_private_1_port.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo + vlb_private_0_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vdns_private_0_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vlb_0.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vdns_private_0_port.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo + vdns_0.local_storage: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + vlb_private_1_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vlb_private_network.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vlb_0.local_storage: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + vdns_private_1_port.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo + vdns_private_1_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-Eace933104d443b496b8-template.yml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-Eace933104d443b496b8-template.yml new file mode 100644 index 000000000..3ce20b597 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-Eace933104d443b496b8-template.yml @@ -0,0 +1,2525 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 +metadata: + invariantUUID: 06fe411e-d006-4ac3-8b0e-fb4f13cd78d3 + UUID: 172ce7c5-c2e4-4f8d-b66c-edb49e8e548a + name: eace9331-04d4-43b4-96b8 + description: vendor software product + type: VF + category: Generic + subcategory: Abstract + resourceVendor: 31125954-23a0-4d41-95e5 + resourceVendorRelease: '1.0' +imports: +- NeutronPort: + file: resource-Neutronport-template.yml +- Eace933104d443b496b8.nodes.heat.vfw: + file: resource-Eace933104d443b496b8NodesHeatVfw-template.yml +- Eace933104d443b496b8.nodes.heat.vpg: + file: resource-Eace933104d443b496b8NodesHeatVpg-template.yml +- NeutronNet: + file: resource-Neutronnet-template.yml +- Eace933104d443b496b8.nodes.heat.vsn: + file: resource-Eace933104d443b496b8NodesHeatVsn-template.yml +topology_template: + inputs: + vf_module_id: + type: string + description: The vFirewall Module ID is provided by ECOMP + repo_url_blob: + type: string + description: URL of the repository that hosts the demo packages + public_net_id: + type: string + default: 00000000-0000-0000-0000-000000000000 + description: Public network that enables remote connection to VNF + vfw_private_ip_1: + type: string + description: Private IP address that is assigned to the vFirewall to communicate with the vSink + vfw_private_ip_0: + type: string + description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator + vfw_private_ip_2: + type: string + description: Private IP address that is assigned to the vFirewall to communicate with ECOMP components + vfw_name_0: + type: string + description: Name of the vFirewall + vnf_id: + type: string + description: The VNF ID is provided by ECOMP + dcae_collector_ip: + type: string + description: IP address of the DCAE collector + dcae_collector_port: + type: string + description: Port of the DCAE collector + vpg_private_ip_1: + type: string + description: Private IP address that is assigned to the vPacketGenerator to communicate with ECOMP components + vsn_private_ip_0: + type: string + description: Private IP address that is assigned to the vSink to communicate with the vFirewall + vpg_name_0: + type: string + description: Name of the vPacketGenerator + vpg_private_ip_0: + type: string + description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall + vsn_private_ip_1: + type: string + description: Private IP address that is assigned to the vSink to communicate with ECOMP components + protected_private_net_cidr: + type: string + description: The CIDR of the protected private network + ecomp_private_net_cidr: + type: string + description: The CIDR of the protected private network + unprotected_private_net_cidr: + type: string + description: The CIDR of the unprotected private network + ecomp_private_subnet_id: + type: string + description: Private sub-network that connects ECOMP component and the VNF + vsn_name_0: + type: string + description: Name of the vSink + unprotected_private_net_id: + type: string + description: Private network that connects vPacketGenerator with vFirewall + vfw_flavor_name: + type: string + default: 4 GB General Purpose v1 + description: Type of instance (flavor) to be used + demo_artifacts_version: + type: string + description: Artifacts (jar, tar.gz) version used in demo vnfs + ecomp_private_net_id: + type: string + description: Private network that connects ECOMP component and the VNF + pub_key: + type: string + description: Public key to be installed on the compute instance + key_name: + type: string + description: Public/Private key pair name + repo_url_artifacts: + type: string + description: URL of the repository that hosts the demo packages + vfw_image_name: + type: string + default: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) + description: Image to be used for compute instance + protected_private_net_id: + type: string + description: Private network that connects vFirewall with vSink + node_templates: + vfw_private_0_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: unprotected_private_network + ip_address: + get_input: vfw_private_ip_0 + network: unprotected_private_network + requirements: + - link: + capability: tosca.capabilities.network.Linkable + node: unprotected_private_network + relationship: tosca.relationships.network.LinksTo + - binding: + capability: tosca.capabilities.network.Bindable + node: vfw_0 + relationship: tosca.relationships.network.BindsTo + vsn_private_1_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: + get_input: ecomp_private_subnet_id + ip_address: + get_input: vsn_private_ip_1 + network: + get_input: ecomp_private_net_id + requirements: + - binding: + capability: tosca.capabilities.network.Bindable + node: vsn_0 + relationship: tosca.relationships.network.BindsTo + unprotected_private_network: + type: org.openecomp.resource.vl.nodes.heat.network.neutron.Net + metadata: + invariantUUID: 2870cc3a-d6cd-4423-b7f6-2d63619b0eeb + UUID: b7e764ba-17f9-4f0a-ad29-29877766ef21 + version: '1.0' + name: NeutronNet + description: Represents a network service with optional subnets and advanced configurations. + type: VL + category: Generic + subcategory: Network Elements + properties: + network_name: + get_input: unprotected_private_net_id + subnets: + unprotected_private_subnet: + cidr: + get_input: unprotected_private_net_cidr + vpg_private_1_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: + get_input: ecomp_private_subnet_id + ip_address: + get_input: vpg_private_ip_1 + network: + get_input: ecomp_private_net_id + requirements: + - binding: + capability: tosca.capabilities.network.Bindable + node: vpg_0 + relationship: tosca.relationships.network.BindsTo + vfw_0: + type: org.openecomp.resource.vfc.Eace933104d443b496b8.abstact.nodes.heat.vfw + metadata: + invariantUUID: 0129e34c-d9fa-442d-bb2c-f925d018000a + UUID: 7fa1f6c7-c6bd-4444-8db2-63334a5aed1b + version: '1.0' + name: Eace933104d443b496b8.nodes.heat.vfw + description: Not reusable inner VFC + type: VFC + category: Generic + subcategory: Abstract + properties: + key_name: UNSUPPORTED_RESOURCE_my_keypair + flavor: + get_input: vfw_flavor_name + image: + get_input: vfw_image_name + metadata: + vf_module_id: + get_input: vf_module_id + vnf_id: + get_input: vnf_id + user_data_format: RAW + name: + get_input: vfw_name_0 + vsn_0: + type: org.openecomp.resource.vfc.Eace933104d443b496b8.abstact.nodes.heat.vsn + metadata: + invariantUUID: b19f6643-3db0-4d73-b280-94d6f21caa71 + UUID: 6dca6eb9-330c-4090-a542-7aca5f446e21 + version: '1.0' + name: Eace933104d443b496b8.nodes.heat.vsn + description: Not reusable inner VFC + type: VFC + category: Generic + subcategory: Abstract + properties: + key_name: UNSUPPORTED_RESOURCE_my_keypair + flavor: + get_input: vfw_flavor_name + image: + get_input: vfw_image_name + metadata: + vf_module_id: + get_input: vf_module_id + vnf_id: + get_input: vnf_id + user_data_format: RAW + name: + get_input: vsn_name_0 + vpg_private_0_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: unprotected_private_network + ip_address: + get_input: vpg_private_ip_0 + network: unprotected_private_network + requirements: + - link: + capability: tosca.capabilities.network.Linkable + node: unprotected_private_network + relationship: tosca.relationships.network.LinksTo + - binding: + capability: tosca.capabilities.network.Bindable + node: vpg_0 + relationship: tosca.relationships.network.BindsTo + vsn_private_0_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: protected_private_network + ip_address: + get_input: vsn_private_ip_0 + network: protected_private_network + requirements: + - link: + capability: tosca.capabilities.network.Linkable + node: protected_private_network + relationship: tosca.relationships.network.LinksTo + - binding: + capability: tosca.capabilities.network.Bindable + node: vsn_0 + relationship: tosca.relationships.network.BindsTo + vfw_private_1_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: protected_private_network + ip_address: + get_input: vfw_private_ip_1 + network: protected_private_network + requirements: + - link: + capability: tosca.capabilities.network.Linkable + node: protected_private_network + relationship: tosca.relationships.network.LinksTo + - binding: + capability: tosca.capabilities.network.Bindable + node: vfw_0 + relationship: tosca.relationships.network.BindsTo + vfw_private_2_port: + type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port + metadata: + invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 + UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 + version: '1.0' + name: NeutronPort + description: Represents a logical entity that associates between Compute and Network normative types. + type: CP + category: Generic + subcategory: Network Elements + properties: + fixed_ips: + - subnet: + get_input: ecomp_private_subnet_id + ip_address: + get_input: vfw_private_ip_2 + network: + get_input: ecomp_private_net_id + requirements: + - binding: + capability: tosca.capabilities.network.Bindable + node: vfw_0 + relationship: tosca.relationships.network.BindsTo + vpg_0: + type: org.openecomp.resource.vfc.Eace933104d443b496b8.abstact.nodes.heat.vpg + metadata: + invariantUUID: 7654ae14-4e98-45bc-a8c0-2c43e1805bb4 + UUID: 5267d6dd-f676-4f98-abec-6387ce6beaf2 + version: '1.0' + name: Eace933104d443b496b8.nodes.heat.vpg + description: Not reusable inner VFC + type: VFC + category: Generic + subcategory: Abstract + properties: + key_name: UNSUPPORTED_RESOURCE_my_keypair + flavor: + get_input: vfw_flavor_name + image: + get_input: vfw_image_name + metadata: + vf_module_id: + get_input: vf_module_id + vnf_id: + get_input: vnf_id + user_data_format: RAW + name: + get_input: vpg_name_0 + protected_private_network: + type: org.openecomp.resource.vl.nodes.heat.network.neutron.Net + metadata: + invariantUUID: 2870cc3a-d6cd-4423-b7f6-2d63619b0eeb + UUID: b7e764ba-17f9-4f0a-ad29-29877766ef21 + version: '1.0' + name: NeutronNet + description: Represents a network service with optional subnets and advanced configurations. + type: VL + category: Generic + subcategory: Network Elements + properties: + network_name: + get_input: protected_private_net_id + subnets: + protected_private_subnet: + cidr: + get_input: protected_private_net_cidr + groups: + base_vfw: + type: org.openecomp.groups.heat.HeatStack + members: + - vfw_private_0_port + - vsn_private_1_port + - unprotected_private_network + - vpg_private_1_port + - vfw_0 + - vsn_0 + - vpg_private_0_port + - vsn_private_0_port + - vfw_private_1_port + - vfw_private_2_port + - vpg_0 + - protected_private_network + metadata: + invariantUUID: 44b0c172-7b61-49b5-a68a-810042087e1f + UUID: 24cb02f0-1d72-441f-a327-22d80180deaa + version: '1' + name: base_vfw + Eace933104d443b496b8..base_vfw..module-0: + type: org.openecomp.groups.VfModule + members: + - vfw_private_0_port + - vsn_private_1_port + - unprotected_private_network + - vpg_private_1_port + - vfw_0 + - vsn_0 + - vpg_private_0_port + - vsn_private_0_port + - vfw_private_1_port + - vfw_private_2_port + - vpg_0 + - protected_private_network + metadata: + vfModuleModelName: Eace933104d443b496b8..base_vfw..module-0 + vfModuleModelInvariantUUID: 58c105fd-9c12-4fb7-8a3e-a5ec280183fb + vfModuleModelUUID: ab251d24-4001-4926-aa5c-c01736b36c68 + vfModuleModelVersion: '1' + properties: + vf_module_type: Base + vf_module_description: + volume_group: false + substitution_mappings: + node_type: org.openecomp.resource.vf.Eace933104d443b496b8 + capabilities: + vfw_0.instance: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vfw_0.scalable: + type: tosca.capabilities.Scalable + occurrences: + - 1 + - UNBOUNDED + properties: + max_instances: + type: integer + default: 1 + min_instances: + type: integer + default: 1 + default_instances: + type: integer + vfw_0.instance:type: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance <type> (OpenStack types) + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance:type + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + protected_private_network.link: + type: tosca.capabilities.network.Linkable + occurrences: + - 0 + - UNBOUNDED + vsn_0.cpu: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Cumulative + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.instance:type: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance <type> (OpenStack types) + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance:type + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + unprotected_private_network.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vfw_0.memory: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM allocated to the instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.cpu_util: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average CPU utilization + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: '%' + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu_util + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.endpoint: + type: tosca.capabilities.Endpoint.Admin + occurrences: + - 1 + - UNBOUNDED + properties: + port_name: + type: string + required: false + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + secure: + type: boolean + default: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + url_path: + type: string + required: false + vpg_private_0_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vfw_private_1_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vfw_private_0_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vpg_0.cpu: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Cumulative + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_private_1_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vsn_0.vcpus: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average disk latency + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ms + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: vcpus + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.cpu.delta: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used since previous datapoint + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Delta + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu.delta + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vsn_private_1_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vsn_0.cpu_util: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average CPU utilization + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: '%' + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu_util + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.instance: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vpg_0.scalable: + type: tosca.capabilities.Scalable + occurrences: + - 1 + - UNBOUNDED + properties: + max_instances: + type: integer + default: 1 + min_instances: + type: integer + default: 1 + default_instances: + type: integer + vpg_0.memory: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM allocated to the instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vfw_private_2_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vsn_0.os: + type: tosca.capabilities.OperatingSystem + occurrences: + - 1 + - UNBOUNDED + properties: + distribution: + type: string + required: false + type: + type: string + required: false + version: + type: version + required: false + architecture: + type: string + required: false + vfw_0.memory.resident: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance on the physical machine + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.resident + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vsn_0.scalable: + type: tosca.capabilities.Scalable + occurrences: + - 1 + - UNBOUNDED + properties: + max_instances: + type: integer + default: 1 + min_instances: + type: integer + default: 1 + default_instances: + type: integer + vsn_0.instance: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vfw_0.endpoint: + type: tosca.capabilities.Endpoint.Admin + occurrences: + - 1 + - UNBOUNDED + properties: + port_name: + type: string + required: false + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + secure: + type: boolean + default: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + url_path: + type: string + required: false + vsn_0.cpu.delta: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used since previous datapoint + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Delta + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu.delta + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vfw_0.os: + type: tosca.capabilities.OperatingSystem + occurrences: + - 1 + - UNBOUNDED + properties: + distribution: + type: string + required: false + type: + type: string + required: false + version: + type: version + required: false + architecture: + type: string + required: false + vsn_private_1_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vsn_private_0_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vfw_0.memory.usage: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance from the amount of its allocated memory + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.usage + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vsn_0.host: + type: tosca.capabilities.Container + occurrences: + - 1 + - UNBOUNDED + valid_source_types: + - tosca.nodes.SoftwareComponent + properties: + num_cpus: + type: integer + required: false + disk_size: + type: scalar-unit.size + required: false + cpu_frequency: + type: scalar-unit.frequency + required: false + mem_size: + type: scalar-unit.size + required: false + vsn_0.memory: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM allocated to the instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + unprotected_private_network.link: + type: tosca.capabilities.network.Linkable + occurrences: + - 0 + - UNBOUNDED + vfw_0.host: + type: tosca.capabilities.Container + occurrences: + - 1 + - UNBOUNDED + valid_source_types: + - tosca.nodes.SoftwareComponent + properties: + num_cpus: + type: integer + required: false + disk_size: + type: scalar-unit.size + required: false + cpu_frequency: + type: scalar-unit.frequency + required: false + mem_size: + type: scalar-unit.size + required: false + vsn_private_0_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vfw_private_2_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + unprotected_private_network.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vpg_0.vcpus: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average disk latency + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ms + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: vcpus + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.binding: + type: tosca.capabilities.network.Bindable + occurrences: + - 0 + - UNBOUNDED + vpg_0.host: + type: tosca.capabilities.Container + occurrences: + - 1 + - UNBOUNDED + valid_source_types: + - tosca.nodes.SoftwareComponent + properties: + num_cpus: + type: integer + required: false + disk_size: + type: scalar-unit.size + required: false + cpu_frequency: + type: scalar-unit.frequency + required: false + mem_size: + type: scalar-unit.size + required: false + vsn_0.binding: + type: tosca.capabilities.network.Bindable + occurrences: + - 0 + - UNBOUNDED + protected_private_network.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vfw_0.binding: + type: tosca.capabilities.network.Bindable + occurrences: + - 0 + - UNBOUNDED + vpg_0.memory.usage: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance from the amount of its allocated memory + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.usage + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vfw_private_0_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vsn_0.endpoint: + type: tosca.capabilities.Endpoint.Admin + occurrences: + - 1 + - UNBOUNDED + properties: + port_name: + type: string + required: false + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + secure: + type: boolean + default: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + url_path: + type: string + required: false + vfw_0.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + protected_private_network.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vfw_0.cpu: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Cumulative + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vsn_0.instance:type: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance <type> (OpenStack types) + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance:type + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.os: + type: tosca.capabilities.OperatingSystem + occurrences: + - 1 + - UNBOUNDED + properties: + distribution: + type: string + required: false + type: + type: string + required: false + version: + type: version + required: false + architecture: + type: string + required: false + vsn_0.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vfw_0.vcpus: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average disk latency + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ms + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: vcpus + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vfw_0.cpu.delta: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used since previous datapoint + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Delta + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu.delta + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vsn_0.memory.resident: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance on the physical machine + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.resident + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vsn_0.memory.usage: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance from the amount of its allocated memory + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.usage + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vfw_private_1_port.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + vfw_0.cpu_util: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average CPU utilization + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: '%' + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu_util + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_0.memory.resident: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance on the physical machine + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.resident + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + vpg_private_0_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + vpg_private_1_port.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + requirements: + vsn_private_1_port.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo + vfw_0.local_storage: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + vfw_private_1_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vpg_private_1_port.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo + vsn_0.local_storage: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + protected_private_network.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vfw_private_2_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vfw_private_2_port.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo + unprotected_private_network.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vsn_private_0_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vpg_0.local_storage: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + vsn_private_1_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vfw_0.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vpg_0.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vpg_private_1_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vsn_0.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vpg_private_0_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + vfw_private_0_port.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-57e66ea70ed645c7970f-template.yml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-57e66ea70ed645c7970f-template.yml new file mode 100644 index 000000000..b59c85269 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-57e66ea70ed645c7970f-template.yml @@ -0,0 +1,677 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 +metadata: + invariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc + UUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 + name: 57e66ea7-0ed6-45c7-970f + description: catalog service description + type: Service + category: Network L1-3 + serviceEcompNaming: false + serviceHoming: false +imports: +- eace9331-04d4-43b4-96b8: + file: resource-Eace933104d443b496b8-template.yml +topology_template: + node_templates: + eace9331-04d4-43b4-96b8 1: + type: org.openecomp.resource.vf.Eace933104d443b496b8 + metadata: + invariantUUID: 06fe411e-d006-4ac3-8b0e-fb4f13cd78d3 + UUID: 172ce7c5-c2e4-4f8d-b66c-edb49e8e548a + version: '1.0' + name: eace9331-04d4-43b4-96b8 + description: vendor software product + type: VF + category: Generic + subcategory: Abstract + substitution_mappings: + node_type: org.openecomp.service.57e66ea70ed645c7970f + capabilities: + eace9331-04d4-43b4-96b8 1.memory.resident: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance on the physical machine + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.resident + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.os: + type: tosca.capabilities.OperatingSystem + occurrences: + - 1 + - UNBOUNDED + properties: + distribution: + type: string + required: false + type: + type: string + required: false + version: + type: version + required: false + architecture: + type: string + required: false + eace9331-04d4-43b4-96b8 1.binding: + type: tosca.capabilities.network.Bindable + occurrences: + - 0 + - UNBOUNDED + eace9331-04d4-43b4-96b8 1.host: + type: tosca.capabilities.Container + occurrences: + - 1 + - UNBOUNDED + valid_source_types: + - tosca.nodes.SoftwareComponent + properties: + num_cpus: + type: integer + required: false + disk_size: + type: scalar-unit.size + required: false + cpu_frequency: + type: scalar-unit.frequency + required: false + mem_size: + type: scalar-unit.size + required: false + eace9331-04d4-43b4-96b8 1.instance: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.scalable: + type: tosca.capabilities.Scalable + occurrences: + - 1 + - UNBOUNDED + properties: + max_instances: + type: integer + default: 1 + min_instances: + type: integer + default: 1 + default_instances: + type: integer + eace9331-04d4-43b4-96b8 1.memory: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM allocated to the instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + eace9331-04d4-43b4-96b8 1.vcpus: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average disk latency + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ms + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: vcpus + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.cpu_util: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average CPU utilization + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: '%' + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu_util + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.cpu.delta: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used since previous datapoint + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Delta + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu.delta + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + eace9331-04d4-43b4-96b8 1.cpu: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Cumulative + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.instance:type: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance <type> (OpenStack types) + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance:type + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.link: + type: tosca.capabilities.network.Linkable + occurrences: + - 0 + - UNBOUNDED + eace9331-04d4-43b4-96b8 1.memory.usage: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance from the amount of its allocated memory + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.usage + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + eace9331-04d4-43b4-96b8 1.endpoint: + type: tosca.capabilities.Endpoint.Admin + occurrences: + - 1 + - UNBOUNDED + properties: + port_name: + type: string + required: false + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + secure: + type: boolean + default: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + url_path: + type: string + required: false + requirements: + eace9331-04d4-43b4-96b8 1.local_storage: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + eace9331-04d4-43b4-96b8 1.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + eace9331-04d4-43b4-96b8 1.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-D473899264974dca9db9-template.yml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-D473899264974dca9db9-template.yml new file mode 100644 index 000000000..302cacc0a --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-D473899264974dca9db9-template.yml @@ -0,0 +1,677 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 +metadata: + invariantUUID: dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f + UUID: 2eea06c6-e1d3-4c3a-b9c4-478c506eeedf + name: d4738992-6497-4dca-9db9 + description: catalog service description + type: Service + category: Network L1-3 + serviceEcompNaming: false + serviceHoming: false +imports: +- 59a2ee3f-b580-45fe-b5a1: + file: resource-59a2ee3fB58045feB5a1-template.yml +topology_template: + node_templates: + 59a2ee3f-b580-45fe-b5a1 1: + type: org.openecomp.resource.vf.59a2ee3fB58045feB5a1 + metadata: + invariantUUID: 4b8d4018-068b-4c33-b9bb-d980798e52c2 + UUID: d7d28881-b24d-4512-bfee-1e2eb335591f + version: '1.0' + name: 59a2ee3f-b580-45fe-b5a1 + description: vendor software product + type: VF + category: Generic + subcategory: Abstract + substitution_mappings: + node_type: org.openecomp.service.D473899264974dca9db9 + capabilities: + 59a2ee3f-b580-45fe-b5a1 1.memory.resident: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance on the physical machine + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.resident + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.endpoint: + type: tosca.capabilities.Endpoint.Admin + occurrences: + - 1 + - UNBOUNDED + properties: + port_name: + type: string + required: false + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + secure: + type: boolean + default: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.attachment: + type: tosca.capabilities.Attachment + occurrences: + - 1 + - UNBOUNDED + 59a2ee3f-b580-45fe-b5a1 1.feature: + type: tosca.capabilities.Node + occurrences: + - 1 + - UNBOUNDED + 59a2ee3f-b580-45fe-b5a1 1.binding: + type: tosca.capabilities.network.Bindable + occurrences: + - 0 + - UNBOUNDED + 59a2ee3f-b580-45fe-b5a1 1.vcpus: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average disk latency + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ms + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: vcpus + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.host: + type: tosca.capabilities.Container + occurrences: + - 1 + - UNBOUNDED + valid_source_types: + - tosca.nodes.SoftwareComponent + properties: + num_cpus: + type: integer + required: false + disk_size: + type: scalar-unit.size + required: false + cpu_frequency: + type: scalar-unit.frequency + required: false + mem_size: + type: scalar-unit.size + required: false + 59a2ee3f-b580-45fe-b5a1 1.memory.usage: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM used by the instance from the amount of its allocated memory + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory.usage + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.instance: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.scalable: + type: tosca.capabilities.Scalable + occurrences: + - 1 + - UNBOUNDED + properties: + max_instances: + type: integer + default: 1 + min_instances: + type: integer + default: 1 + default_instances: + type: integer + 59a2ee3f-b580-45fe-b5a1 1.cpu_util: + type: org.openecomp.capabilities.metric.Ceilometer + description: Average CPU utilization + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: '%' + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu_util + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.instance:type: + type: org.openecomp.capabilities.metric.Ceilometer + description: Existence of instance <type> (OpenStack types) + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: instance + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: instance:type + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.cpu.delta: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used since previous datapoint + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Delta + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu.delta + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.memory: + type: org.openecomp.capabilities.metric.Ceilometer + description: Volume of RAM allocated to the instance + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Gauge + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: MB + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: memory + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.link: + type: tosca.capabilities.network.Linkable + occurrences: + - 0 + - UNBOUNDED + 59a2ee3f-b580-45fe-b5a1 1.cpu: + type: org.openecomp.capabilities.metric.Ceilometer + description: CPU time used + occurrences: + - 1 + - UNBOUNDED + properties: + initiator: + type: string + default: source + network_name: + type: string + default: PRIVATE + required: false + description: + type: string + description: Description of the metric + required: false + type: + type: string + default: Cumulative + description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. + required: true + ports: + type: map + required: false + entry_schema: + type: PortSpec + secure: + type: boolean + default: false + port_name: + type: string + required: false + unit: + type: string + default: ns + description: Unit of the metric value + required: true + protocol: + type: string + default: tcp + port: + type: PortDef + required: false + name: + type: string + default: cpu + description: Ceilometer metric type name to monitor. (The name ceilometer is using) + required: true + category: + type: string + default: compute + description: Category of the metric, for an example, compute, disk, network, storage and etc. + required: false + url_path: + type: string + required: false + 59a2ee3f-b580-45fe-b5a1 1.os: + type: tosca.capabilities.OperatingSystem + occurrences: + - 1 + - UNBOUNDED + properties: + distribution: + type: string + required: false + type: + type: string + required: false + version: + type: version + required: false + architecture: + type: string + required: false + requirements: + 59a2ee3f-b580-45fe-b5a1 1.local_storage: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + 59a2ee3f-b580-45fe-b5a1 1.dependency: + occurrences: + - 0 + - UNBOUNDED + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + 59a2ee3f-b580-45fe-b5a1 1.link: + occurrences: + - 1 + - 1 + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/pgstreams.json b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/pgstreams.json new file mode 100644 index 000000000..4d118afa1 --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/pgstreams.json @@ -0,0 +1,26 @@ +{ + "pg-streams": { + "pg-stream": [ + { + "id": "fw_udp1", + "is-enabled": "true" + }, + { + "id": "fw_udp2", + "is-enabled": "true" + }, + { + "id": "fw_udp3", + "is-enabled": "true" + }, + { + "id": "fw_udp4", + "is-enabled": "true" + }, + { + "id": "fw_udp5", + "is-enabled": "true" + } + ] + } +}
\ No newline at end of file diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/policy_OpenECOMP_demo_vDNS.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/policy_OpenECOMP_demo_vDNS.yaml new file mode 100644 index 000000000..5deb8f7ff --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/policy_OpenECOMP_demo_vDNS.yaml @@ -0,0 +1,47 @@ +controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + services: + - serviceName: d4738992-6497-4dca-9db9 + serviceInvariantUUID: dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f + serviceUUID: 2eea06c6-e1d3-4c3a-b9c4-478c506eeedf +# +# OPTIONAL to specify the exact resource VF and/or VFC(s) +# +# resources: +# - resourceInvariantUUID: 4b8d4018-068b-4c33-b9bb-d980798e52c2 +# resourceUUID: d7d28881-b24d-4512-bfee-1e2eb335591f +# resourceVersion: '1.0' +# resourceName: 59a2ee3f-b580-45fe-b5a1 +# resourceType: VF +# +# resources: +# - resourceInvariantUUID: ee585c30-127b-492e-b2c1-871dc61d1dde +# resourceUUID: d816cb01-b5d0-4bbb-b614-f7c3e230ab19 +# resourceVersion: '1.0' +# resourceName: 59a2ee3fB58045feB5a1.nodes.heat.vdns +# resourceType: VFC +# - resourceInvariantUUID: f7f1d745-cfb1-4aa9-83fc-31280d0ce513 +# resourceUUID: 1821f13e-411f-4b29-87a5-ae935897b2e1 +# resourceVersion: '1.0' +# resourceName: 59a2ee3fB58045feB5a1.nodes.heat.vlb +# resourceType: VFC + trigger_policy: unique-policy-id-1-scale-up + timeout: 1200 + +policies: + - id: unique-policy-id-1-scale-up + name: Create a new VF Module + description: + actor: MSO + recipe: VF Module Create + target: + resourceID: 59a2ee3fB58045feB5a1.nodes.heat.vdns + retry: 0 + timeout: 1200 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard diff --git a/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/policy_OpenECOMP_demo_vFirewall.yaml b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/policy_OpenECOMP_demo_vFirewall.yaml new file mode 100644 index 000000000..51597714c --- /dev/null +++ b/ECOMP-ControlloopPolicy/src/test/resources/v2.0.0/policy_OpenECOMP_demo_vFirewall.yaml @@ -0,0 +1,58 @@ +controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + services: + - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc + serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 + serviceName: 57e66ea7-0ed6-45c7-970f +# +# OPTIONAL +# +# IF they want this CL restricted to a particular VFC(s) +# +#resources: +# - resourceInvariantUUID: 06fe411e-d006-4ac3-8b0e-fb4f13cd78d3 +# resourceUUID: 172ce7c5-c2e4-4f8d-b66c-edb49e8e548a +# resourceVersion: '1.0' +# resourceName: eace9331-04d4-43b4-96b8 +# resourceType: VF + +# resources: +# - resourceType: VFC +# resourceInvariantUUID: b19f6643-3db0-4d73-b280-94d6f21caa71 +# resourceUUID: 6dca6eb9-330c-4090-a542-7aca5f446e21 +# resourceVersion: '1.0' +# resourceName: Eace933104d443b496b8.nodes.heat.vsn +# - resourceName: vFW +# resourceType: VFC +# resourceInvariantUUID: 0129e34c-d9fa-442d-bb2c-f925d018000a +# resourceUUID: 7fa1f6c7-c6bd-4444-8db2-63334a5aed1b +# resourceVersion: '1.0' +# resourceName: Eace933104d443b496b8.nodes.heat.vfw +# - resourceType: VFC +# resourceInvariantUUID: 7654ae14-4e98-45bc-a8c0-2c43e1805bb4 +# resourceUUID: 5267d6dd-f676-4f98-abec-6387ce6beaf2 +# resourceVersion: '1.0' +# resourceName: Eace933104d443b496b8.nodes.heat.vpg + trigger_policy: unique-policy-id-1-modifyConfig + timeout: 1200 + +policies: + - id: unique-policy-id-1-modifyConfig + name: Change the Load Balancer + description: + actor: APPC + recipe: ModifyConfig + target: + resourceID: Eace933104d443b496b8.nodes.heat.vpg + payload: + generic-vnf.vnf-id: {generic-vnf.vnf-id} + ref$: pgstreams.json + retry: 0 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard |