Compare commits

...

5 Commits

Author SHA1 Message Date
Zane C. B-H 43a1868d59 document p9shares_list 2021-10-16 09:00:58 -05:00
Zane C. B-H ed18c888c7 add p9shares_list 2021-10-16 08:52:55 -05:00
Zane C. B-H 959ef58b33 finish module rename 2021-10-16 08:37:32 -05:00
Zane C. B-H 326f8f412f update docs to reflect name changes 2021-10-16 08:33:18 -05:00
Zane C. B-H 81da42eb40 rename bhyve modules 2021-10-16 08:16:49 -05:00
27 changed files with 189 additions and 89 deletions

View File

@ -1,19 +1,19 @@
Changes
lib/Rex/Virtualization/CBSD.pm
lib/Rex/Virtualization/CBSD/cbsd_base_dir.pm
lib/Rex/Virtualization/CBSD/create.pm
lib/Rex/Virtualization/CBSD/disk_list.pm
lib/Rex/Virtualization/CBSD/bcreate.pm
lib/Rex/Virtualization/CBSD/bdisk_list.pm
lib/Rex/Virtualization/CBSD/freejname.pm
lib/Rex/Virtualization/CBSD/info.pm
lib/Rex/Virtualization/CBSD/list.pm
lib/Rex/Virtualization/CBSD/nic_list.pm
lib/Rex/Virtualization/CBSD/pause.pm
lib/Rex/Virtualization/CBSD/pci_list.pm
lib/Rex/Virtualization/CBSD/remove.pm
lib/Rex/Virtualization/CBSD/restart.pm
lib/Rex/Virtualization/CBSD/set.pm
lib/Rex/Virtualization/CBSD/start.pm
lib/Rex/Virtualization/CBSD/stop.pm
lib/Rex/Virtualization/CBSD/binfo.pm
lib/Rex/Virtualization/CBSD/blist.pm
lib/Rex/Virtualization/CBSD/bnic_list.pm
lib/Rex/Virtualization/CBSD/bpause.pm
lib/Rex/Virtualization/CBSD/bpci_list.pm
lib/Rex/Virtualization/CBSD/bremove.pm
lib/Rex/Virtualization/CBSD/brestart.pm
lib/Rex/Virtualization/CBSD/bset.pm
lib/Rex/Virtualization/CBSD/bstart.pm
lib/Rex/Virtualization/CBSD/bstop.pm
lib/Rex/Virtualization/CBSD/vm_os_profiles.pm
lib/Rex/Virtualization/CBSD/vm_os_profiles_hash.pm
lib/Rex/Virtualization/CBSD/vm_os_types.pm

View File

