From b0bcbe8d6b81f172850645bc7f197e448595354c Mon Sep 17 00:00:00 2001 From: rettenbe Date: Tue, 26 Feb 2008 17:17:44 +0000 Subject: [PATCH] add new sqliteDB, fai_server_db, holds all fai server,releases and tags git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9137 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 60 ++++++++++++++++++++++------ gosa-si/modules/DBsqlite.pm | 2 +- gosa-si/tests/client.php | 4 +- gosa-si/tests/sqlite-check-server.pl | 13 ++++++ 4 files changed, 64 insertions(+), 15 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 9860dcfc4..5f3c468ac 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -91,24 +91,35 @@ $no_arp = 0; our $prg= basename($0); # holds all gosa jobs -my $job_queue_file_name; our $job_db; our $job_queue_tn = 'jobs'; +my $job_queue_file_name; +my @job_queue_col_names = ("id INTEGER", "timestamp", "status", "result", "progress INTEGER", + "headertag", "targettag", "xmlmessage", "macaddress"); # holds all other gosa-sd as well as the gosa-sd-bus -my $known_server_file_name; our $known_server_db; our $known_server_tn = "known_server"; +my $known_server_file_name; +my @known_server_col_names = ('hostname', 'status', 'hostkey', 'timestamp'); # holds all registrated clients -my $known_clients_file_name; our $known_clients_db; our $known_clients_tn = "known_clients"; +my $known_clients_file_name; +my @known_clients_col_names = ('hostname', 'status', 'hostkey', 'timestamp', 'macaddress', 'events'); # holds all logged in user at each client -my $login_users_file_name; our $login_users_db; our $login_users_tn = "login_users"; +my $login_users_file_name; +my @login_users_col_names = ('client', 'user', 'timestamp'); + +# holds all fai server, the debian release and tag +our $fai_server_db; +our $fai_server_tn = "fai_server"; +my $fai_server_file_name; +my @fai_server_col_names = ('timestamp', 'server', 'release', 'tag'); %cfg_defaults = ( "general" => { @@ -124,6 +135,7 @@ our $login_users_tn = "login_users"; "known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ], "known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'], "login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'], + "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai.db'], "gosa-unit-tag" => [\$gosa_unit_tag, ""], }, "GOsaPackages" => { @@ -1101,6 +1113,28 @@ sub watch_for_new_jobs { } +sub create_fai_server_db { + +##################################################################### +# +# TODO für dich Cajus :-) +# +# ################################################################### + + + + $fai_server_db->add_dbentry( { + table => $fai_server_tn, + primkey => [], + server => "dummyserver", + release => "kleinkind", + tag => "imwachstum", + } ); + return; +} + + + #==== MAIN = main ============================================================== # parse commandline options Getopt::Long::Configure( "bundling" ); @@ -1158,24 +1192,26 @@ if ($no_bus > 0) { #unlink('/tmp/gosa_si_lock*'); # connect to gosa-si job queue -my @job_col_names = ("id INTEGER", "timestamp", "status", "result", "progress INTEGER", "headertag", "targettag", "xmlmessage", "macaddress"); $job_db = GOSA::DBsqlite->new($job_queue_file_name); -$job_db->create_table('jobs', \@job_col_names); +$job_db->create_table($job_queue_tn, \@job_queue_col_names); # connect to known_clients_db -my @clients_col_names = ('hostname', 'status', 'hostkey', 'timestamp', 'macaddress', 'events'); $known_clients_db = GOSA::DBsqlite->new($known_clients_file_name); -$known_clients_db->create_table('known_clients', \@clients_col_names); +$known_clients_db->create_table($known_clients_tn, \@known_clients_col_names); # connect to known_server_db -my @server_col_names = ('hostname', 'status', 'hostkey', 'timestamp'); $known_server_db = GOSA::DBsqlite->new($known_server_file_name); -$known_server_db->create_table('known_server', \@server_col_names); +$known_server_db->create_table($known_server_tn, \@known_server_col_names); # connect to login_usr_db -my @login_users_col_names = ('client', 'user', 'timestamp'); $login_users_db = GOSA::DBsqlite->new($login_users_file_name); -$login_users_db->create_table("login_users", \@login_users_col_names); +$login_users_db->create_table($login_users_tn, \@login_users_col_names); + + +# connect to fai_server_db +$fai_server_db = GOSA::DBsqlite->new($fai_server_file_name); +$fai_server_db->create_table($fai_server_tn, \@fai_server_col_names); +&create_fai_server_db; # create xml object used for en/decrypting $xml = new XML::Simple(); diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 78592fff7..2bd073d7a 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -104,7 +104,7 @@ sub add_dbentry { } my $primkeys = $arg->{'primkey'}; my $prim_statement; - if( 0 != length(@$primkeys) ) { + if( 0 != @$primkeys ) { my @prim_list; foreach my $primkey (@$primkeys) { if($primkey eq 'id') { diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index d3ada5c74..c1820fb43 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -18,7 +18,7 @@ if($sock->connected()){ # jobdb add #$data = "
gosa_network_completition
GOSAGOSAws-muc-2
"; #$data = "
job_sayHello
10.89.1.155:2008300:1B:77:04:8A:6C 20130102133900
"; -#$data = "
job_ping
10.89.1.155:20083 10.89.1.155:2008100:01:6c:9d:b9:fa 20130102133900
"; +$data = "
job_ping
10.89.1.155:20083 10.89.1.155:2008100:01:6c:9d:b9:fa 20130102133900
"; # jobdb delete #$data = "
gosa_delete_jobdb_entry
3
"; @@ -31,7 +31,7 @@ if($sock->connected()){ # jobdb update #$data = "
gosa_update_status_jobdb_entry
GOSAGOSA 00:01:6c:9d:b9:fa 23450101000000XXXXXXXXXXXXXXx
"; -$data = "
gosa_update_status_jobdb_entry
GOSAGOSA waiting processing update
"; +#$data = "
gosa_update_status_jobdb_entry
GOSAGOSA waiting processing update
"; # jobdb query #$data = "
gosa_query_jobdb
andgt0le5
"; diff --git a/gosa-si/tests/sqlite-check-server.pl b/gosa-si/tests/sqlite-check-server.pl index 333d93050..bd0115e1b 100755 --- a/gosa-si/tests/sqlite-check-server.pl +++ b/gosa-si/tests/sqlite-check-server.pl @@ -87,6 +87,19 @@ if (-e $db_name) { print $answer."\n"; } +$db_name = "/var/lib/gosa-si/fai.db"; +if (-e $db_name) { + print "\n############################################################\n"; + my $table_name = "fai_server"; + print "$db_name\n"; + print "$table_name\n"; + + my $sqlite = GOSA::DBsqlite->new($db_name); + my $col_names = $sqlite->get_table_columns($table_name); + print join(', ', @{ $col_names } )."\n" ; + my $answer = $sqlite->show_table($table_name); + print $answer."\n"; +} print "\nFINISH\n"; -- 2.30.2