Updated cdrc and cdre after latest changes

This commit is contained in:
Trial97
2019-03-08 15:24:23 +02:00
committed by Dan Christian Bogos
parent c4487efc79
commit ee1cd56f6d
6 changed files with 69 additions and 49 deletions

View File

@@ -110,6 +110,9 @@ func (self *CsvRecordsProcessor) processRecord(record []string) ([]*engine.CDR,
if err != nil {
return nil, err
}
if tenant == "" {
tenant = config.CgrConfig().GeneralCfg().DefaultTenant
}
// Make sure filters are matching
if len(cdrcCfg.Filters) != 0 {
if pass, err := self.filterS.Pass(tenant,

View File

@@ -121,6 +121,9 @@ func (self *FwvRecordsProcessor) ProcessNextRecord() ([]*engine.CDR, error) {
if err != nil {
return nil, err
}
if tenant == "" {
tenant = config.CgrConfig().GeneralCfg().DefaultTenant
}
if len(cdrcCfg.Filters) != 0 {
if pass, err := self.filterS.Pass(tenant,
cdrcCfg.Filters, fwvProvider); err != nil || !pass {

View File

@@ -121,6 +121,9 @@ func (xmlProc *XMLRecordsProcessor) ProcessNextRecord() (cdrs []*engine.CDR, err
if err != nil {
return nil, err
}
if tenant == "" {
tenant = config.CgrConfig().GeneralCfg().DefaultTenant
}
if len(cdrcCfg.Filters) != 0 {
if pass, err := xmlProc.filterS.Pass(tenant,
cdrcCfg.Filters, xmlProvider); err != nil || !pass {

View File

@@ -29,7 +29,7 @@
"cdr_in_dir": "/tmp/cdrcxmlwithfilters/xmlit1/in",
"cdr_out_dir": "/tmp/cdrcxmlwithfilters/xmlit1/out",
"cdr_path": "broadWorksCDR.cdrData",
"cdr_source_id": "xmlit1",
"cdr_source_id": "xmlit1",
"filters": ["*string:~broadWorksCDR.cdrData.basicModule.userNumber:1002","*string:~broadWorksCDR.cdrData.headerModule.type:Normal"],
"content_fields":[ // import content_fields template, id will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "*voice", "mandatory": true},
@@ -46,54 +46,54 @@
],
},
{
"id": "msw_xml", // identifier of the CDRC runner
"enabled": true, // enable CDR client functionality
"cdr_format": "xml", // CDR file format <csv|freeswitch_csv|fwv|opensips_flatstore|partial_csv.
"cdr_in_dir": "/tmp/cdrcxmlwithfilters2/xmlit2/in",
"cdr_out_dir": "/tmp/cdrcxmlwithfilters2/xmlit2/out",
"cdr_path": "File.CDRs.Call", // path towards one CDR element in case of XML CDRs
"cdr_source_id": "zw_cfs1", // free form field, tag identifying the source of the CDRs within CDRS database
"content_fields":[ // import content_fields template, id will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~File.CDRs.Call.SignalingInfo.PChargingVector.icidvalue", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "*rated", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "XX.liquid.tel", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~File.CDRs.Call.RoutingInfo.DestAddr", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~File.CDRs.Call.RingingTime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~File.CDRs.Call.ConnectTime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*handler", "handler_id": "*substract_usage", "value": "~File.CDRs.Call.ReleaseTime;|;~File.CDRs.Call.ConnectTime", "mandatory": true}
],
},
{
"id": "msw_xml2", // identifier of the CDRC runner
"enabled": true, // enable CDR client functionality
"cdr_format": "xml", // CDR file format <csv|freeswitch_csv|fwv|opensips_flatstore|partial_csv.
"cdr_in_dir": "/tmp/cdrcxmlwithfilters3/xmlit3/in",
"cdr_out_dir": "/tmp/cdrcxmlwithfilters3/xmlit3/out",
"cdr_path": "File.CDRs.Call", // path towards one CDR element in case of XML CDRs
"cdr_source_id": "zw_cfs1", // free form field, tag identifying the source of the CDRs within CDRS database
"content_fields":[ // import content_fields template, id will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~File.CDRs.Call.SignalingInfo.PChargingVector.icidvalue", "mandatory": true},
{"tag": "OriginID2", "field_id": "OriginID", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SIPCallId:s/^(.*)@.*/$1/", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SIPCallId:s/^.*@(.*)/$1/", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "*rated", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "XX.liquid.tel", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~File.CDRs.Call.RoutingInfo.DestAddr", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~File.CDRs.Call.RingingTime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~File.CDRs.Call.ConnectTime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*handler", "handler_id": "*substract_usage", "value": "~File.CDRs.Call.ReleaseTime;|;~File.CDRs.Call.ConnectTime", "mandatory": true}
],
},
{
"id": "msw_xml", // identifier of the CDRC runner
"enabled": true, // enable CDR client functionality
"cdr_format": "xml", // CDR file format <csv|freeswitch_csv|fwv|opensips_flatstore|partial_csv.
"cdr_in_dir": "/tmp/cdrcxmlwithfilters2/xmlit2/in",
"cdr_out_dir": "/tmp/cdrcxmlwithfilters2/xmlit2/out",
"cdr_path": "File.CDRs.Call", // path towards one CDR element in case of XML CDRs
"cdr_source_id": "zw_cfs1", // free form field, tag identifying the source of the CDRs within CDRS database
"content_fields":[ // import content_fields template, id will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~File.CDRs.Call.SignalingInfo.PChargingVector.icidvalue", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "*rated", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "XX.liquid.tel", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~File.CDRs.Call.RoutingInfo.DestAddr", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~File.CDRs.Call.RingingTime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~File.CDRs.Call.ConnectTime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*handler", "handler_id": "*substract_usage", "value": "~File.CDRs.Call.ReleaseTime;|;~File.CDRs.Call.ConnectTime", "mandatory": true}
],
},
{
"id": "msw_xml2", // identifier of the CDRC runner
"enabled": true, // enable CDR client functionality
"cdr_format": "xml", // CDR file format <csv|freeswitch_csv|fwv|opensips_flatstore|partial_csv.
"cdr_in_dir": "/tmp/cdrcxmlwithfilters3/xmlit3/in",
"cdr_out_dir": "/tmp/cdrcxmlwithfilters3/xmlit3/out",
"cdr_path": "File.CDRs.Call", // path towards one CDR element in case of XML CDRs
"cdr_source_id": "zw_cfs1", // free form field, tag identifying the source of the CDRs within CDRS database
"content_fields":[ // import content_fields template, id will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~File.CDRs.Call.SignalingInfo.PChargingVector.icidvalue", "mandatory": true},
{"tag": "OriginID2", "field_id": "OriginID", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SIPCallId:s/^(.*)@.*/$1/", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SIPCallId:s/^.*@(.*)/$1/", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "*rated", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "XX.liquid.tel", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~File.CDRs.Call.OrigParty.SubscriberAddr", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~File.CDRs.Call.RoutingInfo.DestAddr", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~File.CDRs.Call.RingingTime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~File.CDRs.Call.ConnectTime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*handler", "handler_id": "*substract_usage", "value": "~File.CDRs.Call.ReleaseTime;|;~File.CDRs.Call.ConnectTime", "mandatory": true}
],
},
{
"id": "XMLWithFilterID",
"enabled": true,
"cdr_format": "xml",

View File

@@ -372,6 +372,9 @@ func (cdre *CDRExporter) processCDRs() (err error) {
continue
}
if len(cdre.exportTemplate.Filters) != 0 {
if cdre.exportTemplate.Tenant == "" {
cdre.exportTemplate.Tenant = config.CgrConfig().GeneralCfg().DefaultTenant
}
if pass, err := cdre.filterS.Pass(cdre.exportTemplate.Tenant,
cdre.exportTemplate.Filters, config.NewNavigableMap(cdr.AsMapStringIface())); err != nil || !pass {
continue // Not passes filters, ignore this CDR

View File

@@ -171,6 +171,14 @@ func testV1SplSSetSupplierProfilesWithoutRatingPlanIDs(t *testing.T) {
ev, &suplsReply); err.Error() != utils.NewErrServerError(utils.NewErrMandatoryIeMissing("RatingPlanIDs")).Error() {
t.Errorf("Expected error MANDATORY_IE_MISSING: [RatingPlanIDs] recieved:%v\n", err)
}
if err := splSv1Rpc.Call("ApierV1.RemoveSupplierProfile", utils.TenantID{
Tenant: splPrf.Tenant,
ID: splPrf.ID,
}, &result); err != nil {
t.Error(err)
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
}
}
func testV1SplSAddNewSplPrf(t *testing.T) {