Config defaults updated, cdrs=internal on SM components, sanity checks updated

This commit is contained in:
DanB
2015-06-09 12:33:09 +02:00
parent 8b0811267e
commit 471736fcda
4 changed files with 36 additions and 14 deletions

View File

@@ -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.")
}

View File

@@ -175,13 +175,14 @@ const CGRATES_CFG_JSON = `
}
},
"sm_freeswitch": {
"enabled": false, // starts SessionManager service: <true|false>
"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: <true|false>
"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: <true|false>
"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.

View File

@@ -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"),

View File

@@ -179,13 +179,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
// },
//},
//"sm_freeswitch": {
// "enabled": false, // starts SessionManager service: <true|false>
// "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 <http://www.gnu.org/licenses/>
//"sm_kamailio": {
// "enabled": false, // starts SessionManager service: <true|false>
// "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 <http://www.gnu.org/licenses/>
// "enabled": false, // starts SessionManager service: <true|false>
// "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
//},