[sysfink] r204 committed - * remove dependency on YAML and Config::Multi...

1 view
Skip to first unread message

sys...@googlecode.com

unread,
Jan 20, 2010, 10:27:11 AM1/20/10
to sys...@googlegroups.com
Revision: 204
Author: mj41.cz
Date: Wed Jan 20 07:26:46 2010
Log: * remove dependency on YAML and Config::Multi
* Server - small refactor and fix


http://code.google.com/p/sysfink/source/detail?r=204

Added:
/trunk/server/conf/sysfink.conf.example
/trunk/server/t/conf-test.example/sysfink.conf-mysql
/trunk/server/t/conf-test.example/sysfink.conf-sqlite
Deleted:
/trunk/server/conf/web.yml.example
/trunk/server/conf/web_db.yml.example
/trunk/server/t/conf-test.example/web_db.yml-mysql.example
/trunk/server/t/conf-test.example/web_db.yml-sqlite.example
Modified:
/trunk/server/conf
/trunk/server/docs/INSTALL
/trunk/server/lib/SysFink/Server.pm
/trunk/server/lib/SysFink/Utils/Conf.pm
/trunk/server/sql/data-base.pl
/trunk/server/sql/data-dev.pl
/trunk/server/sql/data-stable.pl
/trunk/server/t/base/modules-ext.t
/trunk/server/t/base/schema.t
/trunk/server/t/utils/db.t
/trunk/server/utils/db-run-sqlscript.pl
/trunk/server/utils/test-new.sh

=======================================
--- /dev/null
+++ /trunk/server/conf/sysfink.conf.example Wed Jan 20 07:26:46 2010
@@ -0,0 +1,16 @@
+name SysFink Web interface
+
+<db>
+ name "sysfink"
+ dbi_dsn "dbi:SQLite:sysfink.db"
+ user ""
+ pass ""
+</db>
+
+#<db>
+# name sysfink
+# dbi_dsn "dbi:mysql:database=sysfink;host=localhost"
+# user sysfink
+# pass "Your password for sysfink mysql user."
+#</db>
+
=======================================
--- /dev/null
+++ /trunk/server/t/conf-test.example/sysfink.conf-mysql Wed Jan 20
07:26:46 2010
@@ -0,0 +1,9 @@
+name SysFink Web interface
+
+<db>
+ name sysfink-dev
+ dbi_dsn "dbi:mysql:database=sysfink-dev;host=localhost"
+ user sysfink-dev
+ pass "Your password for sysfink-dev mysql user."
+</db>
+
=======================================
--- /dev/null
+++ /trunk/server/t/conf-test.example/sysfink.conf-sqlite Wed Jan 20
07:26:46 2010
@@ -0,0 +1,8 @@
+name SysFink Web interface
+
+<db>
+ name "sysfink-dev"
+ dbi_dsn "dbi:SQLite:sysfink-dev.db"
+ user ""
+ pass ""
+</db>
=======================================
--- /trunk/server/conf/web.yml.example Wed Jul 15 11:56:26 2009
+++ /dev/null
@@ -1,10 +0,0 @@
----
-name: SysFink Web interface
-
-# Catalyst bug?
http://www.mail-archive.com/cata...@lists.rawmode.org/msg05868.html
-uploadtmp: '/tmp/sysfink/uploads'
-
-session:
- expires: '3600'
- rewrite: '0'
- storage: '/tmp/sysfink/web-sessions'
=======================================
--- /trunk/server/conf/web_db.yml.example Fri Sep 11 11:37:26 2009
+++ /dev/null
@@ -1,6 +0,0 @@
----
-db:
- name : 'sysfink'
- dbi_dsn: 'dbi:SQLite:sysfink.db'
- user: ''
- pass: ''
=======================================
--- /trunk/server/t/conf-test.example/web_db.yml-mysql.example Tue Jan 12
14:24:03 2010
+++ /dev/null
@@ -1,6 +0,0 @@
----
-db:
- name : 'sysfink-dev'
- dbi_dsn: 'dbi:mysql:database=sysfink-dev;host=localhost'
- user: 'sysfink-dev'
- pass: 'someDevPasswd223'
=======================================
--- /trunk/server/t/conf-test.example/web_db.yml-sqlite.example Tue Jan 12
14:24:03 2010
+++ /dev/null
@@ -1,6 +0,0 @@
----
-db:
- name : 'sysfink-dev'
- dbi_dsn: 'dbi:SQLite:sysfink-dev.db'
- user: ''
- pass: ''
=======================================
--- /trunk/server/docs/INSTALL Tue Jan 19 07:58:00 2010
+++ /trunk/server/docs/INSTALL Wed Jan 20 07:26:46 2010
@@ -43,8 +43,7 @@
install DBIx::Class

