From: Ian Jackson Subject: [OSSTEST PATCH 05/32] mg-hosts: Provide new "power" subcommand Date: Tue, 24 Mar 2015 19:02:28 +0000 Message-ID: <1427223775-8592-6-git-send-email-ian.jackson@eu.citrix.com> References: <1427223775-8592-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YaU76-0000uz-Ab for xen-devel@lists.xenproject.org; Tue, 24 Mar 2015 19:03:44 +0000 In-Reply-To: <1427223775-8592-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Signed-off-by: Ian Jackson --- mg-hosts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mg-hosts b/mg-hosts index a6f6e6e..6ec8d56 100755 --- a/mg-hosts +++ b/mg-hosts @@ -122,6 +122,19 @@ END } } +sub cmd_power () { + die unless @ARGV==2; + my ($host,$power) = @ARGV; + $_ = $power; + $power = m/^1|^on/ ? 1 : m/^0|^off/ ? 0 : m/^r|^c/ ? -1 : die; + my $ho= selecthost("host=$host"); + if ($power >= 0) { + power_state($ho, $power); + } else { + power_cycle($ho); + } +} + sub cmd_create_like () { die unless @ARGV==2; my ($src,$dsts) = @ARGV; -- 1.7.10.4