Configuration updates: sm_generic -> smg, sm_freeswitch connecting to smg instead of rals/cdrs

This commit is contained in:
DanB
2017-12-15 19:29:18 +01:00
parent 1c11a52c93
commit 8a30d80095
10 changed files with 135 additions and 197 deletions

View File

@@ -39,6 +39,10 @@
},
],
"smg": {
"enabled": true, // enable Rater service: <true|false>
},
"sm_freeswitch": {
"enabled": true, // starts SessionManager service: <true|false>
"event_socket_conns":[ // instantiate connections to multiple FreeSWITCH servers

View File

@@ -68,7 +68,7 @@ func NewDefaultCGRConfig() (*CGRConfig, error) {
cfg.RALsMaxComputedUsage = make(map[string]time.Duration)
cfg.NodeID = utils.GenUUID()
cfg.DataFolderPath = "/usr/share/cgrates/"
cfg.SmGenericConfig = new(SmGenericConfig)
cfg.SMGConfig = new(SMGConfig)
cfg.cacheConfig = make(CacheConfig)
cfg.SmFsConfig = new(SmFsConfig)
cfg.SmKamConfig = new(SmKamConfig)
@@ -259,7 +259,7 @@ type CGRConfig struct {
CDRStatsSaveInterval time.Duration // Save interval duration
CdreProfiles map[string]*CdreConfig
CdrcProfiles map[string][]*CdrcConfig // Number of CDRC instances running imports, format map[dirPath][]{Configs}
SmGenericConfig *SmGenericConfig
SMGConfig *SMGConfig
SmFsConfig *SmFsConfig // SMFreeSWITCH configuration
SmKamConfig *SmKamConfig // SM-Kamailio Configuration
SmOsipsConfig *SmOsipsConfig // SMOpenSIPS Configuration
@@ -405,19 +405,19 @@ func (self *CGRConfig) checkConfigSanity() error {
}
}
// SMGeneric checks
if self.SmGenericConfig.Enabled {
if len(self.SmGenericConfig.RALsConns) == 0 {
if self.SMGConfig.Enabled {
if len(self.SMGConfig.RALsConns) == 0 {
return errors.New("<SMGeneric> RALs definition is mandatory!")
}
for _, smgRALsConn := range self.SmGenericConfig.RALsConns {
for _, smgRALsConn := range self.SMGConfig.RALsConns {
if smgRALsConn.Address == utils.MetaInternal && !self.RALsEnabled {
return errors.New("<SMGeneric> RALs not enabled but requested by SMGeneric component.")
}
}
if len(self.SmGenericConfig.CDRsConns) == 0 {
if len(self.SMGConfig.CDRsConns) == 0 {
return errors.New("<SMGeneric> CDRs definition is mandatory!")
}
for _, smgCDRSConn := range self.SmGenericConfig.CDRsConns {
for _, smgCDRSConn := range self.SMGConfig.CDRsConns {
if smgCDRSConn.Address == utils.MetaInternal && !self.CDRSEnabled {
return errors.New("<SMGeneric> CDRS not enabled but referenced by SMGeneric component")
}
@@ -425,25 +425,13 @@ func (self *CGRConfig) checkConfigSanity() error {
}
// SMFreeSWITCH checks
if self.SmFsConfig.Enabled {
if len(self.SmFsConfig.RALsConns) == 0 {
return errors.New("<SMFreeSWITCH> RALs definition is mandatory!")
}
for _, smFSRaterConn := range self.SmFsConfig.RALsConns {
if smFSRaterConn.Address == utils.MetaInternal && !self.RALsEnabled {
return errors.New("<SMFreeSWITCH> RALs not enabled but requested by SMFreeSWITCH component.")
for _, connCfg := range self.SmFsConfig.SMGConns {
if connCfg.Address != utils.MetaInternal {
return errors.New("Only <*internal> connectivity allowed in in SMFreeSWITCH towards SMG for now")
}
}
if len(self.SmFsConfig.CDRsConns) == 0 {
return errors.New("<SMFreeSWITCH> CDRS definition is mandatory!")
}
for _, smFSCDRSConn := range self.SmFsConfig.CDRsConns {
if smFSCDRSConn.Address == utils.MetaInternal && !self.CDRSEnabled {
return errors.New("CDRS not enabled but referenced by SMFreeSWITCH component")
}
}
for _, smFSRLsConn := range self.SmFsConfig.RLsConns {
if smFSRLsConn.Address == utils.MetaInternal && !self.resourceSCfg.Enabled {
return errors.New("RLs not enabled but referenced by SMFreeSWITCH component")
if connCfg.Address == utils.MetaInternal &&
!self.SMGConfig.Enabled {
return errors.New("SMGeneric not enabled but referenced by SM-FreeSWITCH")
}
}
}
@@ -497,19 +485,19 @@ func (self *CGRConfig) checkConfigSanity() error {
return errors.New("<SMAsterisk> SMG definition is mandatory!")
}
for _, smAstSMGConn := range self.smAsteriskCfg.SMGConns {
if smAstSMGConn.Address == utils.MetaInternal && !self.SmGenericConfig.Enabled {
if smAstSMGConn.Address == utils.MetaInternal && !self.SMGConfig.Enabled {
return errors.New("<SMAsterisk> SMG not enabled.")
}
}
*/
if !self.SmGenericConfig.Enabled {
if !self.SMGConfig.Enabled {
return errors.New("<SMAsterisk> SMG not enabled.")
}
}
// DAgent checks
if self.diameterAgentCfg.Enabled {
for _, daSMGConn := range self.diameterAgentCfg.SMGenericConns {
if daSMGConn.Address == utils.MetaInternal && !self.SmGenericConfig.Enabled {
for _, daSMGConn := range self.diameterAgentCfg.SMGConns {
if daSMGConn.Address == utils.MetaInternal && !self.SMGConfig.Enabled {
return errors.New("SMGeneric not enabled but referenced by DiameterAgent component")
}
}
@@ -520,8 +508,8 @@ func (self *CGRConfig) checkConfigSanity() error {
}
}
if self.radiusAgentCfg.Enabled {
for _, raSMGConn := range self.radiusAgentCfg.SMGenericConns {
if raSMGConn.Address == utils.MetaInternal && !self.SmGenericConfig.Enabled {
for _, raSMGConn := range self.radiusAgentCfg.SMGConns {
if raSMGConn.Address == utils.MetaInternal && !self.SMGConfig.Enabled {
return errors.New("SMGeneric not enabled but referenced by RadiusAgent component")
}
}
@@ -546,7 +534,7 @@ func (self *CGRConfig) checkConfigSanity() error {
if self.supplierSCfg != nil && self.supplierSCfg.Enabled {
for _, connCfg := range self.supplierSCfg.RALsConns {
if connCfg.Address != utils.MetaInternal {
return errors.New("Only *internal connectivity allowed in SupplierS for now")
return errors.New("Only <*internal> connectivity allowed in SupplierS for now")
}
if connCfg.Address == utils.MetaInternal && !self.RALsEnabled {
return errors.New("RALs not enabled but requested by SupplierS component.")
@@ -637,7 +625,7 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
return err
}
jsnSmGenericCfg, err := jsnCfg.SmGenericJsonCfg()
jsnSmGenericCfg, err := jsnCfg.SmgJsonCfg()
if err != nil {
return err
}
@@ -1114,7 +1102,7 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
}
}
if jsnSmGenericCfg != nil {
if err := self.SmGenericConfig.loadFromJsonCfg(jsnSmGenericCfg); err != nil {
if err := self.SMGConfig.loadFromJsonCfg(jsnSmGenericCfg); err != nil {
return err
}
}

View File

@@ -277,7 +277,7 @@ const CGRATES_CFG_JSON = `
],
"sm_generic": {
"smg": {
"enabled": false, // starts SessionManager service: <true|false>
"listen_bijson": "127.0.0.1:2014", // address where to listen for bidirectional JSON-RPC requests
"rals_conns": [
@@ -300,6 +300,9 @@ const CGRATES_CFG_JSON = `
"sm_asterisk": {
"enabled": false, // starts Asterisk SessionManager service: <true|false>
"smg_conns": [
{"address": "*internal"} // connection towards SMG component for session management: <*internal>
],
"create_cdr": false, // create CDR out of events and sends it to CDRS component
"asterisk_conns":[ // instantiate connections to multiple Asterisk servers
{"address": "127.0.0.1:8088", "user": "cgrates", "password": "CGRateS.org", "connect_attempts": 3,"reconnects": 5}
@@ -309,23 +312,16 @@ const CGRATES_CFG_JSON = `
"sm_freeswitch": {
"enabled": false, // starts SessionManager service: <true|false>
"rals_conns": [
{"address": "*internal"} // address where to reach the Rater <""|*internal|127.0.0.1:2013>
"smg_conns": [
{"address": "*internal"} // connection towards SMG component for session management: <*internal>
],
"cdrs_conns": [
{"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing <*internal|x.y.z.y:1234>
],
"resources_conns": [], // address where to reach the ResourceLimiter service, empty to disable functionality: <""|*internal|x.y.z.y:1234>
"subscribe_park": true, // subscribe via fsock to receive park events
"create_cdr": false, // create CDR out of events and sends them to CDRS component
"extra_fields": [], // extra fields to store in auth/CDRs when creating them
"debit_interval": "10s", // interval to perform debits on.
"min_call_duration": "0s", // only authorize calls with allowed duration higher than this
"max_call_duration": "3h", // maximum call duration a prepaid call can last
"min_dur_low_balance": "5s", // threshold which will trigger low balance warnings for prepaid calls (needs to be lower than debit_interval)
"low_balance_ann_file": "", // file to be played when low balance is reached for prepaid calls
//"min_dur_low_balance": "5s", // threshold which will trigger low balance warnings for prepaid calls (needs to be lower than debit_interval)
//"low_balance_ann_file": "", // file to be played when low balance is reached for prepaid calls
"empty_balance_context": "", // if defined, prepaid calls will be transferred to this context on empty balance
"empty_balance_ann_file": "", // file to be played before disconnecting prepaid calls on empty balance (applies only if no context defined)
"subscribe_park": true, // subscribe via fsock to receive park events
"channel_sync_interval": "5m", // sync channels with freeswitch regularly
"max_wait_connection": "2s", // maximum duration to wait for a connection to be retrieved from the pool
"event_socket_conns":[ // instantiate connections to multiple FreeSWITCH servers
@@ -375,7 +371,7 @@ const CGRATES_CFG_JSON = `
"enabled": false, // enables the diameter agent: <true|false>
"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": [
"smg_conns": [
{"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>
@@ -402,7 +398,7 @@ const CGRATES_CFG_JSON = `
"client_dictionaries": { // per client path towards directory holding additional dictionaries to load (extra to RFC)
"*default": "/usr/share/cgrates/radius/dict/", // key represents the client IP or catch-all <*default|$client_ip>
},
"sm_generic_conns": [
"smg_conns": [
{"address": "*internal"} // connection towards SMG component for session management
],
"create_cdr": true, // create CDR out of Accounting-Stop and send it to SMG component

View File

@@ -42,7 +42,7 @@ const (
CDRSTATS_JSN = "cdrstats"
CDRE_JSN = "cdre"
CDRC_JSN = "cdrc"
SMGENERIC_JSON = "sm_generic"
SMG_JSON = "smg"
SMFS_JSN = "sm_freeswitch"
SMKAM_JSN = "sm_kamailio"
SMOSIPS_JSN = "sm_opensips"
@@ -233,12 +233,12 @@ func (self CgrJsonCfg) CdrcJsonCfg() ([]*CdrcJsonCfg, error) {
return cfg, nil
}
func (self CgrJsonCfg) SmGenericJsonCfg() (*SmGenericJsonCfg, error) {
rawCfg, hasKey := self[SMGENERIC_JSON]
func (self CgrJsonCfg) SmgJsonCfg() (*SmgJsonCfg, error) {
rawCfg, hasKey := self[SMG_JSON]
if !hasKey {
return nil, nil
}
cfg := new(SmGenericJsonCfg)
cfg := new(SmgJsonCfg)
if err := json.Unmarshal(*rawCfg, cfg); err != nil {
return nil, err
}

View File

@@ -483,8 +483,8 @@ func TestDfCdrcJsonCfg(t *testing.T) {
}
}
func TestSmGenericJsonCfg(t *testing.T) {
eCfg := &SmGenericJsonCfg{
func TestSmgJsonCfg(t *testing.T) {
eCfg := &SmgJsonCfg{
Enabled: utils.BoolPointer(false),
Listen_bijson: utils.StringPointer("127.0.0.1:2014"),
Rals_conns: &[]*HaPoolJsonCfg{
@@ -502,7 +502,7 @@ func TestSmGenericJsonCfg(t *testing.T) {
Session_ttl: utils.StringPointer("0s"),
Session_indexes: utils.StringSlicePointer([]string{}),
}
if cfg, err := dfCgrJsonCfg.SmGenericJsonCfg(); err != nil {
if cfg, err := dfCgrJsonCfg.SmgJsonCfg(); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eCfg, cfg) {
t.Error("Received: ", cfg)
@@ -512,25 +512,15 @@ func TestSmGenericJsonCfg(t *testing.T) {
func TestSmFsJsonCfg(t *testing.T) {
eCfg := &SmFsJsonCfg{
Enabled: utils.BoolPointer(false),
Rals_conns: &[]*HaPoolJsonCfg{
Smg_conns: &[]*HaPoolJsonCfg{
&HaPoolJsonCfg{
Address: utils.StringPointer(utils.MetaInternal),
}},
Cdrs_conns: &[]*HaPoolJsonCfg{
&HaPoolJsonCfg{
Address: utils.StringPointer(utils.MetaInternal),
}},
Resources_conns: &[]*HaPoolJsonCfg{},
Subscribe_park: utils.BoolPointer(true),
Create_cdr: utils.BoolPointer(false),
Extra_fields: utils.StringSlicePointer([]string{}),
Debit_interval: utils.StringPointer("10s"),
Min_call_duration: utils.StringPointer("0s"),
Max_call_duration: utils.StringPointer("3h"),
Min_dur_low_balance: utils.StringPointer("5s"),
Low_balance_ann_file: utils.StringPointer(""),
Empty_balance_context: utils.StringPointer(""),
Empty_balance_ann_file: utils.StringPointer(""),
Subscribe_park: utils.BoolPointer(true),
Channel_sync_interval: utils.StringPointer("5m"),
Max_wait_connection: utils.StringPointer("2s"),
Event_socket_conns: &[]*FsConnJsonCfg{
@@ -573,7 +563,8 @@ func TestSmKamJsonCfg(t *testing.T) {
if cfg, err := dfCgrJsonCfg.SmKamJsonCfg(); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eCfg, cfg) {
t.Error("Received: ", cfg)
t.Errorf("Expecting: %s, received: %s: ",
utils.ToJSON(eCfg), utils.ToJSON(cfg))
}
}
@@ -605,7 +596,11 @@ func TestSmOsipsJsonCfg(t *testing.T) {
func TestSmAsteriskJsonCfg(t *testing.T) {
eCfg := &SMAsteriskJsonCfg{
Enabled: utils.BoolPointer(false),
Enabled: utils.BoolPointer(false),
Smg_conns: &[]*HaPoolJsonCfg{
&HaPoolJsonCfg{
Address: utils.StringPointer(utils.MetaInternal),
}},
Create_cdr: utils.BoolPointer(false),
Asterisk_conns: &[]*AstConnJsonCfg{
&AstConnJsonCfg{
@@ -620,7 +615,7 @@ func TestSmAsteriskJsonCfg(t *testing.T) {
if cfg, err := dfCgrJsonCfg.SmAsteriskJsonCfg(); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eCfg, cfg) {
t.Error("Received: ", cfg)
t.Errorf("Expecting: %s, received: %s ", utils.ToJSON(eCfg), utils.ToJSON(cfg))
}
}
@@ -629,7 +624,7 @@ func TestDiameterAgentJsonCfg(t *testing.T) {
Enabled: utils.BoolPointer(false),
Listen: utils.StringPointer("127.0.0.1:3868"),
Dictionaries_dir: utils.StringPointer("/usr/share/cgrates/diameter/dict/"),
Sm_generic_conns: &[]*HaPoolJsonCfg{
Smg_conns: &[]*HaPoolJsonCfg{
&HaPoolJsonCfg{
Address: utils.StringPointer(utils.MetaInternal),
}},
@@ -664,7 +659,7 @@ func TestRadiusAgentJsonCfg(t *testing.T) {
Client_dictionaries: utils.MapStringStringPointer(map[string]string{
utils.META_DEFAULT: "/usr/share/cgrates/radius/dict/",
}),
Sm_generic_conns: &[]*HaPoolJsonCfg{
Smg_conns: &[]*HaPoolJsonCfg{
&HaPoolJsonCfg{
Address: utils.StringPointer(utils.MetaInternal),
}},

View File

@@ -446,7 +446,7 @@ func TestCgrCfgJSONDefaultsCdreProfiles(t *testing.T) {
}
func TestCgrCfgJSONDefaultsSMGenericCfg(t *testing.T) {
eSmGeCfg := &SmGenericConfig{
eSmGeCfg := &SMGConfig{
Enabled: false,
ListenBijson: "127.0.0.1:2014",
RALsConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
@@ -459,8 +459,8 @@ func TestCgrCfgJSONDefaultsSMGenericCfg(t *testing.T) {
SessionIndexes: utils.StringMap{},
}
if !reflect.DeepEqual(cgrCfg.SmGenericConfig, eSmGeCfg) {
t.Errorf("received: %+v, expecting: %+v", cgrCfg.SmGenericConfig, eSmGeCfg)
if !reflect.DeepEqual(cgrCfg.SMGConfig, eSmGeCfg) {
t.Errorf("received: %+v, expecting: %+v", cgrCfg.SMGConfig, eSmGeCfg)
}
}
@@ -547,22 +547,17 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
func TestCgrCfgJSONDefaultsSMFsConfig(t *testing.T) {
eSmFsCfg := &SmFsConfig{
Enabled: false,
RALsConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
CDRsConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
RLsConns: []*HaPoolConfig{},
SMGConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
SubscribePark: true,
CreateCdr: false,
ExtraFields: nil,
DebitInterval: 10 * time.Second,
MinCallDuration: 0 * time.Second,
MaxCallDuration: 3 * time.Hour,
MinDurLowBalance: 5 * time.Second,
LowBalanceAnnFile: "",
EmptyBalanceContext: "",
EmptyBalanceAnnFile: "",
SubscribePark: true,
ChannelSyncInterval: 5 * time.Minute,
MaxWaitConnection: 2 * time.Second,
EventSocketConns: []*FsConnConfig{&FsConnConfig{Address: "127.0.0.1:8021", Password: "ClueCon", Reconnects: 5}},
EventSocketConns: []*FsConnConfig{
&FsConnConfig{Address: "127.0.0.1:8021",
Password: "ClueCon", Reconnects: 5}},
}
if !reflect.DeepEqual(cgrCfg.SmFsConfig, eSmFsCfg) {
@@ -608,9 +603,14 @@ func TestCgrCfgJSONDefaultsSMOsipsConfig(t *testing.T) {
func TestCgrCfgJSONDefaultsSMAsteriskCfg(t *testing.T) {
eSmAsCfg := &SMAsteriskCfg{
Enabled: false,
CreateCDR: false,
AsteriskConns: []*AsteriskConnCfg{&AsteriskConnCfg{Address: "127.0.0.1:8088", User: "cgrates", Password: "CGRateS.org", ConnectAttempts: 3, Reconnects: 5}},
Enabled: false,
SMGConns: []*HaPoolConfig{
&HaPoolConfig{Address: "*internal"}},
CreateCDR: false,
AsteriskConns: []*AsteriskConnCfg{
&AsteriskConnCfg{Address: "127.0.0.1:8088",
User: "cgrates", Password: "CGRateS.org",
ConnectAttempts: 3, Reconnects: 5}},
}
if !reflect.DeepEqual(cgrCfg.smAsteriskCfg, eSmAsCfg) {
@@ -713,10 +713,11 @@ func TestCgrCfgJSONDefaultSupplierSCfg(t *testing.T) {
func TestCgrCfgJSONDefaultsDiameterAgentCfg(t *testing.T) {
testDA := &DiameterAgentCfg{
Enabled: false,
Listen: "127.0.0.1:3868",
DictionariesDir: "/usr/share/cgrates/diameter/dict/",
SMGenericConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
Enabled: false,
Listen: "127.0.0.1:3868",
DictionariesDir: "/usr/share/cgrates/diameter/dict/",
SMGConns: []*HaPoolConfig{
&HaPoolConfig{Address: "*internal"}},
PubSubConns: []*HaPoolConfig{},
CreateCDR: true,
DebitInterval: 5 * time.Minute,
@@ -737,8 +738,8 @@ func TestCgrCfgJSONDefaultsDiameterAgentCfg(t *testing.T) {
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.DictionariesDir, testDA.DictionariesDir) {
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.DictionariesDir, testDA.DictionariesDir)
}
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.SMGenericConns, testDA.SMGenericConns) {
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.SMGenericConns, testDA.SMGenericConns)
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.SMGConns, testDA.SMGConns) {
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.SMGConns, testDA.SMGConns)
}
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.PubSubConns, testDA.PubSubConns) {
t.Errorf("expecting: %+v, received: %+v", cgrCfg.diameterAgentCfg.PubSubConns, testDA.PubSubConns)
@@ -845,7 +846,7 @@ func TestRadiusAgentCfg(t *testing.T) {
ListenAcct: "127.0.0.1:1813",
ClientSecrets: map[string]string{utils.META_DEFAULT: "CGRateS.org"},
ClientDictionaries: map[string]string{utils.META_DEFAULT: "/usr/share/cgrates/radius/dict/"},
SMGenericConns: []*HaPoolConfig{&HaPoolConfig{Address: utils.MetaInternal}},
SMGConns: []*HaPoolConfig{&HaPoolConfig{Address: utils.MetaInternal}},
CreateCDR: true,
CDRRequiresSession: false,
Timezone: "",
@@ -869,8 +870,8 @@ func TestRadiusAgentCfg(t *testing.T) {
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.ClientDictionaries, testRA.ClientDictionaries) {
t.Errorf("expecting: %+v, received: %+v", cgrCfg.radiusAgentCfg.ClientDictionaries, testRA.ClientDictionaries)
}
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.SMGenericConns, testRA.SMGenericConns) {
t.Errorf("expecting: %+v, received: %+v", cgrCfg.radiusAgentCfg.SMGenericConns, testRA.SMGenericConns)
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.SMGConns, testRA.SMGConns) {
t.Errorf("expecting: %+v, received: %+v", cgrCfg.radiusAgentCfg.SMGConns, testRA.SMGConns)
}
if !reflect.DeepEqual(cgrCfg.radiusAgentCfg.CreateCDR, testRA.CreateCDR) {
t.Errorf("received: %+v, expecting: %+v", cgrCfg.radiusAgentCfg.CreateCDR, testRA.CreateCDR)

View File

@@ -28,7 +28,7 @@ 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
SMGConns []*HaPoolConfig // connections towards SMG component
PubSubConns []*HaPoolConfig // connection towards pubsubs
CreateCDR bool
CDRRequiresSession bool
@@ -54,11 +54,11 @@ func (self *DiameterAgentCfg) loadFromJsonCfg(jsnCfg *DiameterAgentJsonCfg) erro
if jsnCfg.Dictionaries_dir != nil {
self.DictionariesDir = *jsnCfg.Dictionaries_dir
}
if jsnCfg.Sm_generic_conns != nil {
self.SMGenericConns = make([]*HaPoolConfig, len(*jsnCfg.Sm_generic_conns))
for idx, jsnHaCfg := range *jsnCfg.Sm_generic_conns {
self.SMGenericConns[idx] = NewDfltHaPoolConfig()
self.SMGenericConns[idx].loadFromJsonCfg(jsnHaCfg)
if jsnCfg.Smg_conns != nil {
self.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
self.SMGConns[idx] = NewDfltHaPoolConfig()
self.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
}
}
if jsnCfg.Pubsubs_conns != nil {

View File

@@ -194,7 +194,7 @@ type CdrcJsonCfg struct {
}
// SM-Generic config section
type SmGenericJsonCfg struct {
type SmgJsonCfg struct {
Enabled *bool
Listen_bijson *string
Rals_conns *[]*HaPoolJsonCfg
@@ -212,25 +212,27 @@ type SmGenericJsonCfg struct {
// SM-FreeSWITCH config section
type SmFsJsonCfg struct {
Enabled *bool
Rals_conns *[]*HaPoolJsonCfg
Cdrs_conns *[]*HaPoolJsonCfg
Resources_conns *[]*HaPoolJsonCfg
Create_cdr *bool
Extra_fields *[]string
Debit_interval *string
Min_call_duration *string
Max_call_duration *string
Min_dur_low_balance *string
Low_balance_ann_file *string
Enabled *bool
Smg_conns *[]*HaPoolJsonCfg // Connections towards generic SMG
Subscribe_park *bool
Create_cdr *bool
Extra_fields *[]string
//Min_dur_low_balance *string
//Low_balance_ann_file *string
Empty_balance_context *string
Empty_balance_ann_file *string
Subscribe_park *bool
Channel_sync_interval *string
Max_wait_connection *string
Event_socket_conns *[]*FsConnJsonCfg
}
// Represents one connection instance towards FreeSWITCH
type FsConnJsonCfg struct {
Address *string
Password *string
Reconnects *int
}
// Represents one connection instance towards a rater/cdrs server
type HaPoolJsonCfg struct {
Address *string
@@ -247,10 +249,10 @@ type AstConnJsonCfg struct {
}
type SMAsteriskJsonCfg struct {
Enabled *bool
Sm_generic_conns *[]*HaPoolJsonCfg // Connections towards generic SMf
Create_cdr *bool
Asterisk_conns *[]*AstConnJsonCfg
Enabled *bool
Smg_conns *[]*HaPoolJsonCfg // Connections towards generic SMG
Create_cdr *bool
Asterisk_conns *[]*AstConnJsonCfg
}
type CacheParamJsonCfg struct {
@@ -262,13 +264,6 @@ type CacheParamJsonCfg struct {
type CacheJsonCfg map[string]*CacheParamJsonCfg
// Represents one connection instance towards FreeSWITCH
type FsConnJsonCfg struct {
Address *string
Password *string
Reconnects *int
}
// SM-Kamailio config section
type SmKamJsonCfg struct {
Enabled *bool
@@ -313,7 +308,7 @@ 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
Smg_conns *[]*HaPoolJsonCfg // Connections towards generic SM
Pubsubs_conns *[]*HaPoolJsonCfg // connection towards pubsubs
Create_cdr *bool
Cdr_requires_session *bool
@@ -347,7 +342,7 @@ type RadiusAgentJsonCfg struct {
Listen_acct *string
Client_secrets *map[string]string
Client_dictionaries *map[string]string
Sm_generic_conns *[]*HaPoolJsonCfg
Smg_conns *[]*HaPoolJsonCfg
Create_cdr *bool
Cdr_requires_session *bool
Timezone *string

View File

@@ -29,7 +29,7 @@ type RadiusAgentCfg struct {
ListenAcct string
ClientSecrets map[string]string
ClientDictionaries map[string]string
SMGenericConns []*HaPoolConfig
SMGConns []*HaPoolConfig
CreateCDR bool
CDRRequiresSession bool
Timezone string
@@ -68,11 +68,11 @@ func (self *RadiusAgentCfg) loadFromJsonCfg(jsnCfg *RadiusAgentJsonCfg) error {
self.ClientDictionaries[k] = v
}
}
if jsnCfg.Sm_generic_conns != nil {
self.SMGenericConns = make([]*HaPoolConfig, len(*jsnCfg.Sm_generic_conns))
for idx, jsnHaCfg := range *jsnCfg.Sm_generic_conns {
self.SMGenericConns[idx] = NewDfltHaPoolConfig()
self.SMGenericConns[idx].loadFromJsonCfg(jsnHaCfg)
if jsnCfg.Smg_conns != nil {
self.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
self.SMGConns[idx] = NewDfltHaPoolConfig()
self.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
}
}
if jsnCfg.Create_cdr != nil {

View File

@@ -88,7 +88,7 @@ func (self *FsConnConfig) loadFromJsonCfg(jsnCfg *FsConnJsonCfg) error {
return nil
}
type SmGenericConfig struct {
type SMGConfig struct {
Enabled bool
ListenBijson string
RALsConns []*HaPoolConfig
@@ -104,7 +104,7 @@ type SmGenericConfig struct {
SessionIndexes utils.StringMap
}
func (self *SmGenericConfig) loadFromJsonCfg(jsnCfg *SmGenericJsonCfg) error {
func (self *SMGConfig) loadFromJsonCfg(jsnCfg *SmgJsonCfg) error {
if jsnCfg == nil {
return nil
}
@@ -177,20 +177,15 @@ func (self *SmGenericConfig) loadFromJsonCfg(jsnCfg *SmGenericJsonCfg) error {
}
type SmFsConfig struct {
Enabled bool
RALsConns []*HaPoolConfig
CDRsConns []*HaPoolConfig
RLsConns []*HaPoolConfig
CreateCdr bool
ExtraFields []*utils.RSRField
DebitInterval time.Duration
MinCallDuration time.Duration
MaxCallDuration time.Duration
MinDurLowBalance time.Duration
LowBalanceAnnFile string
Enabled bool
SMGConns []*HaPoolConfig
SubscribePark bool
CreateCdr bool
ExtraFields []*utils.RSRField
//MinDurLowBalance time.Duration
//LowBalanceAnnFile string
EmptyBalanceContext string
EmptyBalanceAnnFile string
SubscribePark bool
ChannelSyncInterval time.Duration
MaxWaitConnection time.Duration
EventSocketConns []*FsConnConfig
@@ -204,26 +199,15 @@ func (self *SmFsConfig) loadFromJsonCfg(jsnCfg *SmFsJsonCfg) error {
if jsnCfg.Enabled != nil {
self.Enabled = *jsnCfg.Enabled
}
if jsnCfg.Rals_conns != nil {
self.RALsConns = make([]*HaPoolConfig, len(*jsnCfg.Rals_conns))
for idx, jsnHaCfg := range *jsnCfg.Rals_conns {
self.RALsConns[idx] = NewDfltHaPoolConfig()
self.RALsConns[idx].loadFromJsonCfg(jsnHaCfg)
if jsnCfg.Smg_conns != nil {
self.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
self.SMGConns[idx] = NewDfltHaPoolConfig()
self.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
}
}
if jsnCfg.Cdrs_conns != nil {
self.CDRsConns = make([]*HaPoolConfig, len(*jsnCfg.Cdrs_conns))
for idx, jsnHaCfg := range *jsnCfg.Cdrs_conns {
self.CDRsConns[idx] = NewDfltHaPoolConfig()
self.CDRsConns[idx].loadFromJsonCfg(jsnHaCfg)
}
}
if jsnCfg.Resources_conns != nil {
self.RLsConns = make([]*HaPoolConfig, len(*jsnCfg.Resources_conns))
for idx, jsnHaCfg := range *jsnCfg.Resources_conns {
self.RLsConns[idx] = NewDfltHaPoolConfig()
self.RLsConns[idx].loadFromJsonCfg(jsnHaCfg)
}
if jsnCfg.Subscribe_park != nil {
self.SubscribePark = *jsnCfg.Subscribe_park
}
if jsnCfg.Create_cdr != nil {
self.CreateCdr = *jsnCfg.Create_cdr
@@ -233,38 +217,13 @@ func (self *SmFsConfig) loadFromJsonCfg(jsnCfg *SmFsJsonCfg) error {
return err
}
}
if jsnCfg.Debit_interval != nil {
if self.DebitInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Debit_interval); err != nil {
return err
}
}
if jsnCfg.Min_call_duration != nil {
if self.MinCallDuration, err = utils.ParseDurationWithNanosecs(*jsnCfg.Min_call_duration); err != nil {
return err
}
}
if jsnCfg.Max_call_duration != nil {
if self.MaxCallDuration, err = utils.ParseDurationWithNanosecs(*jsnCfg.Max_call_duration); err != nil {
return err
}
}
if jsnCfg.Min_dur_low_balance != nil {
if self.MinDurLowBalance, err = utils.ParseDurationWithNanosecs(*jsnCfg.Min_dur_low_balance); err != nil {
return err
}
}
if jsnCfg.Low_balance_ann_file != nil {
self.LowBalanceAnnFile = *jsnCfg.Low_balance_ann_file
}
if jsnCfg.Empty_balance_context != nil {
self.EmptyBalanceContext = *jsnCfg.Empty_balance_context
}
if jsnCfg.Empty_balance_ann_file != nil {
self.EmptyBalanceAnnFile = *jsnCfg.Empty_balance_ann_file
}
if jsnCfg.Subscribe_park != nil {
self.SubscribePark = *jsnCfg.Subscribe_park
}
if jsnCfg.Channel_sync_interval != nil {
if self.ChannelSyncInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Channel_sync_interval); err != nil {
return err
@@ -512,9 +471,9 @@ func (aCfg *SMAsteriskCfg) loadFromJsonCfg(jsnCfg *SMAsteriskJsonCfg) (err error
if jsnCfg.Enabled != nil {
aCfg.Enabled = *jsnCfg.Enabled
}
if jsnCfg.Sm_generic_conns != nil {
aCfg.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Sm_generic_conns))
for idx, jsnHaCfg := range *jsnCfg.Sm_generic_conns {
if jsnCfg.Smg_conns != nil {
aCfg.SMGConns = make([]*HaPoolConfig, len(*jsnCfg.Smg_conns))
for idx, jsnHaCfg := range *jsnCfg.Smg_conns {
aCfg.SMGConns[idx] = NewDfltHaPoolConfig()
aCfg.SMGConns[idx].loadFromJsonCfg(jsnHaCfg)
}