lib/publiccloud/instance.pm

run_ssh_command

run_ssh_command(cmd => 'command'[, timeout => 90][, ssh_opts =>'..'][, username => 'XXX'][, no_quote => 0][, rc_only => 0]);

Runs a command cmd via ssh in the given VM. Retrieves the output. If the command retrieves not zero, a exception is thrown.. Timeout can be set by timeout or 90 sec by default. <proceed_on_failure=1>> allows to proceed with validation when cmd is failing (return non-zero exit code) By default, the command is passed in single quotes to SSH. To avoid quoting use <no_quote=1>>. With <ssh_opts='...'>> you can overwrite all default ops which are in <$instance-ssh_opts>>. Use argument username to specify a different username then <$instance-username()>>. Use argument rc_only to only check for the return code of the command.

retry_ssh_command

ssh_script_retry(command[, retry => 3][, delay => 10][, timeout => 90][, ssh_opts =>'..'][, username => 'XXX'][, no_quote => 0]);

Run a command via ssh in the given PC instance until it succeeds or the given number of retries is exhausted and an exception is thrown. Timeout can be set by timeout or 90 sec by default. By default, the command is passed in single quotes to SSH. To avoid quoting use <no_quote=1>>. With <ssh_opts='...'>> you can overwrite all default ops which are in <$instance-ssh_opts>>. Use argument username to specify a different username then <$instance-username()>>.

This function is deprecated. Please use ssh_script_retry instead.

ssh_script_run

ssh_script_run($cmd [, timeout => $timeout] [, fail_message => $fail_message] [,quiet => $quiet] [,ssh_opts => $ssh_opts] [,username => $username])

Runs a command cmd via ssh on the publiccloud instance and returns the return code.

ssh_assert_script_run

ssh_assert_script_run($cmd [, timeout => $timeout] [, fail_message => $fail_message] [,quiet => $quiet] [,ssh_opts => $ssh_opts] [,username => $username])

Runs a command cmd via ssh on the publiccloud instance and die, unless it returns zero.

ssh_script_output

ssh_script_output($script [, $wait, type_command => 1, proceed_on_failure => 1] [,quiet => $quiet] [,ssh_opts => $ssh_opts] [,username => $username])

Executing script inside SUT with bash -eo and directs stdout (but not stderr!) to the serial console and returns the output if the script exits with 0. Otherwise the test is set to failed.

ssh_script_retry

ssh_script_retry($cmd, [expect => $expect], [retry => $retry], [delay => $delay], [timeout => $timeout], [die => $die] [,ssh_opts => $ssh_opts] [,username => $username])

Repeat command until expected result or timeout.

scp

scp($from, $to, timeout => 90);

Use scp to copy a file from or to this instance. A url starting with remote: is replaced with the IP from this instance. E.g. a call to copy the file /var/log/cloudregister to /tmp looks like: <<$instance-scp('remote:/var/log/cloudregister', '/tmp');>>>

upload_log

upload_log($filename);

Upload a file from this instance to openqa using upload_logs(). If the file doesn't exists on the instance, no error is thrown.

wait_for_guestregister

wait_for_guestregister([timeout => 300]);

Run command systemctl is-active guestregister on the instance in a loop and wait till guestregister is ready. If guestregister finish with state failed, a soft-failure will be recorded. If guestregister will not finish within timeout seconds, job dies. In case of BYOS images we checking that service is inactive and quit Returns the time needed to wait for the guestregister to complete.

wait_for_ssh

wait_for_ssh([timeout => 600] [, proceed_on_failure => 0])

Check if the SSH port of the instance is reachable and open.

softreboot

($shutdown_time, $bootup_time) = softreboot([timeout => 600]);

Does a softreboot of the instance by running the command shutdown -r. Return an array of two values, first one is the time till the instance isn't reachable anymore. The second one is the estimated bootup time.

stop

stop();

Stop the instance using the CSP api calls.

start

start([timeout => ?]);

Start the instance and check SSH connectivity. Return the number of seconds till the SSH port was available.

get_state

get_state();

Get the status of the instance using the CSP api calls.

network_speed_test

network_speed_test();

Test the network speed.