From 811f5bcdb3af8e8a0f053ad9b41a12e7b1cf11ed Mon Sep 17 00:00:00 2001 From: TeoV Date: Thu, 17 Jan 2019 10:31:30 -0500 Subject: [PATCH] Update Agent Request to rewrite in case of *variable type --- agents/agentreq.go | 2 +- data/conf/samples/diamsctpagent/dryrun.json | 37 ++++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/agents/agentreq.go b/agents/agentreq.go index 4009ca7e0..39ec418b3 100644 --- a/agents/agentreq.go +++ b/agents/agentreq.go @@ -158,8 +158,8 @@ func (ar *AgentRequest) AsNavigableMap(tplFlds []*config.FCTemplate) ( } *nMItm = *prevNMItem // inherit the particularities, ie AttributeName nMItm.Data = prevDataStr + outStr - valSet = valSet[:len(valSet)-1] // discard the last item } + valSet = valSet[:len(valSet)-1] // discard the last item } valSet = append(valSet, nMItm) nM.Set(fldPath, valSet, false, true) diff --git a/data/conf/samples/diamsctpagent/dryrun.json b/data/conf/samples/diamsctpagent/dryrun.json index 927f58ad5..4e3e78df3 100755 --- a/data/conf/samples/diamsctpagent/dryrun.json +++ b/data/conf/samples/diamsctpagent/dryrun.json @@ -2,11 +2,11 @@ "diameter_agent": { "request_processors": [ - { "id": "dryrun1", "filters": ["*string:*vars.*cmd:CCR", "*string:*req.Service-Context-Id:TestDiamItDryRun"], "flags": ["*dryrun"], + "continue_on_success": true, "request_fields":[ {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, @@ -33,14 +33,41 @@ "type": "*constant", "value": "1"}, {"tag": "CCTotalOctets1", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", "type": "*variable", "value": "~*cgreq.UsedUnits1"}, - {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", "value": "2","new_branch": true}, - {"tag": "CCTotalOctets2", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", "value": "~*cgreq.UsedUnits2"}, {"tag": "GrantedUsage", "field_id": "Granted-Service-Unit.CC-Time", "type": "*sum", "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"}, ], }, + { + "id": "dryrun2", + "filters": ["*rsr::~*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[0](!^$)"], // make sure the CC-Total-Octets was populated in the previous processor + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + {"tag": "Val1", "field_id": "Val1", "type": "*constant", "value": "1"}, + {"tag": "Val2", "field_id": "Val2", "type": "*constant", "value": "2"}, + {"tag": "Val3", "field_id": "Val3", "type": "*constant", "value": "3"}, + {"tag": "OptionalField", "field_id":"OptionalField", "type":"*composed", + "value":"~*req.Inexistent", "mandatory":false}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", + "type": "*constant", "value": "*prepaid"}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"tag": "UsedUnits1", "field_id": "UsedUnits1", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"}, + {"tag": "UsedUnits2", "field_id": "UsedUnits2", "type": "*composed", "mandatory": true, + "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"}, + + ], + "reply_fields":[ + {"tag": "RatingGroup", "field_id": "Multiple-Services-Credit-Control.Rating-Group", + "type": "*constant", "value": "2","new_branch": true}, + {"tag": "CCTotalOctets2", "field_id": "Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", + "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + ], + }, + ], },