]> git.zerfleddert.de Git - rsbs2/commitdiff
working powerup(), powerdown() and powercycle() functions
authorMichael Gernoth <michael@gernoth.net>
Wed, 4 Feb 2009 11:25:15 +0000 (12:25 +0100)
committerMichael Gernoth <michael@gernoth.net>
Wed, 4 Feb 2009 11:25:15 +0000 (12:25 +0100)
they still abuse the powercycle serveraction...

rsbs2.pl

index 5255b58e87d76c930c9369555b29501f7db3c68a..a30934720ed365c42458406eff5fae77d678313e 100755 (executable)
--- 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='<?xml version="1.0"?><?RMCXML version="1.0"?><RMCSEQ><REQ CMD="serveraction"><ACT>'.$action.'</ACT></REQ></RMCSEQ>';
        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(<INIFILE>) {
 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='<?xml version="1.0"?><?RMCXML version="1.0"?><RMCSEQ><REQ CMD="boardpropset"><BPROP NAME="BOARD_DESCRIPTION"><VAL>'.$boarddesc_new.'</VAL></BPROP></REQ></RMCSEQ>';
 #print $reqstr."\n";
 #print Dumper(_req($reqstr));
 
 serveraction("hardreset");
-serveraction("powerup");
-serveraction("powerdown");
-serveraction("powercycle");
+powerup();
+powerdown();
+powercycle();
 
 logout();
Impressum, Datenschutz