Compare commits
4 Commits
191079c882
...
8ea0cd5d66
Author | SHA1 | Date |
---|---|---|
Zane C. B-H | 8ea0cd5d66 | |
Zane C. B-H | c1ac43627a | |
Zane C. B-H | c4810cb11a | |
Zane C. B-H | adcd3c7a6c |
|
@ -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;
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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" );
|
|
@ -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" );
|
Loading…
Reference in New Issue