Bug fixes
This commit is contained in:
parent
0997e8cf80
commit
478fbab5dd
|
@ -49,6 +49,8 @@ clone_jobs => {
|
||||||
num_cpus => 2,
|
num_cpus => 2,
|
||||||
mac => '00:50:56:BF:01:01',
|
mac => '00:50:56:BF:01:01',
|
||||||
poweron => 1,
|
poweron => 1,
|
||||||
|
|
||||||
|
# Be very careful with this option! It deletes destination machine if it exists.
|
||||||
overwrite => 1
|
overwrite => 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@ Vcs-Git: https://git.verdnatura.es/vn-vmware
|
||||||
|
|
||||||
Package: vn-vmware
|
Package: vn-vmware
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: perl, tar
|
Depends: perl, pigz
|
||||||
Suggests: pigz
|
|
||||||
Section: misc
|
Section: misc
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Description: Maintenance scripts for VMWare
|
Description: Maintenance scripts for VMWare
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
pkg="vn-vmware_1.0.0"
|
pkg="vn-vmware_1.0.0"
|
||||||
debPkg="${pkg}_all.deb"
|
debPkg="${pkg}_all.deb"
|
||||||
host="root@bacula"
|
host="root@verdnatura.es"
|
||||||
|
|
||||||
debuild -us -uc -b
|
debuild -us -uc -b
|
||||||
#scp ../$debPkg $host:/root
|
scp ../$debPkg $host:/root
|
||||||
#ssh $host dpkg -i /root/$debPkg
|
#ssh $host dpkg -i /root/$debPkg
|
||||||
#ssh $host rm /root/$debPkg
|
#ssh $host rm /root/$debPkg
|
||||||
debian/rules clean
|
debian/rules clean
|
||||||
|
|
19
vn-vmware.pl
19
vn-vmware.pl
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use experimental qw(switch say);
|
||||||
|
|
||||||
use VMware::VIRuntime;
|
use VMware::VIRuntime;
|
||||||
use VMware::VICredStore;
|
use VMware::VICredStore;
|
||||||
use VMware::VILib;
|
use VMware::VILib;
|
||||||
|
@ -15,7 +17,6 @@ use Net::SMTP;
|
||||||
use Term::ANSIColor;
|
use Term::ANSIColor;
|
||||||
use Net::OpenSSH;
|
use Net::OpenSSH;
|
||||||
use XML::LibXML;
|
use XML::LibXML;
|
||||||
use feature qw(switch say);
|
|
||||||
|
|
||||||
use constant false => 0;
|
use constant false => 0;
|
||||||
use constant true => 1;
|
use constant true => 1;
|
||||||
|
@ -32,7 +33,7 @@ my %opts = (
|
||||||
},
|
},
|
||||||
'vm-name' => {
|
'vm-name' => {
|
||||||
type => "=s",
|
type => "=s",
|
||||||
variable => "vm_name",
|
variable => "VM_NAME",
|
||||||
help => "Name of the virtual machine"
|
help => "Name of the virtual machine"
|
||||||
},
|
},
|
||||||
'rotation-days' => {
|
'rotation-days' => {
|
||||||
|
@ -100,7 +101,7 @@ my %opts = (
|
||||||
},
|
},
|
||||||
'overwrite' => {
|
'overwrite' => {
|
||||||
type => "",
|
type => "",
|
||||||
help => "Whether to remove the virtual machine if there is one with the same name",
|
help => "Whether to remove the destination machine if it exists; Be very careful with this option!",
|
||||||
default => 0
|
default => 0
|
||||||
},
|
},
|
||||||
'poweron' => {
|
'poweron' => {
|
||||||
|
@ -127,7 +128,7 @@ my %opts = (
|
||||||
|
|
||||||
Opts::add_options(%opts);
|
Opts::add_options(%opts);
|
||||||
Opts::parse();
|
Opts::parse();
|
||||||
Opts::validate();
|
#Opts::validate();
|
||||||
|
|
||||||
my $operation = Opts::get_option('operation');
|
my $operation = Opts::get_option('operation');
|
||||||
my $job = Opts::get_option('job');
|
my $job = Opts::get_option('job');
|
||||||
|
@ -438,7 +439,7 @@ sub backup_machine() {
|
||||||
my $tar_status = system("tar -I pigz -cf $tar_file -C $local_tmp_dir .");
|
my $tar_status = system("tar -I pigz -cf $tar_file -C $local_tmp_dir .");
|
||||||
|
|
||||||
unless ($tar_status == 0) {
|
unless ($tar_status == 0) {
|
||||||
die "An error occurred when trying to compress the file."
|
die "An error occurred when trying to compress the file.";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
|
@ -535,7 +536,7 @@ sub clone_machine {
|
||||||
sleep(20);
|
sleep(20);
|
||||||
$original_vm->Destroy();
|
$original_vm->Destroy();
|
||||||
} else {
|
} else {
|
||||||
die "Machine with same name exists"
|
die "Machine with same name exists.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +550,7 @@ sub clone_machine {
|
||||||
for my $nic (@nics) {
|
for my $nic (@nics) {
|
||||||
if ($nic->macAddress eq $mac) {
|
if ($nic->macAddress eq $mac) {
|
||||||
my $machineName = $vmRes->name;
|
my $machineName = $vmRes->name;
|
||||||
die "Machine '$machineName' with same MAC exists"
|
die "Machine '$machineName' with same MAC exists.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -858,11 +859,11 @@ sub set_power_state {
|
||||||
given ($state) {
|
given ($state) {
|
||||||
when ('poweredOff') {
|
when ('poweredOff') {
|
||||||
$vm_power->ShutdownGuest();
|
$vm_power->ShutdownGuest();
|
||||||
log_message "Turning off ".$vm_power->name;
|
log_message "Turning off ".$vm_power->name.".";
|
||||||
}
|
}
|
||||||
when ('poweredOn') {
|
when ('poweredOn') {
|
||||||
$vm_power->PowerOnVM();
|
$vm_power->PowerOnVM();
|
||||||
log_message "Turning on ".$vm_power->name;
|
log_message "Turning on ".$vm_power->name.".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sleep(50);
|
sleep(50);
|
||||||
|
|
Reference in New Issue