mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
Update from cgr_supplier to cgr_route for Kamailio and Asterisk
This commit is contained in:
committed by
Dan Christian Bogos
parent
e7ecc05c73
commit
648aa5f3c4
@@ -38,7 +38,7 @@ import (
|
||||
const (
|
||||
CGRAuthAPP = "cgrates_auth"
|
||||
CGRMaxSessionTime = "CGRMaxSessionTime"
|
||||
CGRSupplier = "CGRSupplier"
|
||||
CGRRoute = "CGRRoute"
|
||||
ARIStasisStart = "StasisStart"
|
||||
ARIChannelStateChange = "ChannelStateChange"
|
||||
ARIChannelDestroyed = "ChannelDestroyed"
|
||||
@@ -211,7 +211,7 @@ func (sma *AsteriskAgent) handleStasisStart(ev *SMAsteriskEvent) {
|
||||
if authReply.Routes != nil {
|
||||
for i, route := range authReply.Routes.SortedRoutes {
|
||||
if !sma.setChannelVar(ev.ChannelID(),
|
||||
CGRSupplier+strconv.Itoa(i+1), route.RouteID) {
|
||||
CGRRoute+strconv.Itoa(i+1), route.RouteID) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +156,8 @@ func (smaEv *SMAsteriskEvent) PDD() string {
|
||||
return smaEv.cachedFields[utils.CGR_PDD]
|
||||
}
|
||||
|
||||
func (smaEv *SMAsteriskEvent) Supplier() string {
|
||||
return smaEv.cachedFields[utils.CGR_SUPPLIER]
|
||||
func (smaEv *SMAsteriskEvent) Route() string {
|
||||
return smaEv.cachedFields[utils.CGR_ROUTE]
|
||||
}
|
||||
|
||||
func (smaEv *SMAsteriskEvent) Subsystems() string {
|
||||
@@ -179,7 +179,7 @@ func (smaEv *SMAsteriskEvent) DisconnectCause() string {
|
||||
}
|
||||
|
||||
var primaryFields = utils.NewStringSet([]string{eventType, channelID, timestamp, utils.SetupTime, utils.CGR_ACCOUNT, utils.CGR_DESTINATION, utils.CGR_REQTYPE,
|
||||
utils.CGR_TENANT, utils.CGR_CATEGORY, utils.CGR_SUBJECT, utils.CGR_PDD, utils.CGR_SUPPLIER, utils.CGR_DISCONNECT_CAUSE})
|
||||
utils.CGR_TENANT, utils.CGR_CATEGORY, utils.CGR_SUBJECT, utils.CGR_PDD, utils.CGR_ROUTE, utils.CGR_DISCONNECT_CAUSE})
|
||||
|
||||
func (smaEv *SMAsteriskEvent) ExtraParameters() (extraParams map[string]string) {
|
||||
extraParams = make(map[string]string)
|
||||
@@ -248,8 +248,8 @@ func (smaEv *SMAsteriskEvent) AsMapStringInterface() (mp map[string]interface{})
|
||||
mp[utils.Account] = smaEv.Account()
|
||||
mp[utils.Destination] = smaEv.Destination()
|
||||
mp[utils.SetupTime] = smaEv.SetupTime()
|
||||
if smaEv.Supplier() != "" {
|
||||
mp[utils.SUPPLIER] = smaEv.Supplier()
|
||||
if smaEv.Route() != "" {
|
||||
mp[utils.ROUTE] = smaEv.Route()
|
||||
}
|
||||
for extraKey, extraVal := range smaEv.ExtraParameters() { // Append extraParameters
|
||||
mp[extraKey] = extraVal
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
stasisStart = `{"application":"cgrates_auth","type":"StasisStart","timestamp":"2016-09-12T13:53:48.919+0200","args":["cgr_reqtype=*prepaid","cgr_supplier=supplier1", "extra1=val1", "extra2=val2"],"channel":{"id":"1473681228.6","state":"Ring","name":"PJSIP/1001-00000004","caller":{"name":"1001","number":"1001"},"language":"en","connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"internal","exten":"1002","priority":2},"creationtime":"2016-09-12T13:53:48.918+0200"}}`
|
||||
stasisStart = `{"application":"cgrates_auth","type":"StasisStart","timestamp":"2016-09-12T13:53:48.919+0200","args":["cgr_reqtype=*prepaid","cgr_route=supplier1", "extra1=val1", "extra2=val2"],"channel":{"id":"1473681228.6","state":"Ring","name":"PJSIP/1001-00000004","caller":{"name":"1001","number":"1001"},"language":"en","connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"internal","exten":"1002","priority":2},"creationtime":"2016-09-12T13:53:48.918+0200"}}`
|
||||
channelStateChange = `{"application":"cgrates_auth","type":"ChannelStateChange","timestamp":"2016-09-12T13:53:52.110+0200","channel":{"id":"1473681228.6","state":"Up","name":"PJSIP/1001-00000004","caller":{"name":"1001","number":"1001"},"language":"en","connected":{"name":"","number":"1002"},"accountcode":"","dialplan":{"context":"internal","exten":"1002","priority":3},"creationtime":"2016-09-12T13:53:48.918+0200"}}`
|
||||
channelAnsweredDestroyed = `{"type":"ChannelDestroyed","timestamp":"2016-09-12T13:54:27.335+0200","application":"cgrates_auth","cause_txt":"Normal Clearing","channel":{"id":"1473681228.6","state":"Up","name":"PJSIP/1001-00000004","caller":{"name":"1001","number":"1001"},"language":"en","connected":{"name":"","number":"1002"},"accountcode":"","dialplan":{"context":"internal","exten":"1002","priority":3},"creationtime":"2016-09-12T13:53:48.918+0200"},"cause":16}`
|
||||
channelUnansweredDestroyed = `{"type":"ChannelDestroyed","timestamp":"2016-09-12T18:00:18.121+0200","application":"cgrates_auth","cause_txt":"Normal Clearing","channel":{"id":"1473696018.2","state":"Ring","name":"PJSIP/1002-00000002","caller":{"name":"1002","number":"1002"},"language":"en","connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"internal","exten":"1002","priority":2},"creationtime":"2016-09-12T18:00:18.109+0200"},"cause":16}`
|
||||
@@ -41,7 +41,7 @@ func TestSMAParseStasisArgs(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
smaEv := NewSMAsteriskEvent(ev, "127.0.0.1", "")
|
||||
expAppArgs := map[string]string{"cgr_reqtype": "*prepaid", "cgr_supplier": "supplier1", "extra1": "val1", "extra2": "val2"}
|
||||
expAppArgs := map[string]string{"cgr_reqtype": "*prepaid", "cgr_route": "supplier1", "extra1": "val1", "extra2": "val2"}
|
||||
if !reflect.DeepEqual(smaEv.cachedFields, expAppArgs) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", smaEv.cachedFields, expAppArgs)
|
||||
}
|
||||
@@ -280,19 +280,19 @@ func TestSMAEventPDD(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSMAEventSupplier(t *testing.T) {
|
||||
func TestSMAEventRoute(t *testing.T) {
|
||||
var ev map[string]interface{}
|
||||
if err := json.Unmarshal([]byte(stasisStart), &ev); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
smaEv := NewSMAsteriskEvent(ev, "127.0.0.1", "")
|
||||
if smaEv.Supplier() != "supplier1" {
|
||||
t.Error("Received:", smaEv.Supplier())
|
||||
if smaEv.Route() != "supplier1" {
|
||||
t.Error("Received:", smaEv.Route())
|
||||
}
|
||||
ev = map[string]interface{}{"args": []interface{}{"cgr_supplier=supplier1"}} // Clear previous data
|
||||
ev = map[string]interface{}{"args": []interface{}{"cgr_route=supplier1"}} // Clear previous data
|
||||
smaEv = NewSMAsteriskEvent(ev, "127.0.0.1", "")
|
||||
if smaEv.Supplier() != "supplier1" {
|
||||
t.Error("Received:", smaEv.Supplier())
|
||||
if smaEv.Route() != "supplier1" {
|
||||
t.Error("Received:", smaEv.Route())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ const (
|
||||
DESTINATION = varPrefix + utils.CGR_DESTINATION
|
||||
REQTYPE = varPrefix + utils.CGR_REQTYPE //prepaid or postpaid
|
||||
CATEGORY = varPrefix + utils.CGR_CATEGORY
|
||||
VAR_CGR_SUPPLIER = varPrefix + utils.CGR_SUPPLIER
|
||||
VAR_CGR_ROUTE = varPrefix + utils.CGR_ROUTE
|
||||
UUID = "Unique-ID" // -Unique ID for this call leg
|
||||
CSTMID = varPrefix + utils.CGR_TENANT
|
||||
CALL_DEST_NR = "Caller-Destination-Number"
|
||||
@@ -259,11 +259,11 @@ func (fsev FSEvent) GetADC(fieldName string) (time.Duration, error) {
|
||||
return utils.ParseDurationWithSecs(ACDStr)
|
||||
}
|
||||
|
||||
func (fsev FSEvent) GetSupplier(fieldName string) string {
|
||||
func (fsev FSEvent) GetRoute(fieldName string) string {
|
||||
if strings.HasPrefix(fieldName, utils.STATIC_VALUE_PREFIX) { // Static value
|
||||
return fieldName[len(utils.STATIC_VALUE_PREFIX):]
|
||||
}
|
||||
return utils.FirstNonEmpty(fsev[fieldName], fsev[VAR_CGR_SUPPLIER])
|
||||
return utils.FirstNonEmpty(fsev[fieldName], fsev[VAR_CGR_ROUTE])
|
||||
}
|
||||
|
||||
func (fsev FSEvent) GetDisconnectCause(fieldName string) string {
|
||||
@@ -333,8 +333,8 @@ func (fsev FSEvent) ParseEventValue(rsrFld *config.RSRParser, timezone string) (
|
||||
case utils.PDD:
|
||||
PDD, _ := fsev.GetPdd(utils.MetaDefault)
|
||||
return rsrFld.ParseValue(strconv.FormatFloat(PDD.Seconds(), 'f', -1, 64))
|
||||
case utils.SUPPLIER:
|
||||
return rsrFld.ParseValue(fsev.GetSupplier(""))
|
||||
case utils.ROUTE:
|
||||
return rsrFld.ParseValue(fsev.GetRoute(""))
|
||||
case utils.DISCONNECT_CAUSE:
|
||||
return rsrFld.ParseValue(fsev.GetDisconnectCause(""))
|
||||
case utils.RunID:
|
||||
@@ -386,7 +386,7 @@ func (fsev FSEvent) AsMapStringInterface(timezone string) map[string]interface{}
|
||||
mp[utils.PDD], _ = fsev.GetPdd(utils.MetaDefault)
|
||||
mp[utils.ACD], _ = fsev.GetADC(utils.MetaDefault)
|
||||
mp[utils.COST] = -1.0
|
||||
mp[utils.SUPPLIER] = fsev.GetSupplier(utils.MetaDefault)
|
||||
mp[utils.ROUTE] = fsev.GetRoute(utils.MetaDefault)
|
||||
mp[utils.DISCONNECT_CAUSE] = fsev.GetDisconnectCause(utils.MetaDefault)
|
||||
return mp
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -242,7 +242,7 @@ func (kev KamEvent) AsKamAuthReply(authArgs *sessions.V1AuthorizeArgs,
|
||||
kar.MaxUsage = int(utils.Round(authReply.MaxUsage.Seconds(), 0, utils.ROUNDING_MIDDLE))
|
||||
}
|
||||
if authArgs.GetRoutes && authReply.Routes != nil {
|
||||
kar.Suppliers = authReply.Routes.Digest()
|
||||
kar.Routes = authReply.Routes.Digest()
|
||||
}
|
||||
|
||||
if authArgs.ProcessThresholds && authReply.ThresholdIDs != nil {
|
||||
@@ -335,7 +335,7 @@ func (kev KamEvent) AsKamProcessMessageReply(procEvArgs *sessions.V1ProcessMessa
|
||||
kar.MaxUsage = int(utils.Round(procEvReply.MaxUsage.Seconds(), 0, utils.ROUNDING_MIDDLE))
|
||||
}
|
||||
if procEvArgs.GetRoutes && procEvReply.Routes != nil {
|
||||
kar.Suppliers = procEvReply.Routes.Digest()
|
||||
kar.Routes = procEvReply.Routes.Digest()
|
||||
}
|
||||
|
||||
if procEvArgs.ProcessThresholds {
|
||||
@@ -405,7 +405,7 @@ type KamReply struct {
|
||||
Attributes string
|
||||
ResourceAllocation string
|
||||
MaxUsage int // Maximum session time in case of success, -1 for unlimited
|
||||
Suppliers string // List of suppliers, comma separated
|
||||
Routes string // List of routes, comma separated
|
||||
Thresholds string
|
||||
StatQueues string
|
||||
Error string // Reply in case of error
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
var kamEv = KamEvent{KamTRIndex: "29223", KamTRLabel: "698469260",
|
||||
"callid": "ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ", "from_tag": "eb082607", "to_tag": "4ea9687f", "cgr_account": "dan",
|
||||
"cgr_reqtype": utils.META_PREPAID, "cgr_subject": "dan", "cgr_destination": "+4986517174963", "cgr_tenant": "itsyscom.com",
|
||||
"cgr_duration": "20", utils.CGR_SUPPLIER: "suppl2", utils.CGR_DISCONNECT_CAUSE: "200", "extra1": "val1", "extra2": "val2"}
|
||||
"cgr_duration": "20", utils.CGR_ROUTE: "suppl2", utils.CGR_DISCONNECT_CAUSE: "200", "extra1": "val1", "extra2": "val2"}
|
||||
|
||||
func TestNewKamEvent(t *testing.T) {
|
||||
evStr := `{"event":"CGR_CALL_END",
|
||||
@@ -43,7 +43,7 @@ func TestNewKamEvent(t *testing.T) {
|
||||
"cgr_destination":"1002",
|
||||
"cgr_answertime":"1419839310",
|
||||
"cgr_duration":"3",
|
||||
"cgr_supplier":"supplier2",
|
||||
"cgr_route":"supplier2",
|
||||
"cgr_disconnectcause": "200",
|
||||
"cgr_pdd": "4"}`
|
||||
eKamEv := KamEvent{
|
||||
@@ -57,7 +57,7 @@ func TestNewKamEvent(t *testing.T) {
|
||||
"cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3",
|
||||
"cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200",
|
||||
utils.OriginHost: utils.KamailioAgent,
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func TestKamEvMissingParameter(t *testing.T) {
|
||||
"from_tag": "bf71ad59", "to_tag": "7351fecf",
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_answertime": "1419839310", "cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
if missingParam := kamEv.MissingParameter(); missingParam != true {
|
||||
t.Errorf("Expecting: true, received:%+v ", missingParam)
|
||||
@@ -88,14 +88,14 @@ func TestKamEvAsMapStringInterface(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
expMp := make(map[string]interface{})
|
||||
expMp["cgr_account"] = "1001"
|
||||
expMp["cgr_duration"] = "3"
|
||||
expMp["cgr_pdd"] = "4"
|
||||
expMp["cgr_destination"] = "1002"
|
||||
expMp[utils.CGR_SUPPLIER] = "supplier2"
|
||||
expMp[utils.CGR_ROUTE] = "supplier2"
|
||||
expMp["cgr_answertime"] = "1419839310"
|
||||
expMp[utils.CGR_DISCONNECT_CAUSE] = "200"
|
||||
expMp["callid"] = "46c01a5c249b469e76333fc6bfa87f6a@0:0:0:0:0:0:0:0"
|
||||
@@ -117,7 +117,7 @@ func TestKamEvAsCGREvent(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
@@ -149,7 +149,7 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200",
|
||||
utils.CGRFlags: "*accounts,*routes,*routes_event_cost,*routes_ignore_errors"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
@@ -199,7 +199,7 @@ func TestKamEvAsKamAuthReply(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
@@ -275,7 +275,7 @@ func TestKamEvV1InitSessionArgs(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
@@ -313,7 +313,7 @@ func TestKamEvV1TerminateSessionArgs(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
@@ -351,7 +351,7 @@ func TestKamEvV1ProcessMessageArgs(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
@@ -386,7 +386,7 @@ func TestKamEvAsKamProcessEventReply(t *testing.T) {
|
||||
"cgr_reqtype": utils.META_POSTPAID, "cgr_account": "1001",
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_ROUTE: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
exten => _1XXX,1,NoOp()
|
||||
same => n,Set(CGRMaxSessionTime=0); use it to disconnect automatically the call if CGRateS is not active
|
||||
same => n,DumpChan()
|
||||
same => n,Stasis(cgrates_auth,cgr_reqtype=*prepaid,cgr_supplier=supplier1,"cgr_flags=*accounts,*attributes,*resources,*stats,*routes,*thresholds")
|
||||
same => n,Stasis(cgrates_auth,cgr_reqtype=*prepaid,cgr_routes=supplier1,"cgr_flags=*accounts,*attributes,*resources,*stats,*routes,*thresholds")
|
||||
same => n,Dial(PJSIP/${EXTEN},30,L(${CGRMaxSessionTime}))
|
||||
same => n,Hangup()
|
||||
|
||||
|
||||
@@ -140,8 +140,8 @@ route[CGR_SESSIONAUTH_REPLY] {
|
||||
json_get_field("$evapi(msg)", "MaxUsage", "$var(MaxUsage)");
|
||||
$var(cgrMaxUsage) = $(var(MaxUsage){s.int});
|
||||
|
||||
json_get_field("$evapi(msg)", "Suppliers", "$var(cgrSuppliers)");
|
||||
$var($var(cgrSuppliers)) = $(var(cgrSuppliers){s.rm,"});
|
||||
json_get_field("$evapi(msg)", "Routes", "$var(cgrRoutes)");
|
||||
$var($var(cgrRoutes)) = $(var(cgrRoutes){s.rm,"});
|
||||
|
||||
json_get_field("$evapi(msg)", "Error", "$var(cgrError)");
|
||||
$var(cgrError) = $(var(cgrError){s.rm,"});
|
||||
|
||||
@@ -225,8 +225,8 @@ route[CGRATES_SESSIONAUTH_REPLY] {
|
||||
exit;
|
||||
}
|
||||
|
||||
if $var(cgrSuppliers) != "" { # Enforce the supplier variable to the first one received from CGRateS, here more for demo purposes
|
||||
$dlg_var(cgrSupplier) = $(var(cgrSuppliers){s.select,0,,});
|
||||
if $var(cgrRoutes) != "" { # Enforce the route variable to the first one received from CGRateS, here more for demo purposes
|
||||
$dlg_var(cgrRoutes) = $(var(cgrRoutes){s.select,0,,});
|
||||
}
|
||||
|
||||
# user location service
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
exten => _1XXX,1,NoOp()
|
||||
same => n,Set(CGRMaxSessionTime=0); use it to disconnect automatically the call if CGRateS is not active
|
||||
same => n,DumpChan()
|
||||
same => n,Stasis(cgrates_auth,cgr_reqtype=*prepaid,cgr_supplier=supplier1,"cgr_flags=*accounts,*attributes,*resources,*stats,*routes,*thresholds")
|
||||
same => n,Stasis(cgrates_auth,cgr_reqtype=*prepaid,cgr_route=supplier1,"cgr_flags=*accounts,*attributes,*resources,*stats,*routes,*thresholds")
|
||||
same => n,Dial(PJSIP/${EXTEN},30,L(${CGRMaxSessionTime}))
|
||||
same => n,Hangup()
|
||||
|
||||
|
||||
@@ -140,8 +140,8 @@ route[CGR_SESSIONAUTH_REPLY] {
|
||||
json_get_field("$evapi(msg)", "MaxUsage", "$var(MaxUsage)");
|
||||
$var(cgrMaxUsage) = $(var(MaxUsage){s.int});
|
||||
|
||||
json_get_field("$evapi(msg)", "Suppliers", "$var(cgrSuppliers)");
|
||||
$var($var(cgrSuppliers)) = $(var(cgrSuppliers){s.rm,"});
|
||||
json_get_field("$evapi(msg)", "Routes", "$var(cgrRoutes)");
|
||||
$var($var(cgrRoutes)) = $(var(cgrRoutes){s.rm,"});
|
||||
|
||||
json_get_field("$evapi(msg)", "Error", "$var(cgrError)");
|
||||
$var(cgrError) = $(var(cgrError){s.rm,"});
|
||||
|
||||
@@ -225,8 +225,8 @@ route[CGRATES_SESSIONAUTH_REPLY] {
|
||||
exit;
|
||||
}
|
||||
|
||||
if $var(cgrSuppliers) != "" { # Enforce the supplier variable to the first one received from CGRateS, here more for demo purposes
|
||||
$dlg_var(cgrSupplier) = $(var(cgrSuppliers){s.select,0,,});
|
||||
if $var(cgrRoutes) != "" { # Enforce the route variable to the first one received from CGRateS, here more for demo purposes
|
||||
$dlg_var(cgrRoutes) = $(var(cgrRoutes){s.select,0,,});
|
||||
}
|
||||
|
||||
# user location service
|
||||
|
||||
@@ -92,7 +92,6 @@ var (
|
||||
CategoryLow = strings.ToLower(utils.Category)
|
||||
AccountLow = strings.ToLower(utils.Account)
|
||||
SubjectLow = strings.ToLower(utils.Subject)
|
||||
SupplierLow = strings.ToLower(utils.SUPPLIER)
|
||||
DisconnectCauseLow = strings.ToLower(utils.DISCONNECT_CAUSE)
|
||||
SetupTimeLow = strings.ToLower(utils.SetupTime)
|
||||
AnswerTimeLow = strings.ToLower(utils.AnswerTime)
|
||||
|
||||
@@ -115,7 +115,7 @@ func derivedChargers2AttributeProfile(dc *v1DerivedCharger, tenant, key string,
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, utils.PDD, dc.PDDField)
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, utils.AnswerTime, dc.AnswerTimeField)
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, utils.Usage, dc.UsageField)
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, utils.SUPPLIER, dc.SupplierField)
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, SUPPLIER, dc.SupplierField)
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, utils.DISCONNECT_CAUSE, dc.DisconnectCauseField)
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, utils.Cost, dc.CostField)
|
||||
attr.Attributes = fieldinfo2Attribute(attr.Attributes, utils.PreRated, dc.PreRatedField)
|
||||
|
||||
@@ -28,6 +28,10 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
SUPPLIER = "Supplier"
|
||||
)
|
||||
|
||||
func NewMigratorDataDB(db_type, host, port, name, user, pass,
|
||||
marshaler string, cacheCfg *config.CacheCfg, sentinelName string,
|
||||
itemsCacheCfg map[string]*config.ItemOpt) (db MigratorDataDB, err error) {
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestLibSessionSGetSetCGRID(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.DISCONNECT_CAUSE: "NORMAL_DISCONNECT",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
|
||||
@@ -109,7 +109,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.DISCONNECT_CAUSE: "NORMAL_DISCONNECT",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
"Extra1": "Value1",
|
||||
@@ -429,7 +429,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
s := &Session{
|
||||
@@ -487,7 +487,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier2",
|
||||
utils.ROUTE: "supplier2",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
s2 := &Session{
|
||||
@@ -553,7 +553,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier2",
|
||||
utils.ROUTE: "supplier2",
|
||||
utils.DISCONNECT_CAUSE: "NORMAL_DISCONNECT",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
@@ -647,7 +647,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
s := &Session{
|
||||
@@ -708,7 +708,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier2",
|
||||
utils.ROUTE: "supplier2",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
s2 := &Session{
|
||||
@@ -774,7 +774,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier2",
|
||||
utils.ROUTE: "supplier2",
|
||||
utils.DISCONNECT_CAUSE: "NORMAL_DISCONNECT",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
@@ -1401,7 +1401,7 @@ func TestSessionStransitSState(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
s := &Session{
|
||||
@@ -1447,7 +1447,7 @@ func TestSessionSrelocateSessionS(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
initialCGRID := GetSetCGRID(sSEv)
|
||||
@@ -1659,7 +1659,7 @@ func TestSessionSgetSessionIDsMatchingIndexes(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.DISCONNECT_CAUSE: "NORMAL_DISCONNECT",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
"Extra1": "Value1",
|
||||
@@ -1943,7 +1943,7 @@ func TestSessionSgetSession(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
})
|
||||
s := &Session{
|
||||
@@ -1990,7 +1990,7 @@ func TestSessionSfilterSessions(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.DISCONNECT_CAUSE: "NORMAL_DISCONNECT",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
"Extra1": "Value1",
|
||||
@@ -2050,7 +2050,7 @@ func TestSessionSfilterSessions(t *testing.T) {
|
||||
"Extra3": "",
|
||||
"LastUsed": "21s",
|
||||
"PDD": "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
},
|
||||
NodeID: sSCfg.GeneralCfg().NodeID,
|
||||
}
|
||||
@@ -2075,7 +2075,7 @@ func TestSessionSfilterSessions(t *testing.T) {
|
||||
"Extra3": "",
|
||||
"LastUsed": "21s",
|
||||
"PDD": "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
},
|
||||
NodeID: sSCfg.GeneralCfg().NodeID,
|
||||
}
|
||||
@@ -2166,7 +2166,7 @@ func TestSessionSfilterSessionsCount(t *testing.T) {
|
||||
utils.Usage: "1m23s",
|
||||
utils.LastUsed: "21s",
|
||||
utils.PDD: "300ms",
|
||||
utils.SUPPLIER: "supplier1",
|
||||
utils.ROUTE: "supplier1",
|
||||
utils.DISCONNECT_CAUSE: "NORMAL_DISCONNECT",
|
||||
utils.OriginHost: "127.0.0.1",
|
||||
"Extra1": "Value1",
|
||||
|
||||
@@ -209,7 +209,7 @@ const (
|
||||
Value = "Value"
|
||||
LastUsed = "LastUsed"
|
||||
PDD = "PDD"
|
||||
SUPPLIER = "Supplier"
|
||||
ROUTE = "Route"
|
||||
RunID = "RunID"
|
||||
AttributeIDs = "AttributeIDs"
|
||||
MetaReqRunID = "*req.RunID"
|
||||
@@ -1557,7 +1557,7 @@ const (
|
||||
//cgr_ variables
|
||||
const (
|
||||
CGR_ACCOUNT = "cgr_account"
|
||||
CGR_SUPPLIER = "cgr_supplier"
|
||||
CGR_ROUTE = "cgr_route"
|
||||
CGR_DESTINATION = "cgr_destination"
|
||||
CGR_SUBJECT = "cgr_subject"
|
||||
CGR_CATEGORY = "cgr_category"
|
||||
|
||||
Reference in New Issue
Block a user