Compare commits

...

4 Commits

Author SHA1 Message Date
Zane C. B-H 8ea0cd5d66 info tested and works 2020-04-14 00:06:03 -05:00
Zane C. B-H c1ac43627a more work 2020-04-13 23:53:48 -05:00
Zane C. B-H c4810cb11a add some basic load tests 2020-04-13 23:17:00 -05:00
Zane C. B-H adcd3c7a6c variable name corrections 2020-04-13 23:15:59 -05:00
4 changed files with 76 additions and 2 deletions

View File

@ -0,0 +1,47 @@
#
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
package Rex::Virtualization::CBSD::info;
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, $name ) = @_;
if (!defined( $name ) ){
die('No VM name defined');
}
Rex::Logger::debug("CBSD VM info via cbsd bget jname=".$name);
#
my $returned=i_run ('cbsd bget jname='.$name , fail_ok => 1);
# the output is colorized, if there is an error
$returned=colorstrip($returned);
if ( $returned =~ /^No\ such/ ){
die('"'.$name.'" does not exist');
}
# check for this second as no VM will also exit non-zero
if ( $? != 0 ) {
die("Error running 'cbsd bget jname=".$name."'");
}
my %info;
my @lines=split(/\n/, $returned);
foreach my $line (@lines) {
my ( $vname, $vval )=split(/\:\ /, $line);
$info{$vname}=$vval;
}
return \%info;
}
1;

View File

@ -16,7 +16,7 @@ use Term::ANSIColor qw(colorstrip);
sub execute {
my ( $class, $name ) = @_;
if (!defined( $jname ) ){
if (!defined( $name ) ){
die('No VM name defined');
}
@ -31,8 +31,9 @@ sub execute {
}
# the output is colorized
$returned=colorstrip($found);
$returned=colorstrip($returned);
# as of CBSD 12.1.7, it won't exit non-zero for this, so check here
if ( $returned =~ /^No\ such/ ){
die('"'.$name.'" does not exist');
}

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::list' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::list $Rex::Virtualization::CBSD::list::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::remove' ) || print "Bail out!\n";
}
diag( "Testing Rex::Virtualization::CBSD::remove $Rex::Virtualization::CBSD::remove::VERSION, Perl $], $^X" );