/[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

Contents of /lib/PXElator/amt.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 380 - (show annotations)
Sun Aug 30 16:36:37 2009 UTC (13 years, 5 months ago) by dpavlin
File size: 1275 byte(s)
seems like cleanup, but is really amt information improvement
especially power state

1 package amt;
2
3 use warnings;
4 use strict;
5
6 use lib '/srv/Intel-AMT/lib/';
7 use Intel::AMT::RemoteControl;
8 use Intel::AMT::NetworkAdministration;
9 use Data::Dump qw/dump/;
10 use Regexp::Common qw/net/;
11
12 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 $ip ||= $client_ip;
24
25 $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 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
54
55 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;

  ViewVC Help
Powered by ViewVC 1.1.26