From 9500ff045ad47512aa26df423223ed34876ed770 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 16 Jan 2009 14:04:56 +0000 Subject: [PATCH] -Have rpower reset on Xen act more like a baremetal server git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2618 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/xen.pm | 34 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/xen.pm b/xCAT-server/lib/xcat/plugins/xen.pm index accd38b88..7a7ed58c9 100644 --- a/xCAT-server/lib/xcat/plugins/xen.pm +++ b/xCAT-server/lib/xcat/plugins/xen.pm @@ -400,6 +400,22 @@ sub getpowstate { } } +sub makedom { + my $node=shift; + my $dom; + my $xml=build_xmldesc($node); + my $errstr; + eval { $dom=$hypconn->create_domain($xml); }; + if ($@) { $errstr = $@; } + if (ref $errstr) { + $errstr = ":".$errstr->{message}; + } + if ($errstr) { return (undef,$errstr); } + if ($dom) { + refresh_vm($dom); + } + return $dom; +} sub power { @@ -418,20 +434,11 @@ sub power { $subcommand="reset"; } } + my $errstr; if ($subcommand eq 'on') { unless ($dom) { - my $xml=build_xmldesc($node); - my $errstr; - eval { $dom=$hypconn->create_domain($xml); }; - - if ($@) { $errstr = $@; } - if (ref $errstr) { - $errstr = ":".$errstr->{message}; - } + $dom,$errstr = makedom($node); if ($errstr) { return (1,$errstr); } - if ($dom) { - refresh_vm($dom); - } } else { $retstring .= " $status_noop"; } @@ -445,8 +452,9 @@ sub power { } else { $retstring .= " $status_noop"; } } elsif ($subcommand eq 'reset') { if ($dom) { - $dom->reboot(1); #TODO: Sys::Virt *nor* libvirt have meaningful flags, - #but require it + $dom->destroy(); + $dom = makedom($node); + if ($errstr) { return (1,$errstr); } $retstring.="reset"; } else { $retstring .= " $status_noop"; } } else {