mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Variable cgr_subsystems within AsteriskAgent
This commit is contained in:
@@ -153,6 +153,10 @@ func (smaEv *SMAsteriskEvent) Supplier() string {
|
||||
return smaEv.cachedFields[utils.CGR_SUPPLIER]
|
||||
}
|
||||
|
||||
func (smaEv *SMAsteriskEvent) Subsystems() string {
|
||||
return smaEv.cachedFields[utils.CGRSubsystems]
|
||||
}
|
||||
|
||||
func (smaEv *SMAsteriskEvent) DisconnectCause() string {
|
||||
cachedKey := utils.CGR_DISCONNECT_CAUSE
|
||||
cachedVal, hasIt := smaEv.cachedFields[cachedKey]
|
||||
|
||||
@@ -112,7 +112,7 @@ func (sma *AsteriskAgent) ListenAndServe() (err error) {
|
||||
panic("<AsteriskAgent> ListenAndServe out of select")
|
||||
}
|
||||
|
||||
// hangupChannel will disconnect from CGRateS side with congestion reason
|
||||
// setChannelVar will set the value of a variable
|
||||
func (sma *AsteriskAgent) setChannelVar(chanID string, vrblName, vrblVal string) (success bool) {
|
||||
if _, err := sma.astConn.Call(aringo.HTTP_POST,
|
||||
fmt.Sprintf("http://%s/ari/channels/%s/variable?variable=%s&value=%s", // Asterisk having issue with variable terminating empty so harcoding param in url
|
||||
|
||||
@@ -65,7 +65,7 @@ const (
|
||||
PDD_NOMEDIA_MS = "variable_progressmsec"
|
||||
IGNOREPARK = "variable_cgr_ignorepark"
|
||||
FS_VARPREFIX = "variable_"
|
||||
VarCGRSubsystems = "variable_cgr_subsystems"
|
||||
VarCGRSubsystems = "variable_" + utils.CGRSubsystems
|
||||
CGRResourceAllocation = "cgr_resource_allocation"
|
||||
VAR_CGR_DISCONNECT_CAUSE = "variable_" + utils.CGR_DISCONNECT_CAUSE
|
||||
VAR_CGR_CMPUTELCR = "variable_" + utils.CGR_COMPUTELCR
|
||||
|
||||
@@ -194,7 +194,7 @@ func (ka *KamailioAgent) onCallEnd(evData []byte, connID string) {
|
||||
utils.KamailioAgent, kev[utils.OriginID], err.Error()))
|
||||
// no return here since we want CDR anyhow
|
||||
}
|
||||
if ka.cfg.CreateCdr || strings.Index(kev[KamCGRSubsystems], utils.MetaCDRs) != -1 {
|
||||
if ka.cfg.CreateCdr || strings.Index(kev[utils.CGRSubsystems], utils.MetaCDRs) != -1 {
|
||||
cgrEv, err := kev.AsCGREvent(ka.timezone)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -40,14 +40,13 @@ const (
|
||||
KamHashEntry = "h_entry"
|
||||
KamHashID = "h_id"
|
||||
KamReplyRoute = "reply_route"
|
||||
KamCGRSubsystems = "cgr_subsystems"
|
||||
KamCGRContext = "cgr_context"
|
||||
EvapiConnID = "EvapiConnID" // used to share connID info in event for remote disconnects
|
||||
CGR_DLG_LIST = "CGR_DLG_LIST"
|
||||
)
|
||||
|
||||
var (
|
||||
kamReservedEventFields = []string{EVENT, KamTRIndex, KamTRLabel, KamCGRSubsystems, KamCGRContext, KamReplyRoute}
|
||||
kamReservedEventFields = []string{EVENT, KamTRIndex, KamTRLabel, utils.CGRSubsystems, KamCGRContext, KamReplyRoute}
|
||||
kamReservedCDRFields = append(kamReservedEventFields, KamHashEntry, KamHashID) // HashEntry and id are needed in events for disconnects
|
||||
)
|
||||
|
||||
@@ -182,7 +181,7 @@ func (kev KamEvent) V1AuthorizeArgs() (args *sessions.V1AuthorizeArgs) {
|
||||
GetMaxUsage: true,
|
||||
CGREvent: *cgrEv,
|
||||
}
|
||||
subsystems, has := kev[KamCGRSubsystems]
|
||||
subsystems, has := kev[utils.CGRSubsystems]
|
||||
if !has {
|
||||
return
|
||||
}
|
||||
@@ -250,7 +249,7 @@ func (kev KamEvent) V1InitSessionArgs() (args *sessions.V1InitSessionArgs) {
|
||||
InitSession: true,
|
||||
CGREvent: *cgrEv,
|
||||
}
|
||||
subsystems, has := kev[KamCGRSubsystems]
|
||||
subsystems, has := kev[utils.CGRSubsystems]
|
||||
if !has {
|
||||
return
|
||||
}
|
||||
@@ -272,7 +271,7 @@ func (kev KamEvent) V1TerminateSessionArgs() (args *sessions.V1TerminateSessionA
|
||||
TerminateSession: true,
|
||||
CGREvent: *cgrEv,
|
||||
}
|
||||
subsystems, has := kev[KamCGRSubsystems]
|
||||
subsystems, has := kev[utils.CGRSubsystems]
|
||||
if !has {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) {
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200",
|
||||
KamCGRSubsystems: "*accounts;**suppliers_event_cost;*suppliers_ignore_errors"}
|
||||
utils.CGRSubsystems: "*accounts;**suppliers_event_cost;*suppliers_ignore_errors"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -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)
|
||||
same => n,Stasis(cgrates_auth,cgr_reqtype=*prepaid,cgr_supplier=supplier1,cgr_subsystems=*attributes;*accounts)
|
||||
same => n,Dial(PJSIP/${EXTEN},30,L(${CGRMaxSessionTime}))
|
||||
same => n,Hangup()
|
||||
|
||||
|
||||
@@ -529,6 +529,7 @@ const (
|
||||
MetaCCA = "*cca"
|
||||
OriginRealm = "OriginRealm"
|
||||
ProductName = "ProductName"
|
||||
CGRSubsystems = "cgr_subsystems"
|
||||
)
|
||||
|
||||
// Migrator Action
|
||||
|
||||
Reference in New Issue
Block a user