/[Intel-AMT]/trunk/lib/Intel/AMT/SOAP.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Intel/AMT/SOAP.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5 by dpavlin, Sat Aug 8 20:38:06 2009 UTC revision 23 by dpavlin, Mon Sep 14 14:15:08 2009 UTC
# Line 10  use Data::Dump qw/dump/; Line 10  use Data::Dump qw/dump/;
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    
22    my $timeout = $ENV{'AMT_TIMEOUT'} || 1;
23    
24  my $amt_version;  my $amt_version;
25    
26  #############################################################################  #############################################################################
# Line 76  my %pt_status = ( Line 80  my %pt_status = (
80  my ($nas, $sas, $rcs);  my ($nas, $sas, $rcs);
81    
82  sub SOAP::Transport::HTTP::Client::get_basic_credentials {  sub SOAP::Transport::HTTP::Client::get_basic_credentials {
83          return $main::amt_user => $main::amt_pass;          return 'admin' => $ENV{AMT_PASSWORD};
84  }  }
85    
86  sub init() {  sub init() {
87          my $proxybase = "http://$amt_host:$amt_port";          my $proxybase = soap_url;
88          my $schemabase = "http://schemas.intel.com/platform/client";          my $schemabase = "http://schemas.intel.com/platform/client";
89    
90          $nas = SOAP::Lite->new(          $nas = SOAP::Lite->new(
# Line 97  sub init() { Line 101  sub init() {
101          $sas->autotype(0);          $sas->autotype(0);
102          $rcs->autotype(0);          $rcs->autotype(0);
103    
104            $nas->transport->timeout($timeout);
105            $sas->transport->timeout($timeout);
106            $rcs->transport->timeout($timeout);
107    
108          warn $proxybase;          warn $proxybase;
109    
110          $amt_version = $sas->GetCoreVersion()->paramsout;          $amt_version = $sas->GetCoreVersion()->paramsout;
111  }  }
112    
113    sub _soap {
114            my $name = shift;
115    
116            my $proxybase = soap_url;
117            my $schemabase = "http://schemas.intel.com/platform/client";
118    
119            warn "call_soap $proxybase $name ",dump( @_ );
120    
121            my $soap = SOAP::Lite->new(
122                    proxy      => "$proxybase/${name}Service",
123                    default_ns => "$schemabase/$name/2004/01");
124    
125            $soap->autotype(0);
126            $soap->transport->timeout($timeout);
127    
128            if ( @_ ) {
129                    do_soap($soap, $name, @_)
130            } else {
131                    return $soap;
132            }
133    }
134    
135    
136  #############################################################################  #############################################################################
137  # functions  # functions
# Line 212  sub check_amt_version { Line 242  sub check_amt_version {
242  }  }
243    
244  sub print_general_info() {  sub print_general_info() {
         printf "### AMT info on machine '%s' ###\n", $amt_host;  
245    
246          printf "AMT version:  %s\n", $amt_version;          printf "AMT version:  %s\n", $amt_version;
247                    
# Line 224  sub print_general_info() { Line 253  sub print_general_info() {
253          printf "Powerstate:   %s\n", $ps [ $powerstate & 0x0f ];          printf "Powerstate:   %s\n", $ps [ $powerstate & 0x0f ];
254  }  }
255    
 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);  
 }  
   
256  sub print_network_info() {  sub print_network_info() {
257          my $ret;          my $ret;
258    
# Line 398  sub command { Line 339  sub command {
339    
340          if ($amt_command eq "info") {          if ($amt_command eq "info") {
341                  print_general_info;                  print_general_info;
                 RemoteControlCapabilities;  
342          } elsif ($amt_command eq "netinfo") {          } elsif ($amt_command eq "netinfo") {
343                  check_amt_version(2,5);                  check_amt_version(2,5);
344                  print_network_info;                  print_network_info;
# Line 415  sub command { Line 355  sub command {
355    
356  warn 'loaded';  warn 'loaded';
357    
 warn 'init ', init;  
   
358  1;  1;

Legend:
Removed from v.5  
changed lines
  Added in v.23

  ViewVC Help
Powered by ViewVC 1.1.26