Browse Source

add restart

master
Zane C. B-H 6 months ago
parent
commit
5ad1d298ee
2 changed files with 52 additions and 0 deletions
  1. +39
    -0
      Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/restart.pm
  2. +13
    -0
      Rex-Virtualization-CBSD/t/06-load.t

+ 39
- 0
Rex-Virtualization-CBSD/lib/Rex/Virtualization/CBSD/restart.pm 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;

+ 13
- 0
Rex-Virtualization-CBSD/t/06-load.t 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" );

Loading…
Cancel
Save