-Add Xen console method
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1969 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -16,6 +16,7 @@ use strict;
 | 
			
		||||
#use warnings;
 | 
			
		||||
my %vm_comm_pids;
 | 
			
		||||
my $vmhash;
 | 
			
		||||
my $hmhash;
 | 
			
		||||
 | 
			
		||||
use XML::Simple;
 | 
			
		||||
if ($^O =~ /^linux/i) {
 | 
			
		||||
@@ -61,6 +62,7 @@ my $hyp;
 | 
			
		||||
my $doreq;
 | 
			
		||||
my %hyphash;
 | 
			
		||||
my $node;
 | 
			
		||||
my $hmtab;
 | 
			
		||||
my $vmtab;
 | 
			
		||||
 | 
			
		||||
sub waitforack {
 | 
			
		||||
@@ -183,10 +185,14 @@ sub getvmcons {
 | 
			
		||||
    }
 | 
			
		||||
    my $consdata=refresh_vm($dom);
 | 
			
		||||
    my $hyper=$vmhash->{$node}->[0]->{host};
 | 
			
		||||
 | 
			
		||||
    if ($type eq "text") {
 | 
			
		||||
        return (0,'tty@'.$hyper.": ".$consdata->{textconsole});
 | 
			
		||||
        my $serialspeed;
 | 
			
		||||
        if ($hmhash) {
 | 
			
		||||
            $serialspeed=$hmhash->{$node}->[0]->{serialspeed};
 | 
			
		||||
        }
 | 
			
		||||
        return (0,'tty@'.$hyper.": ".$consdata->{textconsole}."@".$serialspeed);
 | 
			
		||||
    } elsif ($type eq "vnc") {
 | 
			
		||||
        print Dumper($consdata);
 | 
			
		||||
        return (0,'ssh+vnc@'.$hyper.": ".$consdata->{vncport});
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -391,6 +397,10 @@ sub grab_table_data{
 | 
			
		||||
  my $noderange=shift;
 | 
			
		||||
  my $callback=shift;
 | 
			
		||||
  $vmtab = xCAT::Table->new("vm");
 | 
			
		||||
  $hmtab = xCAT::Table->new("nodehm");
 | 
			
		||||
  if ($hmtab) {
 | 
			
		||||
      $hmhash  = $hmtab->getNodesAttribs($noderange,['serialspeed']);
 | 
			
		||||
  }
 | 
			
		||||
  unless ($vmtab) { 
 | 
			
		||||
    $callback->({data=>["Cannot open vm table"]});
 | 
			
		||||
    return;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										48
									
								
								xCAT-server/share/xcat/cons/xen
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										48
									
								
								xCAT-server/share/xcat/cons/xen
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
#!/usr/bin/env perl
 | 
			
		||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
 | 
			
		||||
BEGIN
 | 
			
		||||
{
 | 
			
		||||
    use Time::HiRes qw(sleep);
 | 
			
		||||
    $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
 | 
			
		||||
    my $sleepint=int(rand(10));
 | 
			
		||||
    print "Opening console in ".(2+(0.5*$sleepint))." seconds...\n";
 | 
			
		||||
    #sleep $sleepint;
 | 
			
		||||
}
 | 
			
		||||
use lib "$::XCATROOT/lib/perl";
 | 
			
		||||
require xCAT::Client;
 | 
			
		||||
 | 
			
		||||
require File::Basename;
 | 
			
		||||
import File::Basename;
 | 
			
		||||
my $scriptname = $0;
 | 
			
		||||
 | 
			
		||||
my $cmdref={
 | 
			
		||||
    command=>"getvmcons",
 | 
			
		||||
    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]->{data}->[0]->{desc}->[0];
 | 
			
		||||
        $dsthost=~s/.*@//;
 | 
			
		||||
        $dstty = $rsp->{node}->[0]->{data}->[0]->{contents}->[0];
 | 
			
		||||
        $speed=$dstty;
 | 
			
		||||
        print $speed;
 | 
			
		||||
        $dstty =~ s/@.*$//;
 | 
			
		||||
        $speed =~ s/^.*@//;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
xCAT::Client::submit_request($cmdref,\&getans);
 | 
			
		||||
print "$dsthost $speed $dstty\n";
 | 
			
		||||
exec "ssh -t $dsthost cu -s $speed -l $dstty";
 | 
			
		||||
 | 
			
		||||
#my $pathtochild= dirname($scriptname). "/";
 | 
			
		||||
#exec $pathtochild."blade.expect $mm $slot $username $password";
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user