DiameterAgent, cdr_requires_session config option

This commit is contained in:
DanB
2016-09-02 14:42:01 +02:00
parent 25c61b7d65
commit 7ce4f65f02
5 changed files with 44 additions and 36 deletions

View File

@@ -144,7 +144,8 @@ func (self DiameterAgent) processCCR(ccr *CCR, reqProcessor *config.DARequestPro
smgEv[utils.USAGE] = 0 // For CDR not to debit
}
}
if self.cgrCfg.DiameterAgentCfg().CreateCDR && err == nil || !strings.HasSuffix(err.Error(), utils.ErrNoActiveSession.Error()) { // NO CDR for no active session
if self.cgrCfg.DiameterAgentCfg().CreateCDR &&
(!self.cgrCfg.DiameterAgentCfg().CDRRequiresSession || err == nil || !strings.HasSuffix(err.Error(), utils.ErrNoActiveSession.Error())) { // Check if CDR requires session
if errCdr := self.smg.Call("SMGenericV1.ProcessCDR", smgEv, &rpl); errCdr != nil {
err = errCdr
}

View File

@@ -336,10 +336,11 @@ const CGRATES_CFG_JSON = `
"listen": "127.0.0.1:3868", // address where to listen for diameter requests <x.y.z.y:1234>
"dictionaries_dir": "/usr/share/cgrates/diameter/dict/", // path towards directory holding additional dictionaries to load
"sm_generic_conns": [
{"address": "*internal"} // connection towards SMG component for session management
{"address": "*internal"} // connection towards SMG component for session management
],
"pubsubs_conns": [], // address where to reach the pubusb service, empty to disable pubsub functionality: <""|*internal|x.y.z.y:1234>
"create_cdr": true, // create CDR out of CCR terminate and send it to SMG component
"cdr_requires_session": true, // only create CDR if there is an active session at terminate
"debit_interval": "5m", // interval for CCR updates
"timezone": "", // timezone for timestamps where not specified, empty for general defaults <""|UTC|Local|$IANA_TZ_DB>
"origin_host": "CGR-DA", // diameter Origin-Host AVP used in replies

View File

@@ -525,14 +525,15 @@ func TestDiameterAgentJsonCfg(t *testing.T) {
&HaPoolJsonCfg{
Address: utils.StringPointer(utils.MetaInternal),
}},
Pubsubs_conns: &[]*HaPoolJsonCfg{},
Create_cdr: utils.BoolPointer(true),
Debit_interval: utils.StringPointer("5m"),
Timezone: utils.StringPointer(""),
Origin_host: utils.StringPointer("CGR-DA"),
Origin_realm: utils.StringPointer("cgrates.org"),
Vendor_id: utils.IntPointer(0),
Product_name: utils.StringPointer("CGRateS"),
Pubsubs_conns: &[]*HaPoolJsonCfg{},
Create_cdr: utils.BoolPointer(true),
Cdr_requires_session: utils.BoolPointer(true),
Debit_interval: utils.StringPointer("5m"),
Timezone: utils.StringPointer(""),
Origin_host: utils.StringPointer("CGR-DA"),
Origin_realm: utils.StringPointer("cgrates.org"),
Vendor_id: utils.IntPointer(0),
Product_name: utils.StringPointer("CGRateS"),
Request_processors: &[]*DARequestProcessorJsnCfg{
&DARequestProcessorJsnCfg{
Id: utils.StringPointer("*default"),

View File

@@ -24,19 +24,20 @@ import (
)
type DiameterAgentCfg struct {
Enabled bool // enables the diameter agent: <true|false>
Listen string // address where to listen for diameter requests <x.y.z.y:1234>
DictionariesDir string
SMGenericConns []*HaPoolConfig // connections towards SMG component
PubSubConns []*HaPoolConfig // connection towards pubsubs
CreateCDR bool
DebitInterval time.Duration
Timezone string // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
OriginHost string
OriginRealm string
VendorId int
ProductName string
RequestProcessors []*DARequestProcessor
Enabled bool // enables the diameter agent: <true|false>
Listen string // address where to listen for diameter requests <x.y.z.y:1234>
DictionariesDir string
SMGenericConns []*HaPoolConfig // connections towards SMG component
PubSubConns []*HaPoolConfig // connection towards pubsubs
CreateCDR bool
CDRRequiresSession bool
DebitInterval time.Duration
Timezone string // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
OriginHost string
OriginRealm string
VendorId int
ProductName string
RequestProcessors []*DARequestProcessor
}
func (self *DiameterAgentCfg) loadFromJsonCfg(jsnCfg *DiameterAgentJsonCfg) error {
@@ -69,6 +70,9 @@ func (self *DiameterAgentCfg) loadFromJsonCfg(jsnCfg *DiameterAgentJsonCfg) erro
if jsnCfg.Create_cdr != nil {
self.CreateCDR = *jsnCfg.Create_cdr
}
if jsnCfg.Cdr_requires_session != nil {
self.CDRRequiresSession = *jsnCfg.Cdr_requires_session
}
if jsnCfg.Debit_interval != nil {
var err error
if self.DebitInterval, err = utils.ParseDurationWithSecs(*jsnCfg.Debit_interval); err != nil {

View File

@@ -282,19 +282,20 @@ type OsipsConnJsonCfg struct {
// DiameterAgent configuration
type DiameterAgentJsonCfg struct {
Enabled *bool // enables the diameter agent: <true|false>
Listen *string // address where to listen for diameter requests <x.y.z.y:1234>
Dictionaries_dir *string // path towards additional dictionaries
Sm_generic_conns *[]*HaPoolJsonCfg // Connections towards generic SM
Pubsubs_conns *[]*HaPoolJsonCfg // connection towards pubsubs
Create_cdr *bool
Debit_interval *string
Timezone *string // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
Origin_host *string
Origin_realm *string
Vendor_id *int
Product_name *string
Request_processors *[]*DARequestProcessorJsnCfg
Enabled *bool // enables the diameter agent: <true|false>
Listen *string // address where to listen for diameter requests <x.y.z.y:1234>
Dictionaries_dir *string // path towards additional dictionaries
Sm_generic_conns *[]*HaPoolJsonCfg // Connections towards generic SM
Pubsubs_conns *[]*HaPoolJsonCfg // connection towards pubsubs
Create_cdr *bool
Cdr_requires_session *bool
Debit_interval *string
Timezone *string // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
Origin_host *string
Origin_realm *string
Vendor_id *int
Product_name *string
Request_processors *[]*DARequestProcessorJsnCfg
}
// One Diameter request processor configuration