line |
stmt |
code |
1
|
|
# Copyright 2018-2020 SUSE LLC |
2
|
|
# SPDX-License-Identifier: GPL-2.0-or-later |
3
|
|
|
4
|
|
use Mojo::Base 'backend::virt', -signatures; |
5
|
2
|
|
|
2
|
|
|
2
|
|
6
|
|
# supporting the minimal command set of NovaLink through a ssh tunnel |
7
|
|
|
8
|
|
my $self = $class->SUPER::new; |
9
|
3
|
$bmwqemu::vars{WORKER_HOSTNAME} // die 'Need variable \'WORKER_HOSTNAME\''; |
|
3
|
|
|
3
|
|
10
|
3
|
return $self; |
11
|
3
|
} |
12
|
3
|
|
13
|
|
# only define the novalink console - we leave the actual |
14
|
|
# poweron to the test |
15
|
|
$self->truncate_serial_file; |
16
|
|
$bmwqemu::vars{NOVALINK_HOSTNAME} // die 'Need variable \'NOVALINK_HOSTNAME\''; |
17
|
1
|
$bmwqemu::vars{NOVALINK_PASSWORD} // die 'Need variable \'NOVALINK_PASSWORD\''; |
|
1
|
|
|
1
|
|
18
|
1
|
my $ssh = $testapi::distri->add_console( |
19
|
1
|
'novalink-ssh', |
20
|
1
|
'ssh-xterm', |
21
|
|
{ |
22
|
|
hostname => $bmwqemu::vars{NOVALINK_HOSTNAME}, |
23
|
|
password => $bmwqemu::vars{NOVALINK_PASSWORD}, |
24
|
|
username => $bmwqemu::vars{NOVALINK_USERNAME} // 'root', |
25
|
|
persistent => 1, |
26
|
|
log => $bmwqemu::vars{HARDWARE_CONSOLE_LOG} // 0}); |
27
|
|
$ssh->backend($self); |
28
|
|
|
29
|
1
|
return {}; |
30
|
1
|
} |
31
|
|
|
32
|
1
|
$self->stop_serial_grab; |
33
|
|
$self->deactivate_console({testapi_console => 'novalink-ssh'}); |
34
|
|
return {}; |
35
|
1
|
} |
|
1
|
|
|
1
|
|
36
|
1
|
|
37
|
1
|
my $username = $bmwqemu::vars{NOVALINK_USERNAME} // 'root'; |
38
|
1
|
|
39
|
|
return $self->run_ssh_cmd($cmd, username => $username, password => $password, hostname => $hostname, keep_open => 0); |
40
|
|
} |
41
|
7
|
|
|
7
|
|
|
7
|
|
|
7
|
|
|
7
|
|
|
7
|
|
42
|
7
|
|
43
|
|
my $lpar_id = $bmwqemu::vars{NOVALINK_LPAR_ID} // die 'Need variable \'NOVALINK_LPAR_ID\''; |
44
|
7
|
return $self->run_cmd("! pvmctl lpar list -i id=${lpar_id} | grep 'not a'"); |
45
|
|
} |
46
|
|
|
47
|
1
|
return $self->check_ssh_serial($fh) || $self->SUPER::check_socket($fh, $write); |
|
1
|
|
48
|
|
} |
49
|
1
|
|
|
1
|
|
|
1
|
|
50
|
1
|
$self->stop_ssh_serial; |
51
|
1
|
return; |
52
|
|
} |
53
|
|
|
54
|
1
|
# parameters: on, off, reset |
|
1
|
|
|
1
|
|
|
1
|
|
|
1
|
|
55
|
1
|
my $action = $args->{action}; |
56
|
|
my $lpar_id = $bmwqemu::vars{NOVALINK_LPAR_ID} // die 'Need variable \'NOVALINK_LPAR_ID\''; |
57
|
|
|
58
|
2
|
my %cmds = ( |
|
2
|
|
|
2
|
|
59
|
2
|
on => "pvmctl lpar power-on -i id=${lpar_id} --bootmode norm", |
60
|
2
|
off => "pvmctl lpar power-off -i id=${lpar_id} --hard", |
61
|
|
reset => "pvmctl lpar restart -i id=${lpar_id}"); |
62
|
|
$self->run_cmd($cmds{$action}) if (exists($cmds{$action})) || die "Unknown power action ${action}"; |
63
|
|
} |
64
|
3
|
|
|
3
|
|
|
3
|
|
|
3
|
|
65
|
3
|
1; |