@ -68,7 +68,9 @@ sub new {
=head1 Methods
=head2 cbsd_base_dir
=head2 General
=head3 cbsd_base_dir
This returns the CBSD base dir that the install is stored in.
@ -78,7 +80,24 @@ This will die upon error.
my $cbsd_base_dir=vm 'cbsd_base_dir'
=head2 create
=head3 freejname
Gets the next available VM name.
One argument is required and that is the base VM to use.
The optional argument 'lease_time' may be used to specify the number
of seconds a lease for the VM name should last. The default is 30.
vm 'freejname' => 'foo';
# the same thing, but with a 60 second lease time
vm 'freejname' => 'foo', lease_time => '60';
=head2 bhyve
=head3 bcreate
Creates a new VM.
@ -154,7 +173,7 @@ This will die upon a error.
'vm_cpus'=>'1',
'imgsize'=>'10g';
=head2 disk_list
=head3 bdisk_list
This returns a list of disks setup for use with Bhyve in CBSD via parsing
the output of the command below.
@ -183,7 +202,7 @@ This dies upon failure.
my @disks
eval{
@disks=vm 'disk_list';
@disks=vm 'bdisk_list';
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to the disk list... '.$error);
@ -191,21 +210,7 @@ This dies upon failure.
print Dumper(\@disks);
=head2 freejname
Gets the next available VM name.
One argument is required and that is the base VM to use.
The optional argument 'lease_time' may be used to specify the number
of seconds a lease for the VM name should last. The default is 30.
vm 'freejname' => 'foo';
# the same thing, but with a 60 second lease time
vm 'freejname' => 'foo', lease_time => '60';
=head2 info
=head3 binfo
This fetches the available configuration information for a VM via
the command below.
@ -216,7 +221,7 @@ The returned value is a flat hash of key value pairs.
my %vm_info
eval{
%vm_info=vm 'info' => 'foo';
%vm_info=vm 'binfo' => 'foo';
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to get settings for the VM... '.$error);
@ -226,10 +231,14 @@ The returned value is a flat hash of key value pairs.
print $vm_info_key.": ".$vm_info{$vm_info_key}."\n";
}
=head2 list
=head3 blist
List available VMs.
The command used is...
cbsd bls display=nodename,jname,jid,vm_ram,vm_curmem,vm_cpus,pcpu,vm_os_type,ip4_addr,status,vnc,path header=0
The returned array is a hash of hashes. The first level hash is the jname.
nodename - The node name that this is set to run on.
@ -260,7 +269,7 @@ This dies upon failure.
my %vm_list;
eval{
%vm_list=vm 'list';
%vm_list=vm 'blist';
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to list the VM... '.$error);
@ -284,10 +293,14 @@ This dies upon failure.
"\n"
}
=head2 nic_list
=head3 bnic_list
List configured NICs.
The command used is as below...
cbsd bhyve-nic-list display=nodename,jname,nic_driver,nic_parent,nic_hwaddr,nic_address,nic_mtu,nic_persistent,nic_ratelimit header=0
This returned data is a array of hashes.
The keys are as below.
@ -315,7 +328,7 @@ This dies upon failure.
my @nics
eval{
@nics=vm nic_list;
@nics=vm 'bnic_list';
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to the NIC list... '.$error);
@ -323,7 +336,7 @@ This dies upon failure.
print Dumper(\@nics);
=head2 pause
=head3 bpause
This pauses a VM in question. The following modes are available. If no
more is specified, audo is used.
@ -334,21 +347,25 @@ more is specified, audo is used.
The command called is as below.
cbsd bpause $vm mode=$mode
cbsd 'bpause' => $vm mode=>$mode
This dies upon failure.
eval{
vm 'pause' => 'foo';
vm 'bpause' => 'foo';
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to pause the VM foo... '.$error);
}
=head2 pci_list
=head3 bpci_list
List configured PCI devices for a VM.
The command used is as below.
cbsd bpcibus mode=list jname=$vm
This returned data is a array of hashes.
The keys are as below.
@ -369,7 +386,7 @@ This dies upon failure.
my @devices
eval{
@devices=vm 'nic_list' => 'foo';
@devices=vm 'bnic_list' => 'foo';
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to the PCI device list... '.$error);
@ -377,24 +394,24 @@ This dies upon failure.
print Dumper(\@devices);
=head2 remove
=head3 bremove
This removes the selected VM and remove the data. This is done via the command...
cbsd bdestroy $vm
cbsd bremove $vm
One argument is taken and that is the name of the VM.
This dies upon failure.
eval{
vm 'remove' => 'foo'
vm 'bremove' => 'foo'
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to remove the VM foo... '.$error);
}
=head2 restart
=head3 brestart
This restarts the selected VM. This is done via the command...
@ -405,13 +422,13 @@ One argument is taken and that is the name of the VM.
This dies upon failure.
eval{
vm 'restart' => 'foo'
vm 'brestart' => 'foo'
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to restart the VM foo... '.$error);
}
=head2 set
=head3 bset
This sets various settings for a VM via the use of...
@ -424,11 +441,11 @@ not consider non-existent variables such as 'foofoo' to be a failure
and silently ignores those.
# set the the VM foo to boot from net with a resolution of 800x600
vm 'set' => 'foo',
vm 'bset' => 'foo',
vm_boot => 'net',
bhyve_vnc_resolution => '800x600';
=head2 start
=head3 bstart
This starts a VM. This is done via the command...
@ -440,14 +457,14 @@ start all VM whose names begin with 'vm', e.g. 'vm1', 'vm2'...
This dies upon failure.
eval{
vm 'start' => 'foo'
vm 'bstart' => 'foo'
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to start the VM foo... '.$error);
}
=head2 stop
=head3 bstop
This stops a VM. This is done via the command below...
@ -465,14 +482,33 @@ The following options are optional.
This dies upon failure.
eval{
vm 'stop' => 'foo',
vm 'bstop' => 'foo',
hard_timeout => 60;
} or do {
my $error = $@ || 'Unknown failure';
warn('Failed to stop the VM foo... '.$error);
}
=head2 vm_os_profiles
=head3 p9shares_list
This lists the configured p9 shares. This is fetched using the command below.
cbsd bhyve-p9shares mode=list header=0 display=jname,p9device,p9path
No arguments are taken.
The returned data is a array of hashes. The hash keys are as below.
vm - Name of the VM the share is for.
device - p9 device name, one word.
path - The shared path.
This will die upon error.
my @shares=vm 'p9shares_list';
print Dumper \@shares;
=head3 vm_os_profiles
Get the VM OS profiles for a specified OS type.
@ -494,7 +530,7 @@ This will die upon failure.
@profiles=vm 'vm_os_profiles' => 'freebsd', cloudinit=>1;
print Dumper @profiles;
=head2 vm_os_profiles_hash
=head3 vm_os_profiles_hash
Get the VM OS profiles for a specified OS type.
@ -517,7 +553,7 @@ This will die upon failure.
my %os_profiles=vm 'vm_os_profiles_hash', cloudinit=>1;
print Dumper %os_profiles;
=head2 vm_os_types
=head3 vm_os_types
Get the VM OS types there are profiles for.

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::create;
package Rex::Virtualization::CBSD::bcreate;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::disk_list;
package Rex::Virtualization::CBSD::bdisk_list;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::info;
package Rex::Virtualization::CBSD::binfo;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::list;
package Rex::Virtualization::CBSD::blist;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::nic_list;
package Rex::Virtualization::CBSD::bnic_list;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::pause;
package Rex::Virtualization::CBSD::bpause;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::pci_list;
package Rex::Virtualization::CBSD::bpci_list;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::remove;
package Rex::Virtualization::CBSD::bremove;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::restart;
package Rex::Virtualization::CBSD::brestart;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::set;
package Rex::Virtualization::CBSD::bset;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::start;
package Rex::Virtualization::CBSD::bstart;
use strict;
use warnings;

View File

@ -2,7 +2,7 @@
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::stop;
package Rex::Virtualization::CBSD::bstop;
use strict;
use warnings;

View File

@ -0,0 +1,51 @@
#
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::p9shares_list;
use strict;
use warnings;
our $VERSION = '0.0.1'; # VERSION
use Rex::Logger;
use Rex::Helper::Run;
use Term::ANSIColor qw(colorstrip);
sub execute {
my ($class) = @_;
my $command = 'cbsd bhyve-p9shares mode=list header=0 display=jname,p9device,p9path';
Rex::Logger::debug( "Getting CBSD p9shares info via... " . $command );
my $returned = i_run( $command, fail_ok => 1 );
# the output is colorized, if there is an error
$returned = colorstrip($returned);
# check for this second as no VM will also exit non-zero
if ( $? != 0 ) {
die( "Error running '" . $command . "'" );
}
my @shares;
my @lines = split( /\n/, $returned );
foreach my $line (@lines) {
my %share;
( $share{vm}, $share{device}, $share{path} ) = split( /\:\ /, $line, 3 );
# make sure we did not get a empty line, which it will return if there is none
if ( ( $share{vm} !~ /^$/ )
|| ( !defined( $share{evice} ) )
|| ( !defined( $share{path} ) ) )
{
push( @shares, \%share );
}
}
return @shares;
}
1;

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::create' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bcreate' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::create $Rex::Virtualization::CBSD::create::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bcreate $Rex::Virtualization::CBSD::bcreate::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::info' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::binfo' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::info $Rex::Virtualization::CBSD::info::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::binfo $Rex::Virtualization::CBSD::binfo::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::list' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::blist' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::list $Rex::Virtualization::CBSD::list::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::blist $Rex::Virtualization::CBSD::blist::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::nic_list' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bnic_list' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::nic_list $Rex::Virtualization::CBSD::nic_list::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bnic_list $Rex::Virtualization::CBSD::bnic_list::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::pause' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bpause' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::pause $Rex::Virtualization::CBSD::pause::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bpause $Rex::Virtualization::CBSD::bpause::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::pci_list' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bpci_list' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::pci_list $Rex::Virtualization::CBSD::pci_list::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bpci_list $Rex::Virtualization::CBSD::bpci_list::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::remove' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bremove' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::remove $Rex::Virtualization::CBSD::remove::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bremove $Rex::Virtualization::CBSD::bremove::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::restart' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::brestart' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::restart $Rex::Virtualization::CBSD::restart::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::brestart $Rex::Virtualization::CBSD::brestart::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::set' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bset' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::set $Rex::Virtualization::CBSD::set::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bset $Rex::Virtualization::CBSD::bset::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::start' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bstart' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::start $Rex::Virtualization::CBSD::start::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bstart $Rex::Virtualization::CBSD::bstart::VERSION, Perl $], $^X" );

View File

@ -7,7 +7,7 @@ use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::stop' ) || print "Bail out!\n";
use_ok( 'Rex::Virtualization::CBSD::bstop' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::stop $Rex::Virtualization::CBSD::stop::VERSION, Perl $], $^X" );
diag( "Testing Rex::Virtualization::CBSD::bstop $Rex::Virtualization::CBSD::bstop::VERSION, Perl $], $^X" );

View File

@ -0,0 +1,13 @@
#!perl
use 5.006;
use strict;
use warnings;
use Test::More;
plan tests => 1;
BEGIN {
use_ok( 'Rex::Virtualization::CBSD::p9shares_list' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::p9shares_list $Rex::Virtualization::CBSD::p9shares_list::VERSION, Perl $], $^X" );