From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: [PATCH OSSTEST] PDU/xenuse: Support xenuse on machine not locked by current user Date: Wed, 16 Oct 2013 16:58:30 +0100 Message-ID: <1381939110-30213-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: ian.jackson@eu.citrix.com Cc: Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org xenuse checks that whoever is trying to reboot a machine "owns" that machine via a locking mechanism. This is usually fine doesn't work well when one wants to book a machine out of the osstest pool for adhoc testing. In this case machine ownership is maintained by osstest ahd the machine remains locked to osstest as far as xenuse is concerned. Therefore add a global configuration option and perhost override to override $USER (which xenuse obeys) to osstest. I used eval + save/restore the original user so as not to pollute the whole process, it might have been better to actually fork? --- Osstest/PDU/xenuse.pm | 16 ++++++++++++++-- production-config | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Osstest/PDU/xenuse.pm b/Osstest/PDU/xenuse.pm index 73a542d..da966e3 100644 --- a/Osstest/PDU/xenuse.pm +++ b/Osstest/PDU/xenuse.pm @@ -44,8 +44,20 @@ sub pdu_power_state { my ($mo, $on) = @_; my $onoff= $on ? "on" : "off"; my $xenuse= $c{XenUsePath} || "xenuse"; - - system_checked($xenuse, "--$onoff", "$mo->{Host}{Name}"); + my $user= $c{XenUseUser} || undef; + $user= get_host_property($mo->{Host}, "XenUseUser", $user); + + my $saved_user = $ENV{USER} if $user; + eval { + if ($user) { + logm("XenUse overriding \$USER to $user"); + $ENV{USER} = $user; + } + + system_checked($xenuse, "--$onoff", "$mo->{Host}{Name}"); + }; + $ENV{USER} = $saved_user if $user; + die $@ if $@; } 1; diff --git a/production-config b/production-config index de9e55c..fb9d750 100644 --- a/production-config +++ b/production-config @@ -75,6 +75,7 @@ TftpPxeGroup osstest TftpDiVersion 2013-09-23 XenUsePath /usr/groups/xencore/systems/bin/xenuse +XenUseUser osstest # We use the IP address because Citrix can't manage reliable nameservice #DebianMirrorHost debian.uk.xensource.com -- 1.7.10.4