.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Rex::Commands::Virtualization 3pm" .TH Rex::Commands::Virtualization 3pm "2020-09-18" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Rex::Commands::Virtualization \- Virtualization module .SH "DESCRIPTION" .IX Header "DESCRIPTION" With this module you can manage your virtualization. .PP Version <= 1.0: All these functions will not be reported. .PP All these functions are not idempotent. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& 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"; .Ve .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" .ie n .SS "vm($action => $name, %option)" .el .SS "vm($action => \f(CW$name\fP, \f(CW%option\fP)" .IX Subsection "vm($action => $name, %option)" This module only exports the \fIvm\fR function. You can manage everything with this function. .SH "EXAMPLES" .IX Header "EXAMPLES" .SS "Creating a Virtual Machine" .IX Subsection "Creating a Virtual Machine" Create a (VirtualBox) \s-1VM\s0 named \*(L"vm01\*(R" with 512 \s-1MB\s0 ram and 1 cpu. One harddrive, 10 \s-1GB\s0 in size being a file on disk. With a cdrom as an iso image and a natted network. The bootorder is set to \*(L"dvd\*(R". .PP .Vb 10 \& 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"; .Ve .PP Create a (\s-1KVM\s0) \s-1VM\s0 named \*(L"vm01\*(R" with 512 \s-1MB\s0 ram and 1 cpu. One harddrive, 10 \s-1GB\s0 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 \*(L"cdrom\*(R". .PP .Vb 7 \& 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", \& }, \& ]; .Ve .PP This is the same as above, but with all options in use. .PP .Vb 10 \& 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 => \*(Aqtcp\*(Aq, \& host => \*(Aq127.0.0.1\*(Aq, \& port => 12345, \& }, \& ]; .Ve .PP Create a (Xen/HVM) \s-1VM\s0 named \*(L"vm01\*(R" with 512 \s-1MB\s0 ram and 1 cpu. One harddrive, cloned from an existing one. .PP .Vb 8 \& vm create => "vm01", \& type => "hvm", \& storage => [ \& { \& file => "/mnt/data/libvirt/images/vm01.img", \& template => "/mnt/data/libvirt/images/svn01.img", \& }, \& ]; .Ve .PP This is the same as above, but with all options in use. .PP .Vb 10 \& 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"; .Ve .PP Create a (Xen/PVM) \s-1VM\s0 named \*(L"vm01\*(R" with 512 \s-1MB\s0 ram and 1 cpu. With one root partition (10GB in size) and one swap parition (1GB in size). .PP .Vb 10 \& 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", \& }, \& ]; .Ve .PP This is the same as above, but with all options in use. .PP .Vb 10 \& 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", \& }, \& ]; .Ve .SS "Start/Stop/Destroy" .IX Subsection "Start/Stop/Destroy" Start a stopped vm .PP .Vb 1 \& vm start => "name"; .Ve .PP Stop a running vm (send shutdown signal) .PP .Vb 1 \& vm shutdown => "name"; .Ve .PP Hard Stop a running vm .PP .Vb 1 \& vm destroy => "name"; .Ve .SS "Delete" .IX Subsection "Delete" .Vb 1 \& vm delete => "name"; .Ve .SS "Modifying a \s-1VM\s0" .IX Subsection "Modifying a VM" Currently you can only modify the memory. .PP .Vb 3 \& vm option => "name", \& max_memory => 1024*1024, # in bytes \& memory => 512*1024; .Ve .SS "Request information of a vm" .IX Subsection "Request information of a vm" .Vb 1 \& vm info => "name"; .Ve .SS "Request info from the underlying hypervisor" .IX Subsection "Request info from the underlying hypervisor" .Vb 1 \& vm hypervisor => "capabilities"; .Ve