-More careful treatment of migration to provide more accurate failure descriptions

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2690 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2009-02-01 00:23:52 +00:00
parent b9f440262f
commit afefaa419a
2 changed files with 69 additions and 16 deletions

View File

@ -19,6 +19,8 @@ use Storable qw(store_fd retrieve_fd thaw freeze);
use xCAT::Utils;
use xCAT::Usage;
use Thread qw(yield);
use LWP 5.64;
use HTTP::Request::Common;
my $tfactor = 0;
my $vpdhash;
my %bmc_comm_pids;
@ -41,6 +43,7 @@ sub handled_commands {
rbeacon => 'nodehm:mgt',
reventlog => 'nodehm:mgt',
rfrurewrite => 'nodehm:mgt',
getrvidparms => 'nodehm:mgt'
}
}
@ -70,6 +73,7 @@ my $currnode; #string to describe current node, presumably nodename
my $globrc=0;
my $userid;
my $passwd;
my $ipmi_bmcipaddr;
my $timeout;
my $port;
my $debug;
@ -473,11 +477,11 @@ sub ipmicmd {
$text = "failed to get IP for $node";
return(2,$text);
}
my $nodeip = inet_ntoa($packed_ip);
$ipmi_bmcipaddr=inet_ntoa($packed_ip);
$sock = IO::Socket::INET->new(
Proto => 'udp',
PeerHost => $nodeip,
PeerHost => $ipmi_bmcipaddr,
PeerPort => $port,
);
if(!defined($sock)) {
@ -596,6 +600,9 @@ sub ipmicmd {
elsif($command eq "rbeacon") {
($rc,$text) = beacon($subcommand);
}
elsif($command eq "getrvidparms") {
($rc,@output) = getrvidparms($subcommand);
}
# elsif($command eq "info") {
# if($subcommand eq "sensorname") {
# ($rc,$text) = initsdr();
@ -1259,6 +1266,41 @@ sub idpxthermprofile {
}
sub getrvidparms {
my $netfun = 0x3a;
my @mcinfo=getdevid();
unless ($mcinfo[2] == 2) { #Only implemented for IBM servers
return(1,"Remote video is not supported on this system");
}
#TODO: use get bmc capabilities to see if rvid is actually supported before bothering the client java app
my @build_id;
my $localerror = docmd(
0xe8,
[0x50],
\@build_id
);
if ($localerror) {
return(1,$localerror);
}
@build_id=splice @build_id,36-$authoffset;
unless ($build_id[1]==0x79 and $build_id[2]==0x75 and $build_id[3]==0x6f and $build_id[4]==0x6f) { #Only know how to cope with yuoo builds
return(1,"Remote video is not supported on this system");
}
#wvid should be a possiblity, time to do the http...
my $browser = LWP::UserAgent->new();
my $message = "$userid,$passwd";
$browser->cookie_jar({});
my $baseurl = "http://".$ipmi_bmcipaddr."/";
my $response = $browser->request(POST $baseurl."/session/create",'Content-Type'=>"text/xml",Content=>$message);
unless ($response->content eq "ok") {
return (1,"Server returned unexpected data");
}
$response = $browser->request(GET $baseurl."/kvm/kvm/jnlp");
return (0,"method:imm","jnlp:".$response->content);
}
sub power {
my $subcommand = shift;

View File

@ -356,6 +356,9 @@ sub migrate {
unless ($targ) {
$targ = pick_target($node);
}
unless ($targ) {
return (1,"Unable to identify a suitable target host for guest $node");
}
my $prevhyp;
my $target = "xen+ssh://".$targ."?no_tty=1";
my $currhyp="xen+ssh://";
@ -369,6 +372,13 @@ sub migrate {
if ($currhyp eq $target) {
return (0,"Guest is already on host $targ");
}
my $testhypconn;
eval {#Contain Sys::Virt bugs
$testhypconn= Sys::Virt->new(uri=>"xen+ssh://".$prevhyp."?no_tty=1");
};
unless ($testhypconn) {
return (1,"Unable to reach $prevhyp to perform operation of $node, use nodech to change vm.host if certain of no split-brain possibility exists");
}
my $sock = IO::Socket::INET->new(Proto=>'udp');
my $ipa=inet_aton($node);
my $pa=sockaddr_in(7,$ipa); #UDP echo service, not needed to be actually
@ -376,24 +386,25 @@ sub migrate {
my $rc=system("virsh -c $currhyp migrate --live $node $target");
system("arp -d $node"); #Make ethernet fabric take note of change
send($sock,"dummy",0,$pa); #UDP packet to force forwarding table update in switches, ideally a garp happened, but just in case...
my $newhypconn;
eval {#Contain Sys::Virt bugs
$newhypconn= Sys::Virt->new(uri=>"xen+ssh://".$targ."?no_tty=1");
};
unless ($newhypconn) {
return (1,"Failed migration from $prevhyp to $targ (VM destination unreachable)");
}
my $dom;
eval {
$dom = $newhypconn->get_domain_by_name($node);
};
if ($dom) {
refresh_vm($dom);
}
if ($rc) {
return (1,"Failed migration from $prevhyp to $targ");
} else {
$vmtab->setNodeAttribs($node,{host=>$targ});
my $newhypconn;
eval {#Contain Sys::Virt bugs
$newhypconn= Sys::Virt->new(uri=>"xen+ssh://".$targ."?no_tty=1");
};
if ($newhypconn) {
my $dom;
eval {
$dom = $newhypconn->get_domain_by_name($node);
};
if ($dom) {
refresh_vm($dom);
}
} else {
return (0,"migrated to $targ");
}
return (0,"migrated to $targ");
}
}