/[pxelator]/lib/PXElator/amt.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 /lib/PXElator/amt.pm

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

revision 376 by dpavlin, Sun Aug 30 15:22:41 2009 UTC revision 385 by dpavlin, Sun Aug 30 22:46:57 2009 UTC
# Line 6  use strict; Line 6  use strict;
6  use lib '/srv/Intel-AMT/lib/';  use lib '/srv/Intel-AMT/lib/';
7  use Intel::AMT::RemoteControl;  use Intel::AMT::RemoteControl;
8  use Intel::AMT::NetworkAdministration;  use Intel::AMT::NetworkAdministration;
9    use Intel::AMT::EventManager;
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
11  use Regexp::Common qw/net/;  use Regexp::Common qw/net/;
12    
# Line 15  use CouchDB; Line 16  use CouchDB;
16  use Carp qw/confess/;  use Carp qw/confess/;
17    
18  sub ip {  sub ip {
19          my $client_ip = shift || confess "no ip";          my ( $client_ip, $amt ) = @_;
20          my ( $passwd, $ip ) = split(/\s+/, client::conf( $client_ip => 'amt' ));          return unless $client_ip;
21            $amt ||= client::conf( $client_ip => 'amt' );
22            my ( $passwd, $ip ) = split(/\s+/, $amt);
23          ( $ip, $passwd ) = ( $passwd, $ip ) if $passwd =~ m/$RE{net}{IPv4}/;          ( $ip, $passwd ) = ( $passwd, $ip ) if $passwd =~ m/$RE{net}{IPv4}/;
24    
25          $ip ||= $client_ip;          $ip ||= $client_ip;
26    
         if ( ! ping::host( $ip ) ) {  
                 warn "W: ping $ip unreachable\n";  
         }  
   
         warn "amt $ip ", '*' x length($passwd), "\n";  
   
27          $ENV{AMT_PASSWORD} = $passwd;          $ENV{AMT_PASSWORD} = $passwd;
28          $ENV{AMT_HOST} = $ip;          $ENV{AMT_HOST} = $ip;
   
 }  
   
 sub power_on {  
         ip @_;  
         power_state() == 0;  
29  }  }
30    
31  sub power_state {  sub power_state {
# Line 43  sub power_state { Line 34  sub power_state {
34          return $state;          return $state;
35  }  }
36    
37  sub info {  sub power_on {
38          ip @_;          ip @_;
39            my $state = power_state;
40            defined $state && ( $state & 0x0f ) == 0;
41    }
42    
43          my $amt;  sub network {
44          eval {          ip @_;
                 $amt = Intel::AMT::NetworkAdministration::network_settings;  
                 $amt->{power_state} = Intel::AMT::RemoteControl::SystemPowerState;  
                 CouchDB::audit('network', $amt );  
         };  
         warn "ERROR amt $@" if $@;  
   
         my $out;  
         my $ip = $ENV{AMT_HOST};  
   
         $out =  
                   qq| <a href="http://$ip:16992/" target="$ip">amt</a>|  
                 . qq| <a href="http://$ip:16992/ip.htm" target="$ip">ip</a>|  
                 . qq|<br>|  
                 . html::pre_dump( $amt )  
                 ;  
45    
46          return $out;          my $amt = eval { Intel::AMT::NetworkAdministration::network_settings };
47            if ( $@ ) {
48                    warn "ERROR $@";
49            } else {
50                    $amt->{ip} = $ENV{AMT_HOST};
51                    CouchDB::audit('log', $amt );
52            }
53            $amt;
54  }  }
55    
56    sub log {
57            ip @_;
58    
59            my $amt = eval { Intel::AMT::EventManager::ReadEventLogRecords };
60            if ( $@ ) {
61                    warn "ERROR $@";
62            } else {
63                    $amt->{ip} = $ENV{AMT_HOST};
64                    CouchDB::audit('log', $amt );
65            }
66            $amt;
67    }
68    
69  sub RemoteControl {  sub RemoteControl {
70          ip shift;          ip shift;

Legend:
Removed from v.376  
changed lines
  Added in v.385

  ViewVC Help
Powered by ViewVC 1.1.26