From f4d84b071cbc062f44ecd30c135964612ebcab2a Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Wed, 4 Feb 2009 12:25:15 +0100 Subject: [PATCH] working powerup(), powerdown() and powercycle() functions they still abuse the powercycle serveraction... --- rsbs2.pl | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/rsbs2.pl b/rsbs2.pl index 5255b58..a309347 100755 --- a/rsbs2.pl +++ b/rsbs2.pl @@ -9,6 +9,8 @@ use Digest::MD5 qw(md5); my $ua = LWP::UserAgent->new; my $sid; my $host; +my $poweronms=200; +my $poweroffms=4500; my @fw_vars = qw(ENABLE_LAN_AUTONEG ENABLE_LAN_100 ENABLE_LAN_FDUPLEX GATEWAY IP_ADDRESS NETMASK TFTP_FIRMWARE_FILE TFTP_ADDR_FIRMWARE ENABLE_DHCP @@ -182,7 +184,7 @@ sub setprop { my $oldval = _getprop($property)->{RESP}->{PROPLIST}->{PROP}->{VAL}; if ($value eq $oldval) { - print "${property} is already ${value}\n"; + #print "${property} is already ${value}\n"; return; } @@ -199,6 +201,14 @@ sub setprop { sub serveraction { my $action = shift; + my $pmode = 2; + + setprop("SERVER_HARD_RESET_VIA_IPMI", "FALSE"); + setprop("SERVER_POWER_CHANGE_VIA_IPMI", "FALSE"); + #PM Mode + setprop("SERVER_POWER_ON_MODE", sprintf("0x%x", $pmode)); + setprop("SERVER_POWER_OFF_MODE", sprintf("0x%x", $pmode)); + print "${action}...\n"; my $reqstr=''.$action.''; my $res = _req($reqstr); @@ -208,6 +218,24 @@ sub serveraction { } } +sub powerup { + setprop("SERVER_POWER_ON_PULSE_MS", sprintf("0x%x", $poweronms)); + setprop("SERVER_POWER_OFF_PULSE_MS", "0x0"); + serveraction("powercycle"); +} + +sub powerdown { + setprop("SERVER_POWER_ON_PULSE_MS", "0x0"); + setprop("SERVER_POWER_OFF_PULSE_MS", sprintf("0x%x", $poweroffms)); + serveraction("powercycle"); +} + +sub powercycle { + setprop("SERVER_POWER_ON_PULSE_MS", sprintf("0x%x", $poweronms)); + setprop("SERVER_POWER_OFF_PULSE_MS", sprintf("0x%x", $poweroffms)); + serveraction("powercycle"); +} + sub showprop { my $property = shift; @@ -318,6 +346,8 @@ while() { close(INIFILE); $host = ${$Config{$sections[0]}}{"host"}; +$poweronms = ${$Config{$sections[0]}}{"poweronms"} if (defined(${$Config{$sections[0]}}{"poweronms"})); +$poweroffms = ${$Config{$sections[0]}}{"poweroffms"} if (defined(${$Config{$sections[0]}}{"poweroffms"})); $sid = login(${$Config{$sections[0]}}{"user"}, ${$Config{$sections[0]}}{"pass"}); @@ -339,31 +369,23 @@ board_properties(); syslog_debug("255.255.255.255", "TRUE"); +#Power Mgmt. Pane +setprop("FP_REMOTE_POWER", "TRUE"); + #server_power_on modes: (com/agilent/rmc/mgui/panels/PowerMgmtConf.class) #0: l_pmconf_option_disabled #1: l_pmconf_option_atx #2: l_pmconf_option_relay #default: disabled -my $pmode = 2; - -setprop("SERVER_HARD_RESET_VIA_IPMI", "FALSE"); -setprop("SERVER_POWER_CHANGE_VIA_IPMI", "FALSE"); -#Power Mgmt. Pane -setprop("FP_REMOTE_POWER", "TRUE"); -#PM Mode -setprop("SERVER_POWER_ON_MODE", sprintf("0x%x", $pmode)); -setprop("SERVER_POWER_OFF_MODE", sprintf("0x%x", $pmode)); -#Hack: Abuse powercycloe for powerup and down... -#setprop("SERVER_POWER_ON_PULSE_MS", "0x0"); #$reqstr=''.$boarddesc_new.''; #print $reqstr."\n"; #print Dumper(_req($reqstr)); serveraction("hardreset"); -serveraction("powerup"); -serveraction("powerdown"); -serveraction("powercycle"); +powerup(); +powerdown(); +powercycle(); logout(); -- 2.39.2