Changeset 296


Ignore:
Timestamp:
Oct 4, 2017, 6:24:46 PM (6 years ago)
Author:
g7moreau
Message:
  • Verify checksum switchdb (but do nothing)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r295 r296  
    866866   }
    867867
     868#---------------------------------------------------------------
     869sub 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
    868884################################################################
    869885# command
     
    10631079   init_switch_names('yes', $verb_description, $check_hostname, $check_location);    #nomme les switchs
    10641080
    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
    10661084   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
    10671089   my %db_switch_output_port       = %{$switch_connection->{'output_port'}};
    10681090   my %db_switch_connected_on_port = %{$switch_connection->{'connected_on_port'}};
     
    27122734      }
    27132735
    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 
    27222736   my $switch_connection = {
    27232737      output_port       => \%db_switch_output_port,
     
    27272741      switch_db         => \%SWITCH_DB,
    27282742      timestamp         => $timestamp,
    2729       checksum          => sha512_base64($checksum_data),
     2743      checksum          => get_switchdb_checksum(%SWITCH_DB),
    27302744      };
    27312745
Note: See TracChangeset for help on using the changeset viewer.