6 |
use warnings; |
use warnings; |
7 |
use SOAP::Lite; |
use SOAP::Lite; |
8 |
#use SOAP::Lite +trace => 'all'; |
#use SOAP::Lite +trace => 'all'; |
9 |
|
use Data::Dump qw/dump/; |
10 |
|
|
11 |
|
use lib 'lib'; |
12 |
|
|
13 |
my $amt_host = $ENV{'AMT_HOST'}; |
my $amt_host = $ENV{'AMT_HOST'}; |
14 |
my $amt_port = "16992"; |
my $amt_port = "16992"; |
23 |
# data |
# data |
24 |
|
|
25 |
my @ps = ("S0", "S1", "S2", "S3", "S4", "S5 (soft-off)", "S4/S5", "Off"); |
my @ps = ("S0", "S1", "S2", "S3", "S4", "S5 (soft-off)", "S4/S5", "Off"); |
|
my %rcc = ( |
|
|
"reset" => "16", |
|
|
"powerup" => "17", |
|
|
"powerdown" => "18", |
|
|
"powercycle" => "19", |
|
|
); |
|
|
|
|
|
my %rccs = ( |
|
|
"nop" => "0", |
|
|
"pxe" => "1", |
|
|
"hd" => "2", |
|
|
"hdsafe" => "3", |
|
|
"diag" => "4", |
|
|
"cd" => "5", |
|
|
); |
|
|
my %rccs_oem = ( |
|
|
"bios" => 0xc1, |
|
|
); |
|
26 |
|
|
27 |
# incomplete list |
# incomplete list |
28 |
my %pt_status = ( |
my %pt_status = ( |
79 |
return $main::amt_user => $main::amt_pass; |
return $main::amt_user => $main::amt_pass; |
80 |
} |
} |
81 |
|
|
82 |
sub soap_init() { |
sub init() { |
83 |
my $proxybase = "http://$amt_host:$amt_port"; |
my $proxybase = "http://$amt_host:$amt_port"; |
84 |
my $schemabase = "http://schemas.intel.com/platform/client"; |
my $schemabase = "http://schemas.intel.com/platform/client"; |
85 |
|
|
97 |
$sas->autotype(0); |
$sas->autotype(0); |
98 |
$rcs->autotype(0); |
$rcs->autotype(0); |
99 |
|
|
100 |
|
warn $proxybase; |
101 |
|
|
102 |
$amt_version = $sas->GetCoreVersion()->paramsout; |
$amt_version = $sas->GetCoreVersion()->paramsout; |
103 |
} |
} |
104 |
|
|
105 |
|
sub _soap { |
106 |
|
my $name = shift; |
107 |
|
|
108 |
|
my $proxybase = "http://$amt_host:$amt_port"; |
109 |
|
my $schemabase = "http://schemas.intel.com/platform/client"; |
110 |
|
|
111 |
|
warn "call_soap $proxybase $name ",dump( @_ ); |
112 |
|
|
113 |
|
my $soap = SOAP::Lite->new( |
114 |
|
proxy => "$proxybase/${name}Service", |
115 |
|
default_ns => "$schemabase/$name/2004/01"); |
116 |
|
|
117 |
|
$soap->autotype(0); |
118 |
|
|
119 |
|
if ( @_ ) { |
120 |
|
do_soap($soap, $name, @_) |
121 |
|
} else { |
122 |
|
return $soap; |
123 |
|
} |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
############################################################################# |
############################################################################# |
128 |
# functions |
# functions |
156 |
|
|
157 |
if (!defined($rc)) { |
if (!defined($rc)) { |
158 |
$msg = "soap failure"; |
$msg = "soap failure"; |
159 |
|
warn dump( $ret->faultdetail ); |
160 |
} elsif (!defined($pt_status{$rc})) { |
} elsif (!defined($pt_status{$rc})) { |
161 |
$msg = sprintf("unknown pt_status code: 0x%x", $rc); |
$msg = sprintf("unknown pt_status code: 0x%x", $rc); |
162 |
} else { |
} else { |
244 |
my $powerstate = $rcs->GetSystemPowerState()->paramsout; |
my $powerstate = $rcs->GetSystemPowerState()->paramsout; |
245 |
printf "Powerstate: %s\n", $ps [ $powerstate & 0x0f ]; |
printf "Powerstate: %s\n", $ps [ $powerstate & 0x0f ]; |
246 |
} |
} |
|
|
|
|
sub print_remote_info() { |
|
|
my @rccaps = $rcs->GetRemoteControlCapabilities()->paramsout; |
|
|
printf "Remote Control Capabilities:\n"; |
|
|
printf " IanaOemNumber %x\n", $rccaps[0]; |
|
|
printf " OemDefinedCapabilities %s%s%s%s%s\n", |
|
|
$rccaps[1] & 0x01 ? "IDER " : "", |
|
|
$rccaps[1] & 0x02 ? "SOL " : "", |
|
|
$rccaps[1] & 0x04 ? "BiosReflash " : "", |
|
|
$rccaps[1] & 0x08 ? "BiosSetup " : "", |
|
|
$rccaps[1] & 0x10 ? "BiosPause " : ""; |
|
|
|
|
|
printf " SpecialCommandsSupported %s%s%s%s%s\n", |
|
|
$rccaps[2] & 0x0100 ? "PXE-boot " : "", |
|
|
$rccaps[2] & 0x0200 ? "HD-boot " : "", |
|
|
$rccaps[2] & 0x0400 ? "HD-boot-safemode " : "", |
|
|
$rccaps[2] & 0x0800 ? "diag-boot " : "", |
|
|
$rccaps[2] & 0x1000 ? "cd-boot " : ""; |
|
|
|
|
|
printf " SystemCapabilitiesSupported %s%s%s%s\n", |
|
|
$rccaps[3] & 0x01 ? "powercycle " : "", |
|
|
$rccaps[3] & 0x02 ? "powerdown " : "", |
|
|
$rccaps[3] & 0x03 ? "powerup " : "", |
|
|
$rccaps[3] & 0x04 ? "reset " : ""; |
|
|
|
|
|
printf " SystemFirmwareCapabilities %x\n", $rccaps[4]; |
|
|
} |
|
247 |
|
|
248 |
sub print_network_info() { |
sub print_network_info() { |
249 |
my $ret; |
my $ret; |
260 |
} |
} |
261 |
} |
} |
262 |
|
|
|
sub remote_control($$) { |
|
|
my $command = shift; |
|
|
my $special = shift; |
|
|
my @args; |
|
|
|
|
|
my $hostname = $nas->GetHostName()->paramsout; |
|
|
my $domainname = $nas->GetDomainName()->paramsout; |
|
|
printf "host %s.%s, %s [y/N] ? ", $hostname, $domainname, $command; |
|
|
my $reply = <>; |
|
|
if ($reply =~ m/^(y|yes)$/i) { |
|
|
printf "execute: %s\n", $command; |
|
|
push (@args, SOAP::Data->name('Command' => $rcc{$command})); |
|
|
push (@args, SOAP::Data->name('IanaOemNumber' => 343)); |
|
|
if (defined($special) && defined($rccs{$special})) { |
|
|
push (@args, SOAP::Data->name('SpecialCommand' |
|
|
=> $rccs{$special} )); |
|
|
} |
|
|
if (defined($special) && defined($rccs_oem{$special})) { |
|
|
push (@args, SOAP::Data->name('OEMparameters' => 1 )); |
|
|
push (@args, SOAP::Data->name('SpecialCommand' |
|
|
=> $rccs_oem{$special} )); |
|
|
} |
|
|
do_soap($rcs, "RemoteControl", @args); |
|
|
} else { |
|
|
printf "canceled\n"; |
|
|
} |
|
|
} |
|
|
|
|
263 |
sub ipv4_addr($$) { |
sub ipv4_addr($$) { |
264 |
my $name = shift; |
my $name = shift; |
265 |
my $ipv4 = shift; |
my $ipv4 = shift; |
327 |
sub command { |
sub command { |
328 |
my ($amt_command,$amt_arg) = @_; |
my ($amt_command,$amt_arg) = @_; |
329 |
|
|
330 |
soap_init; |
init; |
331 |
|
|
332 |
if ($amt_command eq "info") { |
if ($amt_command eq "info") { |
333 |
print_general_info; |
print_general_info; |
|
print_remote_info; |
|
334 |
} elsif ($amt_command eq "netinfo") { |
} elsif ($amt_command eq "netinfo") { |
335 |
check_amt_version(2,5); |
check_amt_version(2,5); |
336 |
print_network_info; |
print_network_info; |
337 |
} elsif ($amt_command eq "netconf") { |
} elsif ($amt_command eq "netconf") { |
338 |
check_amt_version(2,5); |
check_amt_version(2,5); |
339 |
configure_network(@ARGV); |
configure_network(@_); |
340 |
} elsif ($amt_command =~ m/^(reset|powerup|powerdown|powercycle)$/) { |
} elsif ($amt_command =~ m/^(reset|powerup|powerdown|powercycle)$/) { |
341 |
remote_control($amt_command, $amt_arg); |
remote_control($amt_command, $amt_arg); |
342 |
} else { |
} else { |