2020-09-28 ONES - Control Loop automation using ONAP
- Former user (Deleted)
Owned by Former user (Deleted)
To illustrate implementation of Control Loop automation using ONAP, following sections contain use case specific code belonging to main components.
Alarming Analytic
Drools rule implementing the detection of the problem
rules.drl Expand source
package ca.bell.kjar; //list any import classes here. import ca.bell.json.ves.model.CommonEventFormat3010; import ca.bell.dcae.controlloop.VirtualControlLoopEvent; import ca.bell.dcae.controlloop.ControlLoopTargetType; import ca.bell.dcae.controlloop.ControlLoopEventStatus import java.util.ArrayList; import java.util.UUID import java.util.HashMap import java.util.Map import java.math.BigDecimal; import java.util.Date; //declare any global variables here global org.apache.nifi.logging.ComponentLog LOG; function long getTimestamp(String hostname){ long timestamp = 0; int index = 0; long mult = 1; char c = hostname.charAt(hostname.length()-1-index); while(c >= '0' && c <= '9'){ timestamp += (c-'0')*mult; mult = mult*10; c = hostname.charAt(hostname.length()-1-(++index)); } return timestamp; } rule "Empty hostname" no-loop true salience 10 when $event :CommonEventFormat3010( $hostname: event.otherFields.hashMap.additionalProperties.get("hostname"), $hostname == "UNDEFINED", $pnf_id: event.commonEventHeader.sourceId ) then $event.getEvent().getOtherFields().getHashMap().setAdditionalProperty("pnfId",$pnf_id); channels["VesMessage"].send($event); retract($event); end //The 2 rules have same action and can be merged into 1 rule, but is kept separated for modular purpose rule "Check timestamp" no-loop true salience 2 when $event :CommonEventFormat3010( $hostname : event.otherFields.hashMap.additionalProperties.get("hostname"), $hostname != "UNDEFINED", $epochMilli : event.commonEventHeader.lastEpochMicrosec, ($epochMilli - getTimestamp($hostname)) >= (5*60*1000), $pnf_id: event.commonEventHeader.sourceId ) then $event.getEvent().getOtherFields().getHashMap().setAdditionalProperty("pnfId",$pnf_id); channels["VesMessage"].send($event); retract($event); end rule "No issue detected" no-loop true salience 1 when $event :CommonEventFormat3010( $hostname : event.otherFields.hashMap.additionalProperties.get("hostname"), $hostname != "UNDEFINED", $epochMilli : event.commonEventHeader.lastEpochMicrosec, ($epochMilli - getTimestamp($hostname)) < (5*60*1000) ) then retract($event); end
State Analytic
Drools rule responsible to detect a state change
rules.drl Expand source
package ca.bell.kjar; //list any import classes here. import ca.bell.json.ves.model.CommonEventFormat3010; import ca.bell.dcae.controlloop.VirtualControlLoopEvent; import ca.bell.dcae.controlloop.ControlLoopTargetType; import ca.bell.dcae.controlloop.ControlLoopEventStatus import java.util.ArrayList; import java.util.UUID import java.util.HashMap import java.util.Map import java.math.BigDecimal; import java.time.Instant; import java.util.Date; //declare any global variables here global org.apache.nifi.logging.ComponentLog LOG; declare Memory previousHostname : String end rule "Initialize memory" salience 10 when not Memory() then Memory mem = new Memory(); mem.setPreviousHostname(null); insert(mem); LOG.info("Initialized memory"); end rule "Hostname changed" no-loop true salience 2 when $mem : Memory($previousHostname : previousHostname) $event: CommonEventFormat3010( $newHostname : event.otherFields.hashMap.additionalProperties.get("hostname") != $previousHostname) then $mem.setPreviousHostname($newHostname); String stateDBvalue = "{\"hostname\" : \"" + $newHostname + "\"}"; $event.getEvent().getOtherFields().getHashMap().setAdditionalProperty("hostname",stateDBvalue); channels["VesMessage"].send($event); LOG.info("Hostname changed!"); retract($event); update($mem); end rule "Hostname unchanged" salience 3 no-loop true when $mem : Memory($previousHostname : previousHostname) $event: CommonEventFormat3010( $newHostname : event.otherFields.hashMap.additionalProperties.get("hostname") == $previousHostname || $newHostname == null) then retract($event); end
Policy
APEX policy responsible to generate the new hostname and request for CDS remediation
tosca-policy.json Expand source
{ "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { "onap.policies.apex.Simplecontrolloop": { "type": "onap.policies.native.Apex", "type_version": "1.0.0", "name": "onap.policies.apex.Simplecontrolloop", "version": "1.0.0", "properties": { "engineServiceParameters": { "name": "MyApexEngine", "version": "0.0.1", "id": 45, "instanceCount": 4, "deploymentPort": 12561, "engineParameters": { "executorParameters": { "JAVASCRIPT": { "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" } }, "contextParameters": { "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", "schemaParameters": { "Avro": { "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" } } }, "taskParameters": [ { "key": "logUrl", "value": "http://message-router:3904/events/POLICY-CL-MGT" } ] }, "policy_type_impl": { "apexPolicyModel": { "key": { "name": "APEXExamplePolicy", "version": "0.0.1" }, "keyInformation": { "key": { "name": "APEXExamplePolicy_KeyInfo", "version": "0.0.1" }, "keyInfoMap": { "entry": [ { "key": { "name": "AAIFailureResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "AAIFailureResponseEvent", "version": "0.0.1" }, "UUID": "70005df0-888e-3e55-a80f-655468fe6ac2", "description": "Generated description for concept referred to by key \"AAIFailureResponseEvent:0.0.1\"" } }, { "key": { "name": "AAIFailureResponseHandlerPolicy", "version": "0.0.1" }, "value": { "key": { "name": "AAIFailureResponseHandlerPolicy", "version": "0.0.1" }, "UUID": "6a4cb3e6-7d0e-3291-9366-7037c63620d4", "description": "Generated description for concept referred to by key \"AAIFailureResponseHandlerPolicy:0.0.1\"" } }, { "key": { "name": "AAIRequestErrorType", "version": "0.0.1" }, "value": { "key": { "name": "AAIRequestErrorType", "version": "0.0.1" }, "UUID": "78bf7461-3b37-3349-b7f4-83af49ca158d", "description": "Generated description for concept referred to by key \"AAIRequestErrorType:0.0.1\"" } }, { "key": { "name": "AAIRequestEvent", "version": "0.0.1" }, "value": { "key": { "name": "AAIRequestEvent", "version": "0.0.1" }, "UUID": "eb518fce-1270-3639-a2a8-9e1085d9ddf3", "description": "Generated description for concept referred to by key \"AAIRequestEvent:0.0.1\"" } }, { "key": { "name": "AAISuccessResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "AAISuccessResponseEvent", "version": "0.0.1" }, "UUID": "3344be07-dcdf-3bc0-badb-fa67acd74bbc", "description": "Generated description for concept referred to by key \"AAISuccessResponseEvent:0.0.1\"" } }, { "key": { "name": "AAISuccessResponseHandlerPolicy", "version": "0.0.1" }, "value": { "key": { "name": "AAISuccessResponseHandlerPolicy", "version": "0.0.1" }, "UUID": "31252826-fbd1-3b8c-970c-8bb7316f3063", "description": "Generated description for concept referred to by key \"AAISuccessResponseHandlerPolicy:0.0.1\"" } }, { "key": { "name": "APEXExamplePolicy", "version": "0.0.1" }, "value": { "key": { "name": "APEXExamplePolicy", "version": "0.0.1" }, "UUID": "f99c27f7-24bf-3634-ac7a-1b3880b14bfc", "description": "Generated description for concept referred to by key \"APEXExamplePolicy:0.0.1\"" } }, { "key": { "name": "APEXExamplePolicy_Albums", "version": "0.0.1" }, "value": { "key": { "name": "APEXExamplePolicy_Albums", "version": "0.0.1" }, "UUID": "c5a78c12-64b7-3a10-a253-c5bf632933de", "description": "Generated description for concept referred to by key \"APEXExamplePolicy_Albums:0.0.1\"" } }, { "key": { "name": "APEXExamplePolicy_Events", "version": "0.0.1" }, "value": { "key": { "name": "APEXExamplePolicy_Events", "version": "0.0.1" }, "UUID": "b7146854-a0b4-3771-9c67-155cc8bf011a", "description": "Generated description for concept referred to by key \"APEXExamplePolicy_Events:0.0.1\"" } }, { "key": { "name": "APEXExamplePolicy_KeyInfo", "version": "0.0.1" }, "value": { "key": { "name": "APEXExamplePolicy_KeyInfo", "version": "0.0.1" }, "UUID": "77c36041-d09f-3299-bea5-daa1ba859b64", "description": "Generated description for concept referred to by key \"APEXExamplePolicy_KeyInfo:0.0.1\"" } }, { "key": { "name": "APEXExamplePolicy_Policies", "version": "0.0.1" }, "value": { "key": { "name": "APEXExamplePolicy_Policies", "version": "0.0.1" }, "UUID": "72a336b7-8093-32a2-9f77-cdb50fcd96d5", "description": "Generated description for concept referred to by key \"APEXExamplePolicy_Policies:0.0.1\"" } }, { "key": { "name": "APEXExamplePolicy_Schemas", "version": "0.0.1" }, "value": { "key": { "name": "APEXExamplePolicy_Schemas", "version": "0.0.1" }, "UUID": "d4a51349-3b55-35be-a7e2-a9df3db2bab4", "description": "Generated description for concept referred to by key \"APEXExamplePolicy_Schemas:0.0.1\"" } }, { "key": { "name": "APEXExamplePolicy_Tasks", "version": "0.0.1" }, "value": { "key": { "name": "APEXExamplePolicy_Tasks", "version": "0.0.1" }, "UUID": "dcf945e6-8191-3b1f-ad79-a456c287a5ab", "description": "Generated description for concept referred to by key \"APEXExamplePolicy_Tasks:0.0.1\"" } }, { "key": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "value": { "key": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "UUID": "6e5fa19b-14df-37e3-a4ae-8c537e861a82", "description": "Generated description for concept referred to by key \"CDSActionIdentifiersType:0.0.1\"" } }, { "key": { "name": "CDSConfigModifyFailureResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyFailureResponseEvent", "version": "0.0.1" }, "UUID": "fa711c8e-94df-316e-b199-1d7f940b4f8c", "description": "Generated description for concept referred to by key \"CDSConfigModifyFailureResponseEvent:0.0.1\"" } }, { "key": { "name": "CDSConfigModifyFailureResponseHandlerPolicy", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyFailureResponseHandlerPolicy", "version": "0.0.1" }, "UUID": "edda3b87-fc1e-33c7-8115-1a28743c3356", "description": "Generated description for concept referred to by key \"CDSConfigModifyFailureResponseHandlerPolicy:0.0.1\"" } }, { "key": { "name": "CDSConfigModifyFailureResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyFailureResponseTask", "version": "0.0.1" }, "UUID": "628762bb-37dc-3f50-a0b9-8703136ba8c1", "description": "Generated description for concept referred to by key \"CDSConfigModifyFailureResponseTask:0.0.1\"" } }, { "key": { "name": "CDSConfigModifyRequestEvent", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyRequestEvent", "version": "0.0.1" }, "UUID": "8b376aad-e7d1-3916-956f-c0fdc5455472", "description": "Generated description for concept referred to by key \"CDSConfigModifyRequestEvent:0.0.1\"" } }, { "key": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "UUID": "fdf8a7c3-197c-3a9a-bfb1-94f71b390be3", "description": "Generated description for concept referred to by key \"CDSConfigModifyRequestPayloadType:0.0.1\"" } }, { "key": { "name": "CDSConfigModifyResponsePayloadType", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyResponsePayloadType", "version": "0.0.1" }, "UUID": "fc04d64e-74cb-38de-9786-ba0f7108557c", "description": "Generated description for concept referred to by key \"CDSConfigModifyResponsePayloadType:0.0.1\"" } }, { "key": { "name": "CDSConfigModifySuccessResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifySuccessResponseEvent", "version": "0.0.1" }, "UUID": "13876c7f-4f61-343b-8f01-a883d07bab1e", "description": "Generated description for concept referred to by key \"CDSConfigModifySuccessResponseEvent:0.0.1\"" } }, { "key": { "name": "CDSConfigModifySuccessResponseHandlerPolicy", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifySuccessResponseHandlerPolicy", "version": "0.0.1" }, "UUID": "dc7cc0b9-a754-31c6-b934-28e329b2e0c2", "description": "Generated description for concept referred to by key \"CDSConfigModifySuccessResponseHandlerPolicy:0.0.1\"" } }, { "key": { "name": "CDSConfigModifySuccessResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifySuccessResponseTask", "version": "0.0.1" }, "UUID": "6cbdd131-beeb-33d4-ac26-34aa124d3b6a", "description": "Generated description for concept referred to by key \"CDSConfigModifySuccessResponseTask:0.0.1\"" } }, { "key": { "name": "CDSFailureResponseCommonHeaderType", "version": "0.0.1" }, "value": { "key": { "name": "CDSFailureResponseCommonHeaderType", "version": "0.0.1" }, "UUID": "a360bd57-b7ef-383f-93aa-ac4ee1f9bb83", "description": "Generated description for concept referred to by key \"CDSFailureResponseCommonHeaderType:0.0.1\"" } }, { "key": { "name": "CDSFailureResponseStatusType", "version": "0.0.1" }, "value": { "key": { "name": "CDSFailureResponseStatusType", "version": "0.0.1" }, "UUID": "24244e17-e159-340d-967b-3a176d375e13", "description": "Generated description for concept referred to by key \"CDSFailureResponseStatusType:0.0.1\"" } }, { "key": { "name": "CDSRequestCommonHeaderType", "version": "0.0.1" }, "value": { "key": { "name": "CDSRequestCommonHeaderType", "version": "0.0.1" }, "UUID": "35590ac0-062c-39f1-8786-b4ff716e30b1", "description": "Generated description for concept referred to by key \"CDSRequestCommonHeaderType:0.0.1\"" } }, { "key": { "name": "CDSSuccessResponseCommonHeaderType", "version": "0.0.1" }, "value": { "key": { "name": "CDSSuccessResponseCommonHeaderType", "version": "0.0.1" }, "UUID": "422199bb-b38b-3986-8a44-01a0d441d1fd", "description": "Generated description for concept referred to by key \"CDSSuccessResponseCommonHeaderType:0.0.1\"" } }, { "key": { "name": "CDSSuccessResponseStatusType", "version": "0.0.1" }, "value": { "key": { "name": "CDSSuccessResponseStatusType", "version": "0.0.1" }, "UUID": "5d159d4a-c9a6-34ca-bc0a-6fd40d364071", "description": "Generated description for concept referred to by key \"CDSSuccessResponseStatusType:0.0.1\"" } }, { "key": { "name": "EventDetailsAlbum", "version": "0.0.1" }, "value": { "key": { "name": "EventDetailsAlbum", "version": "0.0.1" }, "UUID": "5234fcbe-cfac-3bcb-a7d0-ceb2f22d4687", "description": "Generated description for concept referred to by key \"EventDetailsAlbum:0.0.1\"" } }, { "key": { "name": "EventDetailsAlbumType", "version": "0.0.1" }, "value": { "key": { "name": "EventDetailsAlbumType", "version": "0.0.1" }, "UUID": "aa6c8d11-a17e-3784-ac81-10c2f0e3c058", "description": "Generated description for concept referred to by key \"EventDetailsAlbumType:0.0.1\"" } }, { "key": { "name": "HandleAAIFailureResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "HandleAAIFailureResponseTask", "version": "0.0.1" }, "UUID": "baf9be46-6934-3a94-a105-8f68994a2831", "description": "Generated description for concept referred to by key \"HandleAAIFailureResponseTask:0.0.1\"" } }, { "key": { "name": "HandleAAISuccessResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "HandleAAISuccessResponseTask", "version": "0.0.1" }, "UUID": "a9683018-5ef6-329c-837e-e370a0649feb", "description": "Generated description for concept referred to by key \"HandleAAISuccessResponseTask:0.0.1\"" } }, { "key": { "name": "HandleVesEventTask", "version": "0.0.1" }, "value": { "key": { "name": "HandleVesEventTask", "version": "0.0.1" }, "UUID": "12f46075-e431-3b10-9dab-a23c77b06c6e", "description": "Generated description for concept referred to by key \"HandleVesEventTask:0.0.1\"" } }, { "key": { "name": "LogStatusEvent", "version": "0.0.1" }, "value": { "key": { "name": "LogStatusEvent", "version": "0.0.1" }, "UUID": "d6413332-f759-3055-a8a2-7c3029bd01df", "description": "Generated description for concept referred to by key \"LogStatusEvent:0.0.1\"" } }, { "key": { "name": "SimpleBooleanType", "version": "0.0.1" }, "value": { "key": { "name": "SimpleBooleanType", "version": "0.0.1" }, "UUID": "7218fb2f-59e3-321d-9ae1-bc97b19eb4ae", "description": "Generated description for concept referred to by key \"SimpleBooleanType:0.0.1\"" } }, { "key": { "name": "SimpleLongType", "version": "0.0.1" }, "value": { "key": { "name": "SimpleLongType", "version": "0.0.1" }, "UUID": "2dfcd9ec-a6f9-3f9f-958f-9b36cf4ac574", "description": "Generated description for concept referred to by key \"SimpleLongType:0.0.1\"" } }, { "key": { "name": "SimpleStringType", "version": "0.0.1" }, "value": { "key": { "name": "SimpleStringType", "version": "0.0.1" }, "UUID": "8a4957cf-9493-3a76-8c22-a208e23259af", "description": "Generated description for concept referred to by key \"SimpleStringType:0.0.1\"" } }, { "key": { "name": "VesEvent", "version": "0.0.1" }, "value": { "key": { "name": "VesEvent", "version": "0.0.1" }, "UUID": "fe3b7e02-bbb4-3fdc-8a83-f1a6f98d38af", "description": "Generated description for concept referred to by key \"VesEvent:0.0.1\"" } }, { "key": { "name": "VesEventHandlerPolicy", "version": "0.0.1" }, "value": { "key": { "name": "VesEventHandlerPolicy", "version": "0.0.1" }, "UUID": "88ff1def-ecc3-3077-9ccf-fd6cab049a86", "description": "Generated description for concept referred to by key \"VesEventHandlerPolicy:0.0.1\"" } }, { "key": { "name": "VesEventType", "version": "0.0.1" }, "value": { "key": { "name": "VesEventType", "version": "0.0.1" }, "UUID": "37fd6192-11be-301a-9365-48d87d73cf83", "description": "Generated description for concept referred to by key \"VesEventType:0.0.1\"" } }, { "key": { "name": "VnfDetailsType", "version": "0.0.1" }, "value": { "key": { "name": "VnfDetailsType", "version": "0.0.1" }, "UUID": "876b5266-70a9-3a36-9726-c610cd183c9d", "description": "Generated description for concept referred to by key \"VnfDetailsType:0.0.1\"" } } ] } }, "policies": { "key": { "name": "APEXExamplePolicy_Policies", "version": "0.0.1" }, "policyMap": { "entry": [ { "key": { "name": "AAIFailureResponseHandlerPolicy", "version": "0.0.1" }, "value": { "policyKey": { "name": "AAIFailureResponseHandlerPolicy", "version": "0.0.1" }, "template": "Freestyle", "state": { "entry": [ { "key": "ReceiveAAIFailureResponseState", "value": { "stateKey": { "parentKeyName": "AAIFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "NULL", "localName": "ReceiveAAIFailureResponseState" }, "trigger": { "name": "AAIFailureResponseEvent", "version": "0.0.1" }, "stateOutputs": { "entry": [ { "key": "AAIFailureStateOutput", "value": { "key": { "parentKeyName": "AAIFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveAAIFailureResponseState", "localName": "AAIFailureStateOutput" }, "outgoingEvent": { "name": "LogStatusEvent", "version": "0.0.1" }, "nextState": { "parentKeyName": "NULL", "parentKeyVersion": "0.0.0", "parentLocalName": "NULL", "localName": "NULL" } } } ] }, "contextAlbumReference": [], "taskSelectionLogic": { "key": "NULL", "logicFlavour": "UNDEFINED", "logic": "" }, "stateFinalizerLogicMap": { "entry": [] }, "defaultTask": { "name": "HandleAAIFailureResponseTask", "version": "0.0.1" }, "taskReferences": { "entry": [ { "key": { "name": "HandleAAIFailureResponseTask", "version": "0.0.1" }, "value": { "key": { "parentKeyName": "AAIFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveAAIFailureResponseState", "localName": "AAIFailureResponseHandlerPolicy" }, "outputType": "DIRECT", "output": { "parentKeyName": "AAIFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveAAIFailureResponseState", "localName": "AAIFailureStateOutput" } } } ] } } } ] }, "firstState": "ReceiveAAIFailureResponseState" } }, { "key": { "name": "AAISuccessResponseHandlerPolicy", "version": "0.0.1" }, "value": { "policyKey": { "name": "AAISuccessResponseHandlerPolicy", "version": "0.0.1" }, "template": "Freestyle", "state": { "entry": [ { "key": "ReceiveAAISuccessResponseState", "value": { "stateKey": { "parentKeyName": "AAISuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "NULL", "localName": "ReceiveAAISuccessResponseState" }, "trigger": { "name": "AAISuccessResponseEvent", "version": "0.0.1" }, "stateOutputs": { "entry": [ { "key": "AAISuccessStateOutput", "value": { "key": { "parentKeyName": "AAISuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveAAISuccessResponseState", "localName": "AAISuccessStateOutput" }, "outgoingEvent": { "name": "CDSConfigModifyRequestEvent", "version": "0.0.1" }, "nextState": { "parentKeyName": "NULL", "parentKeyVersion": "0.0.0", "parentLocalName": "NULL", "localName": "NULL" } } } ] }, "contextAlbumReference": [], "taskSelectionLogic": { "key": "NULL", "logicFlavour": "UNDEFINED", "logic": "" }, "stateFinalizerLogicMap": { "entry": [] }, "defaultTask": { "name": "HandleAAISuccessResponseTask", "version": "0.0.1" }, "taskReferences": { "entry": [ { "key": { "name": "HandleAAISuccessResponseTask", "version": "0.0.1" }, "value": { "key": { "parentKeyName": "AAISuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveAAISuccessResponseState", "localName": "AAISuccessResponseHandlerPolicy" }, "outputType": "DIRECT", "output": { "parentKeyName": "AAISuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveAAISuccessResponseState", "localName": "AAISuccessStateOutput" } } } ] } } } ] }, "firstState": "ReceiveAAISuccessResponseState" } }, { "key": { "name": "CDSConfigModifyFailureResponseHandlerPolicy", "version": "0.0.1" }, "value": { "policyKey": { "name": "CDSConfigModifyFailureResponseHandlerPolicy", "version": "0.0.1" }, "template": "Freestyle", "state": { "entry": [ { "key": "CDSConfigModifyFailureResponseState", "value": { "stateKey": { "parentKeyName": "CDSConfigModifyFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "NULL", "localName": "CDSConfigModifyFailureResponseState" }, "trigger": { "name": "CDSConfigModifyFailureResponseEvent", "version": "0.0.1" }, "stateOutputs": { "entry": [ { "key": "ConfigModifyFailureResponseOutput", "value": { "key": { "parentKeyName": "CDSConfigModifyFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "CDSConfigModifyFailureResponseState", "localName": "ConfigModifyFailureResponseOutput" }, "outgoingEvent": { "name": "LogStatusEvent", "version": "0.0.1" }, "nextState": { "parentKeyName": "NULL", "parentKeyVersion": "0.0.0", "parentLocalName": "NULL", "localName": "NULL" } } } ] }, "contextAlbumReference": [], "taskSelectionLogic": { "key": "NULL", "logicFlavour": "UNDEFINED", "logic": "" }, "stateFinalizerLogicMap": { "entry": [] }, "defaultTask": { "name": "CDSConfigModifyFailureResponseTask", "version": "0.0.1" }, "taskReferences": { "entry": [ { "key": { "name": "CDSConfigModifyFailureResponseTask", "version": "0.0.1" }, "value": { "key": { "parentKeyName": "CDSConfigModifyFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "CDSConfigModifyFailureResponseState", "localName": "CDSConfigModifyFailureResponseHandlerPolicy" }, "outputType": "DIRECT", "output": { "parentKeyName": "CDSConfigModifyFailureResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "CDSConfigModifyFailureResponseState", "localName": "ConfigModifyFailureResponseOutput" } } } ] } } } ] }, "firstState": "CDSConfigModifyFailureResponseState" } }, { "key": { "name": "CDSConfigModifySuccessResponseHandlerPolicy", "version": "0.0.1" }, "value": { "policyKey": { "name": "CDSConfigModifySuccessResponseHandlerPolicy", "version": "0.0.1" }, "template": "Freestyle", "state": { "entry": [ { "key": "CDSConfigModifySuccessResponseState", "value": { "stateKey": { "parentKeyName": "CDSConfigModifySuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "NULL", "localName": "CDSConfigModifySuccessResponseState" }, "trigger": { "name": "CDSConfigModifySuccessResponseEvent", "version": "0.0.1" }, "stateOutputs": { "entry": [ { "key": "ConfigModifySuccessResponseOutput", "value": { "key": { "parentKeyName": "CDSConfigModifySuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "CDSConfigModifySuccessResponseState", "localName": "ConfigModifySuccessResponseOutput" }, "outgoingEvent": { "name": "LogStatusEvent", "version": "0.0.1" }, "nextState": { "parentKeyName": "NULL", "parentKeyVersion": "0.0.0", "parentLocalName": "NULL", "localName": "NULL" } } } ] }, "contextAlbumReference": [], "taskSelectionLogic": { "key": "NULL", "logicFlavour": "UNDEFINED", "logic": "" }, "stateFinalizerLogicMap": { "entry": [] }, "defaultTask": { "name": "CDSConfigModifySuccessResponseTask", "version": "0.0.1" }, "taskReferences": { "entry": [ { "key": { "name": "CDSConfigModifySuccessResponseTask", "version": "0.0.1" }, "value": { "key": { "parentKeyName": "CDSConfigModifySuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "CDSConfigModifySuccessResponseState", "localName": "CDSConfigModifySuccessResponseHandlerPolicy" }, "outputType": "DIRECT", "output": { "parentKeyName": "CDSConfigModifySuccessResponseHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "CDSConfigModifySuccessResponseState", "localName": "ConfigModifySuccessResponseOutput" } } } ] } } } ] }, "firstState": "CDSConfigModifySuccessResponseState" } }, { "key": { "name": "VesEventHandlerPolicy", "version": "0.0.1" }, "value": { "policyKey": { "name": "VesEventHandlerPolicy", "version": "0.0.1" }, "template": "Freestyle", "state": { "entry": [ { "key": "ReceiveVesState", "value": { "stateKey": { "parentKeyName": "VesEventHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "NULL", "localName": "ReceiveVesState" }, "trigger": { "name": "VesEvent", "version": "0.0.1" }, "stateOutputs": { "entry": [ { "key": "VesOutput", "value": { "key": { "parentKeyName": "VesEventHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveVesState", "localName": "VesOutput" }, "outgoingEvent": { "name": "AAIRequestEvent", "version": "0.0.1" }, "nextState": { "parentKeyName": "NULL", "parentKeyVersion": "0.0.0", "parentLocalName": "NULL", "localName": "NULL" } } } ] }, "contextAlbumReference": [], "taskSelectionLogic": { "key": "NULL", "logicFlavour": "UNDEFINED", "logic": "" }, "stateFinalizerLogicMap": { "entry": [] }, "defaultTask": { "name": "HandleVesEventTask", "version": "0.0.1" }, "taskReferences": { "entry": [ { "key": { "name": "HandleVesEventTask", "version": "0.0.1" }, "value": { "key": { "parentKeyName": "VesEventHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveVesState", "localName": "VesEventHandlerPolicy" }, "outputType": "DIRECT", "output": { "parentKeyName": "VesEventHandlerPolicy", "parentKeyVersion": "0.0.1", "parentLocalName": "ReceiveVesState", "localName": "VesOutput" } } } ] } } } ] }, "firstState": "ReceiveVesState" } } ] } }, "tasks": { "key": { "name": "APEXExamplePolicy_Tasks", "version": "0.0.1" }, "taskMap": { "entry": [ { "key": { "name": "CDSConfigModifyFailureResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyFailureResponseTask", "version": "0.0.1" }, "inputFields": { "entry": [ { "key": "actionIdentifiers", "value": { "key": "actionIdentifiers", "fieldSchemaKey": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "optional": false } }, { "key": "commonHeader", "value": { "key": "commonHeader", "fieldSchemaKey": { "name": "CDSFailureResponseCommonHeaderType", "version": "0.0.1" }, "optional": false } }, { "key": "payload", "value": { "key": "payload", "fieldSchemaKey": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "CDSFailureResponseStatusType", "version": "0.0.1" }, "optional": false } } ] }, "outputFields": { "entry": [ { "key": "eventId", "value": { "key": "eventId", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingEnd", "value": { "key": "eventProcessingEnd", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingStart", "value": { "key": "eventProcessingStart", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "from", "value": { "key": "from", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "message", "value": { "key": "message", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] }, "taskParameters": { "entry": [] }, "contextAlbumReference": [ { "name": "EventDetailsAlbum", "version": "0.0.1" } ], "taskLogic": { "key": "TaskLogic", "logicFlavour": "JAVASCRIPT", "logic": "var uuidType = java.util.UUID;\nvar longType = java.lang.Long;\n\nvar albumID = uuidType.fromString(\"d0050623-18e5-46c9-9298-9a567990cd7c\");\n\nvar eventDetailsAlbum = executor.getContextAlbum(\"EventDetailsAlbum\").get(albumID.toString());\nexecutor.outFields.put(\"eventProcessingStart\", eventDetailsAlbum.get(\"commonEventHeader\").get(\"startEpochMicrosec\"));\nexecutor.outFields.put(\"eventProcessingEnd\", longType(new Date().getTime()));\nexecutor.outFields.put(\"eventId\", eventDetailsAlbum.get(\"commonEventHeader\").get(\"eventId\"));\nexecutor.outFields.put(\"from\", \"APEX\");\nexecutor.outFields.put(\"status\", \"FAILURE\");\nexecutor.outFields.put(\"message\", \"Hostname update operation failed. \"+executor.inFields.get(\"status\").get(\"errorMessage\"));\nexecutor.logger.info(executor.outFields);\ntrue;" } } }, { "key": { "name": "CDSConfigModifySuccessResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifySuccessResponseTask", "version": "0.0.1" }, "inputFields": { "entry": [ { "key": "actionIdentifiers", "value": { "key": "actionIdentifiers", "fieldSchemaKey": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "optional": false } }, { "key": "commonHeader", "value": { "key": "commonHeader", "fieldSchemaKey": { "name": "CDSSuccessResponseCommonHeaderType", "version": "0.0.1" }, "optional": false } }, { "key": "payload", "value": { "key": "payload", "fieldSchemaKey": { "name": "CDSConfigModifyResponsePayloadType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "CDSSuccessResponseStatusType", "version": "0.0.1" }, "optional": false } } ] }, "outputFields": { "entry": [ { "key": "eventId", "value": { "key": "eventId", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingEnd", "value": { "key": "eventProcessingEnd", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingStart", "value": { "key": "eventProcessingStart", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "from", "value": { "key": "from", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "message", "value": { "key": "message", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] }, "taskParameters": { "entry": [] }, "contextAlbumReference": [ { "name": "EventDetailsAlbum", "version": "0.0.1" } ], "taskLogic": { "key": "TaskLogic", "logicFlavour": "JAVASCRIPT", "logic": "var uuidType = java.util.UUID;\nvar longType = java.lang.Long;\n\nvar albumID = uuidType.fromString(\"d0050623-18e5-46c9-9298-9a567990cd7c\");\nvar eventDetailsAlbum = executor.getContextAlbum(\"EventDetailsAlbum\").get(albumID.toString());\nvar commonEventHeader = eventDetailsAlbum.get(\"commonEventHeader\");\n\nexecutor.outFields.put(\"eventProcessingStart\", eventDetailsAlbum.get(\"commonEventHeader\").get(\"startEpochMicrosec\"));\nexecutor.outFields.put(\"eventProcessingEnd\", longType(new Date().getTime()));\nexecutor.outFields.put(\"eventId\", eventDetailsAlbum.get(\"commonEventHeader\").get(\"eventId\"));\nexecutor.outFields.put(\"from\", \"APEX\");\nexecutor.outFields.put(\"status\", \"SUCCESS\");\nexecutor.outFields.put(\"message\", \"Hostname updated successfully. New hostname sent to CDS is: \"+ eventDetailsAlbum.get(\"generatedHostname\"));\nexecutor.logger.info(executor.outFields);\ntrue;" } } }, { "key": { "name": "HandleAAIFailureResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "HandleAAIFailureResponseTask", "version": "0.0.1" }, "inputFields": { "entry": [ { "key": "requestError", "value": { "key": "requestError", "fieldSchemaKey": { "name": "AAIRequestErrorType", "version": "0.0.1" }, "optional": false } } ] }, "outputFields": { "entry": [ { "key": "eventId", "value": { "key": "eventId", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingEnd", "value": { "key": "eventProcessingEnd", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingStart", "value": { "key": "eventProcessingStart", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "from", "value": { "key": "from", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "message", "value": { "key": "message", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] }, "taskParameters": { "entry": [] }, "contextAlbumReference": [ { "name": "EventDetailsAlbum", "version": "0.0.1" } ], "taskLogic": { "key": "TaskLogic", "logicFlavour": "JAVASCRIPT", "logic": "var uuidType = java.util.UUID;\nvar longType = java.lang.Long;\n\nvar albumID = uuidType.fromString(\"d0050623-18e5-46c9-9298-9a567990cd7c\");\n\nvar eventDetailsAlbum = executor.getContextAlbum(\"EventDetailsAlbum\").get(albumID.toString());\nvar aaiErrorMessage = executor.inFields.get(\"requestError\").get(\"serviceException\").get(\"text\");\nexecutor.outFields.put(\"eventProcessingStart\", eventDetailsAlbum.get(\"commonEventHeader\").get(\"startEpochMicrosec\"));\nexecutor.outFields.put(\"eventProcessingEnd\", longType(new Date().getTime()));\nexecutor.outFields.put(\"eventId\", eventDetailsAlbum.get(\"commonEventHeader\").get(\"eventId\"));\nexecutor.outFields.put(\"from\", \"APEX\");\nexecutor.outFields.put(\"status\", \"FAILURE\");\nexecutor.outFields.put(\"message\", aaiErrorMessage);\ntrue;" } } }, { "key": { "name": "HandleAAISuccessResponseTask", "version": "0.0.1" }, "value": { "key": { "name": "HandleAAISuccessResponseTask", "version": "0.0.1" }, "inputFields": { "entry": [ { "key": "equip-model", "value": { "key": "equip-model", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "equip-type", "value": { "key": "equip-type", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "equip-vendor", "value": { "key": "equip-vendor", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "in-maint", "value": { "key": "in-maint", "fieldSchemaKey": { "name": "SimpleBooleanType", "version": "0.0.1" }, "optional": false } }, { "key": "ipaddress-v4-oam", "value": { "key": "ipaddress-v4-oam", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "ipaddress-v6-oam", "value": { "key": "ipaddress-v6-oam", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "management-option", "value": { "key": "management-option", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "pnf-id", "value": { "key": "pnf-id", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "pnf-name", "value": { "key": "pnf-name", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "pnf-name2", "value": { "key": "pnf-name2", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "resource-version", "value": { "key": "resource-version", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] }, "outputFields": { "entry": [ { "key": "actionIdentifiers", "value": { "key": "actionIdentifiers", "fieldSchemaKey": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "optional": false } }, { "key": "commonHeader", "value": { "key": "commonHeader", "fieldSchemaKey": { "name": "CDSRequestCommonHeaderType", "version": "0.0.1" }, "optional": false } }, { "key": "payload", "value": { "key": "payload", "fieldSchemaKey": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "optional": false } } ] }, "taskParameters": { "entry": [] }, "contextAlbumReference": [ { "name": "EventDetailsAlbum", "version": "0.0.1" } ], "taskLogic": { "key": "TaskLogic", "logicFlavour": "JAVASCRIPT", "logic": "var uuidType = java.util.UUID;\nvar HashMapType = java.util.HashMap;\nvar longType = java.lang.Long;\n\nvar albumID = uuidType.fromString(\"d0050623-18e5-46c9-9298-9a567990cd7c\");\nvar eventDetailsAlbum = executor.getContextAlbum(\"EventDetailsAlbum\").get(albumID.toString());\n\nvar commonEventHeader = eventDetailsAlbum.get(\"commonEventHeader\");\nvar otherFieldsMap = eventDetailsAlbum.get(\"otherFields\").get(\"hashMap\");\n\nvar existingHostname = executor.inFields.get(\"pnf-name2\");\nvar hostnameInVesEvent = otherFieldsMap.get(\"hostname\");\nvar returnVal = true;\nif ((String(hostnameInVesEvent) != \"UNDEFINED\") && (String(existingHostname) != String(hostnameInVesEvent))) {\n executor.logger.info(\"sending the status to log.\");\n var logData = '{'\n +'\"eventProcessingStart\" : ' + commonEventHeader.get(\"startEpochMicrosec\") + ','\n +'\"eventProcessingEnd\" : ' + longType(new Date().getTime()) + ','\n +'\"eventId\" : ' + commonEventHeader.get(\"eventId\") + ','\n +'\"from\" : \"APEX\",'\n +'\"status\" : \"FAILURE\",'\n +'\"message\" : \"Hostname available in AAI does not match with the hostname received in the VES Event\"'\n +'}';\n fireLogEvent(logData);\n returnVal = false;\n} else {\n var commonHeader = executor.subject.getOutFieldSchemaHelper(\"commonHeader\").createNewInstance();\n commonHeader.put(\"subRequestId\", commonEventHeader.get(\"eventId\"));\n commonHeader.put(\"requestId\", uuidType.randomUUID().toString());\n commonHeader.put(\"originatorId\", \"POLICY\");\n \n var blueprintName = \"controlloop-hostname-update\";\n var blueprintVersion = \"1.0.4\";\n var newHostname = \"host\" + Math.random().toString(36).substring(7);\n eventDetailsAlbum.put(\"generatedHostname\", newHostname);\n \n var actionIdentifiers = executor.subject.getOutFieldSchemaHelper(\"actionIdentifiers\").createNewInstance();\n actionIdentifiers.put(\"mode\", \"sync\");\n actionIdentifiers.put(\"blueprintName\", blueprintName);\n actionIdentifiers.put(\"blueprintVersion\", blueprintVersion);\n actionIdentifiers.put(\"actionName\", \"update-config\");\n \n var payloadEntry = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewSubInstance(\"CDSConfigModifyRequestPayloadEntry\");\n payloadEntry.put(\"hostname\", newHostname)\n payloadEntry.put(\"IP\", executor.inFields.get(\"ipaddress-v4-oam\"));\n payloadEntry.put(\"pnfId\", otherFieldsMap.get(\"pnfId\"));\n \n var payload = executor.subject.getOutFieldSchemaHelper(\"payload\").createNewInstance();\n payload.put(\"update_DasH_config_DasH_request\", payloadEntry);\n \n executor.outFields.put(\"commonHeader\", commonHeader);\n executor.outFields.put(\"actionIdentifiers\", actionIdentifiers);\n executor.outFields.put(\"payload\", payload);\n}\n\nreturnVal;\n\n\nfunction fireLogEvent(logEvent){\n var headers = new HashMapType();\n //headers.put(\"Authorization\" , \"Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\");\n executor.logger.info(\"LogEvent:\"+logEvent);\n var response = new org.onap.policy.rest.RestManager().post(\n executor.getParameters().get(\"logUrl\"),\n \"\",\n \"\",\n headers,\n \"application/json\",\n logEvent\n );\n executor.logger.info(\"DMaaP Response after sending LogEvent: \" + response);\n return response;\n}" } } }, { "key": { "name": "HandleVesEventTask", "version": "0.0.1" }, "value": { "key": { "name": "HandleVesEventTask", "version": "0.0.1" }, "inputFields": { "entry": [ { "key": "event", "value": { "key": "event", "fieldSchemaKey": { "name": "VesEventType", "version": "0.0.1" }, "optional": false } } ] }, "outputFields": { "entry": [ { "key": "aaifield", "value": { "key": "aaifield", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] }, "taskParameters": { "entry": [] }, "contextAlbumReference": [ { "name": "EventDetailsAlbum", "version": "0.0.1" } ], "taskLogic": { "key": "TaskLogic", "logicFlavour": "JAVASCRIPT", "logic": "var uuidType = java.util.UUID;\nvar HashMapType = java.util.HashMap;\nvar longType = java.lang.Long;\n\n//albumID will be used to fetch info from our album later\nvar albumID = uuidType.fromString(\"d0050623-18e5-46c9-9298-9a567990cd7c\");\nvar eventDetailsAlbum = executor.getContextAlbum(\"EventDetailsAlbum\").getSchemaHelper().createNewInstance();\nvar returnValue = true;\n\nvar event = executor.inFields.get(\"event\");\nexecutor.logger.info(\"HandleVesEventTask processing VesEvent - \" + event);\n\nvar commonEventHeader = event.get(\"commonEventHeader\");\nvar otherFields = event.get(\"otherFields\");\n// save the event processing start time in apex\ncommonEventHeader.put(\"startEpochMicrosec\", longType(new Date().getTime()));\n//save the incoming fault event details to album\neventDetailsAlbum.put(\"commonEventHeader\", commonEventHeader)\neventDetailsAlbum.put(\"otherFields\", otherFields)\nexecutor.getContextAlbum(\"EventDetailsAlbum\").put(albumID.toString(), eventDetailsAlbum);\n\nexecutor.getExecutionProperties().setProperty(\"pnfId\", otherFields.get(\"hashMap\").get(\"pnfId\"));\n\nexecutor.logger.info(executor.outFields);\nexecutor.logger.info(\"sending the status to log.\");\nvar logData = '{'\n +'\"eventProcessingStart\" : ' + eventDetailsAlbum.get(\"commonEventHeader\").get(\"startEpochMicrosec\") + ','\n +'\"eventProcessingEnd\" : ' + longType(new Date().getTime()) + ','\n +'\"eventId\" : ' + eventDetailsAlbum.get(\"commonEventHeader\").get(\"eventId\") + ','\n +'\"from\" : \"APEX\",'\n +'\"status\" : \"ACTIVE\",'\n +'\"message\" : \"VES Event received\"'\n +'}';\nfireLogEvent(logData);\nreturnValue;\n\n\nfunction fireLogEvent(logEvent){\n var headers = new HashMapType();\n //headers.put(\"Authorization\" , \"Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==\");\n executor.logger.info(\"LogEvent:\"+logEvent);\n var response = new org.onap.policy.rest.RestManager().post(\n executor.getParameters().get(\"logUrl\"),\n \"\",\n \"\",\n headers,\n \"application/json\",\n logEvent\n );\n executor.logger.info(\"DMaaP Response after sending LogEvent: \" + response);\n return response;\n}" } } } ] } }, "events": { "key": { "name": "APEXExamplePolicy_Events", "version": "0.0.1" }, "eventMap": { "entry": [ { "key": { "name": "AAIFailureResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "AAIFailureResponseEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "AAI", "target": "APEX", "parameter": { "entry": [ { "key": "requestError", "value": { "key": "requestError", "fieldSchemaKey": { "name": "AAIRequestErrorType", "version": "0.0.1" }, "optional": false } } ] } } }, { "key": { "name": "AAIRequestEvent", "version": "0.0.1" }, "value": { "key": { "name": "AAIRequestEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "APEX", "target": "AAI", "parameter": { "entry": [ { "key": "aaifield", "value": { "key": "aaifield", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] } } }, { "key": { "name": "AAISuccessResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "AAISuccessResponseEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "AAI", "target": "APEX", "parameter": { "entry": [ { "key": "equip-model", "value": { "key": "equip-model", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "equip-type", "value": { "key": "equip-type", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "equip-vendor", "value": { "key": "equip-vendor", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "in-maint", "value": { "key": "in-maint", "fieldSchemaKey": { "name": "SimpleBooleanType", "version": "0.0.1" }, "optional": false } }, { "key": "ipaddress-v4-oam", "value": { "key": "ipaddress-v4-oam", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "ipaddress-v6-oam", "value": { "key": "ipaddress-v6-oam", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "management-option", "value": { "key": "management-option", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "pnf-id", "value": { "key": "pnf-id", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "pnf-name", "value": { "key": "pnf-name", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "pnf-name2", "value": { "key": "pnf-name2", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "resource-version", "value": { "key": "resource-version", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] } } }, { "key": { "name": "CDSConfigModifyFailureResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyFailureResponseEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "CDS", "target": "APEX", "parameter": { "entry": [ { "key": "actionIdentifiers", "value": { "key": "actionIdentifiers", "fieldSchemaKey": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "optional": false } }, { "key": "commonHeader", "value": { "key": "commonHeader", "fieldSchemaKey": { "name": "CDSFailureResponseCommonHeaderType", "version": "0.0.1" }, "optional": false } }, { "key": "payload", "value": { "key": "payload", "fieldSchemaKey": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "CDSFailureResponseStatusType", "version": "0.0.1" }, "optional": false } } ] } } }, { "key": { "name": "CDSConfigModifyRequestEvent", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyRequestEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "APEX", "target": "APEX", "parameter": { "entry": [ { "key": "actionIdentifiers", "value": { "key": "actionIdentifiers", "fieldSchemaKey": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "optional": false } }, { "key": "commonHeader", "value": { "key": "commonHeader", "fieldSchemaKey": { "name": "CDSRequestCommonHeaderType", "version": "0.0.1" }, "optional": false } }, { "key": "payload", "value": { "key": "payload", "fieldSchemaKey": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "optional": false } } ] } } }, { "key": { "name": "CDSConfigModifySuccessResponseEvent", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifySuccessResponseEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "CDS", "target": "APEX", "parameter": { "entry": [ { "key": "actionIdentifiers", "value": { "key": "actionIdentifiers", "fieldSchemaKey": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "optional": false } }, { "key": "commonHeader", "value": { "key": "commonHeader", "fieldSchemaKey": { "name": "CDSSuccessResponseCommonHeaderType", "version": "0.0.1" }, "optional": false } }, { "key": "payload", "value": { "key": "payload", "fieldSchemaKey": { "name": "CDSConfigModifyResponsePayloadType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "CDSSuccessResponseStatusType", "version": "0.0.1" }, "optional": false } } ] } } }, { "key": { "name": "LogStatusEvent", "version": "0.0.1" }, "value": { "key": { "name": "LogStatusEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "APEX", "target": "DCAE", "parameter": { "entry": [ { "key": "eventId", "value": { "key": "eventId", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingEnd", "value": { "key": "eventProcessingEnd", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "eventProcessingStart", "value": { "key": "eventProcessingStart", "fieldSchemaKey": { "name": "SimpleLongType", "version": "0.0.1" }, "optional": false } }, { "key": "from", "value": { "key": "from", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "message", "value": { "key": "message", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } }, { "key": "status", "value": { "key": "status", "fieldSchemaKey": { "name": "SimpleStringType", "version": "0.0.1" }, "optional": false } } ] } } }, { "key": { "name": "VesEvent", "version": "0.0.1" }, "value": { "key": { "name": "VesEvent", "version": "0.0.1" }, "nameSpace": "org.onap.policy.apex.example", "source": "DCAE", "target": "APEX", "parameter": { "entry": [ { "key": "event", "value": { "key": "event", "fieldSchemaKey": { "name": "VesEventType", "version": "0.0.1" }, "optional": false } } ] } } } ] } }, "albums": { "key": { "name": "APEXExamplePolicy_Albums", "version": "0.0.1" }, "albums": { "entry": [ { "key": { "name": "EventDetailsAlbum", "version": "0.0.1" }, "value": { "key": { "name": "EventDetailsAlbum", "version": "0.0.1" }, "scope": "policy", "isWritable": true, "itemSchema": { "name": "EventDetailsAlbumType", "version": "0.0.1" } } } ] } }, "schemas": { "key": { "name": "APEXExamplePolicy_Schemas", "version": "0.0.1" }, "schemas": { "entry": [ { "key": { "name": "AAIRequestErrorType", "version": "0.0.1" }, "value": { "key": { "name": "AAIRequestErrorType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"name\": \"AAIRequestErrorType\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"serviceException\",\n \"type\": {\n \"name\": \"serviceException\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"messageId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"text\",\n \"type\": \"string\"\n },\n {\n \"name\": \"variables\",\n \"type\": {\n \"type\": \"array\",\n \"items\": \"string\"\n }\n }\n ]\n }\n }\n ]\n}" } }, { "key": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "value": { "key": { "name": "CDSActionIdentifiersType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"CDSActionIdentifiers_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"actionName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"blueprintVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"mode\",\n \"type\": \"string\"\n }\n ]\n}" } }, { "key": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyRequestPayloadType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"type\": \"map\",\n \"values\": {\n \"type\": \"record\",\n \"name\": \"CDSConfigModifyRequestPayloadEntry\",\n \"fields\": [\n {\n \"name\": \"hostname\",\n \"type\": \"string\"\n },\n {\n \"name\": \"IP\",\n \"type\": \"string\"\n },\n {\n \"name\": \"pnfId\",\n \"type\": \"string\"\n }\n ]\n }\n}" } }, { "key": { "name": "CDSConfigModifyResponsePayloadType", "version": "0.0.1" }, "value": { "key": { "name": "CDSConfigModifyResponsePayloadType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"name\": \"CDSConfigResponsePayloadEntry\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"update_DasH_config_DasH_response\",\n \"type\": {\n \"name\": \"update_DasH_config_DasH_response\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"execute_DasH_command_DasH_logs\",\n \"type\": {\n \"type\": \"array\",\n \"items\": \"string\"\n }\n },\n {\n \"name\": \"prepare_DasH_environment_DasH_logs\",\n \"type\": {\n \"type\": \"array\",\n \"items\": \"string\"\n }\n }\n ]\n }\n }\n ]\n}" } }, { "key": { "name": "CDSFailureResponseCommonHeaderType", "version": "0.0.1" }, "value": { "key": { "name": "CDSFailureResponseCommonHeaderType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"CDSResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n }\n ]\n}" } }, { "key": { "name": "CDSFailureResponseStatusType", "version": "0.0.1" }, "value": { "key": { "name": "CDSFailureResponseStatusType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"CDSResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n },\n {\n \"name\": \"errorMessage\",\n \"type\": \"string\"\n }\n ]\n}" } }, { "key": { "name": "CDSRequestCommonHeaderType", "version": "0.0.1" }, "value": { "key": { "name": "CDSRequestCommonHeaderType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"CDSRequestCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n }\n ]\n}" } }, { "key": { "name": "CDSSuccessResponseCommonHeaderType", "version": "0.0.1" }, "value": { "key": { "name": "CDSSuccessResponseCommonHeaderType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"CDSResponseCommonHeader_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"originatorId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"subRequestId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n }\n ]\n}" } }, { "key": { "name": "CDSSuccessResponseStatusType", "version": "0.0.1" }, "value": { "key": { "name": "CDSSuccessResponseStatusType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"CDSResponseStatus_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.helloworld\",\n \"fields\": [\n {\n \"name\": \"code\",\n \"type\": \"int\"\n },\n {\n \"name\": \"eventType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"timestamp\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}" } }, { "key": { "name": "EventDetailsAlbumType", "version": "0.0.1" }, "value": { "key": { "name": "EventDetailsAlbumType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"name\": \"eventDetails\",\n \"type\": \"record\",\n \"namespace\": \"com.acme.avro\",\n \"fields\": [\n {\n \"name\":\"commonEventHeader\",\n \"type\":{\n \"name\":\"commonEventHeader\",\n \"type\":\"record\",\n \"fields\":[\n {\n \"name\":\"domain\",\n \"type\":\"string\"\n },\n {\n \"name\":\"eventId\",\n \"type\":\"string\"\n },\n {\n \"name\":\"eventName\",\n \"type\":\"string\"\n },\n {\n \"name\":\"lastEpochMicrosec\",\n \"type\":\"long\"\n },\n {\n \"name\":\"priority\",\n \"type\":\"string\"\n },\n {\n \"name\":\"reportingEntityName\",\n \"type\":\"string\"\n },\n {\n \"name\":\"sequence\",\n \"type\":\"int\"\n },\n {\n \"name\":\"sourceId\",\n \"type\":\"string\"\n },\n {\n \"name\":\"sourceName\",\n \"type\":\"string\"\n },\n {\n \"name\":\"startEpochMicrosec\",\n \"type\":\"long\"\n },\n {\n \"name\":\"timeZoneOffset\",\n \"type\":\"string\"\n },\n {\n \"name\":\"version\",\n \"type\":\"string\"\n },\n {\n \"name\":\"internalHeaderFields\",\n \"type\":{\n \"name\":\"internalHeaderFields\",\n \"type\":\"record\",\n \"fields\":[\n\n ]\n }\n },\n {\n \"name\":\"vesEventListenerVersion\",\n \"type\":\"string\"\n }\n ]\n }\n },\n {\n \"name\":\"otherFields\",\n \"type\":{\n \"name\":\"otherFields\",\n \"type\":\"record\",\n \"fields\":[\n {\n \"name\":\"hashMap\",\n \"type\":{\n \"name\":\"hashMap\",\n \"type\":\"record\",\n \"fields\":[\n {\n \"name\":\"hostname\",\n \"type\":\"string\"\n },\n {\n \"name\":\"pnfId\",\n \"type\":\"string\"\n },\n {\n \"name\":\"ip\",\n \"type\":\"string\"\n }\n ]\n }\n },\n {\n \"name\":\"otherFieldsVersion\",\n \"type\":\"string\"\n }\n ]\n }\n },\n {\n \"name\":\"generatedHostname\",\n \"type\": \"string\"\n }\n ]\n}" } }, { "key": { "name": "SimpleBooleanType", "version": "0.0.1" }, "value": { "key": { "name": "SimpleBooleanType", "version": "0.0.1" }, "schemaFlavour": "Java", "schemaDefinition": "java.lang.Boolean" } }, { "key": { "name": "SimpleLongType", "version": "0.0.1" }, "value": { "key": { "name": "SimpleLongType", "version": "0.0.1" }, "schemaFlavour": "Java", "schemaDefinition": "java.lang.Long" } }, { "key": { "name": "SimpleStringType", "version": "0.0.1" }, "value": { "key": { "name": "SimpleStringType", "version": "0.0.1" }, "schemaFlavour": "Java", "schemaDefinition": "java.lang.String" } }, { "key": { "name": "VesEventType", "version": "0.0.1" }, "value": { "key": { "name": "VesEventType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"name\":\"event\",\n \"type\":\"record\",\n \"namespace\":\"com.acme.avro\",\n \"fields\":[\n {\n \"name\":\"commonEventHeader\",\n \"type\":{\n \"name\":\"commonEventHeader\",\n \"type\":\"record\",\n \"fields\":[\n {\n \"name\":\"domain\",\n \"type\":\"string\"\n },\n {\n \"name\":\"eventId\",\n \"type\":\"string\"\n },\n {\n \"name\":\"eventName\",\n \"type\":\"string\"\n },\n {\n \"name\":\"lastEpochMicrosec\",\n \"type\":\"long\"\n },\n {\n \"name\":\"priority\",\n \"type\":\"string\"\n },\n {\n \"name\":\"reportingEntityName\",\n \"type\":\"string\"\n },\n {\n \"name\":\"sequence\",\n \"type\":\"int\"\n },\n {\n \"name\":\"sourceId\",\n \"type\":\"string\"\n },\n {\n \"name\":\"sourceName\",\n \"type\":\"string\"\n },\n {\n \"name\":\"startEpochMicrosec\",\n \"type\":\"long\"\n },\n {\n \"name\":\"version\",\n \"type\":\"string\"\n },\n {\n \"name\":\"internalHeaderFields\",\n \"type\":{\n \"name\":\"internalHeaderFields\",\n \"type\":\"record\",\n \"fields\":[\n\n ]\n }\n },\n {\n \"name\":\"vesEventListenerVersion\",\n \"type\":\"string\"\n }\n ]\n }\n },\n {\n \"name\":\"otherFields\",\n \"type\":{\n \"name\":\"otherFields\",\n \"type\":\"record\",\n \"fields\":[\n {\n \"name\":\"hashMap\",\n \"type\":{\n \"name\":\"hashMap\",\n \"type\":\"record\",\n \"fields\":[\n {\n \"name\":\"hostname\",\n \"type\":\"string\"\n },\n {\n \"name\":\"pnfId\",\n \"type\":\"string\"\n },\n {\n \"name\":\"ip\",\n \"type\":\"string\"\n }\n ]\n }\n },\n {\n \"name\":\"otherFieldsVersion\",\n \"type\":\"string\"\n }\n ]\n }\n }\n ]\n}" } }, { "key": { "name": "VnfDetailsType", "version": "0.0.1" }, "value": { "key": { "name": "VnfDetailsType", "version": "0.0.1" }, "schemaFlavour": "Avro", "schemaDefinition": "{\n \"name\": \"GenericVnfDetailsType\",\n \"type\": \"array\",\n \"items\": {\n \"name\": \"MyClass_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"vnf_DasH_id\",\n \"type\": \"string\"\n },\n {\n \"name\": \"vnf_DasH_name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"vnf_DasH_type\",\n \"type\": \"string\"\n },\n {\n \"name\": \"service_DasH_id\",\n \"type\": \"string\"\n },\n {\n \"name\": \"prov_DasH_status\",\n \"type\": \"string\"\n },\n {\n \"name\": \"orchestration_DasH_status\",\n \"type\": \"string\"\n },\n {\n \"name\": \"in_DasH_maint\",\n \"type\": \"boolean\"\n },\n {\n \"name\": \"is_DasH_closed_DasH_loop_DasH_disabled\",\n \"type\": \"boolean\"\n },\n {\n \"name\": \"resource_DasH_version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"model_DasH_invariant_DasH_id\",\n \"type\": \"string\"\n },\n {\n \"name\": \"model_DasH_version_DasH_id\",\n \"type\": \"string\"\n },\n {\n \"name\": \"model_DasH_customization_DasH_id\",\n \"type\": \"string\"\n },\n {\n \"name\": \"relationship_DasH_list\",\n \"type\": {\n \"name\": \"relationship_DasH_list\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"relationship\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"relationship_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"related_DasH_to\",\n \"type\": \"string\"\n },\n {\n \"name\": \"relationship_DasH_label\",\n \"type\": \"string\"\n },\n {\n \"name\": \"related_DasH_link\",\n \"type\": \"string\"\n },\n {\n \"name\": \"relationship_DasH_data\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"relationship_DasH_data_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"relationship_DasH_key\",\n \"type\": \"string\"\n },\n {\n \"name\": \"relationship_DasH_value\",\n \"type\": \"string\"\n }\n ]\n }\n }\n },\n {\n \"name\": \"related_DasH_to_DasH_property\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"name\": \"related_DasH_to_DasH_property_record\",\n \"type\": \"record\",\n \"fields\": [\n {\n \"name\": \"property_DasH_key\",\n \"type\": \"string\"\n },\n {\n \"name\": \"property_DasH_value\",\n \"type\": \"string\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n}" } } ] } } } } }, "eventInputParameters": { "DCAEConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://message-router:3904/events/unauthenticated.DCAE_CL_OUTPUT/cl/apex?timeout=30000" } }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventName": "VesEvent", "eventNameFilter": "VesEvent" }, "AAISuccessResponseConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://aai:8443/aai/v14/network/pnfs/pnf?pnf-id={pnfId}", "httpMethod": "GET", "httpCodeFilter": "[2][0-1][0-9]", "httpHeaders": [ [ "Accept", "application/json" ], [ "Content-Type", "application/json" ], [ "X-FromAppId", "dcae-curl" ], [ "x-transactionId", "9998" ], [ "Authorization", "Basic QUFJOkFBSQ==" ] ] } }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventName": "AAISuccessResponseEvent", "eventNameFilter": "AAISuccessResponseEvent", "requestorMode": true, "requestorPeer": "AAIProducer1", "requestorTimeout": 2000 }, "AAIFailureResponseConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://aai:8443/aai/v14/network/pnfs/pnf?pnf-id={pnfId}", "httpMethod": "GET", "httpCodeFilter": "[4-5][0-1][0-9]", "httpHeaders": [ [ "Accept", "application/json" ], [ "Content-Type", "application/json" ], [ "X-FromAppId", "dcae-curl" ], [ "x-transactionId", "9998" ], [ "Authorization", "Basic QUFJOkFBSQ==" ] ] } }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventName": "AAIFailureResponseEvent", "eventNameFilter": "AAIFailureResponseEvent", "requestorMode": true, "requestorPeer": "AAIProducer2", "requestorTimeout": 2000 }, "CDSConfigModifySuccessResponseConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "GRPC", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventName": "CDSConfigModifySuccessResponseEvent", "eventNameFilter": "CDSConfigModifySuccessResponseEvent", "requestorMode": true, "requestorPeer": "CDSConfigModifyRequestProducer1", "requestorTimeout": 500 } }, "eventOutputParameters": { "AAIProducer1": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventNameFilter": "AAIRequestEvent", "requestorMode": true, "requestorPeer": "AAISuccessResponseConsumer", "requestorTimeout": 2000 }, "AAIProducer2": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventNameFilter": "AAIRequestEvent", "requestorMode": true, "requestorPeer": "AAIFailureResponseConsumer", "requestorTimeout": 2000 }, "CDSConfigModifyRequestProducer1": { "carrierTechnologyParameters": { "carrierTechnology": "GRPC", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters", "parameters": { "host": "cds-blueprints-processor-grpc", "port": 9111, "username": "ccsdkapps", "password": "ccsdkapps", "timeout": 60 } }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventNameFilter": "CDSConfigModifyRequestEvent", "requestorMode": true, "requestorPeer": "CDSConfigModifySuccessResponseConsumer", "requestorTimeout": 500 }, "CDSReplyProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://message-router:3904/events/POLICY-CL-MGT" } }, "eventProtocolParameters": { "eventProtocol": "JSON" }, "eventNameFilter": "LogStatusEvent" }, "logOutputter": { "carrierTechnologyParameters": { "carrierTechnology": "FILE", "parameters": { "fileName": "outputevents.log" } }, "eventProtocolParameters": { "eventProtocol": "JSON" } } } } } } ] } }
CDS
Blueprint responsible to execute the remediation action
Scripts/python/Configuration.py Expand source
#!/usr/bin/python import sys import logging import time import requests import constant from datetime import datetime import json import xml.etree.ElementTree as ET logging.getLogger().setLevel(logging.INFO) class NetConfSimulator: def process(self): """Handles the whole process of configuring the device. """ logging.info("Initial Device Configuration") self.display_configuration() logging.info("Device Details in A&AI before") response_aai = self.get_aai().json() if response_aai["pnf-name2"] != constant.HOSTNAME: logging.info("configuring Device....") response = self.modify_configuration() if self.response_validation(response): logging.info("Device Configuration Successful. New Configuration") self.display_configuration() response = self.update_aai(response_aai) if self.response_validation(response): logging.info("A&AI updated successfully. New AAI Details") self.get_aai().json() else: logging.info(response) logging.error("Problem while updating A&AI") else: logging.error("Problem while configuring Device....") logging.info(response.text) def response_validation(self, response): """ Check if the response is valid :param response- response received :return boolean true if the response is valid else false: """ response_valid = response != "" and (response.status_code == 201 or response.status_code == 200) return response_valid def display_configuration(self): """ Used to Display the device configuration. :return response - Information received from the get request: """ request_url = "http://{}:{}/restconf/config/network-topology:network-topology/topology" \ "/topology" \ "-netconf/node/{}/yang-ext:mount".format(constant.SERVER_NAME, constant.PORT_NUMBER, constant.DEVICE_NAME) logging.info(request_url) headers_data = constant.HEADERS try: response = requests.get(url=request_url, headers=headers_data) logging.info(response.text) except requests.RequestException as e: logging.error(str(e)) raise return response def modify_configuration(self): """ Used to Modify the device confifuration (edit-config). :return response - Status response received from the request: """ request_url = "http://{}:{}/restconf/config/network-topology:network-topology/topology" \ "/topology" \ "-netconf/node/{}/yang-ext:mount/{}:{}".format(constant.SERVER_NAME, constant.PORT_NUMBER, constant.DEVICE_NAME, constant.MODULE_NAME, constant.CONTAINER_NAME) tree = ET.ElementTree(ET.fromstring(constant.CONFIGURATION_BODY)) root = tree.getroot() logging.info("Device name updating device : " + constant.HOSTNAME) root[0].text = constant.HOSTNAME ET.register_namespace("", "urn:opendaylight:hostname") payload_data = ET.tostring(root).decode() headers_data = constant.HEADERS try: response = requests.put(url=request_url, headers=headers_data, data=payload_data) except requests.RequestException as e: logging.error(str(e)) raise return response def get_aai(self): """ :return: """ request_url = constant.A_AI_URL headers_data = constant.A_AI_HEADERS try: response = requests.get(url=request_url, headers=headers_data) logging.info(response.text) except requests.RequestException as e: logging.error(str(e)) raise return response def update_aai(self, aai_data): """ Used to update the inventory in A&AI with the new hostname that is being received from policy :return: """ request_url = constant.A_AI_URL headers_data = constant.A_AI_HEADERS headers_data['x-transactionId'] = str(int(headers_data['x-transactionId'])+1) payload_data = aai_data logging.info("Device name updating A&AI : " + constant.HOSTNAME) payload_data["pnf-name2"] = constant.HOSTNAME try: response = requests.put(url=request_url, headers=headers_data, data=json.dumps(payload_data)) except requests.RequestException as e: logging.error(str(e)) raise return response if __name__ == "__main__": # Assigning output variables from resource resolution to constants hostname = sys.argv[1].split(',')[0] IP = sys.argv[1].split(',')[1] # current date and time millis = int(round(time.time() * 1000)) constant.HOSTNAME = hostname + "-" + str(millis) constant.SERVER_NAME = IP # netconf instance netconf = NetConfSimulator() netconf.process() sys.exit(0)