Changeset 1251

Show
Ignore:
Timestamp:
02/22/08 15:04:44 (8 months ago)
Author:
kindlund
Message:

Initial commit of client cleanup code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/trunk/bin/cleanup_broken_clients.pl

    • Property svn:keywords set to Id "$file"
    r1212 r1251  
    11#!/usr/bin/perl -w -Ilib 
     2 
     3# $Id$ 
    24 
    35use strict; 
     
    57 
    68use Data::Dumper; 
     9use HoneyClient::Util::Config qw(getVar); 
    710use HoneyClient::Manager::Database; 
     11use Sys::Hostname::Long; 
     12use Log::Log4perl qw(:easy); 
    813 
    9 my $urls = { 
    10     'http://www.cpan.org/' => 20, 
    11     'http://www.craigslist.org/' => 100, 
     14our $LOG = get_logger(); 
     15 
     16my $args = { 
     17    hostname => Sys::Hostname::Long::hostname_long, 
    1218}; 
    1319 
    14 my $output = HoneyClient::Manager::Database::insert_queue_urls($urls); 
    15 print Dumper($output) . " URL(s) inserted.\n"; 
     20my $datastore_path = getVar(name => "datastore_path", namespace => "HoneyClient::Manager::VM"); 
     21my $snapshot_path = getVar(name => "snapshot_path", namespace => "HoneyClient::Manager::VM"); 
     22 
     23my $clients = HoneyClient::Manager::Database::get_broken_clients($args); 
     24 
     25#my ($cid, $id); 
     26while (my ($cid, $id) = each %{$clients}) { 
     27 
     28    $LOG->info("Deleting VM (" . $cid . ")"); 
     29 
     30    print "Executing: vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.vmx\n"; 
     31    system("vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.vmx"); 
     32 
     33    print "Executing: vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.cfg\n"; 
     34    system("vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.cfg"); 
     35     
     36    print "Executing: rm -rf " . $datastore_path . "/" . $cid . "\n"; 
     37    system("rm -rf " . $datastore_path . "/" . $cid); 
     38 
     39    print "Executing: rm -f " . $snapshot_path . "/" . $cid . "*\n"; 
     40    system("rm -f " . $snapshot_path . "/" . $cid . "*"); 
     41 
     42    HoneyClient::Manager::Database::set_client_deleted($id); 
     43 
     44    print "\n"; 
     45
     46 
  • honeyclient/trunk/bin/insert_queue_urls.pl

    • Property svn:keywords set to Id "$file"
    r1212 r1251  
    11#!/usr/bin/perl -w -Ilib 
     2 
     3# $Id$ 
    24 
    35use strict; 
  • honeyclient/trunk/lib/HoneyClient/Manager/Database.pm

    r1250 r1251  
    270270} 
    271271 
     272# XXX: Need to comment this further. 
     273sub get_broken_clients { 
     274    $AUTOLOAD = "Database::get_broken_clients"; 
     275    my $obj = shift; 
     276    my $obj_yaml = YAML::XS::Dump(Data::Structure::Util::unbless($obj)); 
     277    # Results from this call are YAML-encoded; need to deserialize them. 
     278    return YAML::XS::Load(_AUTOLOAD($obj_yaml)); 
     279} 
     280 
    272281####################################################################### 
    273282