-
-
05 Jul 2021 21:04:56 UTC
- Distribution: Rex
- Module version: v1.13.4
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (711 / 4 / 2)
- Kwalitee
Bus factor: 2- 49.25% Coverage
- License: apache_2_0
- Perl: v5.10.1
- Activity
24 month- Tools
- Download (342.78KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 118 contributors-
Jan Gehring
-
A Happy User
-
Alexander Romanenko
-
Alexandr Ciornii
-
Alex Mestiashvili
-
Ali Polatel
-
alx542
-
Anders Ossowicki
-
Andrej Zverev
-
Andrew Solomon
-
Andy Beverley
-
Arnold Bechtoldt
-
Boris Däppen
-
Brian Manning
-
Cameron Daniel
-
Chris Steigmeier
-
Christophe Wolfhugel
-
Crimson Thompson
-
Daniel Bäurer
-
Daniel Cesario
-
Daniel Dico
-
Denis Silakov
-
Dmitry Kopytov
-
Dominik Schulz
-
E. Choroba
-
Eduardo J
-
Eivin Giske Skaaren
-
elisdg
-
Elmer Quintanilla
-
Eric Johnson
-
Erik Huelsmann
-
Ferenc Erki
-
Franky Van Liedekerke
-
Fran Rodriguez
-
Gabor Szabo
-
Graham Todd
-
Harm Müller
-
Hayato Imai
-
Hiroaki Nakamura
-
Hiroki Matsuo
-
iblinder
-
Ilya Pavlov
-
James D Bearden
-
jdelgado7
-
Jean Charles Passard
-
Jean-Marie Renouard
-
Jeen Lee
-
Jens Berthold
-
Joachim Bargsten
-
John Karr
-
Jon Gentle
-
Joris DE POOTER
-
Jose Luis Martinez
-
Jose Luis Perez Diez
-
Kasim Tuman
-
Keedi Kim
-
Ken Crowell
-
Kent Fredric
-
Kirill Babikhin
-
labbeduddel
-
Leah Neukirchen
-
LeMerP
-
Mario Domgoergen
-
Max E. Aubrey
-
Mitch Broadhead
-
Nathan Abu
-
Naveed Massjouni
-
necrophcodr
-
Nicolas Leclercq
-
Nigel Gregoire
-
Nikolay A. Fetisov
-
Nils Domrose
-
okaoka
-
Oleg Hardt
-
Olivier Cherrier
-
Orange
-
Paco Esteban
-
Patrick Lauer
-
Pavel Timofeev
-
perlancar
-
Peter H. Ezetta
-
Peter Manthey
-
petersonchen
-
Pierrick DINTRAT
-
Piotr Karbowski
-
Prajithp
-
Randy Lauen
-
Renée Bäcker
-
Robert Abraham
-
Roy Storey
-
Samuele Tognini
-
Sascha Askani
-
Sascha Guenther
-
Simon Bertrang
-
Solène Rapenne
-
Stephane Benoit
-
Steve Dondley
-
Sven Dowideit
-
Tamas Molnar
-
Tianon Gravi
-
Tokuhiro Matsuno
-
Tomohiro Hosaka
-
Volker Kroll
-
Walery Wysotsky
-
Yanick Champoux
-
Yegor Korablev
-
Zane C. Bowers-Hadley
-
Сергей Романов
-
范野人
-
饶琛琳
-
Cuong Manh Le
-
David Golovan
-
Dominik Danter
-
Ilya Evseev
-
Niklas Larsson
-
Qiao Liu
-
Renato CRON
-
Peter Jankovics
- Dependencies
- AWS::Signature4
- Carp
- Cwd
- Data::Dumper
- Data::Validate::IP
- Devel::Caller
- Digest::HMAC_SHA1
- Digest::MD5
- English
- Exporter
- Fcntl
- File::Basename
- File::Spec
- File::Spec::Unix
- File::Spec::Win32
- FindBin
- HTTP::Request
- HTTP::Request::Common
- Hash::Merge
- IO::File
- IO::Select
- IO::Socket
- IO::String
- IPC::Open3
- JSON::MaybeXS
- LWP::UserAgent
- List::Util
- MIME::Base64
- Net::OpenSSH::ShellQuoter
- POSIX
- Scalar::Util
- Sort::Naturally
- Storable
- Symbol
- Term::ReadKey
- Test::Builder::Module
- Text::Glob
- Text::Wrap
- Time::HiRes
- UNIVERSAL
- URI
- URI::QueryParam
- XML::Simple
- YAML
- attributes
- base
- constant
- lib
- overload
- strict
- vars
- version
- warnings
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Rex::Commands::Virtualization - Virtualization module
DESCRIPTION
With this module you can manage your virtualization.
Version <= 1.0: All these functions will not be reported.
All these functions are not idempotent.
SYNOPSIS
use Rex::Commands::Virtualization; set virtualization => "LibVirt"; set virtualization => "VBox"; use Data::Dumper; print Dumper vm list => "all"; print Dumper vm list => "running"; vm destroy => "vm01"; vm delete => "vm01"; vm start => "vm01"; vm shutdown => "vm01"; vm reboot => "vm01"; vm option => "vm01", max_memory => 1024*1024, memory => 512*1024; print Dumper vm info => "vm01"; # creating a vm on a kvm host vm create => "vm01", storage => [ { file => "/mnt/data/libvirt/images/vm01.img", dev => "vda", } ]; print Dumper vm hypervisor => "capabilities";
EXPORTED FUNCTIONS
vm($action => $name, %option)
This module only exports the vm function. You can manage everything with this function.
EXAMPLES
Creating a Virtual Machine
Create a (VirtualBox) VM named "vm01" with 512 MB ram and 1 cpu. One harddrive, 10 GB in size being a file on disk. With a cdrom as an iso image and a natted network. The bootorder is set to "dvd".
vm create => "vm01", storage => [ { file => "/mnt/data/vbox/vm01.img", size => "10G", }, { file => "/mnt/iso/debian6.iso", } ], memory => 512, type => "Linux26", cpus => 1, boot => "dvd";
Create a (KVM) VM named "vm01" with 512 MB ram and 1 cpu. One harddrive, 10 GB in size being a file on disk. With a cdrom as an iso image and a bridged network on the bridge virbr0. The Bootorder is set to "cdrom".
vm create => "vm01", boot => "cdrom", storage => [ { size => "10G", file => "/mnt/data/libvirt/images/vm01.img", }, { file => "/mnt/data/iso/debian-6.0.2.1-amd64-netinst.iso", }, ];
This is the same as above, but with all options in use.
vm create => "vm01", memory => 512*1024, cpus => 1, arch => "x86_64", boot => "cdrom", clock => "utc", emulator => "/usr/bin/qemu-system-x86_64", on_poweroff => "destroy", on_reboot => "restart", on_crash => "restart", storage => [ { type => "file", size => "10G", device => "disk", driver_type => "qcow2", # supports all formats qemu-img supports. file => "/mnt/data/libvirt/images/vm01.img", dev => "vda", bus => "virtio", address => { type => "pci", domain => "0x0000", bus => "0x00", slot => "0x05", function => "0x0", }, }, { type => "file", device => "cdrom", file => "/mnt/data/iso/debian-6.0.2.1-amd64-netinst.iso", dev => "hdc", bus => "ide", readonly => 1, address => { type => "drive", controller => 0, bus => 1, unit => 0, }, }, ], network => [ { type => "bridge", bridge => "virbr0", model => "virtio", address => { type => "pci", domain => "0x0000", bus => "0x00", slot => "0x03", function => "0x0", }, }, ], serial_devices => [ { type => 'tcp', host => '127.0.0.1', port => 12345, }, ];
Create a (Xen/HVM) VM named "vm01" with 512 MB ram and 1 cpu. One harddrive, cloned from an existing one.
vm create => "vm01", type => "hvm", storage => [ { file => "/mnt/data/libvirt/images/vm01.img", template => "/mnt/data/libvirt/images/svn01.img", }, ];
This is the same as above, but with all options in use.
vm create => "vm01", memory => 512*1024, cpus => 1, boot => "hd", clock => "utc", on_poweroff => "destroy", on_reboot => "restart", on_crash => "restart", storage => [ { type => "file", size => "10G", device => "disk", file => "/mnt/data/libvirt/images/vm01.img", dev => "hda", bus => "ide", template => "/mnt/data/libvirt/images/svn01.img", }, { type => "file", device => "cdrom", dev => "hdc", bus => "ide", readonly => 1, }, ], network => [ { type => "bridge", bridge => "virbr0", }, ], type => "hvm";
Create a (Xen/PVM) VM named "vm01" with 512 MB ram and 1 cpu. With one root partition (10GB in size) and one swap parition (1GB in size).
vm create => "vm01", type => "pvm", storage => [ { file => "/mnt/data/libvirt/images/domains/vm01/disk.img", dev => "xvda2", is_root => 1, }, { file => "/mnt/data/libvirt/images/domains/vm01/swap.img", dev => "xvda1", }, ];
This is the same as above, but with all options in use.
vm create => "vm01", type => "pvm", memory => 512*1024, cpus => 1, clock => "utc", on_poweroff => "destroy", on_reboot => "restart", on_crash => "restart", os => { type => "linux", kernel => "/boot/vmlinuz-2.6.32-5-xen-amd64", initrd => "/boot/initrd.img-2.6.32-5-xen-amd64", cmdline => "root=/dev/xvda2 ro", }, storage => [ { type => "file", size => "10G", device => "disk", file => "/mnt/data/libvirt/images/domains/vm01/disk.img", dev => "xvda2", bus => "xen", aio => 1, # if you want to use aio }, { type => "file", size => "4G", device => "disk", file => "/mnt/data/libvirt/images/domains/vm01/swap.img", dev => "xvda1", bus => "xen", aio => 1, # if you want to use aio }, ], network => [ { type => "bridge", bridge => "virbr0", }, ];
Start/Stop/Destroy
Start a stopped vm
vm start => "name";
Stop a running vm (send shutdown signal)
vm shutdown => "name";
Hard Stop a running vm
vm destroy => "name";
Delete
vm delete => "name";
Modifying a VM
Currently you can only modify the memory.
vm option => "name", max_memory => 1024*1024, # in bytes memory => 512*1024;
Request information of a vm
vm info => "name";
Request info from the underlying hypervisor
vm hypervisor => "capabilities";
Module Install Instructions
To install Rex, copy and paste the appropriate command in to your terminal.
cpanm Rex
perl -MCPAN -e shell install Rex
For more information on module installation, please visit the detailed CPAN module installation guide.