diff options
Diffstat (limited to 'policy')
-rw-r--r-- | policy/apex/EventsIn.json.txt | 42 | ||||
-rw-r--r-- | policy/apex/NomadicONTContextType.avsc | 112 | ||||
-rw-r--r-- | policy/apex/NomadicONTPolicyModel.apex | 266 | ||||
-rw-r--r-- | policy/apex/NomadicONTPolicyModel_config.json | 103 | ||||
-rw-r--r-- | policy/apex/NomadicONTToscaPolicy.json | 2551 | ||||
-rw-r--r-- | policy/apex/ToscaTemplate.json | 16 | ||||
-rw-r--r-- | policy/apex/config/config.txt | 8 | ||||
-rw-r--r-- | policy/apex/logic/AAIServiceAssignedTask.js | 260 | ||||
-rw-r--r-- | policy/apex/logic/AAIServiceCreateTask.js | 116 | ||||
-rw-r--r-- | policy/apex/logic/ErrorAAIServiceAssignedLogTask.js | 29 | ||||
-rw-r--r-- | policy/apex/logic/ErrorSdncResourceUpdateTaskLogTask.js | 27 | ||||
-rw-r--r-- | policy/apex/logic/GetBBSCloseLoopEventTask.js | 113 | ||||
-rw-r--r-- | policy/apex/logic/NomadicEventSuccessTask.js | 47 | ||||
-rw-r--r-- | policy/apex/logic/RUorInitStateSelect.js | 44 | ||||
-rw-r--r-- | policy/apex/logic/SU2orInitStateSelect.js | 46 | ||||
-rw-r--r-- | policy/apex/logic/SdncResourceUpdateTask.js | 470 | ||||
-rw-r--r-- | policy/apex/logic/ServiceUpdateStateCpeAuthTask.js | 118 |
17 files changed, 4368 insertions, 0 deletions
diff --git a/policy/apex/EventsIn.json.txt b/policy/apex/EventsIn.json.txt new file mode 100644 index 0000000..75973e9 --- /dev/null +++ b/policy/apex/EventsIn.json.txt @@ -0,0 +1,42 @@ +{ + "closedLoopEventClient":"DCAE.BBS_event_processor_mSInstance", + "policyVersion":"1.0.0.5", + "policyName":"Nomadic_ONT", + "policyScope":"reRegPolicyScope", + "target_type":"VM", + "AAI":{ + "attachmentPoint":"olt11-1-1", + "service-information.hsia-cfs-service-instance-id":"1923eaa8-8ab7-49ef-b4c2-e185efbbe832", + "cvlan":"1005", + "svlan":"100", + "remoteId":"some-remote-id" + }, + "closedLoopAlarmStart":1553067455, + "closedLoopEventStatus":"ONSET", + "closedLoopControlName":"reRegControlName", + "version":"1.0.2", + "target":"vserver.vserver-name", + "requestID":"407a6515-4b10-46ad-a249-efe529a36c69", + "from":"DCAE" +} +{ + "closedLoopEventClient":"DCAE.BBS_event_processor_mSInstance", + "policyVersion":"1.0.0.5", + "policyName":"CPE_Authentication", + "policyScope":"reRegPolicyScope", + "target_type":"VM", + "AAI":{ + "attachmentPoint":"olt11-1-1", + "service-information.hsia-cfs-service-instance-id":"1923eaa8-8ab7-49ef-b4c2-e185efbbe832", + "cvlan":"1005", + "svlan":"100", + "remoteId":"some-remote-id" + }, + "closedLoopAlarmStart":1553067455, + "closedLoopEventStatus":"ONSET", + "closedLoopControlName":"reRegControlName", + "version":"1.0.2", + "target":"vserver.vserver-name", + "requestID":"407a6515-4b10-46ad-a249-efe529a36c69", + "from":"DCAE" +}
\ No newline at end of file diff --git a/policy/apex/NomadicONTContextType.avsc b/policy/apex/NomadicONTContextType.avsc new file mode 100644 index 0000000..2eaeb71 --- /dev/null +++ b/policy/apex/NomadicONTContextType.avsc @@ -0,0 +1,112 @@ +{ + "type": "record", + "name": "NomadicONTContext", + "fields": [ + { + "name": "AAI", + "type": { + "type": "record", + "name": "VCPE_AAI_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "attachmentPoint", + "type": "string" + }, + { + "name": "service_information_hsia_cfs_service_instance_id", + "type": "string" + }, + { + "name": "cvlan", + "type": "string" + }, + { + "name": "svlan", + "type": "string" + }, + { + "name": "remoteId", + "type": "string" + } + ] + } + }, + { + "name": "closedLoopAlarmStart", + "type": "long" + }, + { + "name": "closedLoopAlarmEnd", + "type": "long" + }, + { + "name": "closedLoopControlName", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "requestID", + "type": "string" + }, + { + "name": "closedLoopEventClient", + "type": "string" + }, + { + "name": "closedLoopEventStatus", + "type": "string" + }, + { + "name": "target_type", + "type": "string" + }, + { + "name": "target", + "type": "string" + }, + { + "name": "from", + "type": "string" + }, + { + "name": "policyScope", + "type": "string" + }, + { + "name": "policyName", + "type": "string" + }, + { + "name": "policyVersion", + "type": "string" + }, + { + "name": "notification", + "type": "string" + }, + { + "name": "notificationTime", + "type": "long" + }, + { + "name": "result", + "type": "string" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "url", + "type": "string" + }, + { + "name": "aai_message", + "type": "string" + } + ] +}
\ No newline at end of file diff --git a/policy/apex/NomadicONTPolicyModel.apex b/policy/apex/NomadicONTPolicyModel.apex new file mode 100644 index 0000000..1166f5a --- /dev/null +++ b/policy/apex/NomadicONTPolicyModel.apex @@ -0,0 +1,266 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2019 Huawei. 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +#------------------------------------------------------------------------------- + +#========> create Policy model +model create name=NomadicONTPolicyModel version=1.0.2 + + +#========> Define Schema and Data types +schema create name=SimpleStringType flavour=Java schema=java.lang.String +schema create name=SimpleLongType flavour=Java schema=java.lang.Long +schema create name=SimpleBooleanType flavour=Java schema=java.lang.Boolean +schema create name=UUIDType flavour=Java schema=java.util.UUID + +schema create name=VirtualControlLoopEventType flavour=Java schema=org.onap.policy.controlloop.VirtualControlLoopEvent + +schema create name=NomadicONTContextType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/NomadicONTContextType.avsc" +LE + +#=======================> Create Albums +album create name=NomadicONTContextAlbum scope=policy writable=true schemaName=NomadicONTContextType + + +#===================================> Define Events +#=============>Nomadic ONT +event create name=Nomadic_ONT version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=DCAE target=APEX +event parameter create name=Nomadic_ONT parName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType + +event create name=AAI_SERVICE_ASSIGNED version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=APEX target=APEX +event parameter create name=AAI_SERVICE_ASSIGNED parName=requestID schemaName=UUIDType +event parameter create name=AAI_SERVICE_ASSIGNED parName=attachmentPoint schemaName=SimpleStringType +event parameter create name=AAI_SERVICE_ASSIGNED parName=serviceInstanceId schemaName=SimpleStringType optional=true + +event create name=SDNC_RESOURCE_UPDATE version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=APEX target=APEX +event parameter create name=SDNC_RESOURCE_UPDATE parName=result schemaName=SimpleStringType +event parameter create name=SDNC_RESOURCE_UPDATE parName=requestID schemaName=UUIDType +event parameter create name=SDNC_RESOURCE_UPDATE parName=attachmentPoint schemaName=SimpleStringType +event parameter create name=SDNC_RESOURCE_UPDATE parName=serviceInstanceId schemaName=SimpleStringType optional=true + +event create name=AAI_SERVICE_CREATE version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=APEX target=APEX +event parameter create name=AAI_SERVICE_CREATE parName=result schemaName=SimpleStringType +event parameter create name=AAI_SERVICE_CREATE parName=requestID schemaName=UUIDType +event parameter create name=AAI_SERVICE_CREATE parName=attachmentPoint schemaName=SimpleStringType +event parameter create name=AAI_SERVICE_CREATE parName=serviceInstanceId schemaName=SimpleStringType optional=true + +event create name=ERROR_LOG version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=APEX target=APEX +event parameter create name=ERROR_LOG parName=errorLogParam schemaName=SimpleStringType + +event create name=END_CONTROL_LOOP version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=APEX target=APEX +event parameter create name=END_CONTROL_LOOP parName=result schemaName=SimpleStringType +event parameter create name=END_CONTROL_LOOP parName=requestID schemaName=UUIDType +event parameter create name=END_CONTROL_LOOP parName=attachmentPoint schemaName=SimpleStringType +event parameter create name=END_CONTROL_LOOP parName=serviceInstanceId schemaName=SimpleStringType optional=true + + +event create name=END_EVENT version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=APEX target=DCAE +event parameter create name=END_EVENT parName=result schemaName=SimpleStringType optional=true +event parameter create name=END_EVENT parName=requestID schemaName=UUIDType +event parameter create name=END_EVENT parName=attachmentPoint schemaName=SimpleStringType +event parameter create name=END_EVENT parName=serviceInstanceId schemaName=SimpleStringType optional=true + +#=============>CPE Authentication +event create name=CPE_Authentication version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=DCAE target=APEX +event parameter create name=CPE_Authentication parName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType + +event create name=AAI_CPE_AUTH_UPDATE version=1.0.2 nameSpace=org.onap.policy.apex.onap.bbs source=APEX target=DCAE +event parameter create name=AAI_CPE_AUTH_UPDATE parName=result schemaName=SimpleStringType +event parameter create name=AAI_CPE_AUTH_UPDATE parName=requestID schemaName=UUIDType +event parameter create name=AAI_CPE_AUTH_UPDATE parName=attachmentPoint schemaName=SimpleStringType +event parameter create name=AAI_CPE_AUTH_UPDATE parName=serviceInstanceId schemaName=SimpleStringType optional=true + + +#========> Define Tasks (1) +task create name=GetBBSCloseLoopEventTask + +task inputfield create name=GetBBSCloseLoopEventTask fieldName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType +task outputfield create name=GetBBSCloseLoopEventTask fieldName=requestID schemaName=UUIDType +task outputfield create name=GetBBSCloseLoopEventTask fieldName=attachmentPoint schemaName=SimpleStringType +task outputfield create name=GetBBSCloseLoopEventTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task contextref create name=GetBBSCloseLoopEventTask albumName=NomadicONTContextAlbum + +task logic create name=GetBBSCloseLoopEventTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/GetBBSCloseLoopEventTask.js" +LE + +#========> Define Tasks (2) +task create name=AAIServiceAssignedTask +task inputfield create name=AAIServiceAssignedTask fieldName=requestID schemaName=UUIDType +task inputfield create name=AAIServiceAssignedTask fieldName=attachmentPoint schemaName=SimpleStringType +task inputfield create name=AAIServiceAssignedTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=AAIServiceAssignedTask fieldName=requestID schemaName=UUIDType +task outputfield create name=AAIServiceAssignedTask fieldName=attachmentPoint schemaName=SimpleStringType +task outputfield create name=AAIServiceAssignedTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=AAIServiceAssignedTask fieldName=result schemaName=SimpleStringType + +task contextref create name=AAIServiceAssignedTask albumName=NomadicONTContextAlbum + +task logic create name=AAIServiceAssignedTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/AAIServiceAssignedTask.js" +LE + +#========> Define Tasks (3) +task create name=ErrorAAIServiceAssignedLogTask +task inputfield create name=ErrorAAIServiceAssignedLogTask fieldName=result schemaName=SimpleStringType +task inputfield create name=ErrorAAIServiceAssignedLogTask fieldName=requestID schemaName=UUIDType +task inputfield create name=ErrorAAIServiceAssignedLogTask fieldName=attachmentPoint schemaName=SimpleStringType +task inputfield create name=ErrorAAIServiceAssignedLogTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=ErrorAAIServiceAssignedLogTask fieldName=errorLogParam schemaName=SimpleStringType + +task logic create name=ErrorAAIServiceAssignedLogTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/ErrorAAIServiceAssignedLogTask.js" +LE + +#========> Define Tasks (4) +task create name=SdncResourceUpdateTask +task inputfield create name=SdncResourceUpdateTask fieldName=requestID schemaName=UUIDType +task inputfield create name=SdncResourceUpdateTask fieldName=attachmentPoint schemaName=SimpleStringType +task inputfield create name=SdncResourceUpdateTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=SdncResourceUpdateTask fieldName=requestID schemaName=UUIDType +task outputfield create name=SdncResourceUpdateTask fieldName=attachmentPoint schemaName=SimpleStringType +task outputfield create name=SdncResourceUpdateTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=SdncResourceUpdateTask fieldName=result schemaName=SimpleStringType +task contextref create name=SdncResourceUpdateTask albumName=NomadicONTContextAlbum + +task logic create name=SdncResourceUpdateTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/SdncResourceUpdateTask.js" +LE + +#========> Define Tasks (5) +task create name=ErrorSdncResourceUpdateTaskLogTask +task inputfield create name=ErrorSdncResourceUpdateTaskLogTask fieldName=result schemaName=SimpleStringType +task inputfield create name=ErrorSdncResourceUpdateTaskLogTask fieldName=requestID schemaName=UUIDType +task inputfield create name=ErrorSdncResourceUpdateTaskLogTask fieldName=attachmentPoint schemaName=SimpleStringType +task inputfield create name=ErrorSdncResourceUpdateTaskLogTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=ErrorSdncResourceUpdateTaskLogTask fieldName=errorLogParam schemaName=SimpleStringType + +task logic create name=ErrorSdncResourceUpdateTaskLogTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/ErrorSdncResourceUpdateTaskLogTask.js" +LE + +#========> Define Tasks (6) +task create name=AAIServiceCreateTask +task inputfield create name=AAIServiceCreateTask fieldName=requestID schemaName=UUIDType +task inputfield create name=AAIServiceCreateTask fieldName=attachmentPoint schemaName=SimpleStringType +task inputfield create name=AAIServiceCreateTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=AAIServiceCreateTask fieldName=requestID schemaName=UUIDType +task outputfield create name=AAIServiceCreateTask fieldName=attachmentPoint schemaName=SimpleStringType +task outputfield create name=AAIServiceCreateTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=AAIServiceCreateTask fieldName=result schemaName=SimpleStringType +task contextref create name=AAIServiceCreateTask albumName=NomadicONTContextAlbum + +task logic create name=AAIServiceCreateTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/AAIServiceCreateTask.js" +LE + +#========> Define Tasks (7) +task create name=NomadicEventSuccessTask +task inputfield create name=NomadicEventSuccessTask fieldName=requestID schemaName=UUIDType +task inputfield create name=NomadicEventSuccessTask fieldName=attachmentPoint schemaName=SimpleStringType +task inputfield create name=NomadicEventSuccessTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task outputfield create name=NomadicEventSuccessTask fieldName=result schemaName=SimpleStringType optional=true +task contextref create name=NomadicEventSuccessTask albumName=NomadicONTContextAlbum + +task logic create name=NomadicEventSuccessTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/NomadicEventSuccessTask.js" +LE + + + +#========> Define Tasks (8) +task create name=ServiceUpdateStateCpeAuthTask +task inputfield create name=ServiceUpdateStateCpeAuthTask fieldName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType +task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=result schemaName=SimpleStringType +task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=requestID schemaName=UUIDType +task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=attachmentPoint schemaName=SimpleStringType +task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true +task contextref create name=ServiceUpdateStateCpeAuthTask albumName=NomadicONTContextAlbum + +task logic create name=ServiceUpdateStateCpeAuthTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js" +LE + +#========> Create Policy (1) +policy create name=ONTRegistrationPolicy template=Freestyle firstState=INIT + +policy state create name=ONTRegistrationPolicy stateName=NOMADIC_ONT_REG_SUCCESS triggerName=END_CONTROL_LOOP defaultTaskName=NomadicEventSuccessTask +policy state output create name=ONTRegistrationPolicy stateName=NOMADIC_ONT_REG_SUCCESS outputName=NomadicEventSuccessOutPut eventName=END_EVENT +policy state taskref create name=ONTRegistrationPolicy stateName=NOMADIC_ONT_REG_SUCCESS taskName=NomadicEventSuccessTask outputType=DIRECT outputName=NomadicEventSuccessOutPut + +#========> Create State (1.4) +policy state create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE triggerName=AAI_SERVICE_CREATE defaultTaskName=AAIServiceCreateTask + +policy state output create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE outputName=AAIServiceCreateTaskOutput eventName=END_CONTROL_LOOP nextState=NOMADIC_ONT_REG_SUCCESS +policy state taskref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE taskName=AAIServiceCreateTask outputType=DIRECT outputName=AAIServiceCreateTaskOutput + +policy state output create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE outputName=SdncResourceUpdateErrorLogOutput eventName=ERROR_LOG +policy state taskref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE taskName=ErrorSdncResourceUpdateTaskLogTask outputType=DIRECT outputName=SdncResourceUpdateErrorLogOutput + +policy state contextref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE albumName=NomadicONTContextAlbum + +policy state selecttasklogic create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/SU2orInitStateSelect.js" +LE + + +#========> Create State (1.3) +policy state create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE triggerName=SDNC_RESOURCE_UPDATE defaultTaskName=SdncResourceUpdateTask + +policy state output create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE outputName=SdncResourceUpdateOutput eventName=AAI_SERVICE_CREATE nextState=AAI_SERVICE_CREATE +policy state taskref create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE taskName=SdncResourceUpdateTask outputType=DIRECT outputName=SdncResourceUpdateOutput + +policy state output create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE outputName=AAIServiceAssignedErrorLogOutput eventName=ERROR_LOG +policy state taskref create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE taskName=ErrorAAIServiceAssignedLogTask outputType=DIRECT outputName=AAIServiceAssignedErrorLogOutput + +policy state contextref create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE albumName=NomadicONTContextAlbum + +policy state selecttasklogic create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/RUorInitStateSelect.js" +LE + + + +#========> Create State (1.2) +policy state create name=ONTRegistrationPolicy stateName=AAI_SERVICE_ASSIGN triggerName=AAI_SERVICE_ASSIGNED defaultTaskName=AAIServiceAssignedTask + +policy state output create name=ONTRegistrationPolicy stateName=AAI_SERVICE_ASSIGN outputName=AAIServiceAssignedOutput eventName=SDNC_RESOURCE_UPDATE nextState=SDNC_RES_UPDATE +policy state taskref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_ASSIGN taskName=AAIServiceAssignedTask outputType=DIRECT outputName=AAIServiceAssignedOutput + + + + + +#========> Create State (1.1) +policy state create name=ONTRegistrationPolicy stateName=INIT triggerName=Nomadic_ONT defaultTaskName=GetBBSCloseLoopEventTask +policy state output create name=ONTRegistrationPolicy stateName=INIT outputName=BBSCloseLoopEventOutPut eventName=AAI_SERVICE_ASSIGNED nextState=AAI_SERVICE_ASSIGN +policy state taskref create name=ONTRegistrationPolicy stateName=INIT taskName=GetBBSCloseLoopEventTask outputType=DIRECT outputName=BBSCloseLoopEventOutPut + + + +#========> Create Policy (2) +policy create name=CPEAuthenticationPolicy template=Freestyle firstState=INIT + + +#========> Create State (2.1) +policy state create name=CPEAuthenticationPolicy stateName=INIT triggerName=CPE_Authentication defaultTaskName=ServiceUpdateStateCpeAuthTask +policy state output create name=CPEAuthenticationPolicy stateName=INIT outputName=ServiceUpdateCpeAuthOutPut eventName=AAI_CPE_AUTH_UPDATE +policy state taskref create name=CPEAuthenticationPolicy stateName=INIT taskName=ServiceUpdateStateCpeAuthTask outputType=DIRECT outputName=ServiceUpdateCpeAuthOutPut + +validate diff --git a/policy/apex/NomadicONTPolicyModel_config.json b/policy/apex/NomadicONTPolicyModel_config.json new file mode 100644 index 0000000..83fdbc8 --- /dev/null +++ b/policy/apex/NomadicONTPolicyModel_config.json @@ -0,0 +1,103 @@ +{ + "engineServiceParameters": { + "name": "NomadicONTPolicyModelEngine", + "version": "0.0.1", + "id": 101, + "instanceCount": 4, + "deploymentPort": 12345, + "engineParameters": { + "executorParameters": { + "MVEL": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" + }, + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "taskParameters": [ + { + "key": "AAI_URL", + "value": "aai:8443" + }, + { + "key": "AAI_USERNAME", + "value": "AAI" + }, + { + "key": "AAI_PASSWORD", + "value": "AAI" + }, + { + "key": "AAI_VERSION", + "value": "v16" + }, + { + "key": "SDNC_URL", + "value": "sdnc:8443" + }, + { + "key": "SDNC_USERNAME", + "value": "admin" + }, + { + "key": "SDNC_PASSWORD", + "value": "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" + }, + { + "key": "SVC_NOTIFICATION_URL", + "value": "http://c1.vm1.mso.simpledemo.openecomp.org:8080" + } + ], + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java": { + "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters": { + "Instant": { + "adaptedClass": "java.time.Instant", + "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + } + } + } + } + } + } + }, + "eventOutputParameters": { + "FirstProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "standardIo": true + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + }, + "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/g1/c1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "nameAlias": "policyName", + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopEvent" + } + } + } + } +} diff --git a/policy/apex/NomadicONTToscaPolicy.json b/policy/apex/NomadicONTToscaPolicy.json new file mode 100644 index 0000000..e97509b --- /dev/null +++ b/policy/apex/NomadicONTToscaPolicy.json @@ -0,0 +1,2551 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "topology_template": { + "policies": [ + { + "operational.onapbbs": { + "type": "onap.policies.controlloop.operational.Apex", + "type_version": "1.0.0", + "name": "operational.onapbbs", + "version": "1.0.0", + "properties": { + "engineServiceParameters": { + "name": "NomadicONTPolicyModelEngine", + "version": "0.0.1", + "id": 101, + "instanceCount": 4, + "deploymentPort": 12345, + "engineParameters": { + "executorParameters": { + "MVEL": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" + }, + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "taskParameters": [ + { + "key": "AAI_URL", + "value": "aai:8443" + }, + { + "key": "AAI_USERNAME", + "value": "AAI" + }, + { + "key": "AAI_PASSWORD", + "value": "AAI" + }, + { + "key": "AAI_VERSION", + "value": "v16" + }, + { + "key": "SDNC_URL", + "value": "sdnc:8443" + }, + { + "key": "SDNC_USERNAME", + "value": "admin" + }, + { + "key": "SDNC_PASSWORD", + "value": "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" + }, + { + "key": "SVC_NOTIFICATION_URL", + "value": "http://c1.vm1.mso.simpledemo.openecomp.org:8080" + } + ], + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java": { + "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters": { + "Instant": { + "adaptedClass": "java.time.Instant", + "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + } + } + } + } + } + }, + "policy_type_impl": { + "apexPolicyModel": { + "key": { + "name": "NomadicONTPolicyModel", + "version": "1.0.2" + }, + "keyInformation": { + "key": { + "name": "NomadicONTPolicyModel_KeyInfo", + "version": "1.0.2" + }, + "keyInfoMap": { + "entry": [ + { + "key": { + "name": "AAIServiceAssignedTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "AAIServiceAssignedTask", + "version": "0.0.1" + }, + "UUID": "2af956bf-4c3f-370b-8112-44d7eca870a7", + "description": "Generated description for concept referred to by key \"AAIServiceAssignedTask:0.0.1\"" + } + }, + { + "key": { + "name": "AAIServiceCreateTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "AAIServiceCreateTask", + "version": "0.0.1" + }, + "UUID": "e1fcaf11-adce-3d40-90e2-9b74d523b7ba", + "description": "Generated description for concept referred to by key \"AAIServiceCreateTask:0.0.1\"" + } + }, + { + "key": { + "name": "AAI_CPE_AUTH_UPDATE", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "AAI_CPE_AUTH_UPDATE", + "version": "1.0.2" + }, + "UUID": "d9543444-f74f-31e8-a782-0d93dea34f26", + "description": "Generated description for concept referred to by key \"AAI_CPE_AUTH_UPDATE:1.0.2\"" + } + }, + { + "key": { + "name": "AAI_SERVICE_ASSIGNED", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "AAI_SERVICE_ASSIGNED", + "version": "1.0.2" + }, + "UUID": "4720575a-89a3-39d0-9554-24bdb8b21f56", + "description": "Generated description for concept referred to by key \"AAI_SERVICE_ASSIGNED:1.0.2\"" + } + }, + { + "key": { + "name": "AAI_SERVICE_CREATE", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "AAI_SERVICE_CREATE", + "version": "1.0.2" + }, + "UUID": "1f18fd72-307e-3c25-940c-69fed411649b", + "description": "Generated description for concept referred to by key \"AAI_SERVICE_CREATE:1.0.2\"" + } + }, + { + "key": { + "name": "CPEAuthenticationPolicy", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "CPEAuthenticationPolicy", + "version": "0.0.1" + }, + "UUID": "f8c31efd-6755-3bd8-8720-b622e7e61a4d", + "description": "Generated description for concept referred to by key \"CPEAuthenticationPolicy:0.0.1\"" + } + }, + { + "key": { + "name": "CPE_Authentication", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "CPE_Authentication", + "version": "1.0.2" + }, + "UUID": "7fe1283a-ff26-3fdc-9856-bcebd2f7b3d2", + "description": "Generated description for concept referred to by key \"CPE_Authentication:1.0.2\"" + } + }, + { + "key": { + "name": "END_CONTROL_LOOP", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "END_CONTROL_LOOP", + "version": "1.0.2" + }, + "UUID": "a666ac83-2ae2-3769-8a25-ce1630b04efa", + "description": "Generated description for concept referred to by key \"END_CONTROL_LOOP:1.0.2\"" + } + }, + { + "key": { + "name": "END_EVENT", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "END_EVENT", + "version": "1.0.2" + }, + "UUID": "c50ae42d-d12f-3fde-8714-fe751b2f2a4e", + "description": "Generated description for concept referred to by key \"END_EVENT:1.0.2\"" + } + }, + { + "key": { + "name": "ERROR_LOG", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "ERROR_LOG", + "version": "1.0.2" + }, + "UUID": "cee4b299-3851-3779-aa1a-60b90dd95ee4", + "description": "Generated description for concept referred to by key \"ERROR_LOG:1.0.2\"" + } + }, + { + "key": { + "name": "ErrorAAIServiceAssignedLogTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "ErrorAAIServiceAssignedLogTask", + "version": "0.0.1" + }, + "UUID": "4b5311bb-b3e8-31f6-9ea1-0fd026d739d7", + "description": "Generated description for concept referred to by key \"ErrorAAIServiceAssignedLogTask:0.0.1\"" + } + }, + { + "key": { + "name": "ErrorSdncResourceUpdateTaskLogTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "ErrorSdncResourceUpdateTaskLogTask", + "version": "0.0.1" + }, + "UUID": "daa86721-a761-334f-96bf-6f5c781f65ed", + "description": "Generated description for concept referred to by key \"ErrorSdncResourceUpdateTaskLogTask:0.0.1\"" + } + }, + { + "key": { + "name": "GetBBSCloseLoopEventTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "GetBBSCloseLoopEventTask", + "version": "0.0.1" + }, + "UUID": "0791e26f-5d94-3cee-991c-31f226e83c4e", + "description": "Generated description for concept referred to by key \"GetBBSCloseLoopEventTask:0.0.1\"" + } + }, + { + "key": { + "name": "NomadicEventSuccessTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "NomadicEventSuccessTask", + "version": "0.0.1" + }, + "UUID": "6fe3e6f7-a429-3979-9146-db0fa239591b", + "description": "Generated description for concept referred to by key \"NomadicEventSuccessTask:0.0.1\"" + } + }, + { + "key": { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + }, + "UUID": "3d9cf947-a5ef-3781-8c70-ec0e94f65693", + "description": "Generated description for concept referred to by key \"NomadicONTContextAlbum:0.0.1\"" + } + }, + { + "key": { + "name": "NomadicONTContextType", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "NomadicONTContextType", + "version": "0.0.1" + }, + "UUID": "b9508c97-79b6-35ec-8e45-731eac9d37cc", + "description": "Generated description for concept referred to by key \"NomadicONTContextType:0.0.1\"" + } + }, + { + "key": { + "name": "NomadicONTPolicyModel", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "NomadicONTPolicyModel", + "version": "1.0.2" + }, + "UUID": "457e3fcf-a901-37b2-bfc0-14d56abfc507", + "description": "Generated description for concept referred to by key \"NomadicONTPolicyModel:1.0.2\"" + } + }, + { + "key": { + "name": "NomadicONTPolicyModel_Albums", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "NomadicONTPolicyModel_Albums", + "version": "1.0.2" + }, + "UUID": "9a0edd63-7d9b-3122-8750-d6a17c248f0f", + "description": "Generated description for concept referred to by key \"NomadicONTPolicyModel_Albums:1.0.2\"" + } + }, + { + "key": { + "name": "NomadicONTPolicyModel_Events", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "NomadicONTPolicyModel_Events", + "version": "1.0.2" + }, + "UUID": "82ff2635-a05e-3b3e-ae59-526735db78fc", + "description": "Generated description for concept referred to by key \"NomadicONTPolicyModel_Events:1.0.2\"" + } + }, + { + "key": { + "name": "NomadicONTPolicyModel_KeyInfo", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "NomadicONTPolicyModel_KeyInfo", + "version": "1.0.2" + }, + "UUID": "530bcf35-a3cb-305a-8b41-0499945b510f", + "description": "Generated description for concept referred to by key \"NomadicONTPolicyModel_KeyInfo:1.0.2\"" + } + }, + { + "key": { + "name": "NomadicONTPolicyModel_Policies", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "NomadicONTPolicyModel_Policies", + "version": "1.0.2" + }, + "UUID": "9223db37-fb3b-3b3f-a85b-eb7e7b3a4e10", + "description": "Generated description for concept referred to by key \"NomadicONTPolicyModel_Policies:1.0.2\"" + } + }, + { + "key": { + "name": "NomadicONTPolicyModel_Schemas", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "NomadicONTPolicyModel_Schemas", + "version": "1.0.2" + }, + "UUID": "41ba496f-6bfb-31e7-972e-6b2fab3e7d52", + "description": "Generated description for concept referred to by key \"NomadicONTPolicyModel_Schemas:1.0.2\"" + } + }, + { + "key": { + "name": "NomadicONTPolicyModel_Tasks", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "NomadicONTPolicyModel_Tasks", + "version": "1.0.2" + }, + "UUID": "c337fda0-0a48-3329-af48-ed710214c092", + "description": "Generated description for concept referred to by key \"NomadicONTPolicyModel_Tasks:1.0.2\"" + } + }, + { + "key": { + "name": "Nomadic_ONT", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "Nomadic_ONT", + "version": "1.0.2" + }, + "UUID": "b375c6f5-19ca-390f-ba19-2a0a49f233af", + "description": "Generated description for concept referred to by key \"Nomadic_ONT:1.0.2\"" + } + }, + { + "key": { + "name": "ONTRegistrationPolicy", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "ONTRegistrationPolicy", + "version": "0.0.1" + }, + "UUID": "45773f7e-e1f6-3286-8f82-144836629edb", + "description": "Generated description for concept referred to by key \"ONTRegistrationPolicy:0.0.1\"" + } + }, + { + "key": { + "name": "SDNC_RESOURCE_UPDATE", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "SDNC_RESOURCE_UPDATE", + "version": "1.0.2" + }, + "UUID": "445af002-8069-37ce-b8c1-49cc1422e279", + "description": "Generated description for concept referred to by key \"SDNC_RESOURCE_UPDATE:1.0.2\"" + } + }, + { + "key": { + "name": "SdncResourceUpdateTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "SdncResourceUpdateTask", + "version": "0.0.1" + }, + "UUID": "db7d3e67-12a8-35c8-b063-bc2a1fd77662", + "description": "Generated description for concept referred to by key \"SdncResourceUpdateTask:0.0.1\"" + } + }, + { + "key": { + "name": "ServiceUpdateStateCpeAuthTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "ServiceUpdateStateCpeAuthTask", + "version": "0.0.1" + }, + "UUID": "78fa10b8-23e9-3362-893a-0dd7a656c7b6", + "description": "Generated description for concept referred to by key \"ServiceUpdateStateCpeAuthTask: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": "UUIDType", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "UUIDType", + "version": "0.0.1" + }, + "UUID": "6a8cc68e-dfc8-3403-9c6d-071c886b319c", + "description": "Generated description for concept referred to by key \"UUIDType:0.0.1\"" + } + }, + { + "key": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "UUID": "15aca887-8f6c-3713-8114-0f49f03adab7", + "description": "Generated description for concept referred to by key \"VirtualControlLoopEventType:0.0.1\"" + } + } + ] + } + }, + "policies": { + "key": { + "name": "NomadicONTPolicyModel_Policies", + "version": "1.0.2" + }, + "policyMap": { + "entry": [ + { + "key": { + "name": "CPEAuthenticationPolicy", + "version": "0.0.1" + }, + "value": { + "policyKey": { + "name": "CPEAuthenticationPolicy", + "version": "0.0.1" + }, + "template": "Freestyle", + "state": { + "entry": [ + { + "key": "INIT", + "value": { + "stateKey": { + "parentKeyName": "CPEAuthenticationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "INIT" + }, + "trigger": { + "name": "CPE_Authentication", + "version": "1.0.2" + }, + "stateOutputs": { + "entry": [ + { + "key": "ServiceUpdateCpeAuthOutPut", + "value": { + "key": { + "parentKeyName": "CPEAuthenticationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "INIT", + "localName": "ServiceUpdateCpeAuthOutPut" + }, + "outgoingEvent": { + "name": "AAI_CPE_AUTH_UPDATE", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "NULL", + "parentKeyVersion": "0.0.0", + "parentLocalName": "NULL", + "localName": "NULL" + } + } + } + ] + }, + "contextAlbumReference": [], + "taskSelectionLogic": { + "key": "NULL", + "logicFlavour": "UNDEFINED", + "logic": "" + }, + "stateFinalizerLogicMap": { + "entry": [] + }, + "defaultTask": { + "name": "ServiceUpdateStateCpeAuthTask", + "version": "0.0.1" + }, + "taskReferences": { + "entry": [ + { + "key": { + "name": "ServiceUpdateStateCpeAuthTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "CPEAuthenticationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "INIT", + "localName": "CPEAuthenticationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "CPEAuthenticationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "INIT", + "localName": "ServiceUpdateCpeAuthOutPut" + } + } + } + ] + } + } + } + ] + }, + "firstState": "INIT" + } + }, + { + "key": { + "name": "ONTRegistrationPolicy", + "version": "0.0.1" + }, + "value": { + "policyKey": { + "name": "ONTRegistrationPolicy", + "version": "0.0.1" + }, + "template": "Freestyle", + "state": { + "entry": [ + { + "key": "AAI_SERVICE_ASSIGN", + "value": { + "stateKey": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "AAI_SERVICE_ASSIGN" + }, + "trigger": { + "name": "AAI_SERVICE_ASSIGNED", + "version": "1.0.2" + }, + "stateOutputs": { + "entry": [ + { + "key": "AAIServiceAssignedOutput", + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_ASSIGN", + "localName": "AAIServiceAssignedOutput" + }, + "outgoingEvent": { + "name": "SDNC_RESOURCE_UPDATE", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "SDNC_RES_UPDATE" + } + } + } + ] + }, + "contextAlbumReference": [], + "taskSelectionLogic": { + "key": "NULL", + "logicFlavour": "UNDEFINED", + "logic": "" + }, + "stateFinalizerLogicMap": { + "entry": [] + }, + "defaultTask": { + "name": "AAIServiceAssignedTask", + "version": "0.0.1" + }, + "taskReferences": { + "entry": [ + { + "key": { + "name": "AAIServiceAssignedTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_ASSIGN", + "localName": "ONTRegistrationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_ASSIGN", + "localName": "AAIServiceAssignedOutput" + } + } + } + ] + } + } + }, + { + "key": "AAI_SERVICE_CREATE", + "value": { + "stateKey": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "AAI_SERVICE_CREATE" + }, + "trigger": { + "name": "AAI_SERVICE_CREATE", + "version": "1.0.2" + }, + "stateOutputs": { + "entry": [ + { + "key": "AAIServiceCreateTaskOutput", + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_CREATE", + "localName": "AAIServiceCreateTaskOutput" + }, + "outgoingEvent": { + "name": "END_CONTROL_LOOP", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "NOMADIC_ONT_REG_SUCCESS" + } + } + }, + { + "key": "SdncResourceUpdateErrorLogOutput", + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_CREATE", + "localName": "SdncResourceUpdateErrorLogOutput" + }, + "outgoingEvent": { + "name": "ERROR_LOG", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "NULL", + "parentKeyVersion": "0.0.0", + "parentLocalName": "NULL", + "localName": "NULL" + } + } + } + ] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskSelectionLogic": { + "key": "TaskSelectionLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nexecutor.logger.info(\"Begin Execution SU2orInitStateSelect.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar result = null;\n\nvar attachmentPoint = executor.inFields.get(\"attachmentPoint\");\nvar NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").get(\n attachmentPoint);\n\nexecutor.logger.info(executor.inFields);\n\nresult = NomadicONTContext.get(\"result\");\n\nif (result == \"SUCCESS\") {\n executor.subject.getTaskKey(\"AAIServiceCreateTask\").copyTo(executor.selectedTask);\n} else {\n executor.subject.getTaskKey(\"SdncResourceUpdateErrorLogOutput\").copyTo(\n executor.selectedTask);\n onsetFlag = executor.isFalse;\n}\n\nexecutor.logger.info(\"State Selected Task:\" + executor.selectedTask);\nexecutor.logger.info(\"End Execution SU2orInitStateSelect.js\");\n\ntrue;" + }, + "stateFinalizerLogicMap": { + "entry": [] + }, + "defaultTask": { + "name": "AAIServiceCreateTask", + "version": "0.0.1" + }, + "taskReferences": { + "entry": [ + { + "key": { + "name": "AAIServiceCreateTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_CREATE", + "localName": "ONTRegistrationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_CREATE", + "localName": "AAIServiceCreateTaskOutput" + } + } + }, + { + "key": { + "name": "ErrorSdncResourceUpdateTaskLogTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_CREATE", + "localName": "ONTRegistrationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "AAI_SERVICE_CREATE", + "localName": "SdncResourceUpdateErrorLogOutput" + } + } + } + ] + } + } + }, + { + "key": "INIT", + "value": { + "stateKey": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "INIT" + }, + "trigger": { + "name": "Nomadic_ONT", + "version": "1.0.2" + }, + "stateOutputs": { + "entry": [ + { + "key": "BBSCloseLoopEventOutPut", + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "INIT", + "localName": "BBSCloseLoopEventOutPut" + }, + "outgoingEvent": { + "name": "AAI_SERVICE_ASSIGNED", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "AAI_SERVICE_ASSIGN" + } + } + } + ] + }, + "contextAlbumReference": [], + "taskSelectionLogic": { + "key": "NULL", + "logicFlavour": "UNDEFINED", + "logic": "" + }, + "stateFinalizerLogicMap": { + "entry": [] + }, + "defaultTask": { + "name": "GetBBSCloseLoopEventTask", + "version": "0.0.1" + }, + "taskReferences": { + "entry": [ + { + "key": { + "name": "GetBBSCloseLoopEventTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "INIT", + "localName": "ONTRegistrationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "INIT", + "localName": "BBSCloseLoopEventOutPut" + } + } + } + ] + } + } + }, + { + "key": "NOMADIC_ONT_REG_SUCCESS", + "value": { + "stateKey": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "NOMADIC_ONT_REG_SUCCESS" + }, + "trigger": { + "name": "END_CONTROL_LOOP", + "version": "1.0.2" + }, + "stateOutputs": { + "entry": [ + { + "key": "NomadicEventSuccessOutPut", + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NOMADIC_ONT_REG_SUCCESS", + "localName": "NomadicEventSuccessOutPut" + }, + "outgoingEvent": { + "name": "END_EVENT", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "NULL", + "parentKeyVersion": "0.0.0", + "parentLocalName": "NULL", + "localName": "NULL" + } + } + } + ] + }, + "contextAlbumReference": [], + "taskSelectionLogic": { + "key": "NULL", + "logicFlavour": "UNDEFINED", + "logic": "" + }, + "stateFinalizerLogicMap": { + "entry": [] + }, + "defaultTask": { + "name": "NomadicEventSuccessTask", + "version": "0.0.1" + }, + "taskReferences": { + "entry": [ + { + "key": { + "name": "NomadicEventSuccessTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NOMADIC_ONT_REG_SUCCESS", + "localName": "ONTRegistrationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NOMADIC_ONT_REG_SUCCESS", + "localName": "NomadicEventSuccessOutPut" + } + } + } + ] + } + } + }, + { + "key": "SDNC_RES_UPDATE", + "value": { + "stateKey": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "SDNC_RES_UPDATE" + }, + "trigger": { + "name": "SDNC_RESOURCE_UPDATE", + "version": "1.0.2" + }, + "stateOutputs": { + "entry": [ + { + "key": "AAIServiceAssignedErrorLogOutput", + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "SDNC_RES_UPDATE", + "localName": "AAIServiceAssignedErrorLogOutput" + }, + "outgoingEvent": { + "name": "ERROR_LOG", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "NULL", + "parentKeyVersion": "0.0.0", + "parentLocalName": "NULL", + "localName": "NULL" + } + } + }, + { + "key": "SdncResourceUpdateOutput", + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "SDNC_RES_UPDATE", + "localName": "SdncResourceUpdateOutput" + }, + "outgoingEvent": { + "name": "AAI_SERVICE_CREATE", + "version": "1.0.2" + }, + "nextState": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "NULL", + "localName": "AAI_SERVICE_CREATE" + } + } + } + ] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskSelectionLogic": { + "key": "TaskSelectionLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nexecutor.logger.info(\"Begin Execution RUorInitStateSelect.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar result = null;\n\nvar attachmentPoint = executor.inFields.get(\"attachmentPoint\");\nvar NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").get(\n attachmentPoint);\n\nresult = NomadicONTContext.get(\"result\");\n\nif (result == \"SUCCESS\") {\n executor.subject.getTaskKey(\"SdncResourceUpdateTask\").copyTo(executor.selectedTask);\n} else {\n executor.subject.getTaskKey(\"ErrorAAIServiceAssignedLogTask\").copyTo(\n executor.selectedTask);\n onsetFlag = executor.isFalse;\n}\n\nexecutor.logger.info(\"State Selected Task:\" + executor.selectedTask);\nexecutor.logger.info(\"End Execution RUorInitStateSelect.js\");\n\ntrue;" + }, + "stateFinalizerLogicMap": { + "entry": [] + }, + "defaultTask": { + "name": "SdncResourceUpdateTask", + "version": "0.0.1" + }, + "taskReferences": { + "entry": [ + { + "key": { + "name": "ErrorAAIServiceAssignedLogTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "SDNC_RES_UPDATE", + "localName": "ONTRegistrationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "SDNC_RES_UPDATE", + "localName": "AAIServiceAssignedErrorLogOutput" + } + } + }, + { + "key": { + "name": "SdncResourceUpdateTask", + "version": "0.0.1" + }, + "value": { + "key": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "SDNC_RES_UPDATE", + "localName": "ONTRegistrationPolicy" + }, + "outputType": "DIRECT", + "output": { + "parentKeyName": "ONTRegistrationPolicy", + "parentKeyVersion": "0.0.1", + "parentLocalName": "SDNC_RES_UPDATE", + "localName": "SdncResourceUpdateOutput" + } + } + } + ] + } + } + } + ] + }, + "firstState": "INIT" + } + } + ] + } + }, + "tasks": { + "key": { + "name": "NomadicONTPolicyModel_Tasks", + "version": "1.0.2" + }, + "taskMap": { + "entry": [ + { + "key": { + "name": "AAIServiceAssignedTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "AAIServiceAssignedTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2019-2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Begin Execution AAIServiceAssignedTask.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar attachmentPoint = executor.inFields.get(\"attachmentPoint\");\nvar requestID = executor.inFields.get(\"requestID\");\nvar serviceInstanceId = executor.inFields.get(\"serviceInstanceId\");\n\nvar NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").get(attachmentPoint);\nexecutor.logger.info(NomadicONTContext);\n\nvar jsonObj;\nvar aaiUpdateResult = true;\n\nvar wbClient = org.onap.policy.apex.examples.bbs.WebClient;\nvar client = new wbClient();\n\n/* Get AAI URL from Configuration file. */\nvar AAI_URL = \"localhost:8080\";\nvar CUSTOMER_ID = requestID;\nvar SERVICE_INSTANCE_ID = serviceInstanceId;\nvar AAI_VERSION = \"v14\";\nvar resource_version;\nvar relationship_list;\nvar HTTP_PROTOCOL = \"https://\";\nvar results;\nvar putUrl;\nvar service_instance;\n\nAAI_URL = executor.parameters.get(\"AAI_URL\");\nAAI_USERNAME = executor.parameters.get(\"AAI_USERNAME\");\nAAI_PASSWORD = executor.parameters.get(\"AAI_PASSWORD\");\nAAI_VERSION = executor.parameters.get(\"AAI_VERSION\");\n\nexecutor.logger.info(\"AAI_URL \" + AAI_URL);\n\n/* Get service instance Id from AAI */\ntry {\n var urlGet = HTTP_PROTOCOL + AAI_URL + \"/aai/\" + AAI_VERSION + \"/nodes/service-instances/service-instance/\"\n + SERVICE_INSTANCE_ID + \"?format=resource_and_url\";\n\n executor.logger.info(\"Query url\" + urlGet);\n\n result = client.httpRequest(urlGet, \"GET\", null, AAI_USERNAME, AAI_PASSWORD, \"application/json\");\n executor.logger.info(\"Data received From \" + urlGet + \" \" + result);\n jsonObj = JSON.parse(result.toString());\n\n executor.logger.info(JSON.stringify(jsonObj, null, 4));\n /* Retrieve the service instance id */\n results = jsonObj['results'][0];\n putUrl = results['url'];\n service_instance = results['service-instance'];\n service_instance_id = service_instance['service-instance-id'];\n resource_version = service_instance['resource-version'];\n relationship_list = service_instance['relationship-list'];\n executor.logger.info(\"After Parse service_instance \" + JSON.stringify(service_instance, null, 4) + \"\\n url \"\n + putUrl + \"\\n Service instace Id \" + service_instance_id);\n\n if (result == \"\") {\n aaiUpdateResult = false;\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n aaiUpdateResult = false;\n}\n\n/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */\nvar putUpddateServInstance;\nputUpddateServInstance = service_instance;\ntry {\n if (aaiUpdateResult == true) {\n putUpddateServInstance[\"orchestration-status\"] = \"active\";\n executor.logger.info(\"ready to putAfter Parse \" + JSON.stringify(putUpddateServInstance, null, 4));\n var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + \"?resource_version=\" + resource_version;\n result = client.httpRequest(urlPut, \"PUT\", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD,\n \"application/json\");\n executor.logger.info(\"Data received From \" + urlPut + \" \" + result);\n /* If failure to retrieve data proceed to Failure */\n if (result != \"\") {\n aaiUpdateResult = false;\n }\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n aaiUpdateResult = false;\n}\n\nif (!service_instance.hasOwnProperty('input-parameters') || !service_instance.hasOwnProperty('metadata')) {\n aaiUpdateResult = false;\n executor.logger.info(\"Validate data failed. input-parameters or metadata is missing\");\n}\n\n/* update logical link in pnf */\nvar oldLinkName = \"\";\ntry {\n if (aaiUpdateResult == true) {\n var pnfName = \"\";\n var pnfResponse;\n var pnfUpdate;\n var relationShips = relationship_list[\"relationship\"];\n\n for (var i = 0; i < relationShips.length; i++) {\n if (relationShips[i][\"related-to\"] == \"pnf\") {\n var relationship_data = relationShips[i][\"relationship-data\"];\n for (var j = 0; j < relationship_data.length; j++) {\n if (relationship_data[j][\"relationship-key\"] == \"pnf.pnf-name\") {\n pnfName = relationship_data[j]['relationship-value'];\n break;\n }\n }\n }\n }\n executor.logger.info(\"pnf-name found \" + pnfName);\n /* 1. Get PNF */\n var urlGetPnf = HTTP_PROTOCOL + AAI_URL + \"/aai/\" + AAI_VERSION + \"/network/pnfs/pnf/\" + pnfName;\n executor.logger.info(\"*********************** Executing call to fetch PNF\");\n pnfResponse = client.httpRequest(urlGetPnf, \"GET\", null, AAI_USERNAME, AAI_PASSWORD, \"application/json\");\n executor.logger.info(\"Data received From \" + urlGetPnf + \" >\" + pnfResponse + \"<\");\n /* If failure to retrieve data proceed to Failure */\n if (!pnfResponse) {\n executor.logger.info(\"*********************** Fetch PNF with relation marked it ERROR\");\n aaiUpdateResult = false;\n }\n pnfUpdate = JSON.parse(pnfResponse.toString());\n executor.logger.info(JSON.stringify(pnfUpdate, null, 4));\n\n /* 2. Create logical link */\n var link_name = attachmentPoint;\n var logicalLink = {};\n logicalLink[\"link-name\"] = String(link_name);\n logicalLink[\"in-maint\"] = String(false);\n logicalLink[\"link-type\"] = \"attachment-point\";\n // var logicalLink = \"{\\\"link-name\\\":\\\"\" + link_name + \"\\\",\\\"in-maint\\\": false, \\\"link-type\\\":\\\"attachment-point\\\"}\";\n // var logicalLink = {\n // \"link-name\" : link_name,\n // \"in-maint\" : false,\n // \"link-type\" : \"attachment-point\"\n // };\n var urlNewLogicalLink = HTTP_PROTOCOL + AAI_URL + \"/aai/\" + AAI_VERSION\n + \"/network/logical-links/logical-link/\" + link_name;\n executor.logger.info(\"URL to be used >>\" + urlNewLogicalLink + \"<<\");\n var logicalLinkStr = JSON.stringify(logicalLink);\n executor.logger.info(\"Body to be used >>\" + logicalLinkStr + \"<<\");\n executor.logger.info(\"*********************** Executing call to create new Logical Link\");\n result = client.httpRequest(urlNewLogicalLink, \"PUT\", logicalLinkStr, AAI_USERNAME, AAI_PASSWORD,\n \"application/json\");\n executor.logger.info(\"Data received From \" + urlNewLogicalLink + \" >\" + result + \"<\");\n /* If failure to retrieve data proceed to Failure */\n if (result != \"\") {\n executor.logger.info(\"*********************** CREATE NEW LOGICAL LINK marked it ERROR\");\n aaiUpdateResult = false;\n }\n\n /* 3. Update pnf with new relation */\n for (var i = 0; i < pnfUpdate[\"relationship-list\"][\"relationship\"].length; i++) {\n if (pnfUpdate[\"relationship-list\"][\"relationship\"][i]['related-to'] == 'logical-link') {\n pnfUpdate[\"relationship-list\"][\"relationship\"][i]['related-link'] = String(\"/aai/\" + AAI_VERSION\n + \"/network/logical-links/logical-link/\" + link_name);\n for (var j = 0; j < pnfUpdate[\"relationship-list\"][\"relationship\"][i]['relationship-data'].length; j++) {\n if (pnfUpdate[\"relationship-list\"][\"relationship\"][i]['relationship-data'][j]['relationship-key'] == \"logical-link.link-name\") {\n oldLinkName = pnfUpdate[\"relationship-list\"][\"relationship\"][i]['relationship-data'][j]['relationship-value'];\n pnfUpdate[\"relationship-list\"][\"relationship\"][i]['relationship-data'][j]['relationship-value'] = String(link_name);\n break;\n }\n }\n break;\n }\n }\n executor.logger.info(\"*********************** Just before calling stringify\");\n var pnfUpdateStr = JSON.stringify(pnfUpdate);\n executor.logger.info(\"Put pnf to aai \" + pnfUpdateStr);\n var urlPutPnf = HTTP_PROTOCOL + AAI_URL + \"/aai/\" + AAI_VERSION + \"/network/pnfs/pnf/\" + pnfName;\n executor.logger.info(\"*********************** Executing call to update PNF with new relation\");\n result = client.httpRequest(urlPutPnf, \"PUT\", pnfUpdateStr, AAI_USERNAME, AAI_PASSWORD,\n \"application/json\");\n executor.logger.info(\"Data received From \" + urlPutPnf + \" >\" + result + \"<\");\n\n /* If failure to retrieve data proceed to Failure */\n if (result != \"\") {\n executor.logger.info(\"*********************** UPDATE PNF with relation marked it ERROR\");\n aaiUpdateResult = false;\n }\n /* Get and Delete the Stale logical link */\n var oldLinkResult;\n var linkResult;\n var urlOldLogicalLink = HTTP_PROTOCOL + AAI_URL + \"/aai/\" + AAI_VERSION\n + \"/network/logical-links/logical-link/\" + oldLinkName;\n executor.logger.info(\"*********************** Executing call to fetch old logical link\");\n linkResult = client.httpRequest(urlOldLogicalLink, \"GET\", null, AAI_USERNAME, AAI_PASSWORD, \"application/json\");\n executor.logger.info(\"Data received From \" + urlOldLogicalLink + \" \" + linkResult + \" \"\n + linkResult.hasOwnProperty(\"link-name\"));\n oldLinkResult = JSON.parse(linkResult.toString());\n if (oldLinkResult.hasOwnProperty(\"link-name\") == true) {\n var res_version = oldLinkResult[\"resource-version\"];\n var urlDelOldLogicalLink = urlOldLogicalLink + \"?resource-version=\" + res_version;\n executor.logger.info(\"Delete called for \" + urlDelOldLogicalLink);\n executor.logger.info(\"*********************** Executing call to delete old logical link\");\n result = client.httpRequest(urlDelOldLogicalLink, \"DELETE\", null, AAI_USERNAME, AAI_PASSWORD,\n \"application/json\");\n executor.logger.info(\"Delete called for \" + urlDelOldLogicalLink + \" result \" + result);\n }\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n aaiUpdateResult = false;\n}\n\n/* If Success then Fill output schema */\nif (aaiUpdateResult == true) {\n executor.outFields.put(\"result\", \"SUCCESS\");\n NomadicONTContext.put(\"result\", \"SUCCESS\");\n executor.logger.info(\"*********************** Just before calling stringify when output to context (service-instance)\");\n NomadicONTContext.put(\"aai_message\", JSON.stringify(service_instance));\n executor.logger.info(\"*********************** Just after calling stringify when output to context (service-instance)\");\n NomadicONTContext.put(\"url\", putUrl);\n} else {\n executor.outFields.put(\"result\", \"FAILURE\");\n NomadicONTContext.put(\"result\", \"FAILURE\");\n}\n\nexecutor.outFields.put(\"requestID\", requestID);\nexecutor.outFields.put(\"attachmentPoint\", attachmentPoint);\nexecutor.outFields.put(\"serviceInstanceId\", executor.inFields.get(\"serviceInstanceId\"));\n\nexecutor.logger.info(executor.outFields);\nexecutor.logger.info(\"End Execution AAIServiceAssignedTask.js\");\n\ntrue;\n\n/* Utility functions Begin */\nfunction IsValidJSONString(str) {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n}\n/* Utility functions End */" + } + } + }, + { + "key": { + "name": "AAIServiceCreateTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "AAIServiceCreateTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2019-2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Begin Execution AAIServiceCreateTask.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar attachmentPoint = executor.inFields.get(\"attachmentPoint\");\nvar requestID = executor.inFields.get(\"requestID\");\nvar serviceInstanceId = executor.inFields.get(\"serviceInstanceId\");\n\nvar NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").get(attachmentPoint);\nexecutor.logger.info(NomadicONTContext);\n\n// Get the AAI URL from configuraiotn file\nvar AAI_URL = \"localhost:8080\";\nvar CUSTOMER_ID = requestID;\nvar BBS_CFS_SERVICE_TYPE = \"BBS-CFS-Access_Test\";\nvar SERVICE_INSTANCE_ID = serviceInstanceId;\nvar AAI_VERSION = \"v14\";\nvar HTTP_PROTOCOL = \"https://\";\nvar wbClient = org.onap.policy.apex.examples.bbs.WebClient;\nvar client = new wbClient();\nvar AAI_USERNAME = null;\nvar AAI_PASSWORD = null;\nAAI_URL = executor.parameters.get(\"AAI_URL\");\nAAI_USERNAME = executor.parameters.get(\"AAI_USERNAME\");\nAAI_PASSWORD = executor.parameters.get(\"AAI_PASSWORD\");\nAAI_VERSION = executor.parameters.get(\"AAI_VERSION\");\nexecutor.logger.info(\"AAI_URL \" + AAI_URL);\nvar aaiUpdateResult = true;\n/* Get service instance Id from AAI */\ntry {\n var urlGet = HTTP_PROTOCOL + AAI_URL + \"/aai/\" + AAI_VERSION + \"/nodes/service-instances/service-instance/\"\n + SERVICE_INSTANCE_ID + \"?format=resource_and_url\";\n\n executor.logger.info(\"Query url\" + urlGet);\n\n result = client.httpRequest(urlGet, \"GET\", null, AAI_USERNAME, AAI_PASSWORD, \"application/json\");\n executor.logger.info(\"Data received From \" + urlGet + \" \" + result);\n jsonObj = JSON.parse(result);\n\n executor.logger.info(JSON.stringify(jsonObj, null, 4));\n /* Retrieve the service instance id */\n results = jsonObj['results'][0];\n putUrl = results['url'];\n service_instance = results['service-instance'];\n executor.logger.info(\"After Parse service_instance \" + JSON.stringify(service_instance, null, 4) + \"\\n url \"\n + putUrl + \"\\n Service instace Id \" + SERVICE_INSTANCE_ID);\n\n if (result == \"\") {\n aaiUpdateResult = false;\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n aaiUpdateResult = false;\n}\n\nvar putUpddateServInstance = service_instance;\nputUpddateServInstance['orchestration-status'] = \"created\";\nexecutor.logger.info(\" string\" + JSON.stringify(putUpddateServInstance, null, 4));\nvar resource_version = putUpddateServInstance['resource-version'];\nvar putUrl = NomadicONTContext.get(\"url\");\n\n/* BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ] */\ntry {\n if (aaiUpdateResult == true) {\n executor.logger.info(\"ready to putAfter Parse \" + JSON.stringify(putUpddateServInstance, null, 4));\n var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + \"?resource_version=\" + resource_version;\n result = client.httpRequest(urlPut, \"PUT\", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD,\n \"application/json\");\n executor.logger.info(\"Data received From \" + urlPut + \" \" + result);\n /* If failure to retrieve data proceed to Failure */\n if (result != \"\") {\n aaiUpdateResult = false;\n }\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n aaiUpdateResult = false;\n}\n/* If Success then Fill output schema */\nif (aaiUpdateResult == true) {\n NomadicONTContext.put(\"result\", \"SUCCESS\");\n} else {\n NomadicONTContext.put(\"result\", \"FAILURE\");\n\n}\n\nexecutor.outFields.put(\"requestID\", requestID);\nexecutor.outFields.put(\"attachmentPoint\", attachmentPoint);\nexecutor.outFields.put(\"serviceInstanceId\", executor.inFields.get(\"serviceInstanceId\"));\n\nexecutor.logger.info(executor.outFields);\nexecutor.logger.info(\"End Execution AAIServiceCreateTask.js\");\n\ntrue;" + } + } + }, + { + "key": { + "name": "ErrorAAIServiceAssignedLogTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "ErrorAAIServiceAssignedLogTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "errorLogParam", + "value": { + "key": "errorLogParam", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nexecutor.logger.info(\"Begin Execution ErrorServiceUpdateOneLogTask.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nexecutor.logger.info(executor.outFields);\n\nexecutor.logger.info(\"Begin Execution ErrorServiceUpdateOneLogTask.js\");\n\ntrue;" + } + } + }, + { + "key": { + "name": "ErrorSdncResourceUpdateTaskLogTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "ErrorSdncResourceUpdateTaskLogTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "errorLogParam", + "value": { + "key": "errorLogParam", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nexecutor.logger.info(\"Begin Execution ErrorResourceUpdateLogTask.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nexecutor.logger.info(\"End Execution ErrorResourceUpdateLogTask.js\");\n\ntrue;" + } + } + }, + { + "key": { + "name": "GetBBSCloseLoopEventTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "GetBBSCloseLoopEventTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "VirtualControlLoopEvent", + "value": { + "key": "VirtualControlLoopEvent", + "fieldSchemaKey": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "optional": false + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Begin Execution GetBBSCloseLoopEventTask.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\nvar returnValue = true;\n\nvar clEventType = org.onap.policy.controlloop.VirtualControlLoopEvent;\nvar clEvent = executor.inFields.get(\"VirtualControlLoopEvent\");\nexecutor.logger.info(clEvent.toString());\nexecutor.logger.info(clEvent.getClosedLoopControlName());\n\nvar requestID = clEvent.getRequestId();\nexecutor.logger.info(\"requestID = \" + requestID);\nvar attachmentPoint = null;\nvar NomadicONTContext = null;\nvar serviceInstanceId = null;\n\nif (clEvent.getAai().get(\"attachmentPoint\") != null) {\n attachmentPoint = clEvent.getAai().get(\"attachmentPoint\");\n executor.logger.info(\"attachmentPoint = \" + attachmentPoint);\n NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").get(\n attachmentPoint);\n serviceInstanceId = clEvent.getAai().get(\n \"service-information.hsia-cfs-service-instance-id\");\n executor.logger.info(\"serviceInstanceId = \" + serviceInstanceId);\n\n if (NomadicONTContext == null) {\n executor.logger.info(\n \"Creating context information for new ONT Device \\\"\" +\n attachmentPoint.toString() + \"\\\"\");\n\n NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").getSchemaHelper()\n .createNewInstance();\n\n NomadicONTContext.put(\"closedLoopControlName\", clEvent.getClosedLoopControlName());\n NomadicONTContext.put(\"closedLoopAlarmStart\", clEvent.getClosedLoopAlarmStart()\n .toEpochMilli());\n NomadicONTContext.put(\"closedLoopEventClient\", clEvent.getClosedLoopEventClient());\n NomadicONTContext.put(\"closedLoopEventStatus\", clEvent.getClosedLoopEventStatus()\n .toString());\n NomadicONTContext.put(\"version\", clEvent.getVersion());\n NomadicONTContext.put(\"requestID\", clEvent.getRequestId().toString());\n NomadicONTContext.put(\"target_type\", clEvent.getTargetType().toString());\n NomadicONTContext.put(\"target\", clEvent.getTarget());\n NomadicONTContext.put(\"from\", clEvent.getFrom());\n NomadicONTContext.put(\"policyScope\", \"Nomadic ONT\");\n NomadicONTContext.put(\"policyName\", clEvent.getPolicyName());\n NomadicONTContext.put(\"policyVersion\", \"1.0.2\");\n NomadicONTContext.put(\"notificationTime\", java.lang.System.currentTimeMillis());\n NomadicONTContext.put(\"message\", \"\");\n NomadicONTContext.put(\"result\", \"SUCCESS\");\n var aaiInfo = executor.getContextAlbum(\"NomadicONTContextAlbum\").getSchemaHelper()\n .createNewSubInstance(\"VCPE_AAI_Type\");\n\n aaiInfo.put(\"attachmentPoint\", clEvent.getAai().get(\"attachmentPoint\"));\n aaiInfo.put(\"cvlan\", clEvent.getAai().get(\"cvlan\"));\n aaiInfo.put(\"service_information_hsia_cfs_service_instance_id\", clEvent\n .getAai().get(\n \"service-information.hsia-cfs-service-instance-id\"));\n aaiInfo.put(\"svlan\", clEvent.getAai().get(\"svlan\"));\n aaiInfo.put(\"remoteId\", clEvent.getAai().get(\"remoteId\"));\n\n\n NomadicONTContext.put(\"AAI\", aaiInfo);\n\n if (clEvent.getClosedLoopAlarmEnd() != null) {\n NomadicONTContext.put(\"closedLoopAlarmEnd\", clEvent.getClosedLoopAlarmEnd()\n .toEpochMilli());\n } else {\n NomadicONTContext.put(\"closedLoopAlarmEnd\", java.lang.Long.valueOf(\n 0));\n }\n\n executor.getContextAlbum(\"NomadicONTContextAlbum\").put(attachmentPoint.toString(),\n NomadicONTContext);\n executor.logger.info(\"Created context information for new vCPE VNF \\\"\" +\n attachmentPoint.toString() + \"\\\"\");\n }\n\n executor.outFields.put(\"requestID\", requestID);\n executor.outFields.put(\"attachmentPoint\", attachmentPoint);\n executor.outFields.put(\"serviceInstanceId\", serviceInstanceId);\n executor.logger.info(executor.outFields);\n executor.logger.info(\"Event Successfully Received and stored in album\");\n}\nelse\n{\n executor.message = \"Received NULL attachment-point\";\n returnValue = false;\n}\n\nreturnValue;" + } + } + }, + { + "key": { + "name": "NomadicEventSuccessTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "NomadicEventSuccessTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Begin Execution NomadicEventSuccess.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar attachmentPoint = executor.inFields.get(\"attachmentPoint\");\nvar NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").get(\n attachmentPoint);\n\nexecutor.logger.info(executor.outFields);\nexecutor.logger.info(executor.inFields);\n\nresult = NomadicONTContext.get(\"result\");\nvar returnValue = true;\n\nif (result == \"SUCCESS\") {\n executor.outFields.put(\"result\", \"SUCCCESS\");\n executor.logger.info(\"BBS policy Execution Done\");\n} else {\n executor.logger.info(\"BBS policy Execution Failed\");\n executor.outFields.put(\"result\", \"FAILURE\");\n returnValue = false;\n}\n\nexecutor.logger.info(\"End Execution NomadicEventSuccess.js\");\n\nreturnValue;" + } + } + }, + { + "key": { + "name": "SdncResourceUpdateTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "SdncResourceUpdateTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Begin Execution SdncResourceUpdateTask.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar attachmentPoint = executor.inFields.get(\"attachmentPoint\");\nvar requestID = executor.inFields.get(\"requestID\");\nvar serviceInstanceId = executor.inFields.get(\"serviceInstanceId\");\nvar uuidType = java.util.UUID;\n\nvar wbClient = org.onap.policy.apex.examples.bbs.WebClient;\nvar client = new wbClient();\n\nvar NomadicONTContext = executor.getContextAlbum(\"NomadicONTContextAlbum\").get(attachmentPoint);\nvar sdncUUID = uuidType.randomUUID();\nexecutor.logger.info(NomadicONTContext);\nvar jsonObj;\nvar aaiUpdateResult = true;\nvar SDNC_URL = \"localhost:8080\";\nvar HTTP_PROTOCOL = \"https://\"\nvar SVC_NOTIFICATION_URL;\nvar putUpddateServInstance = JSON.parse(NomadicONTContext.get(\"aai_message\"));\nvar aaiData = JSON.parse(NomadicONTContext.get(\"AAI\"));\nvar input_param = JSON.parse(putUpddateServInstance['input-parameters']);\nSDNC_URL = executor.parameters.get(\"SDNC_URL\");\nSVC_NOTIFICATION_URL = executor.parameters.get(\"SVC_NOTIFICATION_URL\");\nSDNC_USERNAME = executor.parameters.get(\"SDNC_USERNAME\");\nSDNC_PASSWORD = executor.parameters.get(\"SDNC_PASSWORD\");\nexecutor.logger.info(\"SDNC_URL \" + SDNC_URL);\n\nvar result;\nvar jsonObj;\nvar sdncUpdateResult = true;\n\n/* BBS Policy calls SDN-C GR-API to delete AccessConnectivity VF ID */\n/* Prepare Data */\nvar xmlDeleteAccess =\n \"<input xmlns=\\\"org:onap:sdnc:northbound:generic-resource\\\">\\n\" +\n \"<sdnc-request-header>\\n\" +\n \"<svc-request-id>svc_request_id_value</svc-request-id>\\n\" +\n \"<svc-action>delete</svc-action>\\n\" +\n \"<svc-notification-url>svc_notification_url_value</svc-notification-url>\\n\" +\n \"</sdnc-request-header>\\n\" +\n \"<request-information>\\n\" +\n \"<request-id>request_id_value</request-id>\\n\" +\n \"<request-action>DeleteAccessConnectivityInstance</request-action>\\n\" +\n \"<source>null</source>\\n\" +\n \"<notification-url></notification-url>\\n\" +\n \"<order-number></order-number>\\n\" +\n \"<order-version></order-version>\\n\" +\n \"</request-information>\\n\" +\n \"<service-information>\\n\" +\n \"<service-id>service_id_value</service-id>\\n\" +\n \"<service-instance-id>service_instance_id_value</service-instance-id>\\n\" +\n \"<subscription-service-type>service_type_value</subscription-service-type>\\n\" +\n \"<global-customer-id>customer_id_value</global-customer-id>\\n\" +\n \"<subscriber-name>customer_name_value</subscriber-name>\\n\" +\n \"<onap-model-information>\\n\" +\n \"<model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>\\n\" +\n \"<model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>\\n\" +\n \"<model-uuid>srv_info_model_uuid_value</model-uuid>\\n\" +\n \"<model-name>srv_info_model_name_value</model-name>\\n\" +\n \"</onap-model-information>\\n\" +\n \"</service-information>\\n\" +\n \"<vnf-information>\\n\" +\n \"<onap-model-information>\\n\" +\n \"<model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>\\n\" +\n \"<model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>\\n\" +\n \"<model-uuid>network_info_model_uuid_value</model-uuid>\\n\" +\n \"<model-name>network_info_model_name_value</model-name>\\n\" +\n \"</onap-model-information>\\n\" +\n \"</vnf-information>\\n\" +\n \"<vnf-request-input>\\n\" +\n \"<vnf-input-parameters>\\n\" +\n \"<param>\\n\" +\n \"<name>manufacturer</name>\\n\" +\n \"<value>vendor_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>serviceID</name>\\n\" +\n \"<value>service_id_value</value>\\n\" +\n \"</param>\\n\" +\n \"</vnf-input-parameters>\\n\" +\n \"</vnf-request-input>\\n\" +\n \"</input>\\n\";\n\n/* BBS Policy calls SDN-C GR-API to delete AccessConnectivity */\nxmlDeleteAccess = xmlDeleteAccess.replace(\"svc_request_id_value\", sdncUUID);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"svc_notification_url_value\", SVC_NOTIFICATION_URL);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"request_id_value\", sdncUUID);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"service_id_value\", sdncUUID);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"service_instance_id_value\", putUpddateServInstance['service-instance-id']);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"service_type_value\", input_param['service']['serviceType']);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"customer_id_value\", input_param['service']['globalSubscriberId']);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"customer_name_value\", input_param['service']['globalSubscriberId']);\n\nxmlDeleteAccess = xmlDeleteAccess.replace(\"srv_info_model_inv_uuid_value\", getResourceInvariantUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlDeleteAccess = xmlDeleteAccess.replace(\"srv_info_model_custom_uuid_value\", getResourceCustomizationUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlDeleteAccess = xmlDeleteAccess.replace(\"srv_info_model_uuid_value\", getResourceUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlDeleteAccess = xmlDeleteAccess.replace(\"srv_info_model_name_value\", \"AccessConnectivity\");\nxmlDeleteAccess = xmlDeleteAccess.replace(\"network_info_model_inv_uuid_value\", getResourceInvariantUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlDeleteAccess = xmlDeleteAccess.replace(\"network_info_model_custom_uuid_value\", getResourceCustomizationUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlDeleteAccess = xmlDeleteAccess.replace(\"network_info_model_uuid_value\", getResourceUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlDeleteAccess = xmlDeleteAccess.replace(\"network_info_model_name_value\", \"AccessConnectivity\");\n\nxmlDeleteAccess = xmlDeleteAccess.replace(\"vendor_value\",\n input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']);\nxmlDeleteAccess = xmlDeleteAccess.replace(\"service_id_value\", getMetaValue(\n putUpddateServInstance['metadata']['metadatum'], 'controller-service-id'));\nexecutor.logger.info(client.toPrettyString(xmlDeleteAccess, 4));\n\ntry {\n var urlPost1 = HTTP_PROTOCOL + SDNC_URL + \"/restconf/operations/GENERIC-RESOURCE-API:vnf-topology-operation\";\n result = client.httpRequest(urlPost1, \"POST\", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, \"application/xml\");\n executor.logger.info(\"Data received From \" + urlPost1 + \" \" + result);\n if (result == \"\") {\n sdncUpdateResult = false;\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n sdncUpdateResult = false;\n}\n\n/* BBS Policy calls SDN-C GR-API to create new AccessConnectivity VF */\n\n/* Prepare Data */\nvar xmlCreateAccess =\n \"<input xmlns=\\\"org:onap:sdnc:northbound:generic-resource\\\">\\n\" +\n \"<sdnc-request-header>\\n\" +\n \"<svc-request-id>svc_request_id_value</svc-request-id>\\n\" +\n \"<svc-action>create</svc-action>\\n\" +\n \"<svc-notification-url>svc_notification_url_value</svc-notification-url>\\n\" +\n \"</sdnc-request-header>\\n\" +\n \"<request-information>\\n\" +\n \"<request-id>request_id_value</request-id>\\n\" +\n \"<request-action>CreateAccessConnectivityInstance</request-action>\\n\" +\n \"<source>null</source>\\n\" +\n \"<notification-url></notification-url>\\n\" +\n \"<order-number></order-number>\\n\" +\n \"<order-version></order-version>\\n\" +\n \"</request-information>\\n\" +\n \"<service-information>\\n\" +\n \"<service-id>service_id_value</service-id>\\n\" +\n \"<service-instance-id>service_instance_id_value</service-instance-id>\\n\" +\n \"<subscription-service-type>service_type_value</subscription-service-type>\\n\" +\n \"<global-customer-id>customer_id_value</global-customer-id>\\n\" +\n \"<subscriber-name>customer_name_value</subscriber-name>\\n\" +\n \"<onap-model-information>\\n\" +\n \"<model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>\\n\" +\n \"<model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>\\n\" +\n \"<model-uuid>srv_info_model_uuid_value</model-uuid>\\n\" +\n \"<model-name>srv_info_model_name_value</model-name>\\n\" +\n \"</onap-model-information>\\n\" +\n \"</service-information>\\n\" +\n \"<vnf-information>\\n\" +\n \"<onap-model-information>\\n\" +\n \"<model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>\\n\" +\n \"<model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>\\n\" +\n \"<model-uuid>network_info_model_uuid_value</model-uuid>\\n\" +\n \"<model-name>network_info_model_name_value</model-name>\\n\" +\n \"</onap-model-information>\\n\" +\n \"</vnf-information>\\n\" +\n \"<vnf-request-input>\\n\" +\n \"<vnf-input-parameters>\\n\" +\n \"<param>\\n\" +\n \"<name>manufacturer</name>\\n\" +\n \"<value>vendor_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>ONTSN</name>\\n\" +\n \"<value>ont_sn_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>CVLAN</name>\\n\" +\n \"<value>c_vlan_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>SVLAN</name>\\n\" +\n \"<value>s_vlan_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>remote_id</name>\\n\" +\n \"<value>remote_id_value</value>\\n\" +\n \"</param>\" +\n \"</vnf-input-parameters>\\n\" +\n \"</vnf-request-input>\\n\" +\n \"</input>\\n\";\n\nxmlCreateAccess = xmlCreateAccess.replace(\"svc_request_id_value\", sdncUUID);\nxmlCreateAccess = xmlCreateAccess.replace(\"svc_notification_url_value\", SVC_NOTIFICATION_URL);\nxmlCreateAccess = xmlCreateAccess.replace(\"request_id_value\", requestID);\nxmlCreateAccess = xmlCreateAccess.replace(\"service_id_value\", sdncUUID);\nxmlCreateAccess = xmlCreateAccess.replace(\"service_instance_id_value\", putUpddateServInstance['service-instance-id']);\nxmlCreateAccess = xmlCreateAccess.replace(\"service_type_value\", input_param['service']['serviceType']);\nxmlCreateAccess = xmlCreateAccess.replace(\"customer_id_value\", input_param['service']['globalSubscriberId']);\nxmlCreateAccess = xmlCreateAccess.replace(\"customer_name_value\", input_param['service']['globalSubscriberId']);\n\nxmlCreateAccess = xmlCreateAccess.replace(\"srv_info_model_inv_uuid_value\", getResourceInvariantUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlCreateAccess = xmlCreateAccess.replace(\"srv_info_model_custom_uuid_value\", getResourceCustomizationUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlCreateAccess = xmlCreateAccess.replace(\"srv_info_model_uuid_value\", getResourceUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlCreateAccess = xmlCreateAccess.replace(\"srv_info_model_name_value\", \"AccessConnectivity\");\nxmlCreateAccess = xmlCreateAccess.replace(\"network_info_model_inv_uuid_value\", getResourceInvariantUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlCreateAccess = xmlCreateAccess.replace(\"network_info_model_custom_uuid_value\", getResourceCustomizationUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlCreateAccess = xmlCreateAccess.replace(\"network_info_model_uuid_value\", getResourceUuid(\n input_param['service']['parameters']['resources'], 'AccessConnectivity'));\nxmlCreateAccess = xmlCreateAccess.replace(\"network_info_model_name_value\", \"AccessConnectivity\");\n\nxmlCreateAccess = xmlCreateAccess.replace(\"vendor_value\",\n input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']);\nxmlCreateAccess = xmlCreateAccess.replace(\"ont_sn_value\",\n input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']);\nxmlCreateAccess = xmlCreateAccess.replace(\"s_vlan_value\", aaiData[\"svlan\"]);\nxmlCreateAccess = xmlCreateAccess.replace(\"c_vlan_value\", aaiData[\"cvlan\"]);\nxmlCreateAccess = xmlCreateAccess.replace(\"remote_id_value\", aaiData[\"remoteId\"]);\n\n\nexecutor.logger.info(client.toPrettyString(xmlCreateAccess, 4));\n\ntry {\n if (sdncUpdateResult == true) {\n var urlPost2 = HTTP_PROTOCOL + SDNC_URL\n + \"/restconf/operations/GENERIC-RESOURCE-API:vnf-topology-operation\";\n result = client.httpRequest(urlPost2, \"POST\", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, \"application/xml\");\n executor.logger.info(\"Data received From \" + urlPost2 + \" \" + result);\n if (result == \"\") {\n sdncUpdateResult = false;\n }\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n sdncUpdateResult = false;\n}\n\n/* BBS Policy calls SDN-C GR-API to create change Internet Profile */\nvar xmlChangeProfile =\n \"<input xmlns=\\\"org:onap:sdnc:northbound:generic-resource\\\">\\n\" +\n \"<sdnc-request-header>\\n\" +\n \"<svc-request-id>svc_request_id_value</svc-request-id>\\n\" +\n \"<svc-action>update</svc-action>\\n\" +\n \"<svc-notification-url>svc_notification_url_value</svc-notification-url>\\n\" +\n \"</sdnc-request-header>\\n\" +\n \"<request-information>\\n\" +\n \"<request-id>request_id_value</request-id>\\n\" +\n \"<request-action>ChangeInternetProfileInstance</request-action>\\n\" +\n \"<source>null</source>\\n\" +\n \"<notification-url></notification-url>\\n\" +\n \"<order-number></order-number>\\n\" +\n \"<order-version></order-version>\\n\" +\n \"</request-information>\\n\" +\n \"<service-information>\\n\" +\n \"<service-id>service_id_value</service-id>\\n\" +\n \"<service-instance-id>service_instance_id_value</service-instance-id>\\n\" +\n \"<subscription-service-type>service_type_value</subscription-service-type>\\n\" +\n \"<global-customer-id>customer_id_value</global-customer-id>\\n\" +\n \"<subscriber-name>customer_name_value</subscriber-name>\\n\" +\n \"<onap-model-information>\\n\" +\n \"<model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>\\n\" +\n \"<model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>\\n\" +\n \"<model-uuid>srv_info_model_uuid_value</model-uuid>\\n\" +\n \"<model-name>srv_info_model_name_value</model-name>\\n\" +\n \"</onap-model-information>\\n\" +\n \"</service-information>\\n\" +\n \"<vnf-information>\\n\" +\n \"<onap-model-information>\\n\" +\n \"<model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>\\n\" +\n \"<model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>\\n\" +\n \"<model-uuid>network_info_model_uuid_value</model-uuid>\\n\" +\n \"<model-name>network_info_model_name_value</model-name>\\n\" +\n \"</onap-model-information>\\n\" +\n \"</vnf-information>\\n\" +\n \"<vnf-request-input>\\n\" +\n \"<vnf-input-parameters>\\n\" +\n \"<param>\\n\" +\n \"<name>manufacturer</name>\\n\" +\n \"<value>vendor_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>service_id</name>\\n\" +\n \"<value>service_id_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>ip_remote_id</name>\\n\" +\n \"<value>remote_id_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>ont_sn</name>\\n\" +\n \"<value>ont_sn_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>ip_service_type</name>\\n\" +\n \"<value>service_type_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>ip_rg_mac_addr</name>\\n\" +\n \"<value>mac_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>ip_upstream_speed</name>\\n\" +\n \"<value>up_speed_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>ip_downstream_speed</name>\\n\" +\n \"<value>down_speed_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>s_vlan</name>\\n\" +\n \"<value>s_vlan_value</value>\\n\" +\n \"</param>\\n\" +\n \"<param>\\n\" +\n \"<name>c_vlan</name>\\n\" +\n \"<value>c_vlan_value</value>\\n\" +\n \"</param>\\n\" +\n \"</vnf-input-parameters>\\n\" +\n \"</vnf-request-input>\\n\" +\n \"</input>\\n\";\n\nxmlChangeProfile = xmlChangeProfile.replace(\"svc_request_id_value\", sdncUUID);\nxmlChangeProfile = xmlChangeProfile.replace(\"svc_notification_url_value\", SVC_NOTIFICATION_URL);\nxmlChangeProfile = xmlChangeProfile.replace(\"request_id_value\", requestID);\nxmlChangeProfile = xmlChangeProfile.replace(\"service_id_value\", sdncUUID);\nxmlChangeProfile = xmlChangeProfile.replace(\"service_instance_id_value\", putUpddateServInstance['service-instance-id']);\nxmlChangeProfile = xmlChangeProfile.replace(\"service_type_value\", input_param['service']['serviceType']);\nxmlChangeProfile = xmlChangeProfile.replace(\"customer_id_value\", input_param['service']['globalSubscriberId']);\nxmlChangeProfile = xmlChangeProfile.replace(\"customer_name_value\", input_param['service']['globalSubscriberId']);\n\nxmlChangeProfile = xmlChangeProfile.replace(\"srv_info_model_inv_uuid_value\", getResourceInvariantUuid(\n input_param['service']['parameters']['resources'], 'InternetProfile'));\nxmlChangeProfile = xmlChangeProfile.replace(\"srv_info_model_custom_uuid_value\", getResourceCustomizationUuid(\n input_param['service']['parameters']['resources'], 'InternetProfile'));\nxmlChangeProfile = xmlChangeProfile.replace(\"srv_info_model_uuid_value\", getResourceUuid(\n input_param['service']['parameters']['resources'], 'InternetProfile'));\nxmlChangeProfile = xmlChangeProfile.replace(\"srv_info_model_name_value\", \"InternetProfile\");\nxmlChangeProfile = xmlChangeProfile.replace(\"network_info_model_inv_uuid_value\", getResourceInvariantUuid(\n input_param['service']['parameters']['resources'], 'InternetProfile'));\nxmlChangeProfile = xmlChangeProfile.replace(\"network_info_model_custom_uuid_value\", getResourceCustomizationUuid(\n input_param['service']['parameters']['resources'], 'InternetProfile'));\nxmlChangeProfile = xmlChangeProfile.replace(\"network_info_model_uuid_value\", getResourceUuid(\n input_param['service']['parameters']['resources'], 'InternetProfile'));\nxmlChangeProfile = xmlChangeProfile.replace(\"network_info_model_name_value\", \"InternetProfile\");\n\nxmlChangeProfile = xmlChangeProfile.replace(\"vendor_value\",\n input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']);\nxmlChangeProfile = xmlChangeProfile.replace(\"service_id_value\", getMetaValue(\n putUpddateServInstance['metadata']['metadatum'], 'controller-service-id'));\nxmlChangeProfile = xmlChangeProfile.replace(\"ont_sn_value\",\n input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']);\nxmlChangeProfile = xmlChangeProfile.replace(\"service_type_value\", input_param['service']['serviceType']);\nxmlChangeProfile = xmlChangeProfile.replace(\"mac_value\", getMetaValue(putUpddateServInstance['metadata']['metadatum'],\n 'rgw-mac-address'));\nxmlChangeProfile = xmlChangeProfile.replace(\"up_speed_value\", getMetaValue(\n putUpddateServInstance['metadata']['metadatum'], 'up-speed'));\nxmlChangeProfile = xmlChangeProfile.replace(\"down_speed_value\", getMetaValue(\n putUpddateServInstance['metadata']['metadatum'], 'down-speed'));\nxmlChangeProfile = xmlChangeProfile.replace(\"s_vlan_value\", aaiData[\"svlan\"]);\nxmlChangeProfile = xmlChangeProfile.replace(\"c_vlan_value\", aaiData[\"cvlan\"]);\nxmlChangeProfile = xmlChangeProfile.replace(\"remote_id_value\", aaiData[\"remoteId\"]);\n\nexecutor.logger.info(client.toPrettyString(xmlChangeProfile, 4));\ntry {\n if (sdncUpdateResult == true) {\n var urlPost3 = HTTP_PROTOCOL + SDNC_URL\n + \"/restconf/operations/GENERIC-RESOURCE-API:vnf-topology-operation\";\n result = client\n .httpRequest(urlPost3, \"POST\", xmlChangeProfile, SDNC_USERNAME, SDNC_PASSWORD, \"application/xml\");\n executor.logger.info(\"Data received From \" + urlPost3 + \" \" + result);\n if (result == \"\") {\n sdncUpdateResult = false;\n }\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n sdncUpdateResult = false;\n}\n\n/* If Success then Fill output schema */\n\nif (sdncUpdateResult == true) {\n NomadicONTContext.put(\"result\", \"SUCCESS\");\n executor.outFields.put(\"result\", \"SUCCESS\");\n} else {\n NomadicONTContext.put(\"result\", \"FAILURE\");\n executor.outFields.put(\"result\", \"FAILURE\");\n}\n\nexecutor.outFields.put(\"requestID\", requestID);\nexecutor.outFields.put(\"attachmentPoint\", attachmentPoint);\nexecutor.outFields.put(\"serviceInstanceId\", executor.inFields.get(\"serviceInstanceId\"));\n\nexecutor.logger.info(executor.outFields);\nexecutor.logger.info(\"End Execution SdncResourceUpdateTask.js\");\n\ntrue;\n\nfunction getMetaValue(metaJson, metaname) {\n for (var i = 0; i < metaJson.length; i++) {\n if (metaJson[i]['metaname'] == metaname) {\n return metaJson[i]['metaval'];\n }\n }\n\n}\n\nfunction getResourceInvariantUuid(resJson, resourceName) {\n for (var i = 0; i < resJson.length; i++) {\n if (resJson[i]['resourceName'] == resourceName) {\n return resJson[i]['resourceInvariantUuid'];\n }\n }\n\n}\n\nfunction getResourceUuid(resJson, resourceName) {\n for (var i = 0; i < resJson.length; i++) {\n if (resJson[i]['resourceName'] == resourceName) {\n return resJson[i]['resourceUuid'];\n }\n }\n\n}\n\nfunction getResourceCustomizationUuid(resJson, resourceName) {\n for (var i = 0; i < resJson.length; i++) {\n if (resJson[i]['resourceName'] == resourceName) {\n return resJson[i]['resourceCustomizationUuid'];\n }\n }\n\n}\n\n/* Utility functions Begin */\nfunction IsValidJSONString(str) {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n}\n/* Utility functions End */" + } + } + }, + { + "key": { + "name": "ServiceUpdateStateCpeAuthTask", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "ServiceUpdateStateCpeAuthTask", + "version": "0.0.1" + }, + "inputFields": { + "entry": [ + { + "key": "VirtualControlLoopEvent", + "value": { + "key": "VirtualControlLoopEvent", + "fieldSchemaKey": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "optional": false + } + } + ] + }, + "outputFields": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + }, + "taskParameters": { + "entry": [] + }, + "contextAlbumReference": [ + { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + } + ], + "taskLogic": { + "key": "TaskLogic", + "logicFlavour": "JAVASCRIPT", + "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2019 Huawei. All rights reserved.\n * Modifications Copyright (C) 2019-2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Begin Execution ServiceUpdateStateCpeAuthTask.js\");\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar clEventType = org.onap.policy.controlloop.VirtualControlLoopEvent;\nvar clEvent = executor.inFields.get(\"VirtualControlLoopEvent\");\n\nvar serviceInstanceId = clEvent.getAai().get(\"service-information.hsia-cfs-service-instance-id\");\nvar requestID = clEvent.getRequestId();\n\nvar jsonObj;\nvar aaiUpdateResult = true;\nvar wbClient = org.onap.policy.apex.examples.bbs.WebClient;\nvar client = new wbClient();\nvar oldState = clEvent.getAai().get(\"cpe.old-authentication-state\");\nvar newState = clEvent.getAai().get(\"cpe.new-authentication-state\");\nexecutor.logger.info(\"New CPE Authentication State: \" + newState);\n/* Get AAI URL from Configuration file. */\nvar AAI_URL = \"localhost:8080\";\nvar CUSTOMER_ID = requestID;\nvar SERVICE_INSTANCE_ID = serviceInstanceId;\nvar resource_version;\nvar HTTP_PROTOCOL = \"https://\";\nvar results;\nvar putUrl;\nvar service_instance;\nvar AAI_VERSION = \"v14\";\n\nAAI_URL = executor.parameters.get(\"AAI_URL\");\nAAI_USERNAME = executor.parameters.get(\"AAI_USERNAME\");\nAAI_PASSWORD = executor.parameters.get(\"AAI_PASSWORD\");\nAAI_VERSION = executor.parameters.get(\"AAI_VERSION\");\n\nexecutor.logger.info(\"AAI_URL=>\" + AAI_URL);\n\n/* Get service instance Id from AAI */\ntry {\n var urlGet = HTTP_PROTOCOL + AAI_URL + \"/aai/\" + AAI_VERSION + \"/nodes/service-instances/service-instance/\"\n + SERVICE_INSTANCE_ID + \"?format=resource_and_url\"\n executor.logger.info(\"Query url: \" + urlGet);\n\n result = client.httpRequest(urlGet, \"GET\", null, AAI_USERNAME, AAI_PASSWORD, \"application/json\");\n executor.logger.info(\"Data received From \" + urlGet + \" \" + result);\n jsonObj = JSON.parse(result);\n\n /* Retrieve the service instance id */\n results = jsonObj['results'][0];\n putUrl = results[\"url\"];\n service_instance = results['service-instance'];\n resource_version = service_instance['resource-version'];\n executor.logger.info(\"After Parse service_instance \" + JSON.stringify(service_instance, null, 4) + \"\\n url \"\n + putUrl + \"\\n Service instace Id \" + SERVICE_INSTANCE_ID);\n\n if (result == \"\") {\n aaiUpdateResult = false;\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n aaiUpdateResult = false;\n}\n\n/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */\nvar putUpddateServInstance;\nputUpddateServInstance = service_instance;\n\nif (newState == 'inService') {\n putUpddateServInstance['orchestration-status'] = \"active\";\n} else {\n putUpddateServInstance['orchestration-status'] = \"inActive\";\n}\ntry {\n if (aaiUpdateResult == true) {\n executor.logger.info(\"ready to put After Parse \" + JSON.stringify(putUpddateServInstance, null, 4));\n var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + \"?resource_version=\" + resource_version;\n result = client.httpRequest(urlPut, \"PUT\", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD,\n \"application/json\");\n executor.logger.info(\"Data received From \" + urlPut + \" \" + result);\n /* If failure to retrieve data proceed to Failure */\n if (result != \"\") {\n aaiUpdateResult = false;\n }\n }\n} catch (err) {\n executor.logger.info(\"Failed to retrieve data \" + err);\n aaiUpdateResult = false;\n}\n\nif (aaiUpdateResult == true) {\n executor.outFields.put(\"result\", \"SUCCCESS\");\n} else {\n executor.outFields.put(\"result\", \"FAILURE\");\n}\n\nexecutor.logger.info(executor.outFields);\nexecutor.logger.info(\"End Execution ServiceUpdateStateCpeAuthTask.js\");\n\ntrue;" + } + } + } + ] + } + }, + "events": { + "key": { + "name": "NomadicONTPolicyModel_Events", + "version": "1.0.2" + }, + "eventMap": { + "entry": [ + { + "key": { + "name": "AAI_CPE_AUTH_UPDATE", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "AAI_CPE_AUTH_UPDATE", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "APEX", + "target": "DCAE", + "parameter": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + } + } + }, + { + "key": { + "name": "AAI_SERVICE_ASSIGNED", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "AAI_SERVICE_ASSIGNED", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "APEX", + "target": "APEX", + "parameter": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + } + } + }, + { + "key": { + "name": "AAI_SERVICE_CREATE", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "AAI_SERVICE_CREATE", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "APEX", + "target": "APEX", + "parameter": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + } + } + }, + { + "key": { + "name": "CPE_Authentication", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "CPE_Authentication", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "DCAE", + "target": "APEX", + "parameter": { + "entry": [ + { + "key": "VirtualControlLoopEvent", + "value": { + "key": "VirtualControlLoopEvent", + "fieldSchemaKey": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "optional": false + } + } + ] + } + } + }, + { + "key": { + "name": "END_CONTROL_LOOP", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "END_CONTROL_LOOP", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "APEX", + "target": "APEX", + "parameter": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + } + } + }, + { + "key": { + "name": "END_EVENT", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "END_EVENT", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "APEX", + "target": "DCAE", + "parameter": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + } + } + }, + { + "key": { + "name": "ERROR_LOG", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "ERROR_LOG", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "APEX", + "target": "APEX", + "parameter": { + "entry": [ + { + "key": "errorLogParam", + "value": { + "key": "errorLogParam", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + } + ] + } + } + }, + { + "key": { + "name": "Nomadic_ONT", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "Nomadic_ONT", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "DCAE", + "target": "APEX", + "parameter": { + "entry": [ + { + "key": "VirtualControlLoopEvent", + "value": { + "key": "VirtualControlLoopEvent", + "fieldSchemaKey": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "optional": false + } + } + ] + } + } + }, + { + "key": { + "name": "SDNC_RESOURCE_UPDATE", + "version": "1.0.2" + }, + "value": { + "key": { + "name": "SDNC_RESOURCE_UPDATE", + "version": "1.0.2" + }, + "nameSpace": "org.onap.policy.apex.onap.bbs", + "source": "APEX", + "target": "APEX", + "parameter": { + "entry": [ + { + "key": "attachmentPoint", + "value": { + "key": "attachmentPoint", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "requestID", + "value": { + "key": "requestID", + "fieldSchemaKey": { + "name": "UUIDType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "result", + "value": { + "key": "result", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": false + } + }, + { + "key": "serviceInstanceId", + "value": { + "key": "serviceInstanceId", + "fieldSchemaKey": { + "name": "SimpleStringType", + "version": "0.0.1" + }, + "optional": true + } + } + ] + } + } + } + ] + } + }, + "albums": { + "key": { + "name": "NomadicONTPolicyModel_Albums", + "version": "1.0.2" + }, + "albums": { + "entry": [ + { + "key": { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "NomadicONTContextAlbum", + "version": "0.0.1" + }, + "scope": "policy", + "isWritable": true, + "itemSchema": { + "name": "NomadicONTContextType", + "version": "0.0.1" + } + } + } + ] + } + }, + "schemas": { + "key": { + "name": "NomadicONTPolicyModel_Schemas", + "version": "1.0.2" + }, + "schemas": { + "entry": [ + { + "key": { + "name": "NomadicONTContextType", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "NomadicONTContextType", + "version": "0.0.1" + }, + "schemaFlavour": "Avro", + "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"NomadicONTContext\",\n \"fields\": [\n {\n \"name\": \"AAI\",\n \"type\": {\n \"type\": \"record\",\n \"name\": \"VCPE_AAI_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.vcpe\",\n \"fields\": [\n {\n \"name\": \"attachmentPoint\",\n \"type\": \"string\"\n },\n {\n \"name\": \"service_information_hsia_cfs_service_instance_id\",\n \"type\": \"string\"\n },\n {\n \"name\": \"cvlan\",\n \"type\": \"string\"\n },\n {\n \"name\": \"svlan\",\n \"type\": \"string\"\n },\n {\n \"name\": \"remoteId\",\n \"type\": \"string\"\n }\n ]\n }\n },\n {\n \"name\": \"closedLoopAlarmStart\",\n \"type\": \"long\"\n },\n {\n \"name\": \"closedLoopAlarmEnd\",\n \"type\": \"long\"\n },\n {\n \"name\": \"closedLoopControlName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestID\",\n \"type\": \"string\"\n },\n {\n \"name\": \"closedLoopEventClient\",\n \"type\": \"string\"\n },\n {\n \"name\": \"closedLoopEventStatus\",\n \"type\": \"string\"\n },\n {\n \"name\": \"target_type\",\n \"type\": \"string\"\n },\n {\n \"name\": \"target\",\n \"type\": \"string\"\n },\n {\n \"name\": \"from\",\n \"type\": \"string\"\n },\n {\n \"name\": \"policyScope\",\n \"type\": \"string\"\n },\n {\n \"name\": \"policyName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"policyVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"notification\",\n \"type\": \"string\"\n },\n {\n \"name\": \"notificationTime\",\n \"type\": \"long\"\n },\n {\n \"name\": \"result\",\n \"type\": \"string\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n },\n {\n \"name\": \"url\",\n \"type\": \"string\"\n },\n {\n \"name\": \"aai_message\",\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": "UUIDType", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "UUIDType", + "version": "0.0.1" + }, + "schemaFlavour": "Java", + "schemaDefinition": "java.util.UUID" + } + }, + { + "key": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "value": { + "key": { + "name": "VirtualControlLoopEventType", + "version": "0.0.1" + }, + "schemaFlavour": "Java", + "schemaDefinition": "org.onap.policy.controlloop.VirtualControlLoopEvent" + } + } + ] + } + } + } + } + }, + "eventOutputParameters": { + "FirstProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "standardIo": true + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + }, + "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/g1/c1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "nameAlias": "policyName", + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopEvent" + } + } + } + } + } + } + } + ] + } +} diff --git a/policy/apex/ToscaTemplate.json b/policy/apex/ToscaTemplate.json new file mode 100644 index 0000000..36b2c4e --- /dev/null +++ b/policy/apex/ToscaTemplate.json @@ -0,0 +1,16 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "topology_template": { + "policies": [ + { + "operational.onapbbs": { + "type": "onap.policies.controlloop.operational.Apex", + "type_version": "1.0.0", + "name": "operational.onapbbs", + "version": "1.0.0", + "properties": {} + } + } + ] + } +} diff --git a/policy/apex/config/config.txt b/policy/apex/config/config.txt new file mode 100644 index 0000000..162335d --- /dev/null +++ b/policy/apex/config/config.txt @@ -0,0 +1,8 @@ +AAI_URL=aai:8443 +AAI_USERNAME=AAI +AAI_PASSWORD=AAI +AAI_VERSION=v14 +SDNC_URL=sdnc:8282 +SDNC_USERNAME=admin +SDNC_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U +SVC_NOTIFICATION_URL=http://c1.vm1.mso.simpledemo.openecomp.org:8080
\ No newline at end of file diff --git a/policy/apex/logic/AAIServiceAssignedTask.js b/policy/apex/logic/AAIServiceAssignedTask.js new file mode 100644 index 0000000..0cb4967 --- /dev/null +++ b/policy/apex/logic/AAIServiceAssignedTask.js @@ -0,0 +1,260 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info("Begin Execution AAIServiceAssignedTask.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var attachmentPoint = executor.inFields.get("attachmentPoint"); +var requestID = executor.inFields.get("requestID"); +var serviceInstanceId = executor.inFields.get("serviceInstanceId"); + +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); +executor.logger.info(NomadicONTContext); + +var jsonObj; +var aaiUpdateResult = true; + +var wbClient = org.onap.policy.apex.examples.bbs.WebClient; +var client = new wbClient(); + +/* Get AAI URL from Configuration file. */ +var AAI_URL = "localhost:8080"; +var CUSTOMER_ID = requestID; +var SERVICE_INSTANCE_ID = serviceInstanceId; +var AAI_VERSION = "v14"; +var resource_version; +var relationship_list; +var HTTP_PROTOCOL = "https://"; +var results; +var putUrl; +var service_instance; + +AAI_URL = executor.parameters.get("AAI_URL"); +AAI_USERNAME = executor.parameters.get("AAI_USERNAME"); +AAI_PASSWORD = executor.parameters.get("AAI_PASSWORD"); +AAI_VERSION = executor.parameters.get("AAI_VERSION"); + +executor.logger.info("AAI_URL " + AAI_URL); + +/* Get service instance Id from AAI */ +try { + var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + + SERVICE_INSTANCE_ID + "?format=resource_and_url"; + + executor.logger.info("Query url" + urlGet); + + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json"); + executor.logger.info("Data received From " + urlGet + " " + result); + jsonObj = JSON.parse(result.toString()); + + executor.logger.info(JSON.stringify(jsonObj, null, 4)); + /* Retrieve the service instance id */ + results = jsonObj['results'][0]; + putUrl = results['url']; + service_instance = results['service-instance']; + service_instance_id = service_instance['service-instance-id']; + resource_version = service_instance['resource-version']; + relationship_list = service_instance['relationship-list']; + executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url " + + putUrl + "\n Service instace Id " + service_instance_id); + + if (result == "") { + aaiUpdateResult = false; + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + aaiUpdateResult = false; +} + +/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */ +var putUpddateServInstance; +putUpddateServInstance = service_instance; +try { + if (aaiUpdateResult == true) { + putUpddateServInstance["orchestration-status"] = "active"; + executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4)); + var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json"); + executor.logger.info("Data received From " + urlPut + " " + result); + /* If failure to retrieve data proceed to Failure */ + if (result != "") { + aaiUpdateResult = false; + } + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + aaiUpdateResult = false; +} + +if (!service_instance.hasOwnProperty('input-parameters') || !service_instance.hasOwnProperty('metadata')) { + aaiUpdateResult = false; + executor.logger.info("Validate data failed. input-parameters or metadata is missing"); +} + +/* update logical link in pnf */ +var oldLinkName = ""; +try { + if (aaiUpdateResult == true) { + var pnfName = ""; + var pnfResponse; + var pnfUpdate; + var relationShips = relationship_list["relationship"]; + + for (var i = 0; i < relationShips.length; i++) { + if (relationShips[i]["related-to"] == "pnf") { + var relationship_data = relationShips[i]["relationship-data"]; + for (var j = 0; j < relationship_data.length; j++) { + if (relationship_data[j]["relationship-key"] == "pnf.pnf-name") { + pnfName = relationship_data[j]['relationship-value']; + break; + } + } + } + } + executor.logger.info("pnf-name found " + pnfName); + /* 1. Get PNF */ + var urlGetPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; + executor.logger.info("*********************** Executing call to fetch PNF"); + pnfResponse = client.httpRequest(urlGetPnf, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json"); + executor.logger.info("Data received From " + urlGetPnf + " >" + pnfResponse + "<"); + /* If failure to retrieve data proceed to Failure */ + if (!pnfResponse) { + executor.logger.info("*********************** Fetch PNF with relation marked it ERROR"); + aaiUpdateResult = false; + } + pnfUpdate = JSON.parse(pnfResponse.toString()); + executor.logger.info(JSON.stringify(pnfUpdate, null, 4)); + + /* 2. Create logical link */ + var link_name = attachmentPoint; + var logicalLink = {}; + logicalLink["link-name"] = String(link_name); + logicalLink["in-maint"] = String(false); + logicalLink["link-type"] = "attachment-point"; + // var logicalLink = "{\"link-name\":\"" + link_name + "\",\"in-maint\":false, \"link-type\":\"attachment-point\"}"; + // var logicalLink = { + // "link-name" : link_name, + // "in-maint" : false, + // "link-type" : "attachment-point" + // }; + var urlNewLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + link_name; + executor.logger.info("URL to be used >>" + urlNewLogicalLink + "<<"); + var logicalLinkStr = JSON.stringify(logicalLink); + executor.logger.info("Body to be used >>" + logicalLinkStr + "<<"); + executor.logger.info("*********************** Executing call to create new Logical Link"); + result = client.httpRequest(urlNewLogicalLink, "PUT", logicalLinkStr, AAI_USERNAME, AAI_PASSWORD, + "application/json"); + executor.logger.info("Data received From " + urlNewLogicalLink + " >" + result + "<"); + /* If failure to retrieve data proceed to Failure */ + if (result != "") { + executor.logger.info("*********************** CREATE NEW LOGICAL LINK marked it ERROR"); + aaiUpdateResult = false; + } + + /* 3. Update pnf with new relation */ + for (var i = 0; i < pnfUpdate["relationship-list"]["relationship"].length; i++) { + if (pnfUpdate["relationship-list"]["relationship"][i]['related-to'] == 'logical-link') { + pnfUpdate["relationship-list"]["relationship"][i]['related-link'] = String("/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + link_name); + for (var j = 0; j < pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'].length; j++) { + if (pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-key'] == "logical-link.link-name") { + oldLinkName = pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value']; + pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value'] = String(link_name); + break; + } + } + break; + } + } + executor.logger.info("*********************** Just before calling stringify"); + var pnfUpdateStr = JSON.stringify(pnfUpdate); + executor.logger.info("Put pnf to aai " + pnfUpdateStr); + var urlPutPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; + executor.logger.info("*********************** Executing call to update PNF with new relation"); + result = client.httpRequest(urlPutPnf, "PUT", pnfUpdateStr, AAI_USERNAME, AAI_PASSWORD, + "application/json"); + executor.logger.info("Data received From " + urlPutPnf + " >" + result + "<"); + + /* If failure to retrieve data proceed to Failure */ + if (result != "") { + executor.logger.info("*********************** UPDATE PNF with relation marked it ERROR"); + aaiUpdateResult = false; + } + /* Get and Delete the Stale logical link */ + var oldLinkResult; + var linkResult; + var urlOldLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + oldLinkName; + executor.logger.info("*********************** Executing call to fetch old logical link"); + linkResult = client.httpRequest(urlOldLogicalLink, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json"); + executor.logger.info("Data received From " + urlOldLogicalLink + " " + linkResult + " " + + linkResult.hasOwnProperty("link-name")); + oldLinkResult = JSON.parse(linkResult.toString()); + if (oldLinkResult.hasOwnProperty("link-name") == true) { + var res_version = oldLinkResult["resource-version"]; + var urlDelOldLogicalLink = urlOldLogicalLink + "?resource-version=" + res_version; + executor.logger.info("Delete called for " + urlDelOldLogicalLink); + executor.logger.info("*********************** Executing call to delete old logical link"); + result = client.httpRequest(urlDelOldLogicalLink, "DELETE", null, AAI_USERNAME, AAI_PASSWORD, + "application/json"); + executor.logger.info("Delete called for " + urlDelOldLogicalLink + " result " + result); + } + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + aaiUpdateResult = false; +} + +/* If Success then Fill output schema */ +if (aaiUpdateResult == true) { + executor.outFields.put("result", "SUCCESS"); + NomadicONTContext.put("result", "SUCCESS"); + executor.logger.info("*********************** Just before calling stringify when output to context (service-instance)"); + NomadicONTContext.put("aai_message", JSON.stringify(service_instance)); + executor.logger.info("*********************** Just after calling stringify when output to context (service-instance)"); + NomadicONTContext.put("url", putUrl); +} else { + executor.outFields.put("result", "FAILURE"); + NomadicONTContext.put("result", "FAILURE"); +} + +executor.outFields.put("requestID", requestID); +executor.outFields.put("attachmentPoint", attachmentPoint); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); + +executor.logger.info(executor.outFields); +executor.logger.info("End Execution AAIServiceAssignedTask.js"); + +true; + +/* Utility functions Begin */ +function IsValidJSONString(str) { + try { + JSON.parse(str); + } catch (e) { + return false; + } + return true; +} +/* Utility functions End */ diff --git a/policy/apex/logic/AAIServiceCreateTask.js b/policy/apex/logic/AAIServiceCreateTask.js new file mode 100644 index 0000000..d6c86c2 --- /dev/null +++ b/policy/apex/logic/AAIServiceCreateTask.js @@ -0,0 +1,116 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info("Begin Execution AAIServiceCreateTask.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var attachmentPoint = executor.inFields.get("attachmentPoint"); +var requestID = executor.inFields.get("requestID"); +var serviceInstanceId = executor.inFields.get("serviceInstanceId"); + +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); +executor.logger.info(NomadicONTContext); + +// Get the AAI URL from configuraiotn file +var AAI_URL = "localhost:8080"; +var CUSTOMER_ID = requestID; +var BBS_CFS_SERVICE_TYPE = "BBS-CFS-Access_Test"; +var SERVICE_INSTANCE_ID = serviceInstanceId; +var AAI_VERSION = "v14"; +var HTTP_PROTOCOL = "https://"; +var wbClient = org.onap.policy.apex.examples.bbs.WebClient; +var client = new wbClient(); +var AAI_USERNAME = null; +var AAI_PASSWORD = null; +AAI_URL = executor.parameters.get("AAI_URL"); +AAI_USERNAME = executor.parameters.get("AAI_USERNAME"); +AAI_PASSWORD = executor.parameters.get("AAI_PASSWORD"); +AAI_VERSION = executor.parameters.get("AAI_VERSION"); +executor.logger.info("AAI_URL " + AAI_URL); +var aaiUpdateResult = true; +/* Get service instance Id from AAI */ +try { + var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + + SERVICE_INSTANCE_ID + "?format=resource_and_url"; + + executor.logger.info("Query url" + urlGet); + + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json"); + executor.logger.info("Data received From " + urlGet + " " + result); + jsonObj = JSON.parse(result); + + executor.logger.info(JSON.stringify(jsonObj, null, 4)); + /* Retrieve the service instance id */ + results = jsonObj['results'][0]; + putUrl = results['url']; + service_instance = results['service-instance']; + executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url " + + putUrl + "\n Service instace Id " + SERVICE_INSTANCE_ID); + + if (result == "") { + aaiUpdateResult = false; + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + aaiUpdateResult = false; +} + +var putUpddateServInstance = service_instance; +putUpddateServInstance['orchestration-status'] = "created"; +executor.logger.info(" string" + JSON.stringify(putUpddateServInstance, null, 4)); +var resource_version = putUpddateServInstance['resource-version']; +var putUrl = NomadicONTContext.get("url"); + +/* BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ] */ +try { + if (aaiUpdateResult == true) { + executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4)); + var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json"); + executor.logger.info("Data received From " + urlPut + " " + result); + /* If failure to retrieve data proceed to Failure */ + if (result != "") { + aaiUpdateResult = false; + } + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + aaiUpdateResult = false; +} +/* If Success then Fill output schema */ +if (aaiUpdateResult == true) { + NomadicONTContext.put("result", "SUCCESS"); +} else { + NomadicONTContext.put("result", "FAILURE"); + +} + +executor.outFields.put("requestID", requestID); +executor.outFields.put("attachmentPoint", attachmentPoint); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); + +executor.logger.info(executor.outFields); +executor.logger.info("End Execution AAIServiceCreateTask.js"); + +true; + diff --git a/policy/apex/logic/ErrorAAIServiceAssignedLogTask.js b/policy/apex/logic/ErrorAAIServiceAssignedLogTask.js new file mode 100644 index 0000000..a9d7f31 --- /dev/null +++ b/policy/apex/logic/ErrorAAIServiceAssignedLogTask.js @@ -0,0 +1,29 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +executor.logger.info("Begin Execution ErrorServiceUpdateOneLogTask.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +executor.logger.info(executor.outFields); + +executor.logger.info("Begin Execution ErrorServiceUpdateOneLogTask.js"); + +true; diff --git a/policy/apex/logic/ErrorSdncResourceUpdateTaskLogTask.js b/policy/apex/logic/ErrorSdncResourceUpdateTaskLogTask.js new file mode 100644 index 0000000..3fbb0df --- /dev/null +++ b/policy/apex/logic/ErrorSdncResourceUpdateTaskLogTask.js @@ -0,0 +1,27 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +executor.logger.info("Begin Execution ErrorResourceUpdateLogTask.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +executor.logger.info("End Execution ErrorResourceUpdateLogTask.js"); + +true; diff --git a/policy/apex/logic/GetBBSCloseLoopEventTask.js b/policy/apex/logic/GetBBSCloseLoopEventTask.js new file mode 100644 index 0000000..3de6340 --- /dev/null +++ b/policy/apex/logic/GetBBSCloseLoopEventTask.js @@ -0,0 +1,113 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info("Begin Execution GetBBSCloseLoopEventTask.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); +var returnValue = true; + +var clEventType = org.onap.policy.controlloop.VirtualControlLoopEvent; +var clEvent = executor.inFields.get("VirtualControlLoopEvent"); +executor.logger.info(clEvent.toString()); +executor.logger.info(clEvent.getClosedLoopControlName()); + +var requestID = clEvent.getRequestId(); +executor.logger.info("requestID = " + requestID); +var attachmentPoint = null; +var NomadicONTContext = null; +var serviceInstanceId = null; + +if (clEvent.getAai().get("attachmentPoint") != null) { + attachmentPoint = clEvent.getAai().get("attachmentPoint"); + executor.logger.info("attachmentPoint = " + attachmentPoint); + NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( + attachmentPoint); + serviceInstanceId = clEvent.getAai().get( + "service-information.hsia-cfs-service-instance-id"); + executor.logger.info("serviceInstanceId = " + serviceInstanceId); + + if (NomadicONTContext == null) { + executor.logger.info( + "Creating context information for new ONT Device \"" + + attachmentPoint.toString() + "\""); + + NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").getSchemaHelper() + .createNewInstance(); + + NomadicONTContext.put("closedLoopControlName", clEvent.getClosedLoopControlName()); + NomadicONTContext.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart() + .toEpochMilli()); + NomadicONTContext.put("closedLoopEventClient", clEvent.getClosedLoopEventClient()); + NomadicONTContext.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus() + .toString()); + NomadicONTContext.put("version", clEvent.getVersion()); + NomadicONTContext.put("requestID", clEvent.getRequestId().toString()); + NomadicONTContext.put("target_type", clEvent.getTargetType().toString()); + NomadicONTContext.put("target", clEvent.getTarget()); + NomadicONTContext.put("from", clEvent.getFrom()); + NomadicONTContext.put("policyScope", "Nomadic ONT"); + NomadicONTContext.put("policyName", clEvent.getPolicyName()); + NomadicONTContext.put("policyVersion", "1.0.2"); + NomadicONTContext.put("notificationTime", java.lang.System.currentTimeMillis()); + NomadicONTContext.put("message", ""); + NomadicONTContext.put("result", "SUCCESS"); + var aaiInfo = executor.getContextAlbum("NomadicONTContextAlbum").getSchemaHelper() + .createNewSubInstance("VCPE_AAI_Type"); + + aaiInfo.put("attachmentPoint", clEvent.getAai().get("attachmentPoint")); + aaiInfo.put("cvlan", clEvent.getAai().get("cvlan")); + aaiInfo.put("service_information_hsia_cfs_service_instance_id", clEvent + .getAai().get( + "service-information.hsia-cfs-service-instance-id")); + aaiInfo.put("svlan", clEvent.getAai().get("svlan")); + aaiInfo.put("remoteId", clEvent.getAai().get("remoteId")); + + + NomadicONTContext.put("AAI", aaiInfo); + + if (clEvent.getClosedLoopAlarmEnd() != null) { + NomadicONTContext.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd() + .toEpochMilli()); + } else { + NomadicONTContext.put("closedLoopAlarmEnd", java.lang.Long.valueOf( + 0)); + } + + executor.getContextAlbum("NomadicONTContextAlbum").put(attachmentPoint.toString(), + NomadicONTContext); + executor.logger.info("Created context information for new vCPE VNF \"" + + attachmentPoint.toString() + "\""); + } + + executor.outFields.put("requestID", requestID); + executor.outFields.put("attachmentPoint", attachmentPoint); + executor.outFields.put("serviceInstanceId", serviceInstanceId); + executor.logger.info(executor.outFields); + executor.logger.info("Event Successfully Received and stored in album"); +} +else +{ + executor.message = "Received NULL attachment-point"; + returnValue = false; +} + +returnValue; + diff --git a/policy/apex/logic/NomadicEventSuccessTask.js b/policy/apex/logic/NomadicEventSuccessTask.js new file mode 100644 index 0000000..1723410 --- /dev/null +++ b/policy/apex/logic/NomadicEventSuccessTask.js @@ -0,0 +1,47 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info("Begin Execution NomadicEventSuccess.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var attachmentPoint = executor.inFields.get("attachmentPoint"); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( + attachmentPoint); + +executor.logger.info(executor.outFields); +executor.logger.info(executor.inFields); + +result = NomadicONTContext.get("result"); +var returnValue = true; + +if (result == "SUCCESS") { + executor.outFields.put("result", "SUCCCESS"); + executor.logger.info("BBS policy Execution Done"); +} else { + executor.logger.info("BBS policy Execution Failed"); + executor.outFields.put("result", "FAILURE"); + returnValue = false; +} + +executor.logger.info("End Execution NomadicEventSuccess.js"); + +returnValue; diff --git a/policy/apex/logic/RUorInitStateSelect.js b/policy/apex/logic/RUorInitStateSelect.js new file mode 100644 index 0000000..04a36cd --- /dev/null +++ b/policy/apex/logic/RUorInitStateSelect.js @@ -0,0 +1,44 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +executor.logger.info("Begin Execution RUorInitStateSelect.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var result = null; + +var attachmentPoint = executor.inFields.get("attachmentPoint"); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( + attachmentPoint); + +result = NomadicONTContext.get("result"); + +if (result == "SUCCESS") { + executor.subject.getTaskKey("SdncResourceUpdateTask").copyTo(executor.selectedTask); +} else { + executor.subject.getTaskKey("ErrorAAIServiceAssignedLogTask").copyTo( + executor.selectedTask); + onsetFlag = executor.isFalse; +} + +executor.logger.info("State Selected Task:" + executor.selectedTask); +executor.logger.info("End Execution RUorInitStateSelect.js"); + +true; diff --git a/policy/apex/logic/SU2orInitStateSelect.js b/policy/apex/logic/SU2orInitStateSelect.js new file mode 100644 index 0000000..eafbe92 --- /dev/null +++ b/policy/apex/logic/SU2orInitStateSelect.js @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +executor.logger.info("Begin Execution SU2orInitStateSelect.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var result = null; + +var attachmentPoint = executor.inFields.get("attachmentPoint"); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( + attachmentPoint); + +executor.logger.info(executor.inFields); + +result = NomadicONTContext.get("result"); + +if (result == "SUCCESS") { + executor.subject.getTaskKey("AAIServiceCreateTask").copyTo(executor.selectedTask); +} else { + executor.subject.getTaskKey("SdncResourceUpdateErrorLogOutput").copyTo( + executor.selectedTask); + onsetFlag = executor.isFalse; +} + +executor.logger.info("State Selected Task:" + executor.selectedTask); +executor.logger.info("End Execution SU2orInitStateSelect.js"); + +true; diff --git a/policy/apex/logic/SdncResourceUpdateTask.js b/policy/apex/logic/SdncResourceUpdateTask.js new file mode 100644 index 0000000..0d1bcd2 --- /dev/null +++ b/policy/apex/logic/SdncResourceUpdateTask.js @@ -0,0 +1,470 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info("Begin Execution SdncResourceUpdateTask.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var attachmentPoint = executor.inFields.get("attachmentPoint"); +var requestID = executor.inFields.get("requestID"); +var serviceInstanceId = executor.inFields.get("serviceInstanceId"); +var uuidType = java.util.UUID; + +var wbClient = org.onap.policy.apex.examples.bbs.WebClient; +var client = new wbClient(); + +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); +var sdncUUID = uuidType.randomUUID(); +executor.logger.info(NomadicONTContext); +var jsonObj; +var aaiUpdateResult = true; +var SDNC_URL = "localhost:8080"; +var HTTP_PROTOCOL = "https://" +var SVC_NOTIFICATION_URL; +var putUpddateServInstance = JSON.parse(NomadicONTContext.get("aai_message")); +var aaiData = JSON.parse(NomadicONTContext.get("AAI")); +var input_param = JSON.parse(putUpddateServInstance['input-parameters']); +SDNC_URL = executor.parameters.get("SDNC_URL"); +SVC_NOTIFICATION_URL = executor.parameters.get("SVC_NOTIFICATION_URL"); +SDNC_USERNAME = executor.parameters.get("SDNC_USERNAME"); +SDNC_PASSWORD = executor.parameters.get("SDNC_PASSWORD"); +executor.logger.info("SDNC_URL " + SDNC_URL); + +var result; +var jsonObj; +var sdncUpdateResult = true; + +/* BBS Policy calls SDN-C GR-API to delete AccessConnectivity VF ID */ +/* Prepare Data */ +var xmlDeleteAccess = + "<input xmlns=\"org:onap:sdnc:northbound:generic-resource\">\n" + + "<sdnc-request-header>\n" + + "<svc-request-id>svc_request_id_value</svc-request-id>\n" + + "<svc-action>delete</svc-action>\n" + + "<svc-notification-url>svc_notification_url_value</svc-notification-url>\n" + + "</sdnc-request-header>\n" + + "<request-information>\n" + + "<request-id>request_id_value</request-id>\n" + + "<request-action>DeleteAccessConnectivityInstance</request-action>\n" + + "<source>null</source>\n" + + "<notification-url></notification-url>\n" + + "<order-number></order-number>\n" + + "<order-version></order-version>\n" + + "</request-information>\n" + + "<service-information>\n" + + "<service-id>service_id_value</service-id>\n" + + "<service-instance-id>service_instance_id_value</service-instance-id>\n" + + "<subscription-service-type>service_type_value</subscription-service-type>\n" + + "<global-customer-id>customer_id_value</global-customer-id>\n" + + "<subscriber-name>customer_name_value</subscriber-name>\n" + + "<onap-model-information>\n" + + "<model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>\n" + + "<model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>\n" + + "<model-uuid>srv_info_model_uuid_value</model-uuid>\n" + + "<model-name>srv_info_model_name_value</model-name>\n" + + "</onap-model-information>\n" + + "</service-information>\n" + + "<vnf-information>\n" + + "<onap-model-information>\n" + + "<model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>\n" + + "<model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>\n" + + "<model-uuid>network_info_model_uuid_value</model-uuid>\n" + + "<model-name>network_info_model_name_value</model-name>\n" + + "</onap-model-information>\n" + + "</vnf-information>\n" + + "<vnf-request-input>\n" + + "<vnf-input-parameters>\n" + + "<param>\n" + + "<name>manufacturer</name>\n" + + "<value>vendor_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>serviceID</name>\n" + + "<value>service_id_value</value>\n" + + "</param>\n" + + "</vnf-input-parameters>\n" + + "</vnf-request-input>\n" + + "</input>\n"; + +/* BBS Policy calls SDN-C GR-API to delete AccessConnectivity */ +xmlDeleteAccess = xmlDeleteAccess.replace("svc_request_id_value", sdncUUID); +xmlDeleteAccess = xmlDeleteAccess.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); +xmlDeleteAccess = xmlDeleteAccess.replace("request_id_value", sdncUUID); +xmlDeleteAccess = xmlDeleteAccess.replace("service_id_value", sdncUUID); +xmlDeleteAccess = xmlDeleteAccess.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlDeleteAccess = xmlDeleteAccess.replace("service_type_value", input_param['service']['serviceType']); +xmlDeleteAccess = xmlDeleteAccess.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlDeleteAccess = xmlDeleteAccess.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_name_value", "AccessConnectivity"); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_name_value", "AccessConnectivity"); + +xmlDeleteAccess = xmlDeleteAccess.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlDeleteAccess = xmlDeleteAccess.replace("service_id_value", getMetaValue( + putUpddateServInstance['metadata']['metadatum'], 'controller-service-id')); +executor.logger.info(client.toPrettyString(xmlDeleteAccess, 4)); + +try { + var urlPost1 = HTTP_PROTOCOL + SDNC_URL + "/restconf/operations/GENERIC-RESOURCE-API:vnf-topology-operation"; + result = client.httpRequest(urlPost1, "POST", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml"); + executor.logger.info("Data received From " + urlPost1 + " " + result); + if (result == "") { + sdncUpdateResult = false; + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + sdncUpdateResult = false; +} + +/* BBS Policy calls SDN-C GR-API to create new AccessConnectivity VF */ + +/* Prepare Data */ +var xmlCreateAccess = + "<input xmlns=\"org:onap:sdnc:northbound:generic-resource\">\n" + + "<sdnc-request-header>\n" + + "<svc-request-id>svc_request_id_value</svc-request-id>\n" + + "<svc-action>create</svc-action>\n" + + "<svc-notification-url>svc_notification_url_value</svc-notification-url>\n" + + "</sdnc-request-header>\n" + + "<request-information>\n" + + "<request-id>request_id_value</request-id>\n" + + "<request-action>CreateAccessConnectivityInstance</request-action>\n" + + "<source>null</source>\n" + + "<notification-url></notification-url>\n" + + "<order-number></order-number>\n" + + "<order-version></order-version>\n" + + "</request-information>\n" + + "<service-information>\n" + + "<service-id>service_id_value</service-id>\n" + + "<service-instance-id>service_instance_id_value</service-instance-id>\n" + + "<subscription-service-type>service_type_value</subscription-service-type>\n" + + "<global-customer-id>customer_id_value</global-customer-id>\n" + + "<subscriber-name>customer_name_value</subscriber-name>\n" + + "<onap-model-information>\n" + + "<model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>\n" + + "<model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>\n" + + "<model-uuid>srv_info_model_uuid_value</model-uuid>\n" + + "<model-name>srv_info_model_name_value</model-name>\n" + + "</onap-model-information>\n" + + "</service-information>\n" + + "<vnf-information>\n" + + "<onap-model-information>\n" + + "<model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>\n" + + "<model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>\n" + + "<model-uuid>network_info_model_uuid_value</model-uuid>\n" + + "<model-name>network_info_model_name_value</model-name>\n" + + "</onap-model-information>\n" + + "</vnf-information>\n" + + "<vnf-request-input>\n" + + "<vnf-input-parameters>\n" + + "<param>\n" + + "<name>manufacturer</name>\n" + + "<value>vendor_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>ONTSN</name>\n" + + "<value>ont_sn_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>CVLAN</name>\n" + + "<value>c_vlan_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>SVLAN</name>\n" + + "<value>s_vlan_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>remote_id</name>\n" + + "<value>remote_id_value</value>\n" + + "</param>" + + "</vnf-input-parameters>\n" + + "</vnf-request-input>\n" + + "</input>\n"; + +xmlCreateAccess = xmlCreateAccess.replace("svc_request_id_value", sdncUUID); +xmlCreateAccess = xmlCreateAccess.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); +xmlCreateAccess = xmlCreateAccess.replace("request_id_value", requestID); +xmlCreateAccess = xmlCreateAccess.replace("service_id_value", sdncUUID); +xmlCreateAccess = xmlCreateAccess.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlCreateAccess = xmlCreateAccess.replace("service_type_value", input_param['service']['serviceType']); +xmlCreateAccess = xmlCreateAccess.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlCreateAccess = xmlCreateAccess.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", "AccessConnectivity"); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", "AccessConnectivity"); + +xmlCreateAccess = xmlCreateAccess.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlCreateAccess = xmlCreateAccess.replace("ont_sn_value", + input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']); +xmlCreateAccess = xmlCreateAccess.replace("s_vlan_value", aaiData["svlan"]); +xmlCreateAccess = xmlCreateAccess.replace("c_vlan_value", aaiData["cvlan"]); +xmlCreateAccess = xmlCreateAccess.replace("remote_id_value", aaiData["remoteId"]); + + +executor.logger.info(client.toPrettyString(xmlCreateAccess, 4)); + +try { + if (sdncUpdateResult == true) { + var urlPost2 = HTTP_PROTOCOL + SDNC_URL + + "/restconf/operations/GENERIC-RESOURCE-API:vnf-topology-operation"; + result = client.httpRequest(urlPost2, "POST", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml"); + executor.logger.info("Data received From " + urlPost2 + " " + result); + if (result == "") { + sdncUpdateResult = false; + } + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + sdncUpdateResult = false; +} + +/* BBS Policy calls SDN-C GR-API to create change Internet Profile */ +var xmlChangeProfile = + "<input xmlns=\"org:onap:sdnc:northbound:generic-resource\">\n" + + "<sdnc-request-header>\n" + + "<svc-request-id>svc_request_id_value</svc-request-id>\n" + + "<svc-action>update</svc-action>\n" + + "<svc-notification-url>svc_notification_url_value</svc-notification-url>\n" + + "</sdnc-request-header>\n" + + "<request-information>\n" + + "<request-id>request_id_value</request-id>\n" + + "<request-action>ChangeInternetProfileInstance</request-action>\n" + + "<source>null</source>\n" + + "<notification-url></notification-url>\n" + + "<order-number></order-number>\n" + + "<order-version></order-version>\n" + + "</request-information>\n" + + "<service-information>\n" + + "<service-id>service_id_value</service-id>\n" + + "<service-instance-id>service_instance_id_value</service-instance-id>\n" + + "<subscription-service-type>service_type_value</subscription-service-type>\n" + + "<global-customer-id>customer_id_value</global-customer-id>\n" + + "<subscriber-name>customer_name_value</subscriber-name>\n" + + "<onap-model-information>\n" + + "<model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>\n" + + "<model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>\n" + + "<model-uuid>srv_info_model_uuid_value</model-uuid>\n" + + "<model-name>srv_info_model_name_value</model-name>\n" + + "</onap-model-information>\n" + + "</service-information>\n" + + "<vnf-information>\n" + + "<onap-model-information>\n" + + "<model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>\n" + + "<model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>\n" + + "<model-uuid>network_info_model_uuid_value</model-uuid>\n" + + "<model-name>network_info_model_name_value</model-name>\n" + + "</onap-model-information>\n" + + "</vnf-information>\n" + + "<vnf-request-input>\n" + + "<vnf-input-parameters>\n" + + "<param>\n" + + "<name>manufacturer</name>\n" + + "<value>vendor_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>service_id</name>\n" + + "<value>service_id_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>ip_remote_id</name>\n" + + "<value>remote_id_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>ont_sn</name>\n" + + "<value>ont_sn_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>ip_service_type</name>\n" + + "<value>service_type_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>ip_rg_mac_addr</name>\n" + + "<value>mac_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>ip_upstream_speed</name>\n" + + "<value>up_speed_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>ip_downstream_speed</name>\n" + + "<value>down_speed_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>s_vlan</name>\n" + + "<value>s_vlan_value</value>\n" + + "</param>\n" + + "<param>\n" + + "<name>c_vlan</name>\n" + + "<value>c_vlan_value</value>\n" + + "</param>\n" + + "</vnf-input-parameters>\n" + + "</vnf-request-input>\n" + + "</input>\n"; + +xmlChangeProfile = xmlChangeProfile.replace("svc_request_id_value", sdncUUID); +xmlChangeProfile = xmlChangeProfile.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); +xmlChangeProfile = xmlChangeProfile.replace("request_id_value", requestID); +xmlChangeProfile = xmlChangeProfile.replace("service_id_value", sdncUUID); +xmlChangeProfile = xmlChangeProfile.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param['service']['serviceType']); +xmlChangeProfile = xmlChangeProfile.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlChangeProfile = xmlChangeProfile.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlChangeProfile = xmlChangeProfile.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlChangeProfile = xmlChangeProfile.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlChangeProfile = xmlChangeProfile.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlChangeProfile = xmlChangeProfile.replace("srv_info_model_name_value", "InternetProfile"); +xmlChangeProfile = xmlChangeProfile.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlChangeProfile = xmlChangeProfile.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlChangeProfile = xmlChangeProfile.replace("network_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlChangeProfile = xmlChangeProfile.replace("network_info_model_name_value", "InternetProfile"); + +xmlChangeProfile = xmlChangeProfile.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlChangeProfile = xmlChangeProfile.replace("service_id_value", getMetaValue( + putUpddateServInstance['metadata']['metadatum'], 'controller-service-id')); +xmlChangeProfile = xmlChangeProfile.replace("ont_sn_value", + input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']); +xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param['service']['serviceType']); +xmlChangeProfile = xmlChangeProfile.replace("mac_value", getMetaValue(putUpddateServInstance['metadata']['metadatum'], + 'rgw-mac-address')); +xmlChangeProfile = xmlChangeProfile.replace("up_speed_value", getMetaValue( + putUpddateServInstance['metadata']['metadatum'], 'up-speed')); +xmlChangeProfile = xmlChangeProfile.replace("down_speed_value", getMetaValue( + putUpddateServInstance['metadata']['metadatum'], 'down-speed')); +xmlChangeProfile = xmlChangeProfile.replace("s_vlan_value", aaiData["svlan"]); +xmlChangeProfile = xmlChangeProfile.replace("c_vlan_value", aaiData["cvlan"]); +xmlChangeProfile = xmlChangeProfile.replace("remote_id_value", aaiData["remoteId"]); + +executor.logger.info(client.toPrettyString(xmlChangeProfile, 4)); +try { + if (sdncUpdateResult == true) { + var urlPost3 = HTTP_PROTOCOL + SDNC_URL + + "/restconf/operations/GENERIC-RESOURCE-API:vnf-topology-operation"; + result = client + .httpRequest(urlPost3, "POST", xmlChangeProfile, SDNC_USERNAME, SDNC_PASSWORD, "application/xml"); + executor.logger.info("Data received From " + urlPost3 + " " + result); + if (result == "") { + sdncUpdateResult = false; + } + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + sdncUpdateResult = false; +} + +/* If Success then Fill output schema */ + +if (sdncUpdateResult == true) { + NomadicONTContext.put("result", "SUCCESS"); + executor.outFields.put("result", "SUCCESS"); +} else { + NomadicONTContext.put("result", "FAILURE"); + executor.outFields.put("result", "FAILURE"); +} + +executor.outFields.put("requestID", requestID); +executor.outFields.put("attachmentPoint", attachmentPoint); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); + +executor.logger.info(executor.outFields); +executor.logger.info("End Execution SdncResourceUpdateTask.js"); + +true; + +function getMetaValue(metaJson, metaname) { + for (var i = 0; i < metaJson.length; i++) { + if (metaJson[i]['metaname'] == metaname) { + return metaJson[i]['metaval']; + } + } + +} + +function getResourceInvariantUuid(resJson, resourceName) { + for (var i = 0; i < resJson.length; i++) { + if (resJson[i]['resourceName'] == resourceName) { + return resJson[i]['resourceInvariantUuid']; + } + } + +} + +function getResourceUuid(resJson, resourceName) { + for (var i = 0; i < resJson.length; i++) { + if (resJson[i]['resourceName'] == resourceName) { + return resJson[i]['resourceUuid']; + } + } + +} + +function getResourceCustomizationUuid(resJson, resourceName) { + for (var i = 0; i < resJson.length; i++) { + if (resJson[i]['resourceName'] == resourceName) { + return resJson[i]['resourceCustomizationUuid']; + } + } + +} + +/* Utility functions Begin */ +function IsValidJSONString(str) { + try { + JSON.parse(str); + } catch (e) { + return false; + } + return true; +} +/* Utility functions End */
\ No newline at end of file diff --git a/policy/apex/logic/ServiceUpdateStateCpeAuthTask.js b/policy/apex/logic/ServiceUpdateStateCpeAuthTask.js new file mode 100644 index 0000000..b6b2c91 --- /dev/null +++ b/policy/apex/logic/ServiceUpdateStateCpeAuthTask.js @@ -0,0 +1,118 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info("Begin Execution ServiceUpdateStateCpeAuthTask.js"); +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var clEventType = org.onap.policy.controlloop.VirtualControlLoopEvent; +var clEvent = executor.inFields.get("VirtualControlLoopEvent"); + +var serviceInstanceId = clEvent.getAai().get("service-information.hsia-cfs-service-instance-id"); +var requestID = clEvent.getRequestId(); + +var jsonObj; +var aaiUpdateResult = true; +var wbClient = org.onap.policy.apex.examples.bbs.WebClient; +var client = new wbClient(); +var oldState = clEvent.getAai().get("cpe.old-authentication-state"); +var newState = clEvent.getAai().get("cpe.new-authentication-state"); +executor.logger.info("New CPE Authentication State: " + newState); +/* Get AAI URL from Configuration file. */ +var AAI_URL = "localhost:8080"; +var CUSTOMER_ID = requestID; +var SERVICE_INSTANCE_ID = serviceInstanceId; +var resource_version; +var HTTP_PROTOCOL = "https://"; +var results; +var putUrl; +var service_instance; +var AAI_VERSION = "v14"; + +AAI_URL = executor.parameters.get("AAI_URL"); +AAI_USERNAME = executor.parameters.get("AAI_USERNAME"); +AAI_PASSWORD = executor.parameters.get("AAI_PASSWORD"); +AAI_VERSION = executor.parameters.get("AAI_VERSION"); + +executor.logger.info("AAI_URL=>" + AAI_URL); + +/* Get service instance Id from AAI */ +try { + var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + + SERVICE_INSTANCE_ID + "?format=resource_and_url" + executor.logger.info("Query url: " + urlGet); + + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json"); + executor.logger.info("Data received From " + urlGet + " " + result); + jsonObj = JSON.parse(result); + + /* Retrieve the service instance id */ + results = jsonObj['results'][0]; + putUrl = results["url"]; + service_instance = results['service-instance']; + resource_version = service_instance['resource-version']; + executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url " + + putUrl + "\n Service instace Id " + SERVICE_INSTANCE_ID); + + if (result == "") { + aaiUpdateResult = false; + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + aaiUpdateResult = false; +} + +/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */ +var putUpddateServInstance; +putUpddateServInstance = service_instance; + +if (newState == 'inService') { + putUpddateServInstance['orchestration-status'] = "active"; +} else { + putUpddateServInstance['orchestration-status'] = "inActive"; +} +try { + if (aaiUpdateResult == true) { + executor.logger.info("ready to put After Parse " + JSON.stringify(putUpddateServInstance, null, 4)); + var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json"); + executor.logger.info("Data received From " + urlPut + " " + result); + /* If failure to retrieve data proceed to Failure */ + if (result != "") { + aaiUpdateResult = false; + } + } +} catch (err) { + executor.logger.info("Failed to retrieve data " + err); + aaiUpdateResult = false; +} + +if (aaiUpdateResult == true) { + executor.outFields.put("result", "SUCCCESS"); +} else { + executor.outFields.put("result", "FAILURE"); +} + +executor.logger.info(executor.outFields); +executor.logger.info("End Execution ServiceUpdateStateCpeAuthTask.js"); + +true; |