| 1 | # | ||||||||||
| 2 | # (c) Zane C. Bowers-Hadley <vvelox@vvelox.net> | ||||||||||
| 3 | # | ||||||||||
| 4 | |||||||||||
| 5 | package Rex::Virtualization::CBSD::brestart; | ||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | our $VERSION = '0.0.1'; # VERSION | |||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use Rex::Logger; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Rex::Helper::Run; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use Term::ANSIColor qw(colorstrip); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 17 | 0 | my ( $class, $name, %opt ) = @_; | |||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | if ( !defined($name) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | die('No VM name defined'); | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 0 | Rex::Logger::debug( "CBSD VM start via cbsd brebstart " . $name ); | |||||||||
| 24 | |||||||||||
| 25 | 0 | my $returned = i_run( 'cbsd brestart ' . $name, fail_ok => 1 ); | |||||||||
| 26 | |||||||||||
| 27 | # the output is colorized | ||||||||||
| 28 | 0 | $returned = colorstrip($returned); | |||||||||
| 29 | |||||||||||
| 30 | # check for failures caused by it not existing | ||||||||||
| 31 | 0 | ▶ | if ( $returned =~ /^No\ such/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | die( '"' . $name . '" does not exist' ); | |||||||||
| 33 | } | ||||||||||
| 34 | 0 | ▶ | if ( $? != 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | die( "Error running 'cbsd brestart " . $name . "'" ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | return 1; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||