From 6876e7bb3a890becb143d9d5cd8e971444c99cdf Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sat, 14 Mar 2009 00:40:38 +0000 Subject: [PATCH] -Inform ssh of the batch nature of via in VM wvid -symlink xen to kvm wvid method -Add conserver backend for kvm git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2894 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/share/xcat/rvid/rvid.kvm | 1 + xCAT-client/share/xcat/rvid/rvid.xen | 1 + xCAT-server/share/xcat/cons/kvm | 88 ++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 120000 xCAT-client/share/xcat/rvid/rvid.kvm create mode 100755 xCAT-server/share/xcat/cons/kvm diff --git a/xCAT-client/share/xcat/rvid/rvid.kvm b/xCAT-client/share/xcat/rvid/rvid.kvm new file mode 120000 index 000000000..feb274c70 --- /dev/null +++ b/xCAT-client/share/xcat/rvid/rvid.kvm @@ -0,0 +1 @@ +rvid.xen \ No newline at end of file diff --git a/xCAT-client/share/xcat/rvid/rvid.xen b/xCAT-client/share/xcat/rvid/rvid.xen index 704520282..936770d20 100755 --- a/xCAT-client/share/xcat/rvid/rvid.xen +++ b/xCAT-client/share/xcat/rvid/rvid.xen @@ -2,4 +2,5 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html myport=${rvid_vncdisplay#*:} let myport=myport-5900; +export VNC_VIA_CMD='/usr/bin/ssh -o BatchMode=yes -f -L "$L":"$H":"$R" "$G" sleep 20' vncviewer :$myport -via $rvid_server >& /dev/null diff --git a/xCAT-server/share/xcat/cons/kvm b/xCAT-server/share/xcat/cons/kvm new file mode 100755 index 000000000..2f99c8a7d --- /dev/null +++ b/xCAT-server/share/xcat/cons/kvm @@ -0,0 +1,88 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +use Fcntl qw(:DEFAULT :flock); +sub get_lock { + unless (flock(LOCKHANDLE,LOCK_EX|LOCK_NB)) { + $| = 1; + print "Acquiring startup lock..."; + flock(LOCKHANDLE,LOCK_EX) or die "Fatal error securing startup lock"; + print "done\n"; + } + truncate(LOCKHANDLE,0); + print LOCKHANDLE $$."\n"; +} + +sub release_lock { + truncate(LOCKHANDLE,0); + flock(LOCKHANDLE,LOCK_UN); +} +BEGIN +{ + use Time::HiRes qw(sleep); + use File::Path; + use Fcntl qw(:DEFAULT :flock); + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; + umask 0077; + mkpath("/tmp/xcat/"); + unless (sysopen(LOCKHANDLE,"/tmp/xcat/consolelock",O_WRONLY | O_CREAT)) { + sleep 15; + print "Unable to open lock file"; + exit 0; + } + get_lock(); + #my $sleepint=int(rand(10)); + #print "Opening console in ".(2+(0.5*$sleepint))." seconds...\n"; + #sleep $sleepint; +} +#BEGIN +#{ +# use Time::HiRes qw(sleep); +# $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +# my $sleepint=int(rand(10)); +# print "Opening console in ".(0.5*$sleepint)." seconds...\n"; +# sleep (0.5*$sleepint); +#} +my $sleepint; +use lib "$::XCATROOT/lib/perl"; +$ENV{HOME}='/root/'; +require xCAT::Client; + +require File::Basename; +import File::Basename; +my $scriptname = $0; + +my $cmdref={ + command=>"getcons", + arg=>"text", + noderange=>$ARGV[0] +}; +use Data::Dumper; +my $dsthost; +my $dstty; +my $speed; +sub getans { + my $rsp = shift; + if ($rsp->{node}) { + $dsthost = $rsp->{node}->[0]->{sshhost}->[0]; + $dstty = $rsp->{node}->[0]->{psuedotty}->[0]; + $speed = $rsp->{node}->[0]->{baudrate}->[0]; + } +} +xCAT::Client::submit_request($cmdref,\&getans); +until ($dsthost and $speed and $dstty) { + release_lock(); + $sleepint=int(rand(30))+60; + print "Console not ready, retrying in $sleepint seconds (Ctrl-e,c,o to skip delay)\n"; + sleep $sleepint; + get_lock(); + xCAT::Client::submit_request($cmdref,\&getans); +} +release_lock(); +exec "ssh -t $dsthost screen -U -a -O -e ^]a -d -R -S serial-".$ARGV[0]."-cons -A $dstty $speed"; + +#my $pathtochild= dirname($scriptname). "/"; +#exec $pathtochild."blade.expect $mm $slot $username $password"; + + + +