| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 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 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 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 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
} |
|---|
| 69 |
|
|---|