install Net::OpenSSH
-install YAML::Any
-install YAML::XS
+install Config::General

# For some devel utils.
# install SQL::Translator
@@ -72,8 +71,7 @@
cd ~/sysfink/server

# Create/edit server config files.
-cp conf/web.yml.example conf/web.yml
-cp conf/web_db.yml.example conf/web_db.yml
+cp conf/sysfink.conf.example conf/sysfink.conf

# Create client's machine config files
cat > conf-machines/my-first-machine
@@ -123,4 +121,3 @@
# normal scan command.
perl sysfink.pl --host=my-first-machine --cmd=renew_client_dir
perl sysfink.pl --host=my-first-machine --cmd=scan
-
=======================================
--- /trunk/server/lib/SysFink/Server.pm Fri Jan 15 14:50:22 2010
+++ /trunk/server/lib/SysFink/Server.pm Wed Jan 20 07:26:46 2010
@@ -48,7 +48,7 @@
$self->{rpc} = undef;
$self->{rpc_ssh_connected} = 0;

- $self->{conf_path} = catdir( $self->{RealBin}, 'conf' );
+ $self->{conf_path} = catfile( $self->{RealBin}, 'conf', 'sysfink.conf'
);

return $self;
}
@@ -86,6 +86,7 @@
},
'renew_client_dir' => {
'load_host_conf_from_db_if_no' => [ qw/ host_dist_type / ],
+ 'host_conf_mandatory_keys' => [ 'ssh_user', 'dist_type', ],
'ssh_connect' => 1,
'type' => 'rpc',
},
@@ -151,7 +152,7 @@
}

