From 20221e497ab28316a804d3a97043dafbac795674 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Mon, 11 Dec 2017 17:40:58 +0100 Subject: [PATCH] TT#25451 sync-db: add general.timezone handling support * general.timezone value from config.yml is now populated into ngcp.timezone DB table.column * it produces an error if general.timezone field is undefined Change-Id: I975f786a7f8ff42916d92e13f6fe9971d5b1e2f0 --- helper/sync-db | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/helper/sync-db b/helper/sync-db index 04f5df12..327310c2 100755 --- a/helper/sync-db +++ b/helper/sync-db @@ -61,6 +61,9 @@ exit 1 unless(sync_extra_sockets($dbh, exit 1 unless(sync_rtp_interfaces($dbh, { map {$_ => $_} @{$config->{rtp_interfaces}} } )); +exit 1 unless(sync_general_timezone($dbh, + $config->{general}->{timezone})); + $dbh->disconnect; exit 0; @@ -135,4 +138,30 @@ sub sync_rtp_interfaces { return generic_enum_sync(@_, 'rtp_interface'); } +## general.timezone handling: ############################## +sub sync_general_timezone { + my $dbh = shift; + my $tz = shift; + + unless ($tz) { + print "Error: general.timezone value is not set\n"; + return; + } + + my $pe = $dbh->{PrintError}; + $dbh->{PrintError} = 0; + $dbh->do(<{PrintError} = $pe; + if ($DBI::err) { + print "Error: Could not insert into ngcp.timezone: $DBI::errstr\n"; + return; + } + + return 1; +} + + ## END OF FILE #################################################################