From 78ce90aa8d18c90dceec4ed756a72506cc524caf Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 6 Oct 2020 11:54:18 +0200 Subject: [PATCH] Ref #2220 --- apps/automation/ansible/tower/custom/api.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/automation/ansible/tower/custom/api.pm b/apps/automation/ansible/tower/custom/api.pm index 665e5b749..312525a46 100644 --- a/apps/automation/ansible/tower/custom/api.pm +++ b/apps/automation/ansible/tower/custom/api.pm @@ -167,6 +167,7 @@ sub request_api { push @$results, @{$decoded->{results}}; last if (!defined($decoded->{next})); + last if if (defined($options{nonext}) && $options{nonext} == 1); $page++; } @@ -204,7 +205,10 @@ sub tower_list_schedules { my $schedules = $self->request_api(endpoint => '/schedules/'); if (defined($options{add_job_status})) { for (my $i = 0; $i < scalar(@$schedules); $i++) { - my $job = $self->request_api(force_endpoint => '/schedules/' . $schedules->[$i]->{id} . '/jobs/?order_by=-id&page_size=1'); + my $job = $self->request_api( + force_endpoint => '/schedules/' . $schedules->[$i]->{id} . '/jobs/?order_by=-id&page_size=1', + nonext => 1 + ); $schedules->[$i]->{last_job} = $job->[0]; } }