[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 6/5] PDU::ipmi_try: New method



For power on, this is just like ipmi.

For power off, it doesn't mind errors (although it has three
attempts).  This is useful when combined with pdu power: if the
chassis power is already off, ipmi will fail.

If the ipmi operation does fail, then the chassing pdu power operation
will do the job.  So this will also fix things if the test case
crashed the bmc or something.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Osstest/PDU/ipmi_try.pm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Osstest/PDU/ipmi_try.pm

diff --git a/Osstest/PDU/ipmi_try.pm b/Osstest/PDU/ipmi_try.pm
new file mode 100644
index 0000000..172f4ec
--- /dev/null
+++ b/Osstest/PDU/ipmi_try.pm
@@ -0,0 +1,55 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2014 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+package Osstest::PDU::ipmi_try;
+
+use strict;
+use warnings;
+
+use Osstest;
+use Osstest::TestSupport;
+use IO::File;
+use Osstest::PDU::ipmi;
+
+BEGIN {
+    use Exporter ();
+    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+    $VERSION     = 1.00;
+    @ISA         = qw(Exporter Osstest::PDU::ipmi);
+    @EXPORT      = qw();
+    %EXPORT_TAGS = ( );
+
+    @EXPORT_OK   = qw();
+}
+
+sub pdu_power_state {
+    my ($mo, $on) = @_;
+
+    if ($on) {
+       $mo->Osstest::PDU::ipmi::pdu_power_state($on);
+    } else {
+        my $attempts = 3;
+       foreach my $attempt (1..$attempts) {
+           eval {
+               $mo->Osstest::PDU::ipmi::pdu_power_state($on);
+           };
+           last unless $@;
+           warn "(attempt $attempt/$attempts) $@";
+       }
+    }
+}
+
+1;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.