ASNMTAP

 view release on metacpan or  search on metacpan

applications/htmlroot/cgi-bin/admin/generateConfig.pl  view on Meta::CPAN

          $compareText = "$compareView";
        } else {
          my (undef, $servername) = split (/: /, $compareView, 2);
          ($type, $activeServer, $server) = split (/-/, $servername, 3);
          my $active = ( ( $type =~ /^[CD]${activeServer}$/ ) ? 1 : 0 );

          $commands {$server} {TODO} {++$_id} {auto} = 0;
          $commands {$server} {TODO} {$_id} {label} = '-g';
          $commands {$server} {TODO} {$_id} {active} = $active;
          $commands {$server} {TODO} {$_id} {command} = read_directory ("$APPLICATIONPATH/tmp/$CONFIGDIR/installed", '', '', '', $debug) ." ?";
          $compareText .= '<br><FONT COLOR="yellow"> ['. $_id .'] '. $commands {$server} {TODO} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $commands {$server} {STOP} {++$_id} {auto} = 0;
          $commands {$server} {STOP} {$_id} {label} = '-h';
          $commands {$server} {STOP} {$_id} {active} = $active;
          $commands {$server} {STOP} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/asnmt...
          $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {STOP} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $commands {$server} {REMOVE} {++$_id} {auto} = 0;
          $commands {$server} {REMOVE} {$_id} {label} = '-i';
          $commands {$server} {REMOVE} {$_id} {active} = $active;
          $commands {$server} {REMOVE} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server rm ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/...
          $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {REMOVE} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $commands {$server} {STOP} {++$_id} {auto} = 0;
          $commands {$server} {STOP} {$_id} {label} = '-j';
          $commands {$server} {STOP} {$_id} {active} = $active;
          $commands {$server} {STOP} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/asnmt...
          $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {STOP} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $commands {$server} {REMOVE} {++$_id} {auto} = 0;
          $commands {$server} {REMOVE} {$_id} {label} = '-k';
          $commands {$server} {REMOVE} {$_id} {active} = $active;
          $commands {$server} {REMOVE} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server rm ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/...
          $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {REMOVE} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $commands {$server} {CRONTAB} {++$_id} {auto} = 0;
          $commands {$server} {CRONTAB} {$_id} {label} = '-l';
          $commands {$server} {CRONTAB} {$_id} {active} = $active;
          $commands {$server} {CRONTAB} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server DELETE ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ...
          $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {CRONTAB} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $commands {$server} {REMOVE} {++$_id} {auto} = 0;
          $commands {$server} {REMOVE} {$_id} {label} = '-m';
          $commands {$server} {REMOVE} {$_id} {active} = $active;
          $commands {$server} {REMOVE} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server rm ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/...
          $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {REMOVE} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $commands {$server} {REMOVE} {++$_id} {auto} = 0;
          $commands {$server} {REMOVE} {$_id} {label} = '-n';
          $commands {$server} {REMOVE} {$_id} {active} = $active;
          $commands {$server} {REMOVE} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server rm ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/...
          $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {REMOVE} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

          $todo = 1;
        }
      } elsif ( $compareView =~ /^Files generated\// ) {
        ($path, $generated, $installed, $compareDiff) = do_compare_diff ($compareView, 3, $details, $debug);

        if ($details) {
          $compareText = "File '$generated' changed into the generated configuration.";
        } else {
          my (undef, $servername, $filename) = split (/\//, $generated, 3);
          ($type, $activeServer, $server) = split (/-/, $servername, 3);
          my $active = ( ( $type =~ /^[CD]${activeServer}$/ ) ? 1 : 0 );

          # Replace 'distributed.citap.be:/opt/asnmtap/applications/slave/asnmtap-display.sh' with '/opt/asnmtap/applications/tmp/$CONFIGDIR/generated/DS-[SM]-distributed.citap.be/slave/asnmtap-display.sh'
          #          <----- $server ---->:$APPLICATIONPATH/<------ $filename ----->        $APPLICATIONPATH/tmp/      /<---------------------- $generated ---------------------->
          $commands {$server} {SCP} {++$_id} {auto} = 1;
          $commands {$server} {SCP} {$_id} {label} = '=a';
          $commands {$server} {SCP} {$_id} {active} = $active;
          $commands {$server} {SCP} {$_id} {command} = "$SCPCOMMAND $connectArguments $APPLICATIONPATH/tmp/$CONFIGDIR/$generated $SSHLOGONNAME\@$server:". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } ."/applications/$filename";
          $compareText .= '<FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {SCP} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );

		  if (($filename =~ /^etc\/DisplayCT-[\w-]+$/) or ($filename =~ /^etc\/CollectorCT-[\w-]+$/)) {
            $filename =~ s/etc\///g;
            $commands {$server} {RELOAD} {++$_id} {auto} = 1;
            $commands {$server} {RELOAD} {$_id} {label} = '=b';
            $commands {$server} {RELOAD} {$_id} {active} = $active;
            $commands {$server} {RELOAD} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/$...
            $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {RELOAD} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
 		  } elsif (($filename =~ /^(slave|master)\/asnmtap-display.sh$/)   or ($filename =~ /^(slave|master)\/asnmtap-collector.sh$/)) {
            $commands {$server} {TODO} {++$_id} {auto} = 0;
            $commands {$server} {TODO} {$_id} {label} = '=c';
            $commands {$server} {TODO} {$_id} {active} = $active;
            $commands {$server} {TODO} {$_id} {command} = "'$filename' ?";
            $compareText .= '<br><FONT COLOR="yellow"> ['. $_id .'] '. $commands {$server} {TODO} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
		  } elsif (($filename =~ /^(slave|master)\/DisplayCT-[\w-]+\.sh$/) or ($filename =~ /^(slave|master)\/CollectorCT-[\w-]+\.sh$/)) {
            $commands {$server} {START} {++$_id} {auto} = 0;
            $commands {$server} {START} {$_id} {label} = '=d';
            $commands {$server} {START} {$_id} {active} = $active;
            $commands {$server} {START} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/$f...
            $compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {START} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
        # } elsif ( $filename =~ /^master\/rsync-mirror-failover-[\w\-.]+.conf$/ or $filename =~ /^slave\/rsync-mirror-failover-[\w\-.]+.conf$/) {
            # deze bestanden worden reeds gecopieerd door middel van bovenstaande SCP in deze sectie
          }
        }
      } elsif ( $compareView =~ /^diff: installed: No such file or directory/ ) {
        $compareText = "The installed configuration doesn't exist.";
      } elsif ( $compareView =~ /^diff: generated: No such file or directory/ ) {
        $compareText = "The generated configuration doesn't exist.";
      } else {
        $compareText = "<b>Under construction:</b> < $compareView >";
      }

      unless ( $details ) { $compareText = "<b>$compareText</b>" if (defined $compareText and ($todo or (defined $activeServer and $type =~ /^[CD]${activeServer}$/))); }

      $statusMessage .= "\n		   <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>$compareView</td></tr>" if ($details or $debug eq 'T');
      $statusMessage .= "\n        <tr bgcolor=\"$COLORSTABLE{NOBLOCK}\"><td>$compareDiff</td></tr>" if (defined $compareDiff);
      $statusMessage .= "\n        <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td>$compareText</td></tr>" if (defined $compareText);
    }
  }

  my ($commandsToExecute, $commandsExecuted, $commandsTODO) = ( $_id, 0 );

  foreach my $_servers ( sort keys %commands ) {
    my $_server = $commands {$_servers};
    $commandsTODO .= "\n        <tr bgcolor=\"$COLORSTABLE{NOBLOCK}\"><td>$_servers</td></tr>";

    my $exitCurrentServer = 0;



( run in 0.810 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )