| 1 | #!/usr/bin/perl
|
|---|
| 2 |
|
|---|
| 3 | use strict;
|
|---|
| 4 | use warnings;
|
|---|
| 5 |
|
|---|
| 6 | #The idea here is that you just clone the amount of machines that you want to run
|
|---|
| 7 | my @machines = glob('/home/chris/VirtualBox\ VMs/sample*');
|
|---|
| 8 |
|
|---|
| 9 | while (1)
|
|---|
| 10 | {
|
|---|
| 11 | foreach my $machine (@machines)
|
|---|
| 12 | {
|
|---|
| 13 |
|
|---|
| 14 | if ($machine =~ /([^\/]+?)$/)
|
|---|
| 15 | {
|
|---|
| 16 | $machine = $1;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | print "Spinning up vm $machine...\n";
|
|---|
| 20 | system("vboxmanage snapshot $machine restorecurrent");
|
|---|
| 21 | system("vboxmanage startvm $machine --type headless");
|
|---|
| 22 | sleep(1);
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | print "Sleeping for 1\n";
|
|---|
| 26 | sleep(1);
|
|---|
| 27 |
|
|---|
| 28 | print "About to start grabbing info\n";
|
|---|
| 29 |
|
|---|
| 30 | foreach my $machine (@machines)
|
|---|
| 31 | {
|
|---|
| 32 | print "Grabbing info for $machine\n";
|
|---|
| 33 | `vboxmanage showvminfo $machine`;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | sleep (1);
|
|---|
| 37 | print "About to start powering down machines\n";
|
|---|
| 38 |
|
|---|
| 39 | foreach my $machine (@machines)
|
|---|
| 40 | {
|
|---|
| 41 |
|
|---|
| 42 | if ($machine =~ /([^\/]+?)$/)
|
|---|
| 43 | {
|
|---|
| 44 | $machine = $1;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | print "Spinning down vm $machine...\n";
|
|---|
| 48 | system("vboxmanage controlvm $machine poweroff");
|
|---|
| 49 | sleep(1);
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|