use Gruntmaster::Daemon::Constants qw/ERR/;
use Gruntmaster::Daemon::Format qw/prepare_files stopvms/;
+use Gruntmaster::SendResults qw/send_results_request/;
use File::Slurp qw/read_file/;
use File::Temp qw/tempdir/;
$meta->{errors} = $errors;
get_logger->info('Job result: ' . $meta->{result_text});
+ send_results_request($meta->{job_id}, $meta->{result}, $meta->{result_text});
}
sub process_job {
format => $pb->{verformat},
content => $pb->{versource},
} if $pb->{verformat};
+ $meta->{job_id} = $job->{id};
process $meta;
--- /dev/null
+package Gruntmaster::SendResults;
+
+use 5.014000;
+use strict;
+use warnings;
+use parent qw/Exporter/;
+
+use HTTP::Request;
+use JSON qw/encode_json decode_json/;
+use LWP::UserAgent;
+
+our $VERSION = '5999.000_005';
+our @EXPORT_OK = qw/send_results_request/;
+
+sub send_results_request {
+ my ($job_id, $result, $result_text) = @_;
+
+ my $url = $ENV{REMOTE_ADDRESS};
+ my $header = [
+ 'Content-Type' => 'application/json'
+ ];
+ my $data = {
+ gm_id => $job_id,
+ result => $result,
+ result_text => $result_text
+ };
+
+ my $encoded_data = encode_json($data);
+ my $request = HTTP::Request->new(POST => $url, $header, $encoded_data);
+ my $ua = LWP::UserAgent->new();
+ my $response = $ua->request($request);
+
+ return $response;
+}
+
+1;