Changeset 1491

Show
Ignore:
Timestamp:
04/09/08 14:36:49 (3 months ago)
Author:
kindlund
Message:

Migrated disk checking into Clone object; switched all SOAP ports to IANA default (7627).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-simpler_agent/etc/honeyclient.xml

    r1490 r1491  
    6262    <!-- HoneyClient::Agent Options --> 
    6363    <Agent> 
    64         <!-- TODO: Update this. --> 
    6564        <address description="The IP or hostname that all Agent modules should use, when accepting SOAP requests." default="0.0.0.0"> 
    6665            0.0.0.0 
     
    6867        <!-- TODO: Update this. --> 
    6968        <!-- Note: This port should be unique and not already in use by other modules, services, or daemons running inside the VM. --> 
    70         <port description="The TCP port number that the SOAP server for all Agent modules will listen on for requests." default="9000"> 
    71             9000 
     69        <port description="The TCP port number that the SOAP server for all Agent modules will listen on for requests." default="7627"> 
     70            7627 
    7271        </port> 
    7372        <allowed_drivers description="List of implemented Drivers that the Agent is allowed to run directly."> 
     
    8079        <!-- HoneyClient::Agent::Driver Options --> 
    8180        <Driver> 
    82             <!-- TODO: Update this. --> 
     81            <!-- TODO: Update this. XXX: Command-line option, eventually? --> 
    8382            <timeout description="How long the Driver waits during a drive operation, before timing out (in seconds)." default="60"> 
    8483                20 
     
    179178    </Crawler> 
    180179    <Manager> 
    181         <!-- TODO: Is this still needed? --> 
    182         <manager_state description="Upon termination, the Manager will attempt to append a complete copy of its state into this file, if specified." default=""> 
    183             manager.dump 
    184         </manager_state> 
    185180        <fingerprint_dump description="When the Manager encounters a suspicious VM, it will attempt to append a complete copy of the fingerprint information to this file, if specified."> 
    186181            fingerprint.dump 
     
    190185        </address> 
    191186        <!-- Note: This port should be unique and not already in use by other modules, services, or daemons running on the host system. --> 
    192         <port description="The TCP port number that the SOAP server for all Manager modules will listen on for requests." default="8089"> 
    193             8089 
     187        <port description="The TCP port number that the SOAP server for all Manager modules will listen on for requests." default="7627"> 
     188            7627 
    194189        </port> 
    195190        <num_urls_to_process description="If database support is enabled, this value indicates how many URLs the Manager will fetch from the database, process, and report back, before fetching for more URLs." default="10"> 
     
    221216                192.168.0.128 
    222217            </address> 
    223             <!-- TODO: Update this. --> 
     218            <!-- TODO: Update this to 7627, eventually. --> 
    224219            <port description="Default FW port number" default="8083"> 
    225220                8083 
     
    311306                /vm/masters/Agent.Master-37/winXPPro.cfg 
    312307            </master_vm_config> 
    313             <port description="The TCP port number that the SOAP server of the VM daemon will listen on for requests.  Note: This port should be unique and not already be used by other modules, services, or daemons running on the host system." default="8089"> 
    314                 8089 
     308            <port description="The TCP port number that the SOAP server of the VM daemon will listen on for requests.  Note: This port should be unique and not already be used by other modules, services, or daemons running on the host system." default="7627"> 
     309                7627 
    315310            </port> 
    316311            <datastore_path description="The absolute path to the parent directory, where all HoneyClient VM data is stored on the host server.  It is assumed that individual VM data is stored in separate subdirectories within this parent directory." default="/vm"> 
  • honeyclient/branches/exp/kindlund-simpler_agent/lib/HoneyClient/Manager.pm

    r1490 r1491  
    243243use Data::Dumper; 
    244244 
    245 # Make sure Filesys::DfPortable loads 
    246 BEGIN { use_ok('Filesys::DfPortable') 
    247         or diag("Can't load Filesys::DfPortable package. Check to make sure the package library is correctly listed within the path."); } 
    248 require_ok('Filesys::DfPortable'); 
    249 use Filesys::DfPortable; 
    250  
    251245=end testing 
    252246 
     
    288282# Include Hash Serialization Utility Libraries 
    289283use Storable qw(nfreeze thaw); 
    290  
    291 # Include Disk Utilization Library 
    292 use Filesys::DfPortable; 
    293284 
    294285# Include Logging Library 
     
    380371####################################################################### 
    381372 
    382 # Helper function to check if the host system has enough disk 
    383 # space available, in order to run the Manager. 
    384 sub _checkSpaceAvailable { 
    385  
    386     my $datastore_path = getVar(name      => "datastore_path", 
    387                                 namespace => "HoneyClient::Manager::VM"); 
    388     my $snapshot_path  = getVar(name      => "snapshot_path", 
    389                                 namespace => "HoneyClient::Manager::VM"); 
    390     my $min_space_free = getVar(name      => "min_space_free", 
    391                                 namespace => "HoneyClient::Manager::VM"); 
    392  
    393                                                     # Obtain sizes in GB 
    394     my $datastore_attr = dfportable($datastore_path, 1024 * 1024 * 1024); 
    395     my $snapshot_attr  = dfportable($snapshot_path,  1024 * 1024 * 1024); 
    396  
    397     if ($datastore_attr->{bavail} < $min_space_free) { 
    398         $LOG->warn("Directory (" . $datastore_path . ") has low disk space (" . $datastore_attr->{bavail} . " GB)."); 
    399     } elsif ($snapshot_attr->{bavail} < $min_space_free) { 
    400         $LOG->warn("Directory (" . $snapshot_path . ") has low disk space (" . $snapshot_attr->{bavail} . " GB)."); 
    401     } else { 
    402         return; 
    403     } 
    404     $LOG->info("Low disk space detected. Shutting down Manager."); 
    405     exit; 
    406 } 
    407  
    408373# Default handler for any faults that are received by a SOAP client. 
    409374# Inputs: Class, SOAP::SOM 
     
    441406    exit; 
    442407} 
    443  
    444 # TODO: Save manager state? - Still needed? 
    445     # This variable may contain a filename that the Manager 
    446     # would use to dump its entire state information, upon termination. 
    447     # XXX: May want to change this format/usage, eventually. 
    448 #    my $STATE_FILE = getVar(name => "manager_state"); 
    449 # 
    450 #    if (length($STATE_FILE) > 0 && 
    451 #        defined($globalAgentState)) { 
    452 #        $LOG->info("Saving state to '" . $STATE_FILE . "'."); 
    453 #        my $dump_file = new IO::File($STATE_FILE, "a"); 
    454 # 
    455 #        # XXX: Delete this block, eventually. 
    456 #        $Data::Dumper::Terse = 0; 
    457 #        $Data::Dumper::Indent = 2; 
    458 #        print $dump_file Dumper(thaw(decode_base64($globalAgentState))); 
    459 #        $dump_file->close(); 
    460 #    } 
    461408 
    462409END { 
     
    517464    # for consistency. 
    518465    my ($class, %args) = @_; 
    519  
    520     # Sanity check: Check disk space. 
    521     # TODO: This needs to be moved closer to the cloning logic. 
    522     _checkSpaceAvailable(); 
    523466 
    524467    # Sanity check: If there's no database support and no work was 
  • honeyclient/branches/exp/kindlund-simpler_agent/lib/HoneyClient/Manager/VM/Clone.pm

    r1490 r1491  
    330330use IO::File; 
    331331 
     332# Make sure Filesys::DfPortable loads 
     333BEGIN { use_ok('Filesys::DfPortable') 
     334        or diag("Can't load Filesys::DfPortable package. Check to make sure the package library is correctly listed within the path."); } 
     335require_ok('Filesys::DfPortable'); 
     336use Filesys::DfPortable; 
     337 
    332338=end testing 
    333339 
     
    389395# Include IO::File Libraries 
    390396use IO::File; 
     397 
     398# Include Disk Utilization Library 
     399use Filesys::DfPortable; 
    391400 
    392401=pod 
     
    541550        # Ignore errors. 
    542551        eval { 
     552            $self->{'_fw_handle'} = getClientHandle(namespace     => "HoneyClient::Manager::FW", 
     553                                                    fault_handler => \&_handleFWFault); 
    543554            $self->_denyNetwork(); 
    544555        }; 
     
    590601} 
    591602 
    592 # Handle SOAP faults. 
     603# Handle FW SOAP faults. 
     604
     605# During VM Clone object destruction, it's possible that the 
     606# firewall will be reset by the Manager's END logic before the chains 
     607# have been properly flushed by the DESTROY logic.  As such, 
     608# we suppress error during chain deletion. 
     609sub _handleFWFault { 
     610 
     611    # Extract arguments. 
     612    my ($class, $res) = @_; 
     613 
     614    # Construct error message. 
     615    # Figure out if the error occurred in transport or over 
     616    # on the other side. 
     617    my $errMsg = $class->transport->status; # Assume transport error. 
     618 
     619    if (ref $res) { 
     620        $errMsg = $res->faultcode . ": ".  $res->faultstring . "\n"; 
     621    } 
     622     
     623    if ($errMsg !~ /Unable to flush entries in chain/) { 
     624        $LOG->warn("Error occurred during processing. " . $errMsg); 
     625        Carp::carp __PACKAGE__ . "->_handleFWFault(): Error occurred during processing.\n" . $errMsg; 
     626    } 
     627
     628 
     629# Handle Agent SOAP faults. 
    593630# 
    594631# When initially contacting the HoneyClient::Agent daemon running 
     
    598635# and the daemon isn't ready to accept commands from the 
    599636# HoneyClient::Manager yet. 
    600 sub _handleFault { 
     637sub _handleAgentFault { 
    601638 
    602639    # Extract arguments. 
     
    615652        ($errMsg !~ /No route to host/)) { 
    616653        $LOG->warn("Error occurred during processing. " . $errMsg); 
    617         Carp::carp __PACKAGE__ . "->_handleFault(): Error occurred during processing.\n" . $errMsg; 
     654        Carp::carp __PACKAGE__ . "->_handleAgentFault(): Error occurred during processing.\n" . $errMsg; 
    618655    } 
    619656} 
     
    737774        $self->{'_agent_handle'} = getClientHandle(namespace     => "HoneyClient::Agent", 
    738775                                                   address       => $self->{'ip_address'}, 
    739                                                    fault_handler => \&_handleFault); 
     776                                                   fault_handler => \&_handleAgentFault); 
    740777 
    741778        eval { 
     
    10131050} 
    10141051 
     1052# Helper function to check if the host system has enough disk 
     1053# space available, in order to run the Manager. 
     1054sub _checkSpaceAvailable { 
     1055 
     1056    my $datastore_path = getVar(name      => "datastore_path", 
     1057                                namespace => "HoneyClient::Manager::VM"); 
     1058    my $snapshot_path  = getVar(name      => "snapshot_path", 
     1059                                namespace => "HoneyClient::Manager::VM"); 
     1060    my $min_space_free = getVar(name      => "min_space_free", 
     1061                                namespace => "HoneyClient::Manager::VM"); 
     1062 
     1063                                                    # Obtain sizes in GB 
     1064    my $datastore_attr = dfportable($datastore_path, 1024 * 1024 * 1024); 
     1065    my $snapshot_attr  = dfportable($snapshot_path,  1024 * 1024 * 1024); 
     1066 
     1067    if ($datastore_attr->{bavail} < $min_space_free) { 
     1068        $LOG->warn("Directory (" . $datastore_path . ") has low disk space (" . $datastore_attr->{bavail} . " GB)."); 
     1069    } elsif ($snapshot_attr->{bavail} < $min_space_free) { 
     1070        $LOG->warn("Directory (" . $snapshot_path . ") has low disk space (" . $snapshot_attr->{bavail} . " GB)."); 
     1071    } else { 
     1072        return; 
     1073    } 
     1074    $LOG->info("Low disk space detected. Shutting down."); 
     1075    exit; 
     1076} 
     1077 
    10151078####################################################################### 
    10161079# Public Methods Implemented                                          # 
     
    11531216    # Get the class name. 
    11541217    my $self = shift; 
     1218     
     1219    # Sanity check: Make sure there is enough disk space available.  
     1220    _checkSpaceAvailable(); 
    11551221 
    11561222    # Get the rest of the arguments, as a hashtable.