diff options
12 files changed, 174 insertions, 75 deletions
diff --git a/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment b/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment index daa98799c..ec5023b2e 100644 --- a/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment +++ b/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment @@ -23,4 +23,5 @@ aai.url=http://localhost:6666 so.url=http://localhost:6667 vfc.url=http://localhost:6668 +guard.url=http://localhost:6669/pdp/api/getDecision diff --git a/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java b/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java index 50876311c..3cee70eda 100644 --- a/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java +++ b/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java @@ -46,6 +46,7 @@ public class ControlLoopUtilsFeature implements PolicyEngineFeatureAPI { Util.buildAaiSim(); Util.buildSoSim(); Util.buildVfcSim(); + Util.buildGuardSim(); } catch (final InterruptedException e) { logger.error("{}: initialization aborted", ControlLoopUtilsFeature.class.getName(), e); Thread.currentThread().interrupt(); diff --git a/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java index 5ba375847..2a8bc35ea 100644 --- a/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java +++ b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java @@ -41,6 +41,7 @@ public class ControlLoopUtilsFeatureTest { assertNotNull(HttpServletServer.factory.get(Util.AAISIM_SERVER_PORT)); assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT)); assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT)); + assertNotNull(HttpServletServer.factory.get(Util.GUARDSIM_SERVER_PORT)); } } diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml index 7672b1bc9..6b4efb879 100644 --- a/controlloop/common/model-impl/vfc/pom.xml +++ b/controlloop/common/model-impl/vfc/pom.xml @@ -51,5 +51,11 @@ <version>6.5.0.Final</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.onap.policy.drools-pdp</groupId> + <artifactId>policy-management</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> </dependencies> </project> diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java index 5cb6d6624..2d635b401 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java @@ -23,6 +23,7 @@ import java.util.Map; import org.drools.core.WorkingMemory; import org.onap.policy.vfc.util.Serialization; +import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.rest.RESTManager; import org.onap.policy.rest.RESTManager.Pair; import org.slf4j.Logger; @@ -42,9 +43,15 @@ public final class VFCManager implements Runnable { public VFCManager(WorkingMemory wm, VFCRequest request) { workingMem = wm; vfcRequest = request; - // TODO: Get base URL, username and password from MSB? - // TODO: Following code is a placeholder, needs to be updated - setVFCParams("http://localhost:6668", "username", "password"); + + /* + * TODO: What if these are null? + */ + String url = PolicyEngine.manager.getEnvironmentProperty("vfc.url"); + String username = PolicyEngine.manager.getEnvironmentProperty("vfc.username"); + String password = PolicyEngine.manager.getEnvironmentProperty("vfc.password"); + + setVFCParams(url, username, password); } diff --git a/controlloop/packages/basex/src/files/config/vDNS-controller.properties b/controlloop/packages/basex/src/files/config/amsterdam-controller.properties index 8f1371dc5..c0032dd94 100644 --- a/controlloop/packages/basex/src/files/config/vDNS-controller.properties +++ b/controlloop/packages/basex/src/files/config/amsterdam-controller.properties @@ -1,6 +1,6 @@ ### # ============LICENSE_START======================================================= -# PDP-D APPS Base Package +# ONAP # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ @@ -18,25 +18,32 @@ # ============LICENSE_END========================================================= ### -controller.name=vDNS +controller.name=amsterdam -ueb.source.topics=${{DCAE_TOPIC}},APPC-CL +ueb.source.topics=${{DCAE_TOPIC}},APPC-CL,APPC-LCM-WRITE ueb.source.topics.${{DCAE_TOPIC}}.servers=${{DCAE_SERVERS}} ueb.source.topics.${{DCAE_TOPIC}}.apiKey= ueb.source.topics.${{DCAE_TOPIC}}.apiSecret= ueb.source.topics.${{DCAE_TOPIC}}.events=org.onap.policy.controlloop.VirtualControlLoopEvent -ueb.source.topics.${{DCAE_TOPIC}}.events.org.onap.policy.controlloop.VirtualControlLoopEvent.filter=closedLoopEventStatus\=.*,closedLoopControlName\=.*DNS.* -ueb.source.topics.${{DCAE_TOPIC}}.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty +ueb.source.topics.${{DCAE_TOPIC}}.events.org.onap.policy.controlloop.VirtualControlLoopEvent.filter=closedLoopEventStatus=.* +ueb.source.topics.${{DCAE_TOPIC}}.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gson ueb.source.topics.APPC-CL.servers=${{DMAAP_SERVERS}} ueb.source.topics.APPC-CL.apiKey= ueb.source.topics.APPC-CL.apiSecret= ueb.source.topics.APPC-CL.events=org.onap.policy.appc.Response -ueb.source.topics.APPC-CL.events.org.onap.policy.appc.Response.filter=CommonHeader=.*,Status=.* +ueb.source.topics.APPC-CL.events.org.onap.policy.appc.Response.filter=CommonHeader\=.*,Status\=.* ueb.source.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty -ueb.sink.topics=APPC-CL,POLICY-CL-MGT +ueb.source.topics.APPC-LCM-WRITE.servers=${{DMAAP_SERVERS}} +ueb.source.topics.APPC-LCM-WRITE.apiKey= +ueb.source.topics.APPC-LCM-WRITE.apiSecret= +ueb.source.topics.APPC-LCM-WRITE.events=org.onap.policy.appclcm.LCMResponseWrapper +ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LCMResponseWrapper.filter=type\=response +ueb.source.topics.APPC-LCM-WRITE.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson + +ueb.sink.topics=APPC-CL,APPC-LCM-READ,POLICY-CL-MGT ueb.sink.topics.APPC-CL.servers=${{DMAAP_SERVERS}} ueb.sink.topics.APPC-CL.apiKey= @@ -44,6 +51,12 @@ ueb.sink.topics.APPC-CL.apiSecret= ueb.sink.topics.APPC-CL.events=org.onap.policy.appc.Request ueb.sink.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty +ueb.sink.topics.APPC-LCM-READ.servers=${{DMAAP_SERVERS}} +ueb.sink.topics.APPC-LCM-READ.apiKey= +ueb.sink.topics.APPC-LCM-READ.apiSecret= +ueb.sink.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.LCMRequestWrapper +ueb.sink.topics.APPC-LCM-READ.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson + ueb.sink.topics.POLICY-CL-MGT.servers=${{DMAAP_SERVERS}} ueb.sink.topics.POLICY-CL-MGT.apiKey= ueb.sink.topics.POLICY-CL-MGT.apiSecret= diff --git a/controlloop/packages/basex/src/files/config/controlloop.properties.environment b/controlloop/packages/basex/src/files/config/controlloop.properties.environment index 1ca906fa0..70f298c47 100644 --- a/controlloop/packages/basex/src/files/config/controlloop.properties.environment +++ b/controlloop/packages/basex/src/files/config/controlloop.properties.environment @@ -37,7 +37,12 @@ vfc.url=${{VFC_URL}} vfc.username=${{VFC_USERNAME}} vfc.password=${{VFC_PASSWORD}} -guard.url=${{GUARD_URL}} -guard.username=${{GUARD_USERNAME}} -guard.password=${{GUARD_PASSWORD}} +pdpx.host=${{PDP_HOST}} +pdpx.username={{PDP_USERNAME}} +pdpx.password={{PDP_PASSWORD}} +pdpx.environment={{PDP_ENVIRONMENT}} +pdpx.client.username={{PDP_CLIENT_USERNAME}} +pdpx.client.password={{PDP_CLIENT_PASSWORD}} + +guard.url=http://${{PDP_HOST}}:8081/pdp/api/getDecision guard.jdbc.url=mariadb://${{SQL_HOST}}:3306/operationshistory10 diff --git a/controlloop/packages/basex/src/files/config/vFW-controller.properties b/controlloop/packages/basex/src/files/config/vFW-controller.properties deleted file mode 100644 index 10a0bf474..000000000 --- a/controlloop/packages/basex/src/files/config/vFW-controller.properties +++ /dev/null @@ -1,55 +0,0 @@ -### -# ============LICENSE_START======================================================= -# PDP-D APPS Base Package -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -controller.name=vFW - -ueb.source.topics=${{DCAE_TOPIC}},APPC-CL - -ueb.source.topics.${{DCAE_TOPIC}}.servers=${{DCAE_SERVERS}} -ueb.source.topics.${{DCAE_TOPIC}}.apiKey= -ueb.source.topics.${{DCAE_TOPIC}}.apiSecret= -ueb.source.topics.${{DCAE_TOPIC}}.events=org.onap.policy.controlloop.VirtualControlLoopEvent -ueb.source.topics.${{DCAE_TOPIC}}.events.org.onap.policy.controlloop.VirtualControlLoopEvent.filter=closedLoopEventStatus\=.*,closedLoopControlName\=.*FRWL.* -ueb.source.topics.${{DCAE_TOPIC}}.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty - -ueb.source.topics.APPC-CL.servers=${{DMAAP_SERVERS}} -ueb.source.topics.APPC-CL.apiKey= -ueb.source.topics.APPC-CL.apiSecret= -ueb.source.topics.APPC-CL.events=org.onap.policy.appc.Response -ueb.source.topics.APPC-CL.events.org.onap.policy.appc.Response.filter=CommonHeader=.*,Status=.* -ueb.source.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty - -ueb.sink.topics=APPC-CL,POLICY-CL-MGT - -ueb.sink.topics.APPC-CL.servers=${{DMAAP_SERVERS}} -ueb.sink.topics.APPC-CL.apiKey= -ueb.sink.topics.APPC-CL.apiSecret= -ueb.sink.topics.APPC-CL.events=org.onap.policy.appc.Request -ueb.sink.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty - -ueb.sink.topics.POLICY-CL-MGT.servers=${{DMAAP_SERVERS}} -ueb.sink.topics.POLICY-CL-MGT.apiKey= -ueb.sink.topics.POLICY-CL-MGT.apiSecret= -ueb.sink.topics.POLICY-CL-MGT.events=org.onap.policy.controlloop.VirtualControlLoopNotification -ueb.sink.topics.POLICY-CL-MGT.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty - -rules.groupId= -rules.artifactId= -rules.version= diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/VoLTE.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/VoLTE.yaml new file mode 100644 index 000000000..fd5869fc8 --- /dev/null +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/VoLTE.yaml @@ -0,0 +1,23 @@ +controlLoop: + version: 2.0.0 + controlLoopName: ${closedLoopControlName} + trigger_policy: unique-policy-id-1-restart + timeout: 3600 + +policies: + - id: unique-policy-id-1-restart + name: Restart the VM + description: + actor: VFC + recipe: Restart + target: + type: VM + retry: 3 + 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/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json new file mode 100644 index 000000000..151912968 --- /dev/null +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json @@ -0,0 +1,18 @@ +{ + "closedLoopControlName": "${closedLoopControlName}", + "closedLoopAlarmStart": 1484677482204798, + "closedLoopEventClient": "DCAE.HolmesInstance", + "closedLoopEventStatus": "ONSET", + "requestID": "97964e10-686e-4790-8c45-bdfa61df770f", + "target_type": "VM", + "target": "vserver.vserver-name", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "vserver.vserver-name": "dfw1lb01lb01", + "service-instance.service-instance-id" : "vserver-name-16102016-aai3255-data-11-1", + "generic-vnf.vnf-id" : "vnf-id-16102016-aai3255-data-11-1", + "generic-vnf.vnf-name" : "vnf-name-16102016-aai3255-data-11-1" + }, + "from": "DCAE", + "version": "1.0.2" +}
\ No newline at end of file diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl index f56a3ff6a..b10cc3bb7 100644 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl @@ -41,6 +41,7 @@ import org.onap.policy.appclcm.LCMRequest; import org.onap.policy.appclcm.LCMResponse; import org.onap.policy.appclcm.LCMCommonHeader; import org.onap.policy.vfc.VFCRequest; +import org.onap.policy.vfc.VFCResponse; import org.onap.policy.vfc.VFCManager; import org.onap.policy.so.SOManager; import org.onap.policy.so.SORequest; @@ -556,13 +557,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" case "VFC": if (request instanceof VFCRequest) { // Start VFC thread - VFCManager vfcManager = new VFCManager((VFCRequest) request); - vfcManager.setVFCParams( - PolicyEngine.manager.getEnvironmentProperty("vfc.url"), - PolicyEngine.manager.getEnvironmentProperty("vfc.user"), - PolicyEngine.manager.getEnvironmentProperty("vfc.password")); - - Thread t = new Thread(vfcManager); + Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request)); t.start(); } break; @@ -1014,6 +1009,78 @@ end /* * +* This rule responds to VFC Response Events +* +*/ +rule "${policyName}.VFC.RESPONSE" + when + $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) + $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET ) + $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName ) + $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID ) + $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() ) + $lock : TargetLock (requestID == $event.requestID) + $response : VFCResponse( requestId.toString() == $event.requestID.toString() ) + then + Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); + logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); + logger.debug("{}: {}: event={} manager={} operation={} lock={} opTimer={} response={}", + $params.getClosedLoopControlName(), drools.getRule().getName(), + $event, $manager, $operation, $lock, $operation, $opTimer, $response); + + // Get the result of the operation + // + PolicyResult policyResult = $operation.onResponse($response); + if (policyResult != null) { + // + // This Operation has completed, construct a notification showing our results + // + VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); + notification.from = "policy"; + notification.policyName = drools.getRule().getName(); + notification.policyScope = "${policyScope}"; + notification.policyVersion = "${policyVersion}"; + notification.message = $operation.getOperationHistory(); + notification.history = $operation.getHistory(); + // + // Ensure the operation is complete + // + if ($operation.isOperationComplete() == true) { + // + // It is complete, remove it from memory + // + retract($operation); + // + // We must also retract the timer object + // NOTE: We could write a Rule to do this + // + retract($opTimer); + // + // Complete the operation + // + modify($manager) {finishOperation($operation)}; + } else { + // + // Just doing this will kick off the LOCKED rule again + // + modify($operation) {}; + } + } else { + // + // Its not finished yet (i.e. expecting more Response objects) + // + // Or possibly it is a leftover response that we timed the request out previously + // + } + // + // We are going to retract these objects from memory + // + retract($response); + +end + +/* +* * This is the timer that manages the timeout for an individual operation. * */ diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java index d5b6e4421..29fdc195a 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java @@ -57,6 +57,7 @@ import org.onap.policy.controlloop.impl.ControlLoopLoggerStdOutImpl; import org.onap.policy.controlloop.policy.ControlLoopPolicy; import org.onap.policy.drools.http.server.HttpServletServer; import org.onap.policy.drools.impl.PolicyEngineJUnitImpl; +import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.vfc.util.Serialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,6 +70,17 @@ public class VFCControlLoopTest { private Util.Pair<ControlLoopPolicy, String> pair; private PolicyEngineJUnitImpl engine; + static { + /* Set environment properties */ + PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); + PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); + PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); + + PolicyEngine.manager.setEnvironmentProperty("vfc.url", "http://localhost:6668"); + PolicyEngine.manager.setEnvironmentProperty("vfc.username", "VFC"); + PolicyEngine.manager.setEnvironmentProperty("vfc.password", "VFC"); + } + @BeforeClass public static void setUpSimulator() { try { |