diff --git a/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/restart.pm b/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/restart.pm new file mode 100644 index 0000000..5370f3b --- /dev/null +++ b/Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/restart.pm @@ -0,0 +1,39 @@ +# +# (c) Zane C. Bowers-Hadley +# + +package Rex::Virtualization::CBSD::restart; + +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 start via cbsd brebstart ".$name); + + my $returned=i_run ('cbsd brestart '.$name , fail_ok => 1); + # the output is colorized + $returned=colorstrip($returned); + # check for failures caused by it not existing + if ( $returned =~ /^No\ such/ ){ + die('"'.$name.'" does not exist'); + } + if ( $? != 0 ) { + die("Error running 'cbsd brestart ".$name."'"); + } + + return 1; +} + +1; diff --git a/Rex-Virtualization-CBSD/t/06-load.t b/Rex-Virtualization-CBSD/t/06-load.t new file mode 100644 index 0000000..7c6a214 --- /dev/null +++ b/Rex-Virtualization-CBSD/t/06-load.t @@ -0,0 +1,13 @@ +#!perl +use 5.006; +use strict; +use warnings; +use Test::More; + +plan tests => 1; + +BEGIN { + use_ok( 'Rex::Virtualization::CBSD::restart' ) || print "Bail out!\n"; +} + +diag( "Testing Rex::Virtualization::CBSD::restart $Rex::Virtualization::CBSD::restart::VERSION, Perl $], $^X" );