10 |
|
|
11 |
use lib 'lib'; |
use lib 'lib'; |
12 |
|
|
13 |
my $amt_host = $ENV{'AMT_HOST'}; |
sub soap_url { |
14 |
my $amt_port = "16992"; |
my $amt_host = $ENV{'AMT_HOST'}; |
15 |
$main::amt_user = "admin"; |
my $amt_port = "16992"; |
16 |
$main::amt_pass = $ENV{'AMT_PASSWORD'}; |
"http://$amt_host:$amt_port"; |
17 |
|
} |
18 |
|
|
19 |
my $amt_debug = 0; |
my $amt_debug = 0; |
20 |
$amt_debug = $ENV{'AMT_DEBUG'} if defined($ENV{'AMT_DEBUG'}); |
$amt_debug = $ENV{'AMT_DEBUG'} if defined($ENV{'AMT_DEBUG'}); |
21 |
|
|
78 |
my ($nas, $sas, $rcs); |
my ($nas, $sas, $rcs); |
79 |
|
|
80 |
sub SOAP::Transport::HTTP::Client::get_basic_credentials { |
sub SOAP::Transport::HTTP::Client::get_basic_credentials { |
81 |
return $main::amt_user => $main::amt_pass; |
return 'admin' => $ENV{AMT_PASSWORD}; |
82 |
} |
} |
83 |
|
|
84 |
sub init() { |
sub init() { |
85 |
my $proxybase = "http://$amt_host:$amt_port"; |
my $proxybase = soap_url; |
86 |
my $schemabase = "http://schemas.intel.com/platform/client"; |
my $schemabase = "http://schemas.intel.com/platform/client"; |
87 |
|
|
88 |
$nas = SOAP::Lite->new( |
$nas = SOAP::Lite->new( |
104 |
$amt_version = $sas->GetCoreVersion()->paramsout; |
$amt_version = $sas->GetCoreVersion()->paramsout; |
105 |
} |
} |
106 |
|
|
107 |
|
sub _soap { |
108 |
|
my $name = shift; |
109 |
|
|
110 |
|
my $proxybase = soap_url; |
111 |
|
my $schemabase = "http://schemas.intel.com/platform/client"; |
112 |
|
|
113 |
|
warn "call_soap $proxybase $name ",dump( @_ ); |
114 |
|
|
115 |
|
my $soap = SOAP::Lite->new( |
116 |
|
proxy => "$proxybase/${name}Service", |
117 |
|
default_ns => "$schemabase/$name/2004/01"); |
118 |
|
|
119 |
|
$soap->autotype(0); |
120 |
|
|
121 |
|
if ( @_ ) { |
122 |
|
do_soap($soap, $name, @_) |
123 |
|
} else { |
124 |
|
return $soap; |
125 |
|
} |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
############################################################################# |
############################################################################# |
130 |
# functions |
# functions |
235 |
} |
} |
236 |
|
|
237 |
sub print_general_info() { |
sub print_general_info() { |
|
printf "### AMT info on machine '%s' ###\n", $amt_host; |
|
238 |
|
|
239 |
printf "AMT version: %s\n", $amt_version; |
printf "AMT version: %s\n", $amt_version; |
240 |
|
|
246 |
printf "Powerstate: %s\n", $ps [ $powerstate & 0x0f ]; |
printf "Powerstate: %s\n", $ps [ $powerstate & 0x0f ]; |
247 |
} |
} |
248 |
|
|
|
use Intel::AMT::RemoteControl; |
|
|
|
|
|
sub describe { |
|
|
warn 'describe ',dump( @_ ) if $amt_debug; |
|
|
my ( $value, $map ) = @_; |
|
|
my $out; |
|
|
foreach my $name ( keys %$map ) { |
|
|
push @$out, $name if $value & $map->{$name}; |
|
|
} |
|
|
push @$out, sprintf("%x", $value) unless $out; |
|
|
return $out; |
|
|
} |
|
|
|
|
|
sub RemoteControlCapabilities { |
|
|
my @rccaps = $rcs->GetRemoteControlCapabilities()->paramsout; |
|
|
|
|
|
my $return = { |
|
|
IanaOemNumber => $rccaps[0], |
|
|
OemDefinedCapabilities => |
|
|
describe( $rccaps[1], $Intel::AMT::RemoteControl::OemDefinedCapabilitiesSupported ), |
|
|
SpecialCommand => |
|
|
describe( $rccaps[2], $Intel::AMT::RemoteControl::SpecialCommandSupported ), |
|
|
SystemCapabilities => |
|
|
describe( $rccaps[3], $Intel::AMT::RemoteControl::SystemCapabilitiesSupported ), |
|
|
SystemFirmwareCapabilities => |
|
|
describe( $rccaps[4], $Intel::AMT::RemoteControl::SystemFirmwareCapabilitiesSupported ), |
|
|
}; |
|
|
|
|
|
warn '# RemoteControlCapabilities ',dump( $return ); |
|
|
return $return; |
|
|
} |
|
|
|
|
|
sub RemoteControl { |
|
|
my @args; |
|
|
|
|
|
my $hostname = $nas->GetHostName()->paramsout; |
|
|
my $domainname = $nas->GetDomainName()->paramsout; |
|
|
|
|
|
warn $hostname, '.', $domainname, ' execute: ', dump( @_ ); |
|
|
|
|
|
my $BootOptions; |
|
|
my $SpecialCommandParameter; |
|
|
|
|
|
foreach my $command ( @_ ) { |
|
|
|
|
|
my $i; |
|
|
|
|
|
if ( $i = $Intel::AMT::RemoteControl::BootOptions->{$command} ) { |
|
|
if ( $BootOptions ) { |
|
|
$BootOptions |= $i; |
|
|
next; |
|
|
} else { |
|
|
$BootOptions = $i; |
|
|
$command = 'SetBootOptions'; |
|
|
} |
|
|
} elsif ( $i = $Intel::AMT::RemoteControl::SpecialCommandParameters->{$command} ) { |
|
|
$SpecialCommandParameter |= $i; |
|
|
} elsif ( $i = $Intel::AMT::RemoteControl::RemoteControlCommand->{$command} ) { |
|
|
push @args, SOAP::Data->name( 'Command' => $i ); |
|
|
} elsif ( $i = $Intel::AMT::RemoteControl::SpecialCommand->{$command} ) { |
|
|
push @args, SOAP::Data->name( 'SpecialCommand' => $i ); |
|
|
} elsif ( $i = $Intel::AMT::RemoteControl::OEMParameters->{$command} ) { |
|
|
push @args, SOAP::Data->name( 'OEMParameters' => $i ); |
|
|
} else { |
|
|
die "can't find $command"; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ( $BootOptions ) { |
|
|
warn "invalid BootOptions $BootOptions" unless |
|
|
( $BootOptions & $Intel::AMT::RemoteControl::BootOptionsReservedBits ); |
|
|
push @args, SOAP::Data->name( 'BootOptions' => $BootOptions ); |
|
|
} |
|
|
|
|
|
if ( $SpecialCommandParameter ) { |
|
|
warn "invalid SpecialCommandParameter $SpecialCommandParameter" unless |
|
|
( $SpecialCommandParameter & $Intel::AMT::RemoteControl::SpecialCommandParametersReservedBits ); |
|
|
push @args, SOAP::Data->name( 'SpecialCommandParameter' => $SpecialCommandParameter ); |
|
|
} |
|
|
|
|
|
push @args, SOAP::Data->name( 'IanaOemNumber' => $Intel::AMT::RemoteControl::IanaNumbers->{IntelIanaNumber} ); |
|
|
warn "args ",dump( @args ); |
|
|
|
|
|
do_soap($rcs, "RemoteControl", @args); |
|
|
} |
|
|
|
|
249 |
sub print_network_info() { |
sub print_network_info() { |
250 |
my $ret; |
my $ret; |
251 |
|
|
332 |
|
|
333 |
if ($amt_command eq "info") { |
if ($amt_command eq "info") { |
334 |
print_general_info; |
print_general_info; |
|
RemoteControlCapabilities; |
|
335 |
} elsif ($amt_command eq "netinfo") { |
} elsif ($amt_command eq "netinfo") { |
336 |
check_amt_version(2,5); |
check_amt_version(2,5); |
337 |
print_network_info; |
print_network_info; |
348 |
|
|
349 |
warn 'loaded'; |
warn 'loaded'; |
350 |
|
|
|
warn 'init ', init; |
|
|
|
|
351 |
1; |
1; |