Changeset 1453

Show
Ignore:
Timestamp:
04/04/08 13:24:42 (4 months ago)
Author:
kindlund
Message:

Still updating support for light-weight Agent.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-simpler_agent/lib/HoneyClient/Manager/VM/Clone.pm

    r1451 r1453  
    683683    $LOG->info("Waiting for a valid IP address of clone VM (" . $self->{'config'} . ")."); 
    684684    $ret = undef; 
    685     my $stubAgent = undef; 
    686685    my $logMsgPrinted = 0; 
    687686    while (!defined($self->{'ip_address'}) or !defined($ret)) { 
     
    700699         
    701700        # Now, try contacting the Agent. 
    702         $stubAgent = getClientHandle(namespace     => "HoneyClient::Agent", 
    703                                      address       => $self->{'ip_address'}, 
    704                                      fault_handler => \&_handleFault); 
     701        $self->{'_agent_handle'} = getClientHandle(namespace     => "HoneyClient::Agent", 
     702                                                   address       => $self->{'ip_address'}, 
     703                                                   fault_handler => \&_handleFault); 
    705704 
    706705        eval { 
    707             $som = $stubAgent->getProperties(driver_name => $self->{'driver_name'}); 
     706            $som = $self->{'_agent_handle'}->getProperties(driver_name => $self->{'driver_name'}); 
    708707            $ret = $som->result(); 
    709708        }; 
     
    768767    # Don't change the status field for any VM that has been marked 
    769768    # as suspicious or compromised. 
    770     if (($self->{'status'} ne "suspicious") && 
    771         ($self->{'status'} ne "compromised")) { 
    772         $self->{'status'} = $args{'status'}; 
     769    if (($self->{'status'} eq "suspicious") || 
     770        ($self->{'status'} eq "compromised")) { 
     771        return $self; 
     772    } 
     773 
     774    # Change the status field. 
     775    $self->{'status'} = $args{'status'}; 
     776 
     777    # Update the corresponding client record in the Drone database. 
     778    if (defined($self->{'database_id'})) { 
     779        for ($self->{'status'}) { 
     780            if (/running/) { 
     781                HoneyClient::Manager::Database::set_client_running($self->{'database_id'}); 
     782            } elsif (/suspended/) { 
     783                HoneyClient::Manager::Database::set_client_suspended($self->{'database_id'}); 
     784            } elsif (/suspicious/) { 
     785                # TODO: Need to implement this properly. 
     786            } elsif (/compromised/) { 
     787                HoneyClient::Manager::Database::set_client_compromised($self->{'database_id'}); 
     788            } elsif (/deleted/) { 
     789                HoneyClient::Manager::Database::set_client_deleted($self->{'database_id'}); 
     790            } 
     791        } 
    773792    } 
    774793 
     
    963982        _vm_handle => undef, 
    964983 
     984        # A SOAP handle to the Agent daemon.  (This internal variable 
     985        # should never be modified externally.) 
     986        _agent_handle => undef, 
     987 
    965988        # A variable indicated how long the object should wait for 
    966         # between subsequent retries to the HoneyClient::Manager::VM 
     989        # between subsequent retries to any SOAP server 
    967990        # daemon (in seconds).  (This internal variable should never 
    968991        # be modified externally.) 
     
    11611184} 
    11621185 
     1186# TODO: Comment this. 
     1187sub something { 
     1188 
     1189    # Extract arguments. 
     1190    my ($self, %args) = @_; 
     1191 
     1192    # Sanity check: Make sure we've been fed an object. 
     1193    unless (ref($self)) { 
     1194        $LOG->error("Error: Function must be called in reference to a " . 
     1195                    __PACKAGE__ . "->new() object!"); 
     1196        Carp::croak "Error: Function must be called in reference to a " . 
     1197                    __PACKAGE__ . "->new() object!\n"; 
     1198    } 
     1199 
     1200    # Log resolved arguments. 
     1201    $LOG->debug(sub { 
     1202        # Make Dumper format more terse. 
     1203        $Data::Dumper::Terse = 1; 
     1204        $Data::Dumper::Indent = 0; 
     1205        Dumper(\%args); 
     1206    }); 
     1207 
     1208    # Sanity checks; check if any args were specified. 
     1209    my $argsExist = scalar(%args); 
     1210 
     1211} 
     1212 
    11631213####################################################################### 
    11641214