Code

add new sqliteDB, fai_server_db, holds all fai server,releases and tags
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Feb 2008 17:17:44 +0000 (17:17 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Feb 2008 17:17:44 +0000 (17:17 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9137 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/modules/DBsqlite.pm
gosa-si/tests/client.php
gosa-si/tests/sqlite-check-server.pl

index 9860dcfc4b7275d1d344e5b5d724b420bc9d7647..5f3c468acbd0bfb6cd72a8578088c490c518e011 100755 (executable)
@@ -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();
index 78592fff7629763f99298c51f0ff778a450c5039..2bd073d7a12db7da6041fcad6c355057be4425c0 100644 (file)
@@ -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') {
index d3ada5c74da18d5a7b34c571b9db03d380f0d7cc..c1820fb4386c57556cb5f4797053b16243f73a22 100755 (executable)
@@ -18,7 +18,7 @@ if($sock->connected()){
 # jobdb add
 #$data = "<xml> <header>gosa_network_completition</header> <source>GOSA</source><target>GOSA</target><hostname>ws-muc-2</hostname></xml>";
 #$data = "<xml> <header>job_sayHello</header> <source>10.89.1.155:20083</source><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133900</timestamp> </xml>";
-#$data = "<xml> <header>job_ping</header> <source>10.89.1.155:20083</source> <target>10.89.1.155:20081</target><mac>00:01:6c:9d:b9:fa</mac> <timestamp>20130102133900</timestamp> </xml>";
+$data = "<xml> <header>job_ping</header> <source>10.89.1.155:20083</source> <target>10.89.1.155:20081</target><macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>20130102133900</timestamp> </xml>";
 
 # jobdb delete
 #$data = "<xml> <header>gosa_delete_jobdb_entry</header><where><clause><phrase><id>3</id></phrase></clause></where></xml>";
@@ -31,7 +31,7 @@ if($sock->connected()){
 
 # jobdb update  
 #$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source><target>GOSA</target><where><clause><phrase> <macaddress>00:01:6c:9d:b9:fa</macaddress></phrase></clause> </where> <update><timestamp>23450101000000</timestamp><result>XXXXXXXXXXXXXXx</result></update></xml>";
-$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source><target>GOSA</target><where><clause><phrase> <status>waiting</status></phrase></clause> </where> <update><status>processing</status> <result>update</result></update></xml>";
+#$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source><target>GOSA</target><where><clause><phrase> <status>waiting</status></phrase></clause> </where> <update><status>processing</status> <result>update</result></update></xml>";
 
 # jobdb query
 #$data = "<xml><header>gosa_query_jobdb</header><where><clause><connector>and</connector><phrase><operator>gt</operator><ROWID>0</ROWID></phrase><phrase><operator>le</operator><ROWID>5</ROWID></phrase></clause></where></xml>";
index 333d930509d8c069fc433c3d8c4dfde7bea82628..bd0115e1bcdf69fcbf1881bb9cf1fa08728f86b0 100755 (executable)
@@ -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";