/[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 262 by dpavlin, Wed Aug 19 11:02:15 2009 UTC revision 380 by dpavlin, Sun Aug 30 16:36:37 2009 UTC
# Line 8  use Intel::AMT::RemoteControl; Line 8  use Intel::AMT::RemoteControl;
8  use Intel::AMT::NetworkAdministration;  use Intel::AMT::NetworkAdministration;
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10  use Regexp::Common qw/net/;  use Regexp::Common qw/net/;
 use Net::Ping;  
11    
12  use html;  use html;
13    use ping;
14  sub info {  use CouchDB;
15          my ( $amt, $client_ip ) = @_;  use Carp qw/confess/;
16    
17    sub ip {
18            my ( $client_ip, $amt ) = @_;
19            $amt ||= client::conf( $client_ip => 'amt' );
20          my ( $passwd, $ip ) = split(/\s+/, $amt);          my ( $passwd, $ip ) = split(/\s+/, $amt);
21          ( $ip, $passwd ) = ( $passwd, $ip ) if $passwd =~ m/$RE{net}{IPv4}/;          ( $ip, $passwd ) = ( $passwd, $ip ) if $passwd =~ m/$RE{net}{IPv4}/;
22    
23          $ip ||= $client_ip;          $ip ||= $client_ip;
24    
25          my $p = Net::Ping->new;          $ENV{AMT_PASSWORD} = $passwd;
26            $ENV{AMT_HOST} = $ip;
27    }
28    
29          if ( ! $p->ping( $ip, 0.7 ) ) {  sub power_state {
30                  return "$ip unreachable";          my $state = eval { Intel::AMT::RemoteControl::SystemPowerState };
31          }          CouchDB::audit('SystemPowerState', { ip => $ENV{AMT_HOST}, SystemPowerState => $state });
32            return $state;
33    }
34    
35          warn "amt $ip ", '*' x length($passwd), "\n";  sub power_on {
36            ip @_;
37            my $state = power_state;
38            defined $state && ( $state & 0x0f ) == 0;
39    }
40    
41          $ENV{AMT_HOST} = $ip;  sub info {
42          $ENV{AMT_PASSWORD} = $passwd;          ip @_;
43    
44          my $out;          my $amt;
45            eval {
46                    $amt = Intel::AMT::NetworkAdministration::network_settings;
47                    $amt->{power_state} = Intel::AMT::RemoteControl::SystemPowerState;
48                    CouchDB::audit('network', $amt );
49            };
50            warn "ERROR amt $@" if $@;
51            $amt;
52    }
53    
         $out = qq|power: S| . Intel::AMT::RemoteControl::SystemPowerState  
                 . qq|<br>|  
                 . 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( Intel::AMT::NetworkAdministration::network_settings )  
                 ;  
54    
55          return $out;  sub RemoteControl {
56            ip shift;
57            my $command = shift;
58            eval { Intel::AMT::RemoteControl::run( $command ) };
59            CouchDB::audit( $command, { ip => $ENV{AMT_HOST}, error => $@ } );
60            warn "ERROR $@" if $@;
61  }  }
62    
63  1;  1;

Legend:
Removed from v.262  
changed lines
  Added in v.380

  ViewVC Help
Powered by ViewVC 1.1.26