lib/YuiRestClient.pm

NAME

YuiRestClient - Perl module to interact with YaST applications via libyui-rest-api

COPYRIGHT

Copyright 2021 SUSE LLC

SPDX-License-Identifier: FSFAP

AUTHORS

QE Yam <qe-yam at suse de>

SYNOPSIS

my $app  = YuiRestClient::get_app(installation => 1, timeout => 60, interval => 1);

DESCRIPTION

Overview

See documentation of the libyui-rest-api project. for more details about server side implementation.

Class and object methods

Main interface methods

get_app(%args) - main routine to create app object. Parameters are:

{timeout} - Timeout for server communication, defaults to 30.
{interval} - Retry interval for communication, defaults to 1.
{installation} - boolean that triggers code to determine IP addresses on various backends.

get_host() will call init_port() and init_host() from the low level interface functions (see below) and then create an app object that will be used during the session.

get_host(%args) - returns name or IP of the REST server.

The %args is a boolean $installation (see parameters of get_app() above.)

get_port() - returns port number for the rest server.

get_timeout() - returns the current timeout.

init_logger - Initializes logger instance.

The log path is 'ulogs/yui-log.txt'

set_host($host) - change REST server host to new address or IP.

set_port($port) - change REST server port number.

set_interval($interval) - change retry interval.

set_timeout($timeout) - change timeout value.

Low level interface methods

init_port() - Determine port for the REST server,

The port number starts at YUI_START_PORT, if VNC is present then ths VNC port number will be added, otherwise the function take a random numer between 0..1000. This function will also set the environment variable. YUI_PORT.

init_host() - Initialize REST server and determine its host address.

This method checks what backend is used for the system under test and adjusts the host address for the REST server accordingly. The following backends are checked:

QEMU: Use 'localhost'.
PowerVM or IPMI: Use what is defined in SUT_IP.
S390 Virtual Machine: Use what is defined in VIRSH_GUEST.
s390x: Extract IP address from output of "ip addr" command.
HyperV Hypervisor: Extract IP address from PowerShell command.
Xen: Extract IP address from output of "ip addr" command.

Helper methods

is_libyui_rest_api() - Returns environment variable YUI_REST_API.

set_libyui_backend_vars() - Sets NICTYPE_USER_OPTIONS and EXTRABOOTPARAMS.

get_yui_params_string($yuiport) - creates String for EXTRABOOTPARAMS. This will return "YUI_HTTP_PORT=$yuiport YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1" so that this string can be appended to the boot parameters.

ENVIRONMENT

BACKEND - Defines which Backend is used. host_init() tests for 's390x'.

EXTRABOOTPARAMS - Additional boot parameters for the bootloader. YuiRestClient will add " extend=libyui-rest-api YUI_HHTP_PORT=$yuiport YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1" to this variable.

NICTYPE_USER_OPTIONS - options for the virtual SUT network configuration. On QEMU backends this variable will get "hostfwd=tcp::$yuiport-:$yuiport" appended.

S390_ZKVM - Defines that the SUT is on a S390 Virtual Machine.

SUT_IP - IP address of the system under test on PowerVM or IPMI backends.

VIRSH_GUEST - defines the host address for S390 Virtual Machines.

VIRSH_VMM_FAMILY - defines the Hypervisor for virtual shells. host_init() tests for 'xen'.

VNC - Port number for VNC connection.

YUI_HTTP_PORT - Port number that the REST server should use for listening.

YUI_HTTP_REMOTE - Boolean, if true, then remote connections to the REST server are allowed.

YUI_LOG_LEVEL - Log lever lor init_logger(), defaults to 'debug'.

YUI_PORT - Port for REST server, caclulated by init_port().

YUI_REST_API - Boolean that defines if the REST API is present.

YUI_REUSE_PORT - Boolean, if 1 then the socket can be reused by other processes.

YUI_SERVER The host address for the REST server.

YUI_START_PORT - Base value for calculating REST server port number, defaults to 39000.