From aa7167572f766cae54c023ee18ef9b35d3afa1d2 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Tue, 12 Oct 2021 08:35:24 -0500 Subject: [PATCH] add cbsd_base_dir and misc doc cleanup --- .../lib/Rex/Virtualization/CBSD.pm | 28 +++++++++++----- .../Rex/Virtualization/CBSD/cbsd_base_dir.pm | 33 +++++++++++++++++++ 2 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/cbsd_base_dir.pm diff --git a/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD.pm b/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD.pm index 3c35469..3dbf773 100644 --- a/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD.pm +++ b/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD.pm @@ -42,6 +42,16 @@ sub new { =head1 Methods +=head2 cbsd_base_dir + +This returns the CBSD base dir that the install is stored in. + +No arguments are taken. + +This will die upon error. + + my $cbsd_base_dir=vm 'cbsd_base_dir' + =head2 disk_list This returns a list of disks setup for use with Bhyve in CBSD via parsing @@ -71,7 +81,7 @@ This dies upon failure. my @disks eval{ - @disks=vm disk_list; + @disks=vm 'disk_list'; } or do { my $error = $@ || 'Unknown failure'; warn('Failed to the disk list... '.$error); @@ -90,7 +100,7 @@ The returned value is a flat hash of key value pairs. my %vm_info eval{ - %vm_info=vm info => 'foo'; + %vm_info=vm 'info' => 'foo'; } or do { my $error = $@ || 'Unknown failure'; warn('Failed to get settings for the VM... '.$error); @@ -134,7 +144,7 @@ This dies upon failure. my %vm_list; eval{ - %vm_list=vm list; + %vm_list=vm 'list'; } or do { my $error = $@ || 'Unknown failure'; warn('Failed to list the VM... '.$error); @@ -212,7 +222,7 @@ The command called is as below. This dies upon failure. eval{ - vm pause => 'foo'; + vm 'pause' => 'foo'; } or do { my $error = $@ || 'Unknown failure'; warn('Failed to pause the VM foo... '.$error); @@ -242,7 +252,7 @@ This dies upon failure. my @devices eval{ - @devices=vm nic_list => 'foo'; + @devices=vm 'nic_list' => 'foo'; } or do { my $error = $@ || 'Unknown failure'; warn('Failed to the PCI device list... '.$error); @@ -261,7 +271,7 @@ One argument is taken and that is the name of the VM. This dies upon failure. eval{ - vm remove => 'foo' + vm 'remove' => 'foo' } or do { my $error = $@ || 'Unknown failure'; warn('Failed to remove the VM foo... '.$error); @@ -278,7 +288,7 @@ One argument is taken and that is the name of the VM. This dies upon failure. eval{ - vm restart => 'foo' + vm 'restart' => 'foo' } or do { my $error = $@ || 'Unknown failure'; warn('Failed to restart the VM foo... '.$error); @@ -296,7 +306,7 @@ start all VM whose names begin with 'vm', e.g. 'vm1', 'vm2'... This dies upon failure. eval{ - vm start => 'foo' + vm 'start' => 'foo' } or do { my $error = $@ || 'Unknown failure'; warn('Failed to start the VM foo... '.$error); @@ -321,7 +331,7 @@ The following options are optional. This dies upon failure. eval{ - vm stop => 'foo', + vm 'stop' => 'foo', hard_timeout => 60; } or do { my $error = $@ || 'Unknown failure'; diff --git a/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/cbsd_base_dir.pm b/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/cbsd_base_dir.pm new file mode 100644 index 0000000..ceed74e --- /dev/null +++ b/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/cbsd_base_dir.pm @@ -0,0 +1,33 @@ +# +# (c) Zane C. Bowers-Hadley +# + +package Rex::Virtualization::CBSD::cbsd_base_dir; + +use strict; +use warnings; + +our $VERSION = '0.0.1'; # VERSION + +use Rex::Logger; +use Rex::Helper::Run; +use Term::ANSIColor qw(colorstrip); +use Rex::Commands::User; + +sub execute { + my ($class) = @_; + + Rex::Logger::debug("Geting the CBSD base dir "); + + my %cbsd; + eval{ + %cbsd= get_user('cbsd'); + } or do{ + my $error = $@ || 'Unknown failure'; + die ( "get_user('cbsd') died with... ".$error ); + }; + + return $cbsd{home}; +} + +1;