more work

This commit is contained in:
Zane C. B-H 2020-04-13 23:53:48 -05:00
parent c4810cb11a
commit c1ac43627a
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,41 @@
#
# (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."'");
}
return 1;
}
1;

View File

@ -33,6 +33,7 @@ sub execute {
# the output is colorized
$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');
}