From patchwork Fri Nov 21 13:16:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 41309 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8977F244B0 for ; Fri, 21 Nov 2014 13:18:59 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id u10sf810908lbd.2 for ; Fri, 21 Nov 2014 05:18:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=N+HNk7nt0XjIgpX0uHAtrQLJyWuEMy2D/5yI7d4g0Tg=; b=Z4aX6upXyn+9SCfOKisK4pIHDD3xq7JyiazX8JE022h01T3s6lSWvz9+QpQlWBzY06 /BJC62eCQA/T4mswQYKIhXveNxjYAiFGuYky4xgt4EOH7Qr3SYgXtPkj3244+QwD8f0B mlPMN8gsiqmz8KqF16xaQ1iNT18bgmKAA3zuxsQTKW1t5ANXHrEYOQ1CKJk4AmIoLtHS NiQSZA68mZ6b1ta4fG3HhnU/z7SPVgqbOnKMdQPL4gJ+EW7MjL2d4MQukhrL3gZCdCGP C/kNsDZyDWqW3EzbD7AfKuY1S1ouDS/4ymHyMoRmKdQ4Yq20TXNHtsNAd/vTQ9+fbk5+ loSw== X-Gm-Message-State: ALoCoQns6Io2/4Ov76pS5dsRHR4wK96ZwtWbMC2LOJMBx9JDhz9OFaAU4GTl+NAUpEoTkgOk2HBf X-Received: by 10.180.102.228 with SMTP id fr4mr1104895wib.1.1416575938399; Fri, 21 Nov 2014 05:18:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.232 with SMTP id m8ls175710laa.45.gmail; Fri, 21 Nov 2014 05:18:58 -0800 (PST) X-Received: by 10.152.204.70 with SMTP id kw6mr3513771lac.85.1416575937998; Fri, 21 Nov 2014 05:18:57 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id m4si5272724laa.107.2014.11.21.05.18.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Nov 2014 05:18:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so4043537lab.8 for ; Fri, 21 Nov 2014 05:18:57 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr4459029lbc.66.1416575937850; Fri, 21 Nov 2014 05:18:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp87193lbc; Fri, 21 Nov 2014 05:18:57 -0800 (PST) X-Received: by 10.224.89.69 with SMTP id d5mr6580945qam.84.1416575936585; Fri, 21 Nov 2014 05:18:56 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id x4si6777275qcn.2.2014.11.21.05.18.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 21 Nov 2014 05:18:56 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xro5P-0007If-Km; Fri, 21 Nov 2014 13:17:19 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xro5O-0007IA-HM for xen-devel@lists.xen.org; Fri, 21 Nov 2014 13:17:18 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id EA/BD-02954-D5B3F645; Fri, 21 Nov 2014 13:17:17 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1416575829!13439228!4 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.12.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4908 invoked from network); 21 Nov 2014 13:17:15 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 21 Nov 2014 13:17:15 -0000 X-IronPort-AV: E=Sophos;i="5.07,431,1413244800"; d="scan'208";a="195229168" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Fri, 21 Nov 2014 08:17:13 -0500 Received: from kazak.uk.xensource.com ([10.80.2.80] helo=zakaz.uk.xensource.com) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1Xro5F-0003Ad-1d; Fri, 21 Nov 2014 13:17:10 +0000 Received: by zakaz.uk.xensource.com (sSMTP sendmail emulation); Fri, 21 Nov 2014 13:17:09 +0000 From: Ian Campbell To: Date: Fri, 21 Nov 2014 13:16:54 +0000 Message-ID: <1416575824-15555-5-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1416505070.26869.2.camel@citrix.com> References: <1416505070.26869.2.camel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH OSSTEST v3 05/15] Osstest/PDU: Add eth008.pm method to control the ARM rack PDU X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: This controls the eth008 relay board: http://www.robot-electronics.co.uk/htm/eth008tech.htm Due to the use of the CGI interface this requires firmware version 4+. Signed-off-by: Ian Campbell --- v3: Use LWP::UserAgent v2: Pass username and password via a netrc file. --- Osstest/PDU/eth008.pm | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Osstest/PDU/eth008.pm diff --git a/Osstest/PDU/eth008.pm b/Osstest/PDU/eth008.pm new file mode 100644 index 0000000..fc5fa96 --- /dev/null +++ b/Osstest/PDU/eth008.pm @@ -0,0 +1,65 @@ +# 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 . + +package Osstest::PDU::eth008; + +use strict; +use warnings; + +use Osstest; +use Osstest::TestSupport; +use LWP::UserAgent; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.00; + @ISA = qw(Exporter); + @EXPORT = qw(); + %EXPORT_TAGS = ( ); + + @EXPORT_OK = qw(); +} + +sub new { + my ($class, $ho, $methname, $pdu, $user, $pass, $port, @opts) = @_; + return bless { Host => $ho, + PDU => $pdu, + User => $user, + Pass => $pass, + Port => $port, + Opts => \@opts }, $class; +} + +sub pdu_power_state { + my ($mo, $on) = @_; + my $op= $on ? "DOA" : "DOI"; # Digital Output (In)Active + + # Use the CGI interface since it is less prone to being firewalled + # off, unlike the standard interface on port 17494. This is only + # available from firmware v4 onwards. + + my $ua = LWP::UserAgent->new; + + $ua->credentials("$mo->{PDU}:80", "Protected", $mo->{User}, $mo->{Pass}); + + my $resp = $ua->get("http://$mo->{PDU}/io.cgi?$op$mo->{Port}=0"); + + die "failed" unless $resp->is_success; + logm($resp->decoded_content); +} + +1;