.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" 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::Box 3pm" .TH Rex::Commands::Box 3pm "2023-08-09" "perl v5.36.0" "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::Box \- Functions / Class to manage Virtual Machines .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a Module to manage Virtual Machines or Cloud Instances in a simple way. Currently it supports Amazon, \s-1KVM\s0 and VirtualBox. .PP Version <= 1.0: All these functions will not be reported. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Rex::Commands::Box; \& \& set box => "VBox"; \& \& group all_my_boxes => map { get_box($_\->{name})\->{ip} } list_boxes; \& \& task mytask => sub { \& \& box { \& my ($box) = @_; \& $box\->name("boxname"); \& $box\->url("http://box.rexify.org/box/base\-image.box"); \& \& $box\->network(1 => { \& type => "nat", \& }); \& \& $box\->network(1 => { \& type => "bridged", \& bridge => "eth0", \& }); \& \& $box\->forward_port(ssh => [2222, 22]); \& \& $box\->share_folder(myhome => "/home/myuser"); \& \& $box\->auth( \& user => "root", \& password => "box", \& ); \& \& $box\->setup(qw/task_to_customize_box/); \& \& }; \& \& }; .Ve .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" .ie n .SS "new(name => $box_name)" .el .SS "new(name => \f(CW$box_name\fP)" .IX Subsection "new(name => $box_name)" Constructor if used in \s-1OO\s0 mode. .PP .Vb 1 \& my $box = Rex::Commands::Box\->new(name => "box_name"); .Ve .SS "box(sub {})" .IX Subsection "box(sub {})" With this function you can create a new Rex/Box. The first parameter of this function is the Box object. With this object you can define your box. .PP .Vb 4 \& box { \& my ($box) = @_; \& $box\->name("boxname"); \& $box\->url("http://box.rexify.org/box/base\-image.box"); \& \& $box\->network(1 => { \& type => "nat", \& }); \& \& $box\->network(1 => { \& type => "bridged", \& bridge => "eth0", \& }); \& \& $box\->forward_port(ssh => [2222, 22]); \& \& $box\->share_folder(myhome => "/home/myuser"); \& \& $box\->auth( \& user => "root", \& password => "box", \& ); \& \& $box\->setup(qw/task_to_customize_box/); \& }; .Ve .SS "list_boxes" .IX Subsection "list_boxes" This function returns an array of hashes containing all information that can be gathered from the hypervisor about the Rex/Box. This function doesn't start a Rex/Box. .PP .Vb 5 \& use Data::Dumper; \& task "get_infos", sub { \& my @all_boxes = list_boxes; \& print Dumper(\e@all_boxes); \& }; .Ve .SS "get_box($box_name)" .IX Subsection "get_box($box_name)" This function tries to gather all information of a Rex/Box. This function also starts a Rex/Box to gather all information of the running system. .PP .Vb 5 \& use Data::Dumper; \& task "get_box_info", sub { \& my $data = get_box($box_name); \& print Dumper($data); \& }; .Ve .ie n .SS "boxes($action, @data)" .el .SS "boxes($action, \f(CW@data\fP)" .IX Subsection "boxes($action, @data)" With this function you can control your boxes. Currently there are 3 actions. .IP "init" 4 .IX Item "init" This action can only be used if you're using a \s-1YAML\s0 file to describe your Rex/Boxes. .Sp .Vb 3 \& task "prepare_boxes", sub { \& boxes "init"; \& }; .Ve .IP "start" 4 .IX Item "start" This action start one or more Rex/Boxes. .Sp .Vb 3 \& task "start_boxes", sub { \& boxes "start", "box1", "box2"; \& }; .Ve .IP "stop" 4 .IX Item "stop" This action stop one or more Rex/Boxes. .Sp .Vb 3 \& task "stop_boxes", sub { \& boxes "stop", "box1", "box2"; \& }; .Ve