From 2bfbdc2c8e8e1f24e9c6e764f61e6e988a4254cc Mon Sep 17 00:00:00 2001 From: DanB Date: Wed, 30 May 2018 15:26:32 +0200 Subject: [PATCH] Diameter processing request flags --- agents/dmtagent.go | 4 ++++ agents/librad_test.go | 12 +++++++++++- data/conf/samples/dmtagent/voice.json | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/agents/dmtagent.go b/agents/dmtagent.go index 8d3a24153..9869022b8 100644 --- a/agents/dmtagent.go +++ b/agents/dmtagent.go @@ -96,6 +96,7 @@ func (da DiameterAgent) processCCR(ccr *CCR, reqProcessor *config.DARequestProce } if !reqProcessor.AppendCCA { *cca = *NewBareCCAFromCCR(ccr, da.cgrCfg.DiameterAgentCfg().OriginHost, da.cgrCfg.DiameterAgentCfg().OriginRealm) + procVars = make(processorVars) } smgEv, err := ccr.AsSMGenericEvent(reqProcessor.CCRFields) if err != nil { @@ -110,6 +111,9 @@ func (da DiameterAgent) processCCR(ccr *CCR, reqProcessor *config.DARequestProce } if len(reqProcessor.Flags) != 0 { smgEv[utils.CGRFlags] = reqProcessor.Flags.String() // Populate CGRFlags automatically + for flag, val := range reqProcessor.Flags { + procVars[flag] = val + } } if reqProcessor.PublishEvent && da.pubsubs != nil { evt, err := smgEv.AsMapStringString() diff --git a/agents/librad_test.go b/agents/librad_test.go index df45393b8..e3d5d0c9d 100644 --- a/agents/librad_test.go +++ b/agents/librad_test.go @@ -289,7 +289,6 @@ func TestPVAsV1AuthorizeArgs(t *testing.T) { CGREvent: *cgrEv, } outVal := processorVars{MetaRadReqType: MetaRadAcctStart}.asV1AuthorizeArgs(cgrEv) - if !reflect.DeepEqual(expected, outVal) { t.Errorf("Expecting: <%s>, received: <%s>", utils.ToJSON(expected), utils.ToJSON(outVal)) } @@ -323,6 +322,17 @@ func TestPVAsV1InitSessionArgs(t *testing.T) { if !reflect.DeepEqual(expected, outVal) { t.Errorf("Expecting: <%s>, received: <%s>", utils.ToJSON(expected), utils.ToJSON(outVal)) } + eInitArgs := &sessions.V1InitSessionArgs{ + InitSession: false, + AllocateResources: true, + GetAttributes: true, + CGREvent: *cgrEv, + } + initArgs := processorVars{MetaRadReqType: MetaRadAcctStart, utils.MetaResources: true, + utils.MetaAttributes: true}.asV1InitSessionArgs(cgrEv) + if !reflect.DeepEqual(eInitArgs, initArgs) { + t.Errorf("expecting: %+v, received: %+v", eInitArgs, initArgs) + } } func TestPVAsV1UpdateSessionArgs(t *testing.T) { diff --git a/data/conf/samples/dmtagent/voice.json b/data/conf/samples/dmtagent/voice.json index 3ac832d34..0c53c09f9 100644 --- a/data/conf/samples/dmtagent/voice.json +++ b/data/conf/samples/dmtagent/voice.json @@ -7,7 +7,7 @@ "id": "VoiceInit", // formal identifier of this processor "dry_run": false, // do not send the events to SMG, just log them "request_filter": "Service-Context-Id(^voice);CC-Request-Type(1)", // filter requests processed by this processor - "continue_on_success": false, // continue to the next template if executed + "flags": ["*accounts"], "ccr_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "^*voice", "mandatory": true}, {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "Session-Id", "mandatory": true}, @@ -38,7 +38,7 @@ "id": "VoiceUpdate", // formal identifier of this processor "dry_run": false, // do not send the events to SMG, just log them "request_filter": "Service-Context-Id(^voice);CC-Request-Type(2)", // filter requests processed by this processor - "continue_on_success": false, // continue to the next template if executed + "flags": ["*accounts"], "ccr_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "^*voice", "mandatory": true}, {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "Session-Id", "mandatory": true}, @@ -64,7 +64,7 @@ "id": "VoiceTerminate", // formal identifier of this processor "dry_run": false, // do not send the events to SMG, just log them "request_filter": "Service-Context-Id(^voice);CC-Request-Type(3)", // filter requests processed by this processor - "continue_on_success": false, // continue to the next template if executed + "flags": ["*accounts"], "ccr_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "^*voice", "mandatory": true}, {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "Session-Id", "mandatory": true},