NAME
VM::Libvirt::CloneHelper - Create a bunch of cloned VMs in via libvirt.
VERSION
Version 0.1.1
SYNOPSIS
# initialize it
my $clone_helper=VM::Libvirt::CloneHelper->new({
blank_domains=>'/usr/local/etc/clonehelper/blank_domains',
net_head=>'/usr/local/etc/clonehelper/net_head',
net_tail=>'/usr/local/etc/clonehelper/net_tail',
windows_blank=>0,
mac_base=>'00:08:74:2d:dd:',
ipv4_base=>'192.168.1.',
start=>100,
to_clone=>'baseVM',
clone_name_base=>'foo',
count=>10,
verbose=>1,
snapshot_name=>'clean',
net=>'default',
wait=>360,
});
$clone_helper->delete_vms;
$clone_helper->clone_vms;
$clone_helper->start_vms;
sleep 500;
$clone_helper->snapshot_vms;
$clone_helper->shutdown_vms;
It should be noted that this is effectively limited to 253 VMs.
This script lib is primarily meant for creating a bunch of cloned VMs on a box for testing purposes, so this is not really a major issue given the design scope.
VMs should be set to us DHCP so they will get their expected IP when they boot.
METHODS
new
Initialize the module.
net=>'default'
Name of the libvirt network in question.
blank_domains=>'/usr/local/etc/clonehelper/blank_domains',
List of domains to blank via setting 'dnsmasq:option value='address=/foo.bar/'.
If not this file does not exist, it will be skipped.
net_head=>'/usr/local/etc/clonehelper/net_head',
The top part of the net XML config that that dnsmasq options will be
sandwhiched between.
net_tail=>'/usr/local/etc/clonehelper/net_tail',
The bottom part of the net XML config that that dnsmasq options will
be sandwhiched between.
windows_blank=>1,
Blank commonly used MS domains. This is handy for reducing network noise
when testing as well as making sure they any VMs don't do something like
run updates when one does not want it to.
mac_base=>'00:08:74:2d:dd:',
Base to use for the MAC.
ipv4_base=>'192.168.1.',
Base to use for the IPs for adding static assignments.
start=>'100',
Where to start in set.
to_clone=>'baseVM',
The name of the VM to clone.
clone_name_base=>'cloneVM',
Base name to use for creating the clones. 'foo' will become 'foo$current', so
for a start of 100, the first one would be 'foo100' and with a count of 10 the
last will be 'foo109'.
count=>10,
How many clones to create.
snapshot_name=>'clean',
The name to use for the snapshot.
wait=>360,
How long to wait if auto-doing all.
clone
Create the clones.
One optional argument is taken and that is the VM to operate on. Otherwise all is ran for them all.
$clone_helper->clone;
delete_clones
Delete all the clones
One optional argument is taken and that is the VM to operate on. Otherwise all is ran for them all.
$clone_helper->delete_clones;
net_xml
Returns a string with the full net config XML.
my $net_config_xml=$clone_helper->net_xml;
print $net_config_xml;
net_redefine
Redefines the network in question.
recreate
Recreate the specified VM.
One optional argument is taken and that is the VM to operate on. Otherwise all is ran for them all.
If you wish to recreate all, you should likely use recreate_all, to avoid any issues caused by starting them all at the same time.
$clone_helper->recreate('foo100');
recreate_all
Recreate all VMs.
Does one at a time.
$clone_helper->recreate_all;
snapshot_clones
Snapshot all the clones
One optional argument is taken and that is the VM to operate on. Otherwise all is ran for them all.
$clone_helper->snapshot_clones;
start_clones
Start all the clones
One optional argument is taken and that is the VM to operate on. Otherwise all is ran for them all.
$clone_helper->start_clones;
stop_clones
Stop all the clones. This does not stop them gracefully as we don't need to as they are being started via snapshot.
One optional argument is taken and that is the VM to operate on. Otherwise all is ran for them all.
$clone_helper->stop_clones;
vm_list
Generate a list of VMs.
BLANKED MS DOMAINS
microsoft.com
windowsupdate.com
windows.com
microsoft.com.nsatc.net
bing.net
live.com
cloudapp.net
cs1.wpc.v0cdn.net
-msedge.net
msedge.net
microsoft.com.akadns.net
footprintpredict.com
microsoft-hohm.com
msn.com
social.ms.akadns.net
msedge.net
dc-msedge.net
bing.com
edgekey.net
azureedge.net
amsn.net
moiawsorigin.clo.footprintdns.com
office365.com
skype.com
trafficmanager.net
AUTHOR
Zane C. Bowers-Hadley, <vvelox at vvelox.net>
BUGS
Please report any bugs or feature requests to bug-vm-libvirt-clonehelper at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=VM-Libvirt-CloneHelper. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc VM::Libvirt::CloneHelper
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=VM-Libvirt-CloneHelper
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2022 by Zane C. Bowers-Hadley.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)