add restart

This commit is contained in:
Zane C. B-H 2020-04-14 02:31:28 -05:00
parent f185724fa6
commit 5ad1d298ee
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,39 @@
#
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
#
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;

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