Add Tenant option for cdre

This commit is contained in:
TeoV
2018-08-06 10:36:12 -04:00
committed by Dan Christian Bogos
parent 12b40afe6f
commit acef7743c6
6 changed files with 10 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ type CdreConfig struct {
FallbackPath string
CDRFilter utils.RSRFields
Filters []string
Tenant string
Synchronous bool
Attempts int
FieldSeparator rune
@@ -61,6 +62,9 @@ func (self *CdreConfig) loadFromJsonCfg(jsnCfg *CdreJsonCfg) error {
self.Filters[i] = fltr
}
}
if jsnCfg.Tenant != nil {
self.Tenant = *jsnCfg.Tenant
}
if jsnCfg.Synchronous != nil {
self.Synchronous = *jsnCfg.Synchronous
}
@@ -108,6 +112,7 @@ func (self *CdreConfig) Clone() *CdreConfig {
clnCdre.Synchronous = self.Synchronous
clnCdre.Attempts = self.Attempts
clnCdre.FieldSeparator = self.FieldSeparator
clnCdre.Tenant = self.Tenant
clnCdre.UsageMultiplyFactor = make(map[string]float64, len(self.UsageMultiplyFactor))
for k, v := range self.UsageMultiplyFactor {
clnCdre.UsageMultiplyFactor[k] = v

View File

@@ -200,6 +200,7 @@ const CGRATES_CFG_JSON = `
"export_path": "/var/spool/cgrates/cdre", // path where the exported CDRs will be placed
"cdr_filter": "", // filter CDRs exported by this template
"filters" :[], // new filters for cdre
"tenant": "cgrates.org", // tenant used in filterS.Pass
"synchronous": false, // block processing until export has a result
"attempts": 1, // Number of attempts if not success
"field_separator": ",", // used field separator in some export formats, eg: *file_csv

View File

@@ -365,6 +365,7 @@ func TestDfCdreJsonCfgs(t *testing.T) {
Cdr_filter: utils.StringPointer(""),
Synchronous: utils.BoolPointer(false),
Attempts: utils.IntPointer(1),
Tenant: utils.StringPointer("cgrates.org"),
Field_separator: utils.StringPointer(","),
Usage_multiply_factor: &map[string]float64{utils.ANY: 1.0},
Cost_multiply_factor: utils.Float64Pointer(1.0),

View File

@@ -581,6 +581,7 @@ func TestCgrCfgJSONDefaultsCdreProfiles(t *testing.T) {
ExportFormat: utils.MetaFileCSV,
ExportPath: "/var/spool/cgrates/cdre",
Filters: []string{},
Tenant: "cgrates.org",
Synchronous: false,
Attempts: 1,
FieldSeparator: ',',

View File

@@ -173,6 +173,7 @@ type CdreJsonCfg struct {
Export_path *string
Cdr_filter *string
Filters *[]string
Tenant *string
Synchronous *bool
Attempts *int
Field_separator *string

View File

@@ -355,7 +355,7 @@ func (cdre *CDRExporter) processCDRs() (err error) {
continue
}
} else {
if pass, err := cdre.filterS.Pass("cgrates.org",
if pass, err := cdre.filterS.Pass(cdre.exportTemplate.Tenant,
cdre.exportTemplate.Filters, NewNavigableMap(cdr.AsMapStringIface())); err != nil || !pass {
continue // Not passes filters, ignore this CDR
}