From 08330e443906a486a5f2756be59627fdf182dd08 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 19 May 2015 10:44:28 +0200 Subject: [PATCH] MT#13001 add config QUOTES and use single quotes as default - use quotes on reseller too Change-Id: I60dcb8ce6f63c0da3ceac46e7915d9adde468211 --- NGCP/CDR/Exporter.pm | 3 ++- cdr-exporter.conf | 2 ++ cdr-exporter.pl | 6 +++--- event-exporter.conf | 2 ++ event-exporter.pl | 6 +++--- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/NGCP/CDR/Exporter.pm b/NGCP/CDR/Exporter.pm index ce60008..7f682c6 100644 --- a/NGCP/CDR/Exporter.pm +++ b/NGCP/CDR/Exporter.pm @@ -53,7 +53,8 @@ my %config = ( 'default.TRANSFER_PORT' => 22, 'default.TRANSFER_USER' => "cdrexport", 'default.TRANSFER_KEY' => "/root/.ssh/id_rsa", - 'default.TRANSFER_REMOTE' => "/home/jail/home/cdrexport" + 'default.TRANSFER_REMOTE' => "/home/jail/home/cdrexport", + 'default.QUOTES' => "'" ); sub DEBUG { diff --git a/cdr-exporter.conf b/cdr-exporter.conf index 67cd4af..98e69c2 100644 --- a/cdr-exporter.conf +++ b/cdr-exporter.conf @@ -16,6 +16,8 @@ PREFIX=ngcp VERSION=007 MAX_ROWS_PER_FILE=5000 +QUOTES="'" + EXPORT_INCOMING=no ADMIN_EXPORT_FIELDS = 'accounting.cdr.id', 'accounting.cdr.update_time', 'accounting.cdr.source_user_id', 'accounting.cdr.source_provider_id', 'accounting.cdr.source_external_subscriber_id', 'source_voip_subscribers.id', 'accounting.cdr.source_external_contract_id', 'accounting.cdr.source_account_id', 'accounting.cdr.source_user', 'accounting.cdr.source_domain', 'accounting.cdr.source_cli', 'accounting.cdr.source_clir', 'accounting.cdr.source_ip', 'accounting.cdr.destination_user_id', 'accounting.cdr.destination_provider_id', 'accounting.cdr.destination_external_subscriber_id', 'destination_voip_subscribers.id', 'accounting.cdr.destination_external_contract_id', 'accounting.cdr.destination_account_id', 'accounting.cdr.destination_user', 'accounting.cdr.destination_domain', 'accounting.cdr.destination_user_in', 'accounting.cdr.destination_domain_in', 'accounting.cdr.destination_user_dialed', 'accounting.cdr.peer_auth_user', 'accounting.cdr.peer_auth_realm', 'accounting.cdr.call_type', 'accounting.cdr.call_status', 'accounting.cdr.call_code', 'CONCAT(FROM_UNIXTIME(accounting.cdr.init_time), ".", SUBSTRING_INDEX(accounting.cdr.init_time, ".", -1))', 'CONCAT(FROM_UNIXTIME(accounting.cdr.start_time), ".", SUBSTRING_INDEX(accounting.cdr.start_time, ".", -1))', 'accounting.cdr.duration', 'accounting.cdr.call_id', 'accounting.cdr.rating_status', 'accounting.cdr.rated_at', 'accounting.cdr.source_carrier_cost', 'accounting.cdr.source_customer_cost', 'COALESCE(source_carrier_bbz.zone, "onnet")', 'source_customer_bbz.zone', 'COALESCE(source_carrier_bbz.detail, "platform internal")', 'source_customer_bbz.detail', 'accounting.cdr.source_carrier_free_time', 'accounting.cdr.source_customer_free_time', 'accounting.cdr.destination_carrier_cost', 'accounting.cdr.destination_customer_cost', 'destination_carrier_bbz.zone', 'destination_customer_bbz.zone', 'destination_carrier_bbz.detail', 'destination_customer_bbz.detail', 'accounting.cdr.destination_carrier_free_time', 'accounting.cdr.destination_customer_free_time', 'accounting.cdr.source_reseller_cost', 'source_reseller_bbz.zone', 'source_reseller_bbz.detail', 'accounting.cdr.source_reseller_free_time', 'accounting.cdr.destination_reseller_cost', 'destination_reseller_bbz.zone', 'destination_reseller_bbz.detail', 'accounting.cdr.destination_reseller_free_time' diff --git a/cdr-exporter.pl b/cdr-exporter.pl index 260c2d3..fa9264b 100755 --- a/cdr-exporter.pl +++ b/cdr-exporter.pl @@ -51,14 +51,14 @@ my @ids; sub callback { my ($row, $res_row) = @_; - + my $quotes = NGCP::CDR::Exporter::confval('QUOTES'); my @fields = @{ $row }; my $id = shift @fields; my $src_uuid = shift @fields; my $dst_uuid = shift @fields; my $src_provid = shift @fields; my $dst_provid = shift @fields; - @fields = map { defined $_ ? "'$_'" : "''" } (@fields); + @fields = map { defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes } (@fields); if(confval('EXPORT_INCOMING') eq "no" && $src_uuid eq "0") { push @ignored_ids, $id; @@ -69,7 +69,7 @@ sub callback { write_reseller('system', $line); push(@ids, $id); - my $reseller_line = join ",", @$res_row; + my $reseller_line = join ",", map { defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes } (@$res_row); if($src_uuid ne "0") { write_reseller_id($src_provid, $reseller_line); diff --git a/event-exporter.conf b/event-exporter.conf index c96751c..0a0166f 100644 --- a/event-exporter.conf +++ b/event-exporter.conf @@ -20,6 +20,8 @@ PREFIX=sipwise VERSION=001 SUFFIX=edr +QUOTES="'" + # none if no remote transfer should be done # other options are sftp (requiring TRANSFER_PASS) # or sftp-sh (requiring TRANSFER_KEY) diff --git a/event-exporter.pl b/event-exporter.pl index b5dad98..3ecc7a7 100755 --- a/event-exporter.pl +++ b/event-exporter.pl @@ -52,12 +52,12 @@ NGCP::CDR::Exporter::run(\&callback); sub callback { my ($row, $res_row) = @_; - + my $quotes = NGCP::CDR::Exporter::confval('QUOTES'); my @head = @{ $row }[0 .. 5]; my ($id, $sub_id, $res_id, $type, $old, $new) = @head; - my @fields = map { defined $_ ? "\"$_\"" : '""' } (@{ $row }[6 .. @{ $row }-1]); + my @fields = map {defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes } (@{ $row }[6 .. @{ $row }-1]); my $line = join ",", @fields; - my $reseller_line = join ",", @$res_row; + my $reseller_line = join ",", map {defined $_ ? $quotes . $_ . $quotes : $quotes. $quotes }(@$res_row); if(confval('FILTER_FLAPPING')) { if($type =~ /^start_(.+)$/) {