root/honeyclient/tags/exp/DOWN1-kindlund-simpler_agent/bin/migrate_clients.pl

Revision 1359, 2.8 kB (checked in by kindlund, 10 months ago)

Updated utility scripts.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl -w -Ilib
2
3 # $Id: migrate_clients.pl 1343 2008-03-07 20:19:24Z kindlund $
4
5 use strict;
6 use warnings;
7
8 use Data::Dumper;
9 use HoneyClient::Util::Config qw(getVar);
10 use HoneyClient::Manager::Database;
11 use Sys::Hostname::Long;
12 use Log::Log4perl qw(:easy);
13
14 our $LOG = get_logger();
15
16 my $args = {
17     hostname => Sys::Hostname::Long::hostname_long,
18 };
19
20 my $old_datastore_path = "/vm.old/clones";
21 my $old_snapshot_path = "/vm.old/snapshots";
22 my $datastore_path = getVar(name => "datastore_path", namespace => "HoneyClient::Manager::VM");
23 my $snapshot_path = getVar(name => "snapshot_path", namespace => "HoneyClient::Manager::VM");
24 my $suspicious_path = "/vm/suspicious";
25
26 my $clients = HoneyClient::Manager::Database::get_not_deleted_clients($args);
27
28 while (my ($cid, $id) = each %{$clients}) {
29
30     $LOG->info("Migrating VM (" . $cid . ")");
31
32     #$LOG->info("Executing: vmware-cmd " . $datastore_path . "/" . $cid . "/*.vmx stop hard");
33     #system("vmware-cmd " . $datastore_path . "/" . $cid . "/*.vmx stop hard");
34
35     #$LOG->info("Executing: vmware-cmd " . $datastore_path . "/" . $cid . "/*.cfg stop hard");
36     #system("vmware-cmd " . $datastore_path . "/" . $cid . "/*.cfg stop hard");
37
38     $LOG->info("Executing: vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.vmx");
39     system("vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.vmx");
40
41     $LOG->info("Executing: vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.cfg");
42     system("vmware-cmd -s unregister " . $datastore_path . "/" . $cid . "/*.cfg");
43    
44     $LOG->info("Executing: mv " . $datastore_path . "/" . $cid . " " . $suspicious_path);
45     system("mv " . $datastore_path . "/" . $cid . " " . $suspicious_path);
46
47     $LOG->info("Executing: vmware-cmd -s register " . $suspicious_path . "/" . $cid . "/*.vmx");
48     system("vmware-cmd -s register " . $suspicious_path . "/" . $cid . "/*.vmx");
49    
50     $LOG->info("Executing: vmware-cmd -s register " . $suspicious_path . "/" . $cid . "/*.cfg");
51     system("vmware-cmd -s register " . $suspicious_path . "/" . $cid . "/*.cfg");
52    
53     #$LOG->info("Executing: cp -Rp " . $old_datastore_path . "/" . $cid . " " . $datastore_path);
54     #system("cp -Rp " . $old_datastore_path . "/" . $cid . " " . $datastore_path);
55
56     #$LOG->info("Executing: cp -Rp " . $old_snapshot_path . "/" . $cid . "* " . $snapshot_path);
57     #system("cp -Rp " . $old_snapshot_path . "/" . $cid . "* " . $snapshot_path);
58     
59     #$LOG->info("Executing: vmware-cmd -s register " . $datastore_path . "/" . $cid . "/*.vmx");
60     #system("vmware-cmd -s register " . $datastore_path . "/" . $cid . "/*.vmx");
61
62     #$LOG->info("Executing: vmware-cmd -s register " . $datastore_path . "/" . $cid . "/*.cfg");
63     #system("vmware-cmd -s register " . $datastore_path . "/" . $cid . "/*.cfg");
64
65     #HoneyClient::Manager::Database::set_client_deleted($id);
66
67     #print "\n";
68 }
69
Note: See TracBrowser for help on using the browser.