Diameter - SIMPA Event handling, own simpa.json sample config, tutorial files modified to add rate for generic category

This commit is contained in:
DanB
2016-02-22 16:58:14 +01:00
parent 610f3925fa
commit 4c0556f6c7
7 changed files with 10 additions and 5 deletions

View File

@@ -604,8 +604,8 @@ func TestDmtAgentSendCCRSimpaEvent(t *testing.T) {
t.Error(err)
} else if len(avps) == 0 {
t.Error("Result-Code")
} else if strResult := avpValAsString(avps[0]); strResult != "5030" { // Result-Code set in the template
t.Errorf("Expecting 5030, received: %s", strResult)
} else if strResult := avpValAsString(avps[0]); strResult != "2001" { // Result-Code set in the template
t.Errorf("Expecting 2001, received: %s", strResult)
}
}

View File

@@ -216,6 +216,8 @@ func metaHandler(m *diam.Message, tag, arg string, dur time.Duration) (string, e
return "", nil
}
// metaValueExponent will multiply the float value with the exponent provided.
// Expects 2 arguments in template separated by |
func metaValueExponent(m *diam.Message, argsTpl utils.RSRFields, roundingDecimals int) (string, error) {
valStr := composedFieldvalue(m, argsTpl, 0)
handlerArgs := strings.Split(valStr, utils.HandlerArgSep)

View File

@@ -6,7 +6,7 @@
{
"id": "simpa_event", // formal identifier of this processor
"dry_run": false, // do not send the events to SMG, just log them
"request_filter": "Service-Context-Id(^simpa);CC-RequestType(4)", // filter requests processed by this processor
"request_filter": "Service-Context-Id(^simpa);CC-Request-Type(4)", // filter requests processed by this processor
"continue_on_success": false, // continue to the next template if executed
"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": "^*generic", "mandatory": true},
@@ -14,10 +14,9 @@
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "^*prepaid", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "^*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "^cgrates.org", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "^call", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "^generic", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "Subscription-Id>Subscription-Id-Data", "field_filter":"Subscription-Id>Subscription-Id-Type(0)", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "Subscription-Id>Subscription-Id-Data", "field_filter":"Subscription-Id>Subscription-Id-Type(0)", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "Service-Information>SMS-Information>Recipient-Address>Address-Data", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "Event-Timestamp", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "Event-Timestamp", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*handler", "handler_id": "*value_exponent",

View File

@@ -8,3 +8,4 @@ DR_FS_10CNT,DST_FS,RT_10CNT,*up,4,0,
DR_SPECIAL_1002,DST_1002,RT_1CNT,*up,4,0,
DR_1007_MAXCOST_DISC,DST_1007,RT_1CNT_PER_SEC,*up,4,0.62,*disconnect
DR_1007_MAXCOST_FREE,DST_1007,RT_1CNT_PER_SEC,*up,4,0.62,*free
DR_GENERIC,*any,RT_GENERIC_1,*up,4,0,
1 #Id DestinationId RatesTag RoundingMethod RoundingDecimals MaxCost MaxCostStrategy
8 DR_SPECIAL_1002 DST_1002 RT_1CNT *up 4 0
9 DR_1007_MAXCOST_DISC DST_1007 RT_1CNT_PER_SEC *up 4 0.62 *disconnect
10 DR_1007_MAXCOST_FREE DST_1007 RT_1CNT_PER_SEC *up 4 0.62 *free
11 DR_GENERIC *any RT_GENERIC_1 *up 4 0

View File

@@ -7,3 +7,4 @@ RT_40CNT,0.8,0.4,60s,30s,0s
RT_40CNT,0,0.2,60s,10s,60s
RT_1CNT,0,0.01,60s,60s,0s
RT_1CNT_PER_SEC,0,0.01,1s,1s,0s
RT_GENERIC_1,0,1,1,1,0
1 #Id ConnectFee Rate RateUnit RateIncrement GroupIntervalStart
7 RT_40CNT 0 0.2 60s 10s 60s
8 RT_1CNT 0 0.01 60s 60s 0s
9 RT_1CNT_PER_SEC 0 0.01 1s 1s 0s
10 RT_GENERIC_1 0 1 1 1 0

View File

@@ -18,3 +18,4 @@ RP_RETAIL2,DR_FS_10CNT,OFFPEAK_EVENING,10
RP_RETAIL2,DR_FS_10CNT,OFFPEAK_WEEKEND,10
RP_RETAIL2,DR_1007_MAXCOST_FREE,ALWAYS,10
RP_SPECIAL_1002,DR_SPECIAL_1002,ALWAYS,10
RP_GENERIC,DR_GENERIC,*any,10
1 #Id DestinationRatesId TimingTag Weight
18 RP_RETAIL2 DR_FS_10CNT OFFPEAK_WEEKEND 10
19 RP_RETAIL2 DR_1007_MAXCOST_FREE ALWAYS 10
20 RP_SPECIAL_1002 DR_SPECIAL_1002 ALWAYS 10
21 RP_GENERIC DR_GENERIC *any 10

View File

@@ -7,3 +7,4 @@
*out,cgrates.org,lcr_profile2,suppl1,2014-01-14T00:00:00Z,RP_RETAIL2,,STATS_SUPPL1
*out,cgrates.org,lcr_profile2,suppl2,2014-01-14T00:00:00Z,RP_RETAIL1,,STATS_SUPPL2
*out,cgrates.org,lcr_profile2,suppl3,2014-01-14T00:00:00Z,RP_SPECIAL_1002,,
*out,cgrates.org,generic,*any,2014-01-14T00:00:00Z,RP_GENERIC,,
1 #Direction Tenant Category Subject ActivationTime RatingPlanId RatesFallbackSubject CdrStatQueueIds
7 *out cgrates.org lcr_profile2 suppl1 2014-01-14T00:00:00Z RP_RETAIL2 STATS_SUPPL1
8 *out cgrates.org lcr_profile2 suppl2 2014-01-14T00:00:00Z RP_RETAIL1 STATS_SUPPL2
9 *out cgrates.org lcr_profile2 suppl3 2014-01-14T00:00:00Z RP_SPECIAL_1002
10 *out cgrates.org generic *any 2014-01-14T00:00:00Z RP_GENERIC