lib/sles4sap/console_redirection.pm

SYNOPSIS

Library that enables console redirection and file transfers from worker based VM to another host. Can be used for cases where worker VM is not the target host for API calls and command execution, but serves only as a jumphost.

handle_login_prompt

handle_login_prompt();

Detects if login prompt appears and types the password. In case of ssh keys being in place and command prompt appears, the function does not type anything.

redirection_init

redirection_init( [, ssh_user=>$ssh_user, destination_ip=>$destination_ip, ssh_tunnel_port=>$ssh_tunnel_port]);

ssh_user: SSH login user for destination_ip - default value is defined by OpenQA parameter REDIRECT_DESTINATION_USER

destination_ip: Destination host IP - default value is defined by OpenQA parameter REDIRECT_DESTINATION_IP

ssh_tunnel_port: Port on the destination_ip to forward ssh traffic to. Default: 22022

Does initial setup for console redirection which includes:

remote_port_forward

remote_port_forward(destination_port=>$destination_port, destination_ip=>$destination_ip
    [, source_port=>$source_port, monitor_port=>$monitor_port, source_ip=>$source_ip]);

source_ip: Source IP address or hostname to forward incoming traffic from. Default: REDIRECT_DESTINATION_IP

destination_ip: Destination IP or hostname where will the traffic be forwarded. Can be localhost as well.

monitor_port: Port for autossh to monitor tunnel status. Needs to be unique for each autossh instance. Default: off

source_port: source_ip port to forward traffic from. Default: source_port=destination_port

destination_port: port which source_port traffic should be forwarded to.

ssh_user: Login user for source_ip host.

Forwards traffic from source_ip:source_port to destination_ip:destination_port. For example: It allows Cloud based SUT uploading logs directly to openQA instance without being able to resolve it directly. Default finction behavior is:

- redirecting same port

- not using autossh monitoring port

set_serial_term_prompt

set_serial_term_prompt();

Set expected serial prompt according to user which is currently active. This changes global setting $testapi::distri->{serial_term_prompt} which is important for calls like wait_for_serial.

connect_target_to_serial

connect_target_to_serial( [, ssh_user=>ssh_user, destination_ip=>$destination_ip]);

ssh_user: SSH login user for destination_ip - default value is defined by OpenQA parameter REDIRECT_DESTINATION_USER

destination_ip: Destination host IP - default value is defined by OpenQA parameter REDIRECT_DESTINATION_IP

Establishes ssh connection to destination host and redirects serial output to serial console on worker VM. This allows OpenQA access to command return codes and output for evaluation by standard API call.

disconnect_target_from_serial

disconnect_target_from_serial( [, base_vm_machine_id=$base_vm_machine_id]);

base_vm_machine_id: ID of the base VM before redirection. Default is BASE_VM_ID value set by redirect_init()

Disconnects target from serial console by typing 'exit' command until host machine ID matches ID of the worker VM.

check_serial_redirection

check_serial_redirection( [, base_vm_machine_id=$base_vm_machine_id]);

base_vm_machine_id: ID of the base VM before redirection. Default is BASE_VM_ID value set by redirect_init()

Compares current machine-id to the worker VM ID either defined by BASE_VM_ID variable or positional argument. Machine ID is used instead of IP addr since cloud VM IP might not be visible from the inside (for example via 'ip a')