use html;
use ping;
use CouchDB;
+use Carp qw/confess/;
-sub info {
- my ( $amt, $client_ip ) = @_;
- my ( $passwd, $ip ) = split(/\s+/, $amt);
+sub ip {
+ my $client_ip = shift || confess "no ip";
+ my ( $passwd, $ip ) = split(/\s+/, client::conf( $client_ip => 'amt' ));
( $ip, $passwd ) = ( $passwd, $ip ) if $passwd =~ m/$RE{net}{IPv4}/;
$ip ||= $client_ip;
if ( ! ping::host( $ip ) ) {
- warn "$ip unreachable";
+ warn "W: ping $ip unreachable\n";
}
warn "amt $ip ", '*' x length($passwd), "\n";
- $ENV{AMT_HOST} = $ip;
$ENV{AMT_PASSWORD} = $passwd;
+ $ENV{AMT_HOST} = $ip;
+
+}
+
+sub power_on {
+ ip @_;
+ power_state() == 0;
+}
+
+sub power_state {
+ my $state = eval { Intel::AMT::RemoteControl::SystemPowerState };
+ CouchDB::audit('SystemPowerState', { ip => $ENV{AMT_HOST}, SystemPowerState => $state });
+ return $state;
+}
+
+sub info {
+ ip @_;
my $amt;
eval {
warn "ERROR amt $@" if $@;
my $out;
+ my $ip = $ENV{AMT_HOST};
$out =
qq| <a href="http://$ip:16992/" target="$ip">amt</a>|
return $out;
}
+
+sub RemoteControl {
+ ip shift;
+ my $command = shift;
+ eval { Intel::AMT::RemoteControl::run( $command ) };
+ CouchDB::audit( $command, { ip => $ENV{AMT_HOST}, error => $@ } );
+ warn "ERROR $@" if $@;
+}
+
1;