/[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 336 by dpavlin, Sat Aug 29 00:07:00 2009 UTC revision 380 by dpavlin, Sun Aug 30 16:36:37 2009 UTC
# Line 12  use Regexp::Common qw/net/; Line 12  use Regexp::Common qw/net/;
12  use html;  use html;
13  use ping;  use ping;
14  use CouchDB;  use CouchDB;
15    use Carp qw/confess/;
16    
17  sub info {  sub ip {
18          my ( $amt, $client_ip ) = @_;          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          if ( ! ping::host( $ip ) ) {          $ENV{AMT_PASSWORD} = $passwd;
26                  warn "$ip unreachable";          $ENV{AMT_HOST} = $ip;
27          }  }
28    
29          warn "amt $ip ", '*' x length($passwd), "\n";  sub power_state {
30            my $state = eval { Intel::AMT::RemoteControl::SystemPowerState };
31            CouchDB::audit('SystemPowerState', { ip => $ENV{AMT_HOST}, SystemPowerState => $state });
32            return $state;
33    }
34    
35          $ENV{AMT_HOST} = $ip;  sub power_on {
36          $ENV{AMT_PASSWORD} = $passwd;          ip @_;
37            my $state = power_state;
38            defined $state && ( $state & 0x0f ) == 0;
39    }
40    
41    sub info {
42            ip @_;
43    
44          my $amt;          my $amt;
45          eval {          eval {
# Line 36  sub info { Line 48  sub info {
48                  CouchDB::audit('network', $amt );                  CouchDB::audit('network', $amt );
49          };          };
50          warn "ERROR amt $@" if $@;          warn "ERROR amt $@" if $@;
51            $amt;
52    }
53    
         my $out;  
   
         $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 )  
                 ;  
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.336  
changed lines
  Added in v.380

  ViewVC Help
Powered by ViewVC 1.1.26