diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index d140ac761..525cebb98 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -189,6 +189,17 @@ func testDiamItResetAllDB(t *testing.T) { if err := engine.InitStorDb(allCfg); err != nil { t.Fatal(err) } + cfgPath2 := path.Join(*dataDir, "conf", "samples", "dispatchers", "all2") + allCfg2, err := config.NewCGRConfigFromPath(cfgPath2) + if err != nil { + t.Fatal(err) + } + if err := engine.InitDataDb(allCfg2); err != nil { + t.Fatal(err) + } + if err := engine.InitStorDb(allCfg2); err != nil { + t.Fatal(err) + } } // Remove data in both rating and accounting db diff --git a/data/conf/samples/diamsctpagent_internal/voice.json b/data/conf/samples/diamsctpagent_internal/voice.json index 400d32aac..56eabd09b 100755 --- a/data/conf/samples/diamsctpagent_internal/voice.json +++ b/data/conf/samples/diamsctpagent_internal/voice.json @@ -102,6 +102,105 @@ }, ], }, + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", diff --git a/data/conf/samples/diamsctpagent_mongo/voice.json b/data/conf/samples/diamsctpagent_mongo/voice.json index 400d32aac..56eabd09b 100755 --- a/data/conf/samples/diamsctpagent_mongo/voice.json +++ b/data/conf/samples/diamsctpagent_mongo/voice.json @@ -102,6 +102,105 @@ }, ], }, + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", diff --git a/data/conf/samples/diamsctpagent_mysql/voice.json b/data/conf/samples/diamsctpagent_mysql/voice.json index 400d32aac..56eabd09b 100755 --- a/data/conf/samples/diamsctpagent_mysql/voice.json +++ b/data/conf/samples/diamsctpagent_mysql/voice.json @@ -102,6 +102,105 @@ }, ], }, + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, { "id": "VoiceInit", "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", diff --git a/data/conf/samples/dispatchers/diamagent/voice.json b/data/conf/samples/dispatchers/diamagent/voice.json index bbd070ee2..7cfc52e94 100644 --- a/data/conf/samples/dispatchers/diamagent/voice.json +++ b/data/conf/samples/dispatchers/diamagent/voice.json @@ -18,6 +18,117 @@ "type": "*constant", "value": "*voice" }, + { + "tag": "*api_key", + "path": "*cgreq.*api_key", + "type": "*constant", + "value": "ses12345" + }, + { + "tag": "OriginID", + "path": "*cgreq.OriginID", + "type": "*variable", + "value": "~*req.Session-Id", + "mandatory": true + }, + { + "tag": "OriginHost", + "path": "*cgreq.OriginHost", + "type": "*remote_host", + "mandatory": true + }, + { + "tag": "RequestType", + "path": "*cgreq.RequestType", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Category", + "path": "*cgreq.Category", + "type": "*constant", + "value": "call" + }, + { + "tag": "Account", + "path": "*cgreq.Account", + "type": "*constant", + "value": "*attributes" + }, + { + "tag": "Destination", + "path": "*cgreq.Destination", + "type": "*variable", + "value": "~*req.Service-Information.IN-Information.Real-Called-Number", + "mandatory": true + }, + { + "tag": "AnswerTime", + "path": "*cgreq.AnswerTime", + "type": "*variable", + "value": "~*req.Event-Timestamp", + "mandatory": true + }, + { + "tag": "Usage", + "path": "*cgreq.Usage", + "type": "*variable", + "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", + "mandatory": true + }, + { + "tag": "SubscriberID", + "path": "*cgreq.SubscriberId", + "type": "*variable", + "value": "~*req.Subscription-Id.Subscription-Id-Data", + "mandatory": true + }, + ], + "reply_fields":[ + { + "tag": "ResultCode", + "filters": ["*notempty:~*cgrep.Error:"], + "path": "*rep.Result-Code", + "type": "*constant", + "value": "5030", + "blocker": true + }, + { + "tag": "ResultCode", + "path": "*rep.Result-Code", + "type": "*constant", + "value": "2001" + }, + { + "tag": "GrantedUnits", + "path": "*rep.Granted-Service-Unit.CC-Time", + "type": "*variable", + "value": "~*cgrep.MaxUsage{*duration_seconds}", + "mandatory": true + }, + ], + }, + { + "id": "VoiceInitForceDuration", + "filters": [ + "*string:~*vars.*cmd:CCR", + "*string:~*req.CC-Request-Type:1", + "*prefix:~*req.Service-Context-Id:forceDurationVoice" + ], + "flags": ["*initiate", "*fd", "*accounts", "*attributes"], + "request_fields":[ + { + "tag": "ToR", + "path": "*cgreq.ToR", + "type": "*constant", + "value": "*voice" + }, + { + "tag": "*api_key", + "path": "*cgreq.*api_key", + "type": "*constant", + "value": "ses12345" + }, { "tag": "OriginID", "path": "*cgreq.OriginID",