Hi,

set_node_nics.svn9141.patch_v2:
     2 fixes: --debug and $env{LANG} != C)

This is a cumulative patch (sorry don't know how to split the 2 stuffs for 
set_node_nics)
Basicaly it replaces all
- oda::print_has with OSCAR::Utils::print_hash
- replaces `/sbin/ifconfig ... with `LC_ALL=C /sbin/ifconfig ...
- adds use OSCAR::Utils

With this fix, set_node_nics --debug --networks correctly fills the Networks 
and the Nics table on CentOS 5.4 with LANG set to fr_FR.UTF-8

The problem was due to the LANG settings: LANG=fr_FR.UTF-8
because of that, the output of ifconfig was badly parsed( Inet adr: found 
instead of Inet Addr (missing d as adresss has a single d in it in French)

SystemServices.pm is also affected by a similar bug. (next mail)

Maybe the best thing would be to set LC_ALL=C when starting oscar-config as 
there are many other places that runs systems commands. Hopefully, few of them 
seems subject to parsing problems due to LANG settings.

Regards,

-- 
        Olivier LAHAYE
        CEA Saclay
        DRT-LIST-DETECS-SSTM
Index: set_node_nics
===================================================================
--- set_node_nics	(révision 9141)
+++ set_node_nics	(copie de travail)
@@ -33,6 +33,7 @@
 use strict;
 use Getopt::Long;
 use OSCAR::oda;
+use OSCAR::Utils;
 use Data::Dumper;
 use OSCAR::Database;
 use OSCAR::Database_generic;
@@ -65,7 +66,7 @@
             'verbose!' )
     || usage( 1 );
 print "$0: after GetOptions ARGV=<@ARGV>\n" if $options{debug};
-oda::print_hash( "", "$0: options after GetOptions", \%options) 
+OSCAR::Utils::print_hash( "", "$0: options after GetOptions", \%options) 
     if $options{debug};
 
 # --help flag just prints out usage information and exits
@@ -86,7 +87,7 @@
         (defined $value) ? $value :
         ( ($oda_option =~ /^no/ ) ? 0 : 1 );
     }
-    oda::print_hash( "", "$0: oda_options", \%oda_options ) 
+    OSCAR::Utils::print_hash( "", "$0: oda_options", \%oda_options ) 
     if $options{debug};
 }
 
@@ -138,7 +139,7 @@
     if $options{verbose};
 my $ifconfig_nics_ref = find_nics( 1 );
 die "$0: fatal error running ifconfig command" if ! defined $ifconfig_nics_ref;
-oda::print_hash( "", "$0: ifconfig nics", $ifconfig_nics_ref ) if $options{debug};
+OSCAR::Utils::print_hash( "", "$0: ifconfig nics", $ifconfig_nics_ref ) if $options{debug};
 if ( $options{verbose} && ! $options{debug} ) {
     my @ifconfig_nic_names = keys %$ifconfig_nics_ref;
     print "... found " . scalar( @ifconfig_nic_names ) . " machine network interface"
@@ -165,7 +166,7 @@
              eq 
              ip_and( $$nic_ref{base_ip}, $$nic_ref{netmask} ) ) {
             $$nic_ref{gateway} = $gateway_address;
-            oda::print_hash( "", "$0: nic $nic_name gateway field set",
+            OSCAR::Utils::print_hash( "", "$0: nic $nic_name gateway field set",
                      $nic_ref ) if $options{debug};
             print "Gateway $gateway_address is on network interface $nic_name\n"
             if $options{verbose} && ! $options{debug};
@@ -227,7 +228,7 @@
         if exists $$nic_ref{ gateway };
     $surmised_networks{ $network_name } = \%network;
 }
-oda::print_hash( "", "$0: ifconfig surmised networks", \%surmised_networks )
+OSCAR::Utils::print_hash( "", "$0: ifconfig surmised networks", \%surmised_networks )
     if $options{debug};
 
 
@@ -300,7 +301,7 @@
 }
 #die "$0: cannot read current database nic records for node $node_name\n"
 #    if ! defined $database_networks_ref;
-oda::print_hash( "", "$0: database nics for node $node_name", $database_nics_ref ) 
+OSCAR::Utils::print_hash( "", "$0: database nics for node $node_name", $database_nics_ref ) 
     if $options{debug};
 if ( $options{verbose} && ! $options{debug} ) {
     my @database_nic_names = keys %$database_nics_ref;
@@ -381,7 +382,7 @@
 
             if ( %assigns ) {
                 my $record_id = $$database_network_record_ref{n_id};
-                oda::print_hash( "", "$0: modifying network " .
+                OSCAR::Utils::print_hash( "", "$0: modifying network " .
                         $$database_network_record_ref{base_ip} . "/" .
                         $$database_network_record_ref{netmask} .
                         "record id=$record_id with these values", 
@@ -421,7 +422,7 @@
                     if $options{debug};
             }
             print "$0: writing out new database network record $$surmised_network_ref{name} $$surmised_network_ref{base_ip}\/$$surmised_network_ref{netmask}\n" if $options{verbose};
-            oda::print_hash( "", "$0: writing out new network", $surmised_network_ref )
+            OSCAR::Utils::print_hash( "", "$0: writing out new network", $surmised_network_ref )
                 if $options{debug};
             if ( $options{verbose} && ! $options{debug} ) {
                 print "Writing out new database network record:\n";
@@ -497,7 +498,7 @@
                 && exists $$database_network_ref{ $field }
                 && $$nic_ref{ $field } eq $$database_network_ref{ $field };
             }
-            oda::print_hash( "", "$0: linked modified ifconfig nic $nic_name",
+            OSCAR::Utils::print_hash( "", "$0: linked modified ifconfig nic $nic_name",
                      $nic_ref) if $options{debug};
             last;
         }
@@ -591,7 +592,7 @@
         foreach my $field ( keys %assigns ) {
             if($assigns{$field}){
                 my $record_id = $$database_nic_ref{id};
-                oda::print_hash( "", "$0: modifying node $node_name nic $nic_name",
+                OSCAR::Utils::print_hash( "", "$0: modifying node $node_name nic $nic_name",
                          \%assigns )
                     if $options{debug};
                 if ( $options{verbose} && ! $options{debug} ) {
@@ -707,7 +708,7 @@
                               ref($print_errors) eq "ARRAY" ) ?
                               $print_errors : \...@error_strings;
 
-    my @ifconfig_output = `/sbin/ifconfig 2>/dev/null`;
+    my @ifconfig_output = `LC_ALL=C /sbin/ifconfig 2>/dev/null`;
     if ( ! @ifconfig_output ) {
         push @$error_strings_ref,
         "$0: cannot find nics with ifconfig command command";
@@ -931,7 +932,7 @@
         my $net_name = $$network_ref{name};
         $$database_networks_ref{$net_name} = $network_ref;
     }
-    oda::print_hash( "", "$0: database network records", $database_networks_ref ) 
+    OSCAR::Utils::print_hash( "", "$0: database network records", $database_networks_ref ) 
     if $options{debug};
 }
 
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Oscar-devel mailing list
Oscar-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oscar-devel

Reply via email to