From patchwork Wed Oct 29 10:41:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 39752 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E64BE24029 for ; Wed, 29 Oct 2014 10:42:54 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf1523878lam.0 for ; Wed, 29 Oct 2014 03:42:53 -0700 (PDT) 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:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=G6ieaXF5rAerBfVQlJjsCrN9FzzykKYNaiBtvpULB20=; b=kykf0Ip77VFACq8eZamhuWr2ev2PQuPr51AnwxOnnPsjjRS1NHd73iDB02/uzmJtZK uBLGoQGNhpETIKkcy5Yi2Ct/UJXsCnjRnC9HD4WrnpBIulH/cifBGib8on0OYebJII9S XAGN/hVmL9IktaGn70oXnmYGLxOkPLAl0/pewhKgUkj8npDE2rAxCV0lntUGZULQM+xS vLdUXfHa1hfRVBv2seYBQ/Prk1xfC2QH73l50dlkk812f7fNQbzcnHpxXCaLUR5l/uPg yn2HWdEDKHYpWHYopIz8QN0VMKyv+uNxyon2l2Mm+MbpqPIer7IRiU+HWKW9pX+v+vrm TdoQ== X-Gm-Message-State: ALoCoQnaDrPDF2SeyyudvsY27eWUBOvK0gAU7+Mwc32ub0C3+/Q4PPmvHP0LJhJzYMvRwWPuQTaD X-Received: by 10.180.186.142 with SMTP id fk14mr5988958wic.4.1414579373779; Wed, 29 Oct 2014 03:42:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.226 with SMTP id b2ls168266lak.36.gmail; Wed, 29 Oct 2014 03:42:53 -0700 (PDT) X-Received: by 10.112.170.99 with SMTP id al3mr9014488lbc.17.1414579373619; Wed, 29 Oct 2014 03:42:53 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id j6si734619laa.71.2014.10.29.03.42.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 03:42:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id z11so231693lbi.19 for ; Wed, 29 Oct 2014 03:42:53 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr10280040laz.27.1414579373505; Wed, 29 Oct 2014 03:42:53 -0700 (PDT) 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.84.229 with SMTP id c5csp633475lbz; Wed, 29 Oct 2014 03:42:52 -0700 (PDT) X-Received: by 10.140.40.239 with SMTP id x102mr13363735qgx.69.1414579369774; Wed, 29 Oct 2014 03:42:49 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id c50si6681723qgc.116.2014.10.29.03.42.49 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 29 Oct 2014 03:42:49 -0700 (PDT) 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 1XjQhS-0002Q4-Qh; Wed, 29 Oct 2014 10:41:58 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XjQhR-0002NS-8i for xen-devel@lists.xen.org; Wed, 29 Oct 2014 10:41:57 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 50/E4-02952-474C0545; Wed, 29 Oct 2014 10:41:56 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1414579313!13416260!2 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.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28916 invoked from network); 29 Oct 2014 10:41:55 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 29 Oct 2014 10:41:55 -0000 X-IronPort-AV: E=Sophos;i="5.04,809,1406592000"; d="scan'208";a="187318376" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Wed, 29 Oct 2014 06:41:54 -0400 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 1XjQhN-00014k-JT; Wed, 29 Oct 2014 10:41:54 +0000 Received: by zakaz.uk.xensource.com (sSMTP sendmail emulation); Wed, 29 Oct 2014 10:41:53 +0000 From: Ian Campbell To: Date: Wed, 29 Oct 2014 10:41:33 +0000 Message-ID: <1414579302-6692-11-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1414579268.29975.13.camel@citrix.com> References: <1414579268.29975.13.camel@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH OSSTEST v2 11/20] 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.217.174 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 --- v2: Pass username and password via a netrc file. --- Osstest/PDU/eth008.pm | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 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..f56cfa0 --- /dev/null +++ b/Osstest/PDU/eth008.pm @@ -0,0 +1,73 @@ +# 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 IO::File; +use File::Temp qw/ tempfile /; + +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. + + # Create a netrc file to avoid putting l/p on command line + my ($passfh, $passfilename) = tempfile( UNLINK => 1 ); + print $passfh "machine $mo->{PDU} login $mo->{User} password $mo->{Pass}\n"; + + my $url = "http://$mo->{PDU}/io.cgi?$op$mo->{Port}=0"; + my $cmd = "curl --silent --netrc --netrc-file $passfilename $url"; + + logm("$cmd"); + open CURL, "$cmd |" or die "fork curl: $!"; + + my $result = ; + close CURL or die "result curl: $!"; + + logm("$result"); + die "curl failed" unless $result =~ /^Success! \d+/; +} + +1;