/[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 181 by dpavlin, Sun Aug 9 19:00:52 2009 UTC revision 380 by dpavlin, Sun Aug 30 16:36:37 2009 UTC
# Line 3  package amt; Line 3  package amt;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6  use lib '/home/dpavlin/llin/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 Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10    use Regexp::Common qw/net/;
11    
12  use html;  use html;
13    use ping;
14    use CouchDB;
15    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);
21            ( $ip, $passwd ) = ( $passwd, $ip ) if $passwd =~ m/$RE{net}{IPv4}/;
22    
23  sub info {          $ip ||= $client_ip;
         my $amt = shift;  
         my ( $passwd, $ip ) = split(/\n/, $amt);  
         warn "amt $ip\n";  
24    
         $ENV{AMT_HOST} = $ip;  
25          $ENV{AMT_PASSWORD} = $passwd;          $ENV{AMT_PASSWORD} = $passwd;
26            $ENV{AMT_HOST} = $ip;
27    }
28    
29    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          my $out;  sub power_on {
36            ip @_;
37            my $state = power_state;
38            defined $state && ( $state & 0x0f ) == 0;
39    }
40    
41    sub info {
42            ip @_;
43    
44            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|<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.181  
changed lines
  Added in v.380

  ViewVC Help
Powered by ViewVC 1.1.26