Changeset 518

Show
Ignore:
Timestamp:
06/17/07 17:04:45 (1 year ago)
Author:
kindlund
Message:

Added error suppression logic and Manager shutdown logic.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/mbriggs-db/lib/HoneyClient/Manager.pm

    r512 r518  
    236236our $STATE_FILE = getVar(name => "manager_state"); 
    237237 
     238# Temporary variable, used to indicate to the fault handler whether 
     239# or not errors/warnings should be suppressed. 
     240our $SUPPRESS_ERRORS = 0; 
     241 
    238242####################################################################### 
    239243# Daemon Initialization / Destruction                                 # 
     
    335339    } 
    336340 
    337     $LOG->warn("Error occurred during processing. " . $errMsg); 
    338     Carp::carp __PACKAGE__ . "->_handleFault(): Error occurred during processing.\n" . $errMsg; 
     341    if (!$SUPPRESS_ERRORS) { 
     342        $LOG->warn("Error occurred during processing. " . $errMsg); 
     343        Carp::carp __PACKAGE__ . "->_handleFault(): Error occurred during processing.\n" . $errMsg; 
     344    } 
    339345} 
    340346 
     
    595601 
    596602            # Try contacting the Agent; ignore any faults. 
     603            $SUPPRESS_ERRORS = 1; 
    597604            $stubAgent = getClientHandle(namespace     => "HoneyClient::Agent", 
    598605                                         address       => $vmIP, 
     
    614621                $ret = undef; 
    615622            } 
     623            $SUPPRESS_ERRORS = 0; 
    616624        } 
    617625    } 
     
    706714                    print "VM Integrity Check: OK!\n"; 
    707715 
    708                     # The Agent::run() thread has stopped; we assume 
    709                     # it's because the Agent is waiting for the firewall 
    710                     # to allow access to the new targets. 
    711                     # TODO: Need to distinguish between run() stopping because 
    712                     # of firewall mods, or if the Agent is completely finished 
    713                     # and needs more input to continue. 
     716                    # Check to see if any links remain to be processed by the 
     717                    # Agent. 
     718                    if (!$ret->{$args{'driver'}}->{status}->{links_remaining}) { 
     719 
     720                        $LOG->info("All URLs exhausted.  Shutting down Manager."); 
     721                        # Get a local copy of the configuration and kill the global copy. 
     722                        my $vmCfg = $vmCloneConfig; 
     723                        $vmCloneConfig = undef; 
     724                        $LOG->info("Calling destroyVM(config => " . $vmCfg . ")."); 
     725                        $stubVM->destroyVM(config => $vmCfg); 
     726                        print "Done!\n"; 
     727                        _cleanup(); 
     728 
     729                    } else { 
     730                        # The Agent::run() thread has stopped; we assume 
     731                        # it's because the Agent is waiting for the firewall 
     732                        # to allow access to the new targets. 
    714733                 
    715                     # Delete the old firewall rules, based upon existing 
    716                     # targets. 
    717                     $stubFW->deleteRules($vmStateTable); 
    718  
    719                     # Get the new targets from the Agent. 
    720                     $vmStateTable->{$vmName}->{targets} = $ret->{$args{'driver'}}->{next}->{targets}; 
    721  
    722                     print "VM State Table:\n"; 
    723                     # Make Dumper format more verbose. 
    724                     $Data::Dumper::Terse = 0; 
    725                     $Data::Dumper::Indent = 2; 
    726                     print Dumper($vmStateTable) . "\n"; 
    727  
    728                     # Add the new targets from the Agent. 
    729                     $stubFW->addRules($vmStateTable); 
    730  
    731                     print "Calling run()...\n"; 
    732                     $som = $stubAgent->run(); 
     734                        # Delete the old firewall rules, based upon existing 
     735                        # targets. 
     736                        $stubFW->deleteRules($vmStateTable); 
     737 
     738                        # Get the new targets from the Agent. 
     739                        $vmStateTable->{$vmName}->{targets} = $ret->{$args{'driver'}}->{next}->{targets}; 
     740 
     741                        print "VM State Table:\n"; 
     742                        # Make Dumper format more verbose. 
     743                        $Data::Dumper::Terse = 0; 
     744                        $Data::Dumper::Indent = 2; 
     745                        print Dumper($vmStateTable) . "\n"; 
     746 
     747                        # Add the new targets from the Agent. 
     748                        $stubFW->addRules($vmStateTable); 
     749 
     750                        print "Calling run()...\n"; 
     751                        $som = $stubAgent->run(); 
     752                    } 
    733753                } 
    734754            }