mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Add Tenant option for cdre
This commit is contained in:
committed by
Dan Christian Bogos
parent
12b40afe6f
commit
acef7743c6
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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: ',',
|
||||
|
||||
@@ -173,6 +173,7 @@ type CdreJsonCfg struct {
|
||||
Export_path *string
|
||||
Cdr_filter *string
|
||||
Filters *[]string
|
||||
Tenant *string
|
||||
Synchronous *bool
|
||||
Attempts *int
|
||||
Field_separator *string
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user