my $cmd_conf = $all_cmd_confs->{ $cmd };
-
+
# Special params.
if ( $cmd_conf->{'load_host_conf_from_db_if_no'} ) {
my $all_found = 1;
@@ -176,19 +177,19 @@
if ( $cmd_conf->{validate_host_name_if_given} && defined $opt->{host}
) {
return 0 unless $self->validate_host_name( $opt->{host} );
}
-
+
# Get user_id from given login or who (get_login).
if ( $cmd_conf->{get_who} ) {
return 0 unless $self->get_who( $opt->{who},
$cmd_conf->{get_who}->{mandatory} );
}
-
+
# Load host config for given hostname from connected DB.
if ( $cmd_conf->{ssh_connect} ) {
return 0 unless $self->prepare_base_host_conf( $opt );
}

if ( $cmd_conf->{load_host_conf_from_db} && !$opt->{no_db} ) {
- return 0 unless $self->prepare_host_conf_from_db();
+ return 0 unless $self->prepare_host_conf_from_db(
$cmd_conf->{'host_conf_mandatory_keys'} );
}

# Next commands needs prepared SSH part of object.
@@ -257,7 +258,7 @@
my ( $self, $param_name, $err_msg_end ) = @_;
my $err_msg = "Parameter --${param_name} is mandatory";
if ( $err_msg_end ) {
- $err_msg .= $err_msg_end
+ $err_msg .= $err_msg_end
} else {
$err_msg .= '.';
}
@@ -276,7 +277,7 @@

return 1 unless defined $hostname;

- my $host_row = $self->{schema}->resultset('machine')->find({
+ my $host_row = $self->{schema}->resultset('machine')->find({
'name' => $hostname,
});
return $self->err("Couldn't find hostname '$hostname' inside DB.")
unless defined $host_row;
@@ -352,7 +353,7 @@
my $user_row = $schema->resultset('user')->find({ login => $who });
return $self->err("User '$who' not found in DB.") unless $user_row;
$self->{user_id} = $user_row->user_id;
-
+
} else {
my $tty_who = getlogin();

@@ -465,7 +466,7 @@
=cut

sub prepare_host_conf_from_db {
- my ( $self ) = @_;
+ my ( $self, $mandatory_keys_list ) = @_;

return 0 unless $self->init_mconf_obj();
my $mconf_obj = $self->{mconf_obj};
@@ -478,7 +479,7 @@

my $machine_id = $mconf_obj->get_machine_id( $host );
return $self->mconf_err() unless $machine_id;
-
+
my $mconf_sec_data = $mconf_obj->get_machine_active_mconf_sec_info(
$machine_id, $conf_section_name );
return $self->mconf_err() unless $mconf_sec_data;
my ( $mconf_sec_id, $mconf_id ) = @$mconf_sec_data;
@@ -509,9 +510,12 @@
dist_type => 'host_dist_type',
ssh_user => 'user',
};
+ unless ( defined $mandatory_keys_list ) {
+ $mandatory_keys_list = [ sort keys %$mandatory_keys ];
+ }

# Check mandatory if not definned on command line.
- foreach my $name ( keys %$mandatory_keys ) {
+ foreach my $name ( @$mandatory_keys_list ) {
unless ( exists $self->{host_conf}->{ $name } ) {
unless ( $section_conf->{ $name } ) {
return $self->err("Can't find mandatory configuration
key '$name' for host '$host' in DB.");
@@ -527,7 +531,7 @@
foreach my $name ( keys %$mandatory_keys ) {
unless ( exists $self->{host_conf}->{ $name } ) {
my $host_conf_key = $mandatory_keys->{ $name };
- $self->{host_conf}->{ $host_conf_key } = $section_conf->{
$name };
+ $self->{host_conf}->{ $host_conf_key } = $section_conf->{
$name } if exists $section_conf->{ $name };
}
}

@@ -614,7 +618,7 @@
sub get_sc_idata_rs {
my ( $self, $machine_id ) = @_;

- my $select_items = [
+ my $select_items = [
'me.sc_idata_id',
'me.sc_mitem_id',
'path_id.path',
@@ -685,7 +689,7 @@
if ( $ignore_not_found && (not defined $new->{ $attr_name }) ) {
next;
}
-
+
my $is_numeric = $attrs->{$attr_name};
#print "$attr_name (is_numeric=$is_numeric)\n"; # debug
if ( $is_numeric ) {
@@ -704,7 +708,7 @@

=head2 get_base_idata

-Return hash ref for database. Hash is created from base_data completed
with keys/values
+Return hash ref for database. Hash is created from base_data completed
with keys/values
from raw_data if found. If not found in raw_data then old_data hash is
used.

=cut
@@ -791,12 +795,12 @@
# Based on ScanHost::processs_path_regexes method.
sub process_path_regexes {
my ( $self, $regexes_conf, $full_path, $base_flags, $base_plus_found )
= @_;
-
+
my $debug_prefix = ' ';

my $flags = { %$base_flags };
my $plus_found = $base_plus_found;
-
+
foreach my $regex_conf ( @$regexes_conf ) {
my ( $regex, $regex_flags, $is_recursive ) = @$regex_conf;
print $debug_prefix." trying '$regex' $is_recursive\n" if
$self->{ver} >= 10;
@@ -812,7 +816,7 @@

=head2 flags_or_regex_succeed

-Try to
+Try to

=cut

@@ -862,13 +866,13 @@
return $plus_found unless exists
$self->{host_conf}->{path_filter_conf}->{$path}->{regexes};

my $regexes_conf =
$self->{host_conf}->{path_filter_conf}->{$path}->{regexes};
- $plus_found = $self->process_path_regexes(
+ $plus_found = $self->process_path_regexes(
$regexes_conf,
$full_path,
$path_conf->{flags},
$plus_found
);
-
+
return $plus_found;
}

@@ -949,7 +953,7 @@

NEXT_DB_ITEM: while ( my $db_row = $prev_sc_idata_rs->next ) {
my $path = $db_row->{path};
-
+
#$self->dump( 'Prev idata row', $db_row ) if $ver >= 6;
if ( $mconf_sec_id != $db_row->{'mconf_sec_id'} ) {
unless ( $self->flags_or_regex_succeed( $path ) ) {
@@ -984,10 +988,10 @@
scan_id => $scan_id,
newer_id => undef,
found => 1,
-
+
};

- # idata changed
+ # idata changed
# prepare scan_path_id if it is or it was a symlink
if ( (defined $new_item_data->{'symlink'}) || (defined
$db_row->{'symlink'}) ) {
# was symlink, but now it's not
@@ -1188,7 +1192,7 @@
if ( $attr eq 'mtime' ) {
return DateTime->from_epoch( epoch => $value )->datetime;;
}
-
+
return $value;
}

@@ -1215,7 +1219,7 @@
return 0 unless $self->init_mconf_obj();
$machine_id = $self->{mconf_obj}->get_machine_id( $host );
return $self->mconf_err() unless $machine_id;
-
+
if ( $opt->{section} ) {
my $section_name = lc( $opt->{section} );
my $mconf_sec_data =
$self->{mconf_obj}->get_machine_active_mconf_sec_info( $machine_id,
$section_name );
@@ -1223,7 +1227,7 @@
$mconf_sec_id = $mconf_sec_data->[0];
}
}
-
+
return ( 1, $machine_id, $mconf_sec_id );
}

@@ -1244,8 +1248,8 @@
my $schema = $self->{schema};

my $base_attrs_conf = get_item_attrs();
-
- my $cols = [ qw/
+
+ my $cols = [ qw/
mc.machine_id
path.path
sd.sc_idata_id
@@ -1267,7 +1271,7 @@
push @$cols, [ 'slp.path', 'sd_symlink' ];
push @$cols, [ 'pslp.path', 'psd_symlink' ];

-
+
my $cols_sql_str = '';
#$cols_sql_str = join( q{, }, @$cols );
my $name_to_pos = {};
@@ -1308,41 +1312,42 @@
my $attrs_conf = { %$base_attrs_conf };
$attrs_conf->{symlink} = 0;

+ my $sql = "
+ select $cols_sql_str
+ from sc_idata sd
+ left join sc_idata psd on psd.newer_id = sd.sc_idata_id
+ left join aud_idata aid on (
+ aid.sc_idata_id = sd.sc_idata_id
+ and aid.newer_id is null
+ )
+ inner join sc_mitem si on si.sc_mitem_id = sd.sc_mitem_id
+ inner join path on path.path_id = si.path_id
+ inner join scan on scan.scan_id = sd.scan_id
+ inner join mconf_sec mcs on mcs.mconf_sec_id = scan.mconf_sec_id
+ inner join mconf mc on mc.mconf_id = mcs.mconf_id
+ inner join machine on machine.machine_id = mc.machine_id
+ left join path slp on slp.path_id = sd.symlink_path_id
+ left join path pslp on pslp.path_id = psd.symlink_path_id
+ where sd.newer_id is null
+ and ( ? is null or scan.mconf_sec_id = ? )
+ and ( ? is null or machine.machine_id = ? )
+ and machine.active = 1
+ and ( aid.aud_idata_id is null
+ or ( aid.aud_status_id != 1 and aid.aud_status_id != 2 )
+ )
+ order by machine.machine_id, path.path
+ ";
+
+ my $ba = [ $mconf_sec_id, $mconf_sec_id, $machine_id, $machine_id ];
+ if ( $self->{ver} >= 10 ) {
+ $self->dump( 'sql', $sql );
+ $self->dump( 'ba', $ba );
+ }
+
+ #my $data = $schema->storage->dbh->selectall_arrayref( $sql, {}, @$ba
);
my $data = $schema->storage->dbh_do(
- sub {
- my ( $storage, $dbh, $cols_str, $in_params ) = @_;
- return $dbh->selectall_arrayref("
- select $cols_str
- from sc_idata sd
- left join sc_idata psd on psd.newer_id = sd.sc_idata_id
- left join aud_idata aid on (
- aid.sc_idata_id = sd.sc_idata_id
- and aid.newer_id is null
- )
- inner join sc_mitem si on si.sc_mitem_id = sd.sc_mitem_id
- inner join path on path.path_id = si.path_id
- inner join scan on scan.scan_id = sd.scan_id
- inner join mconf_sec mcs on mcs.mconf_sec_id =
scan.mconf_sec_id
- inner join mconf mc on mc.mconf_id = mcs.mconf_id
- inner join machine on machine.machine_id = mc.machine_id
- left join path slp on slp.path_id = sd.symlink_path_id
- left join path pslp on pslp.path_id =
psd.symlink_path_id
- where sd.newer_id is null
- and ( ? is null or scan.mconf_sec_id = ? )
- and ( ? is null or machine.machine_id = ? )
- and machine.active = 1
- and ( aid.aud_idata_id is null
- or ( aid.aud_status_id != 1 and
aid.aud_status_id != 2 )
- )
- order by machine.machine_id, path.path
- ",
- {}, @$in_params
- );
- },
- $cols_sql_str,
- [ $mconf_sec_id, $mconf_sec_id, $machine_id, $machine_id ]
+ sub { return $_[1]->selectall_arrayref( $_[2], {}, @{$_[3]} ); },
$sql, $ba
);
- #$self->dump( 'data', $data );

my $prev_machine_name = '';
my $machine_str = undef;
@@ -1369,20 +1374,20 @@
}

} elsif ( ! $row->[ $name_to_pos->{'sd_found'} ] ) {
- $path_str .= " - deleted";
+ $path_str .= " - deleted";
foreach my $attr ( keys %$attrs_conf ) {
my $old = $row->[ $name_to_pos->{'psd_'.$attr} ];
$diff_str .= " $attr: " . $self->get_attr_str($attr,
$old) . "\n";
}
-
+
} else {
- $path_str .= " - changed";
+ $path_str .= " - changed";

# attrs changes
foreach my $attr ( keys %$attrs_conf ) {
my $new = $row->[ $name_to_pos->{'sd_'.$attr} ];
my $old = $row->[ $name_to_pos->{'psd_'.$attr} ];
-
+
my $is_number = $attrs_conf->{ $attr };
if ( (not defined $new) || (not defined $old) ) {
if ( (not defined $new) && (not defined $old) ) {
@@ -1414,19 +1419,19 @@
$machine_str = undef;
}
if ( defined $path_str ) {
- print $path_str . "\n";
+ print $path_str . "\n";
$path_str = undef;
}
print $diff_str;
$diff_str = undef;
-
+
if ( defined $row->[ $name_to_pos->{aid_aud_status_id} ] ) {
print " last audit status: " . $row->[
$name_to_pos->{aid_aud_status_id} ] . "\n";
}
print "\n";
}
}
-
+
return 1;
}

@@ -1444,7 +1449,7 @@
return 0 unless $ret_code;

my $aud_status_id = 1;
-
+
my $ver = $self->{ver};
my $schema = $self->{schema};

@@ -1490,7 +1495,7 @@
},
$cols_sql_str,
[ $mconf_sec_id, $mconf_sec_id, $machine_id, $machine_id ],
-
+
);

foreach my $row ( @$data ) {
@@ -1503,9 +1508,9 @@
});
print "sc_idata_id $sc_idata_id audit status sets to
$aud_status_id\n" if $ver >= 4;
}
-
+
$schema->storage->txn_commit;
-
+
return 1;
}

=======================================
--- /trunk/server/lib/SysFink/Utils/Conf.pm Wed Jul 15 12:38:01 2009
+++ /trunk/server/lib/SysFink/Utils/Conf.pm Wed Jan 20 07:26:46 2010
@@ -8,7 +8,7 @@
our $VERSION = 0.10;
our @EXPORT = qw(load_conf_multi);

-use Config::Multi;
+use Config::General;
use File::Spec::Functions;


@@ -19,25 +19,26 @@
=cut

sub load_conf_multi {
- my ( $cm_dir, @keys ) = @_;
-
- $cm_dir = catfile( $FindBin::Bin , '..', 'conf' ) unless defined
$cm_dir;
-
- my $cm = Config::Multi->new({
- dir => $cm_dir,
- prefix => '',
- app_name => 'web',
- extension => 'yml',
- });
- my $conf = $cm->load();
- my %keys = map { $_ => 1 } @keys;
- foreach my $key ( keys %$conf ) {
- unless ( exists $keys{$key} ) {
- delete $conf->{$key};
+ my ( $conf_fpath, @keys ) = @_;
+
+ $conf_fpath = catfile( $FindBin::Bin , '..', 'conf', 'sysfink.conf' )
unless defined $conf_fpath;
+ die "No config file '$conf_fpath' found." unless -f $conf_fpath;
+
+ my $cg_obj = Config::General->new(
+ -ConfigFile => $conf_fpath,
+ );
+ my %conf = $cg_obj->getall();
+
+ if ( scalar(@keys) ) {
+ my %keys = map { $_ => 1 } @keys;
+ foreach my $key ( keys %conf ) {
+ unless ( exists $keys{$key} ) {
+ delete $conf{$key};
+ }
}
}

- return $conf;
+ return \%conf;
}

1;
=======================================
--- /trunk/server/sql/data-base.pl Tue Jan 12 14:24:03 2010
+++ /trunk/server/sql/data-base.pl Wed Jan 20 07:26:46 2010
@@ -7,7 +7,7 @@
use SysFink::Utils::DB qw(get_connected_schema);


-my $conf_fp = 'conf';
+my $conf_fp = 'conf/sysfink.conf';
my $conf = load_conf_multi( $conf_fp, 'db' );
my $schema = get_connected_schema( $conf->{db} );

=======================================
--- /trunk/server/sql/data-dev.pl Tue Jan 12 01:01:45 2010
+++ /trunk/server/sql/data-dev.pl Wed Jan 20 07:26:46 2010
@@ -10,7 +10,7 @@
use SysFink::Utils::DB qw(get_connected_schema);


-my $conf_fp = 'conf';
+my $conf_fp = 'conf/sysfink.conf';
my $conf = load_conf_multi( $conf_fp, 'db' );
my $schema = get_connected_schema( $conf->{db} );

=======================================
--- /trunk/server/sql/data-stable.pl Sat Jan 9 16:30:22 2010
+++ /trunk/server/sql/data-stable.pl Wed Jan 20 07:26:46 2010
@@ -10,7 +10,7 @@
use SysFink::Utils::DB qw(get_connected_schema);


-my $conf_fp = 'conf';
+my $conf_fp = 'conf/sysfink.conf';
my $conf = load_conf_multi( $conf_fp, 'db' );
my $schema = get_connected_schema( $conf->{db} );

=======================================
--- /trunk/server/t/base/modules-ext.t Sat Jan 9 12:13:07 2010
+++ /trunk/server/t/base/modules-ext.t Wed Jan 20 07:26:46 2010
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 11;
+use Test::More tests => 10;

use lib 'lib';
use lib 'libext';
@@ -10,8 +10,7 @@
use_ok 'File::Spec::Functions';

# config
- use_ok 'YAML::Any';
- use_ok 'Config::Multi';
+ use_ok 'Config::General';

# Server
use_ok 'Net::OpenSSH';
=======================================
--- /trunk/server/t/base/schema.t Thu Jan 7 14:00:32 2010
+++ /trunk/server/t/base/schema.t Wed Jan 20 07:26:46 2010
@@ -2,7 +2,7 @@
use warnings;
use Test::More tests => 2;

-use YAML::Any qw/LoadFile/;
+use Config::General;

use lib 'lib';
use lib 'libext';
@@ -10,8 +10,9 @@
use SysFink::DB::SchemaAdd;


-my $fpath = './conf/web_db.yml';
-my $conf = LoadFile($fpath);
+my $conf_fpath = './conf/sysfink.conf';
+my $cg_obj = Config::General->new( -ConfigFile => $conf_fpath, );
+my $conf = { $cg_obj->getall() };

my %dbi_params = ();
my $schema = SysFink::DB::Schema->connect(
=======================================
--- /trunk/server/t/utils/db.t Thu Jan 7 14:00:32 2010
+++ /trunk/server/t/utils/db.t Wed Jan 20 07:26:46 2010
@@ -13,7 +13,7 @@
use SysFink::Utils::DB qw(get_connected_schema);


-my $conf_fp = 'conf';
+my $conf_fp = 'conf/sysfink.conf';
my $conf = load_conf_multi( $conf_fp, 'db' );
ok( $conf->{db}, 'some configuration for database loaded');

=======================================
--- /trunk/server/utils/db-run-sqlscript.pl Wed Jul 15 12:38:01 2009
+++ /trunk/server/utils/db-run-sqlscript.pl Wed Jan 20 07:26:46 2010
@@ -7,7 +7,7 @@
use FindBin qw($RealBin);

use DBI;
-use YAML::Any qw(LoadFile);
+use Config::General;
use File::Spec::Functions;

use lib "$RealBin/../lib";
@@ -69,8 +69,9 @@

croak "SQL file '$sql_fpath' not found." unless -f $sql_fpath;

-my $conf_fpath = catfile( $RealBin, '..', 'conf', 'web_db.yml' );
-my ( $conf ) = LoadFile( $conf_fpath );
+my $conf_fpath = catfile( $RealBin, '..', 'conf', 'sysfink.conf' );
+my $cg_obj = Config::General->new( -ConfigFile => $conf_fpath, );
+my $conf = { $cg_obj->getall() };
croak "Configuration for database loaded from '$conf_fpath' is empty.\n"
unless $conf->{db};

croak "Database 'dbi_dsn' not found.\n" unless $conf->{db}->{dbi_dsn};
=======================================
--- /trunk/server/utils/test-new.sh Fri Jan 15 08:48:35 2010
+++ /trunk/server/utils/test-new.sh Wed Jan 20 07:26:46 2010
@@ -68,12 +68,12 @@
fi


-TEST_CONF_FILE="t/conf-test/web_db.yml-$DB_TYPE"
+TEST_CONF_FILE="t/conf-test/sysfink.conf-$DB_TYPE"


echo "-------------------------------------------------------------------------------------"

if [ $TEST_TYPE = "current" ]; then
- GREP=`cat conf/web_db.yml | grep SQLite`
+ GREP=`cat conf/sysfink.conf | grep SQLite`
if [ -z "$GREP" ]; then
DB_TYPE="mysql"
else
@@ -93,8 +93,8 @@
exit
fi

- IN_FILE="conf/web_db.yml"
- OUT_FILE="conf/web_db.yml-test.backup"
+ IN_FILE="conf/sysfink.conf"
+ OUT_FILE="conf/sysfink.conf-test.backup"
if [ -f "$IN_FILE" ]; then
echo "Moving '$IN_FILE' to '$OUT_FILE'."
mv "$IN_FILE" "$OUT_FILE" || ( echo "Can't move." && exit )
@@ -102,7 +102,7 @@
fi

IN_FILE="$TEST_CONF_FILE"
- OUT_FILE="conf/web_db.yml"
+ OUT_FILE="conf/sysfink.conf"
if [ -f "$IN_FILE" ]; then
echo "Copying '$IN_FILE' to '$OUT_FILE'."
cp "$IN_FILE" "$OUT_FILE" || ( echo "Can't move." && exit )
@@ -283,8 +283,8 @@
echo ""
fi

- IN_FILE="conf/web_db.yml-test.backup"
- OUT_FILE="conf/web_db.yml"
+ IN_FILE="conf/sysfink.conf-test.backup"
+ OUT_FILE="conf/sysfink.conf"
if [ -f "$IN_FILE" ]; then
echo "Moving '$IN_FILE' to '$OUT_FILE'."
mv "$IN_FILE" "$OUT_FILE" || ( echo "Can't move." && exit )

Reply all
Reply to author
Forward
0 new messages