WIP: Omnishell error xml if YAML::Tiny not installed on agent
This commit is contained in:
parent
f845cc9478
commit
06442fa6e3
|
@ -556,30 +556,38 @@ BEGIN {
|
||||||
sub runCommand {
|
sub runCommand {
|
||||||
my ($self, $ref, $output_mode) = @_;
|
my ($self, $ref, $output_mode) = @_;
|
||||||
|
|
||||||
|
my $result;
|
||||||
if($self->load_libraries()) {
|
if($self->load_libraries()) {
|
||||||
# Functionality possible.
|
# Functionality possible.
|
||||||
my $command = $self->{'commands'}->{$ref};
|
my $command = $self->{'commands'}->{$ref};
|
||||||
my $result = $self->evaluate_command($ref);
|
$result = $self->evaluate_command($ref);
|
||||||
if (ref($result) eq "HASH") {
|
} else {
|
||||||
# Process command result.
|
$result = {
|
||||||
if (defined($output_mode) && $output_mode eq 'xml') {
|
'stderr' => 'Cannot use commands without YAML dependency, please install it.',
|
||||||
my $output = '';
|
'name' => 'YAML::Tiny',
|
||||||
$output .= "<cmd_report>\n";
|
'error_level' => 2,
|
||||||
$output .= " <cmd_response>\n";
|
};
|
||||||
$output .= " <cmd_name><![CDATA[".$result->{'name'}."]]></cmd_name>\n";
|
}
|
||||||
$output .= " <cmd_key><![CDATA[".$ref."]]></cmd_key>\n";
|
|
||||||
$output .= " <cmd_errorlevel><![CDATA[".$result->{'error_level'}."]]></cmd_errorlevel>\n";
|
|
||||||
$output .= " <cmd_stdout><![CDATA[".$result->{'stdout'}."]]></cmd_stdout>\n";
|
|
||||||
$output .= " <cmd_stderr><![CDATA[".$result->{'stderr'}."]]></cmd_stderr>\n";
|
|
||||||
$output .= " </cmd_response>\n";
|
|
||||||
$output .= "</cmd_report>\n";
|
|
||||||
|
|
||||||
return $output;
|
if (ref($result) eq "HASH") {
|
||||||
}
|
# Process command result.
|
||||||
return $result;
|
if (defined($output_mode) && $output_mode eq 'xml') {
|
||||||
} else {
|
my $output = '';
|
||||||
$self->set_last_error('Failed to process ['.$ref.']: '.$result);
|
$output .= "<cmd_report>\n";
|
||||||
|
$output .= " <cmd_response>\n";
|
||||||
|
$output .= " <cmd_name><![CDATA[".$result->{'name'}."]]></cmd_name>\n";
|
||||||
|
$output .= " <cmd_key><![CDATA[".$ref."]]></cmd_key>\n";
|
||||||
|
$output .= " <cmd_errorlevel><![CDATA[".$result->{'error_level'}."]]></cmd_errorlevel>\n";
|
||||||
|
$output .= " <cmd_stdout><![CDATA[".$result->{'stdout'}."]]></cmd_stdout>\n";
|
||||||
|
$output .= " <cmd_stderr><![CDATA[".$result->{'stderr'}."]]></cmd_stderr>\n";
|
||||||
|
$output .= " </cmd_response>\n";
|
||||||
|
$output .= "</cmd_report>\n";
|
||||||
|
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
$self->set_last_error('Failed to process ['.$ref.']: '.$result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
|
|
Loading…
Reference in New Issue