1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-22 05:53:09 +00:00
os-autoinst-distri-fedora/bis.pl
Lukas Ruzicka 0b6c451b3a Rewrite the CLI parsing
Now, it is possible to use named arguments for $architecture (-a),
$variant (-t) and $videomode (-m). When $architecture and $videomode
are omitted, x86_64 and full video mode are considered.
2023-09-19 10:38:40 +02:00

75 lines
1.7 KiB
Perl
Executable File

#!/usr/bin/perl
use warnings;
use strict;
use REST::Client;
use JSON::XS;
use Data::Dumper;
my %cli = @ARGV;
my $variant = $cli{-t};
my ($architecture, $videomode);
# When no architecture is given, fall back to x86_64.
unless ($cli{-a}) {
$architecture = "x86_64";
}
else {
$architecture = $cli{-a};
}
# When BASIC is not defined, fall back to NON-BASIC
unless ($cli{-m}) {
$videomode = "full";
}
else {
$videomode = $cli{-m};
}
my $netinst = "";
$variant = ucfirst($variant);
# If $variant is Netinst, then we will correct
# it to Server to get the correct links and then
# use the $netinst later to specify.
if ($variant eq "Netinst") {
$variant = "Server";
$netinst = "Netinst";
}
elsif ($variant eq "Kde") {
$variant = "KDE";
}
print("I am starting the tests for $variant $netinst.\n");
print("Trying to download the iso links.\n");
# Download the JSON file.
my $client = REST::Client->new();
$client->GET('https://openqa.fedoraproject.org/nightlies.json') or die("The iso links could not be downloaded. Exiting.");
print("Iso links downloaded correctly.\n");
my $json = decode_json($client->responseContent());
my $links = [];
# Push the link to $links when a match is found.
for my $iso (@$json) {
if (($iso->{arch} eq $architecture) and (lc($iso->{subvariant}) eq lc($variant))) {
push(@$links, "$iso->{url}");
}
}
my $isolink = $links->[-1];
if ($variant eq "Server") {
$isolink = $links->[-2];
}
print("Sending the API command to openQA: \n");
my $command = "openqa-cli api -X POST isos DISTRI=fedora VERSION=Rawhide FLAVOR=PiKVM ARCH=$architecture BUILD=Bare_install_$variant DOWNLOAD=$isolink SUBVARIANT=$variant VIDEOMODE=$videomode";
print(" $command\n");
exec($command);