get stop working
This commit is contained in:
parent
8ea0cd5d66
commit
ef5f4f6bae
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
|
||||
#
|
||||
|
||||
package Rex::Virtualization::CBSD::stop;
|
||||
|
||||
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 stop via cbsd bstop ".$name);
|
||||
|
||||
my $returned=i_run ('cbsd bstop '.$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');
|
||||
}
|
||||
# test after no such as that will also exit non-zero
|
||||
if ( $? != 0 ) {
|
||||
die("Error running 'cbsd bstop ".$name."'");
|
||||
}
|
||||
|
||||
# this is warning message will be thrown if stop fails.... does not return 0 though
|
||||
if ( $returned =~ /unable\ to\ determine\ bhyve\ pid/ ){
|
||||
die("Either already stopped or other issue determining bhyve PID for '".$name."'");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue