add restart
This commit is contained in:
parent
f185724fa6
commit
5ad1d298ee
|
@ -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;
|
|
@ -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" );
|
Loading…
Reference in New Issue