/[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 183 by dpavlin, Sun Aug 9 19:26:38 2009 UTC revision 385 by dpavlin, Sun Aug 30 22:46:57 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 Intel::AMT::EventManager;
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
11    use Regexp::Common qw/net/;
12    
13  use html;  use html;
14    use ping;
15    use CouchDB;
16    use Carp qw/confess/;
17    
18    sub ip {
19            my ( $client_ip, $amt ) = @_;
20            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}/;
24    
25  sub info {          $ip ||= $client_ip;
         my $amt = shift;  
         my ( $passwd, $ip ) = split(/\n/, $amt);  
         warn "amt $ip\n";  
26    
         $ENV{AMT_HOST} = $ip;  
27          $ENV{AMT_PASSWORD} = $passwd;          $ENV{AMT_PASSWORD} = $passwd;
28            $ENV{AMT_HOST} = $ip;
29    }
30    
31          my $out;  sub power_state {
32            my $state = eval { Intel::AMT::RemoteControl::SystemPowerState };
33            CouchDB::audit('SystemPowerState', { ip => $ENV{AMT_HOST}, SystemPowerState => $state });
34            return $state;
35    }
36    
37    sub power_on {
38            ip @_;
39            my $state = power_state;
40            defined $state && ( $state & 0x0f ) == 0;
41    }
42    
43          $out = qq|power: S| . Intel::AMT::RemoteControl::SystemPowerState  sub network {
44                  . qq|<br>|          ip @_;
45                  . qq| <a href="http://$ip:16992/" target="$ip">amt</a>|  
46                  . qq| <a href="http://$ip:16992/ip.htm" target="$ip">ip</a>|          my $amt = eval { Intel::AMT::NetworkAdministration::network_settings };
47                  . qq|<br>|          if ( $@ ) {
48                  . html::pre_dump( Intel::AMT::NetworkAdministration::network_settings )                  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          return $out;  sub RemoteControl {
70            ip shift;
71            my $command = shift;
72            eval { Intel::AMT::RemoteControl::run( $command ) };
73            CouchDB::audit( $command, { ip => $ENV{AMT_HOST}, error => $@ } );
74            warn "ERROR $@" if $@;
75  }  }
76    
77  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26