From 471736fcdabb7c60e4e120d095865c9101b51606 Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 9 Jun 2015 12:33:09 +0200 Subject: [PATCH] Config defaults updated, cdrs=internal on SM components, sanity checks updated --- config/config.go | 18 ++++++++++++++++++ config/config_defaults.go | 9 +++++---- config/config_json_test.go | 6 +++--- data/conf/cgrates/cgrates.json | 17 ++++++++++------- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/config/config.go b/config/config.go index ceced44f8..cc9e34c05 100644 --- a/config/config.go +++ b/config/config.go @@ -271,6 +271,12 @@ func (self *CGRConfig) checkConfigSanity() error { } // SM-FreeSWITCH checks if self.SmFsConfig.Enabled { + if self.SmFsConfig.Rater == "" { + return errors.New("Rater definition is mandatory!") + } + if self.SmFsConfig.Cdrs == "" { + return errors.New("Cdrs definition is mandatory!") + } if self.SmFsConfig.Rater == utils.INTERNAL && !self.RaterEnabled { return errors.New("Rater not enabled but requested by SM-FreeSWITCH component.") } @@ -280,6 +286,12 @@ func (self *CGRConfig) checkConfigSanity() error { } // SM-Kamailio checks if self.SmKamConfig.Enabled { + if self.SmKamConfig.Rater == "" { + return errors.New("Rater definition is mandatory!") + } + if self.SmKamConfig.Cdrs == "" { + return errors.New("Cdrs definition is mandatory!") + } if self.SmKamConfig.Rater == utils.INTERNAL && !self.RaterEnabled { return errors.New("Rater not enabled but requested by SM-Kamailio component.") } @@ -289,6 +301,12 @@ func (self *CGRConfig) checkConfigSanity() error { } // SM-OpenSIPS checks if self.SmOsipsConfig.Enabled { + if self.SmOsipsConfig.Rater == "" { + return errors.New("Rater definition is mandatory!") + } + if self.SmOsipsConfig.Cdrs == "" { + return errors.New("Cdrs definition is mandatory!") + } if self.SmOsipsConfig.Rater == utils.INTERNAL && !self.RaterEnabled { return errors.New("Rater not enabled but requested by SM-OpenSIPS component.") } diff --git a/config/config_defaults.go b/config/config_defaults.go index 66f90899e..9f01bc18a 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -175,13 +175,14 @@ const CGRATES_CFG_JSON = ` } }, + "sm_freeswitch": { "enabled": false, // starts SessionManager service: "rater": "internal", // address where to reach the Rater <""|internal|127.0.0.1:2013> - "cdrs": "", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> + "cdrs": "internal", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> "reconnects": 5, // number of reconnect attempts to rater or cdrs "create_cdr": false, // create CDR out of events and sends them to CDRS component - "cdr_extra_fields": [], // extra fields to store in CDRs in case of processing them + "cdr_extra_fields": [], // extra fields to store in 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 @@ -198,7 +199,7 @@ const CGRATES_CFG_JSON = ` "sm_kamailio": { "enabled": false, // starts SessionManager service: "rater": "internal", // address where to reach the Rater <""|internal|127.0.0.1:2013> - "cdrs": "", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> + "cdrs": "internal", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> "reconnects": 5, // number of reconnect attempts to rater or cdrs "create_cdr": false, // create CDR out of events and sends them to CDRS component "debit_interval": "10s", // interval to perform debits on. @@ -214,7 +215,7 @@ const CGRATES_CFG_JSON = ` "enabled": false, // starts SessionManager service: "listen_udp": "127.0.0.1:2020", // address where to listen for datagram events coming from OpenSIPS "rater": "internal", // address where to reach the Rater <""|internal|127.0.0.1:2013> - "cdrs": "", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> + "cdrs": "internal", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> "reconnects": 5, // number of reconnects if connection is lost "create_cdr": false, // create CDR out of events and sends them to CDRS component "debit_interval": "10s", // interval to perform debits on. diff --git a/config/config_json_test.go b/config/config_json_test.go index b7fd6e3a5..10460f7ec 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -306,7 +306,7 @@ func TestSmFsJsonCfg(t *testing.T) { eCfg := &SmFsJsonCfg{ Enabled: utils.BoolPointer(false), Rater: utils.StringPointer("internal"), - Cdrs: utils.StringPointer(""), + Cdrs: utils.StringPointer("internal"), Reconnects: utils.IntPointer(5), Create_cdr: utils.BoolPointer(false), Cdr_extra_fields: utils.StringSlicePointer([]string{}), @@ -335,7 +335,7 @@ func TestSmKamJsonCfg(t *testing.T) { eCfg := &SmKamJsonCfg{ Enabled: utils.BoolPointer(false), Rater: utils.StringPointer("internal"), - Cdrs: utils.StringPointer(""), + Cdrs: utils.StringPointer("internal"), Reconnects: utils.IntPointer(5), Create_cdr: utils.BoolPointer(false), Debit_interval: utils.StringPointer("10s"), @@ -360,7 +360,7 @@ func TestSmOsipsJsonCfg(t *testing.T) { Enabled: utils.BoolPointer(false), Listen_udp: utils.StringPointer("127.0.0.1:2020"), Rater: utils.StringPointer("internal"), - Cdrs: utils.StringPointer(""), + Cdrs: utils.StringPointer("internal"), Reconnects: utils.IntPointer(5), Create_cdr: utils.BoolPointer(false), Debit_interval: utils.StringPointer("10s"), diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 1ab166497..796593598 100644 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -179,13 +179,14 @@ along with this program. If not, see // }, //}, + //"sm_freeswitch": { // "enabled": false, // starts SessionManager service: // "rater": "internal", // address where to reach the Rater <""|internal|127.0.0.1:2013> -// "cdrs": "", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> +// "cdrs": "internal", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> // "reconnects": 5, // number of reconnect attempts to rater or cdrs -// "compute_lcr": false, // when enabled it will compute and set cgr_lcr channel variable with least cost route ids -// "cdr_extra_fields": [], // extra fields to store in CDRs in case of processing them +// "create_cdr": false, // create CDR out of events and sends them to CDRS component +// "cdr_extra_fields": [], // extra fields to store in 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 @@ -202,8 +203,9 @@ along with this program. If not, see //"sm_kamailio": { // "enabled": false, // starts SessionManager service: // "rater": "internal", // address where to reach the Rater <""|internal|127.0.0.1:2013> -// "cdrs": "", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> +// "cdrs": "internal", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> // "reconnects": 5, // number of reconnect attempts to rater or cdrs +// "create_cdr": false, // create CDR out of events and sends them to CDRS component // "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 @@ -217,13 +219,14 @@ along with this program. If not, see // "enabled": false, // starts SessionManager service: // "listen_udp": "127.0.0.1:2020", // address where to listen for datagram events coming from OpenSIPS // "rater": "internal", // address where to reach the Rater <""|internal|127.0.0.1:2013> -// "cdrs": "", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> +// "cdrs": "internal", // address where to reach CDR Server, empty to disable CDR capturing <""|internal|x.y.z.y:1234> +// "reconnects": 5, // number of reconnects if connection is lost +// "create_cdr": false, // create CDR out of events and sends them to CDRS component // "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 // "events_subscribe_interval": "60s", // automatic events subscription to OpenSIPS, 0 to disable it -// "mi_addr": "127.0.0.1:8020", // address where to reach OpenSIPS MI to send session disconnects -// "reconnects": 5, // number of reconnects if connection is lost +// "mi_addr": "127.0.0.1:8020", // address where to reach OpenSIPS MI to send session disconnects //},