/[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 380 by dpavlin, Sun Aug 30 16:36:37 2009 UTC revision 473 by dpavlin, Tue Jan 5 17:26:34 2010 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 16  use Carp qw/confess/; Line 17  use Carp qw/confess/;
17    
18  sub ip {  sub ip {
19          my ( $client_ip, $amt ) = @_;          my ( $client_ip, $amt ) = @_;
20            return unless $client_ip;
21          $amt ||= client::conf( $client_ip => 'amt' );          $amt ||= client::conf( $client_ip => 'amt' );
22          my ( $passwd, $ip ) = split(/\s+/, $amt);          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}/;
# Line 24  sub ip { Line 26  sub ip {
26    
27          $ENV{AMT_PASSWORD} = $passwd;          $ENV{AMT_PASSWORD} = $passwd;
28          $ENV{AMT_HOST} = $ip;          $ENV{AMT_HOST} = $ip;
29    
30            my $hostname = client::conf( $client_ip => 'hostname' ) || $client_ip;
31    
32            client::conf( $ip => 'hostname', default => "amt-$hostname" );
33    
34            return $ip;
35  }  }
36    
37  sub power_state {  sub power_state {
# Line 38  sub power_on { Line 46  sub power_on {
46          defined $state && ( $state & 0x0f ) == 0;          defined $state && ( $state & 0x0f ) == 0;
47  }  }
48    
49  sub info {  sub network {
50          ip @_;          ip @_;
51    
52          my $amt;          my $amt = eval { Intel::AMT::NetworkAdministration::network_settings };
53          eval {          if ( $@ ) {
54                  $amt = Intel::AMT::NetworkAdministration::network_settings;                  warn "ERROR $@";
55                  $amt->{power_state} = Intel::AMT::RemoteControl::SystemPowerState;          } else {
56                  CouchDB::audit('network', $amt );                  $amt->{ip} = $ENV{AMT_HOST};
57          };                  CouchDB::audit('log', $amt );
58          warn "ERROR amt $@" if $@;          }
59          $amt;          $amt;
60  }  }
61    
62    sub log {
63            ip @_;
64    
65            my $amt = eval { Intel::AMT::EventManager::ReadEventLogRecords };
66            if ( $@ ) {
67                    warn "ERROR $@";
68            } else {
69                    $amt->{ip} = $ENV{AMT_HOST};
70                    CouchDB::audit('log', $amt );
71            }
72            $amt;
73    }
74    
75  sub RemoteControl {  sub RemoteControl {
76          ip shift;          ip shift;

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

  ViewVC Help
Powered by ViewVC 1.1.26