diff --git a/config/cdreconfig.go b/config/cdreconfig.go index afc7601d1..9dfd0c34c 100644 --- a/config/cdreconfig.go +++ b/config/cdreconfig.go @@ -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 diff --git a/config/config_defaults.go b/config/config_defaults.go index a396e9eb8..17626097f 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -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 diff --git a/config/config_json_test.go b/config/config_json_test.go index 7f5e2c731..9bdd873fa 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -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), diff --git a/config/config_test.go b/config/config_test.go index 2ffe16c9f..853617947 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -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: ',', diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 5b3751abb..dfc9eddb3 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -173,6 +173,7 @@ type CdreJsonCfg struct { Export_path *string Cdr_filter *string Filters *[]string + Tenant *string Synchronous *bool Attempts *int Field_separator *string diff --git a/engine/cdre.go b/engine/cdre.go index b14b90bb4..82eae9c91 100644 --- a/engine/cdre.go +++ b/engine/cdre.go @@ -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 }