Changeset 296
- Timestamp:
- Oct 4, 2017, 6:24:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r295 r296 866 866 } 867 867 868 #--------------------------------------------------------------- 869 sub get_switchdb_checksum { 870 my %switch_db = @_; # same as global %SWITCH_DB 871 872 my $checksum_data = ''; 873 for my $sw_name (sort keys %switch_db) { # sort to always have the same order 874 $checksum_data .= join ':', 875 $switch_db{$sw_name}->{'description'}, 876 $switch_db{$sw_name}->{model}, 877 $switch_db{$sw_name}->{'hostname'}, 878 "\n"; 879 } 880 881 return sha512_base64($checksum_data); 882 } 883 868 884 ################################################################ 869 885 # command … … 1063 1079 init_switch_names('yes', $verb_description, $check_hostname, $check_location); #nomme les switchs 1064 1080 1065 { # Remplis le champs portignore des ports d'inter-connection pour chaque switch 1081 { 1082 my $switch_checksum = get_switchdb_checksum(%SWITCH_DB); 1083 # Remplis le champs portignore des ports d'inter-connection pour chaque switch 1066 1084 my $switch_connection = YAML::Syck::LoadFile("$KLASK_SW_FILE"); 1085 if $switch_checksum ne $switch_connection->{'checksum'}) { # Verify checksum 1086 print "ERROR: switch database must be rebuild\n"; 1087 } 1088 1067 1089 my %db_switch_output_port = %{$switch_connection->{'output_port'}}; 1068 1090 my %db_switch_connected_on_port = %{$switch_connection->{'connected_on_port'}}; … … 2712 2734 } 2713 2735 2714 my $checksum_data = ''2715 for my $sw_name (keys %SWITCH_DB) {2716 $checksum_data .= join ':', $SWITCH_DB{$sw_name}->{'description'},2717 $SWITCH_DB{$sw_name}->{model},2718 $SWITCH_DB{$sw_name}->{'hostname'},2719 "\n";2720 }2721 2722 2736 my $switch_connection = { 2723 2737 output_port => \%db_switch_output_port, … … 2727 2741 switch_db => \%SWITCH_DB, 2728 2742 timestamp => $timestamp, 2729 checksum => sha512_base64($checksum_data),2743 checksum => get_switchdb_checksum(%SWITCH_DB), 2730 2744 }; 2731 2745
Note: See TracChangeset
for help on using the changeset viewer.