-Fix Table bug where things that weren't a regex were treated as such
-Add columns to track serial console pointer and rvid pointer in VM table -Clean up Xen rpower, store system serial and video information git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1961 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -15,7 +15,7 @@ package xCAT::Schema; | ||||
| #New format, not sql statements, but info enough to describe xcat tables | ||||
| %tabspec = ( | ||||
| vm => { | ||||
|     cols => [qw(node host migrationdest storage memory cpus nics bootorder virtflags beacon comments disable)], | ||||
|     cols => [qw(node host migrationdest storage memory cpus nics bootorder virtflags vncport textconsole beacon comments disable)], | ||||
|     keys => [qw(node)], | ||||
|     table_desc => 'Virtualization parameters', | ||||
|     descriptions => { | ||||
| @@ -28,6 +28,8 @@ vm => { | ||||
|         'nics' => 'Network configuration parameters', | ||||
|         'bootorder' => 'Boot sequence (i.e. net,hd)', | ||||
|         'virtflags' => 'General flags used by the virtualization method.  For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot', | ||||
|         'vncport' => 'Tracks the current VNC display port (currently not meant to be set', | ||||
|         'textconsole' => 'Tracks the Psuedo-TTY that maps to the serial port or console of a VM', | ||||
|         'beacon' => "This flag is used by xCAT to track the state of the identify LED with respect to the VM." | ||||
|     } | ||||
| }, | ||||
|   | ||||
| @@ -1018,7 +1018,7 @@ sub getNodeAttribs | ||||
|     foreach $attrib (@attribs) | ||||
|     { | ||||
|  | ||||
|         if ($datum->{$attrib} =~ /^\/.*\/.*\//) | ||||
|         if ($datum->{$attrib} =~ /^\/.*\/.*\/$/) | ||||
|         { | ||||
|             my $exp = substr($datum->{$attrib}, 1); | ||||
|             chop $exp; | ||||
|   | ||||
| @@ -57,6 +57,7 @@ my $hyp; | ||||
| my $doreq; | ||||
| my %hyphash; | ||||
| my $node; | ||||
| my $vmtab; | ||||
|  | ||||
| sub waitforack { | ||||
|     my $sock = shift; | ||||
| @@ -156,32 +157,70 @@ sub build_xmldesc { | ||||
|     return XMLout(\%xtree,RootName=>"domain"); | ||||
| } | ||||
|  | ||||
| sub power { | ||||
|     my $subcommand = shift; | ||||
|     my $dom; | ||||
|     if ($subcommand eq 'on') { | ||||
|         my $xml=build_xmldesc($node); | ||||
|         eval { $dom=$hypconn->create_domain($xml); }; | ||||
|     } elsif ($subcommand eq 'off') { | ||||
|         eval { $dom = $hypconn->get_domain_by_name($node); }; | ||||
|         if ($dom) { | ||||
|             $dom->destroy(); | ||||
|         } | ||||
|     } elsif ($subcommand eq 'stat') { | ||||
|         eval { | ||||
|         $dom = $hypconn->get_domain_by_name($node); | ||||
|         }; | ||||
|     } | ||||
| sub refresh_vm { | ||||
|     my $dom = shift; | ||||
|  | ||||
|     my $newxml=XMLin($dom->get_xml_description()); | ||||
|     print Dumper($newxml); | ||||
|     my $vncport=$newxml->{devices}->{graphics}->{port}; | ||||
|     my $stty=$newxml->{devices}->{console}->{tty}; | ||||
|     $vmtab->setNodeAttribs($node,{vncport=>$vncport,textconsole=>$stty}); | ||||
|     print Dumper({vncport=>$vncport,textconsole=>$stty}); | ||||
| } | ||||
|  | ||||
| sub getpowstate { | ||||
|     my $dom = shift; | ||||
|     my $vmstat; | ||||
|     if ($dom) { | ||||
|         $vmstat = $dom->get_info; | ||||
|     } | ||||
|     if ($vmstat and $runningstates{$vmstat->{state}}) { | ||||
|         return (0,"on"); | ||||
|         return "on"; | ||||
|     } else { | ||||
|         return (0,"off"); | ||||
|         return "off"; | ||||
|     } | ||||
| } | ||||
|  | ||||
| sub power { | ||||
|     my $subcommand = shift; | ||||
|     my $retstring; | ||||
|     my $dom; | ||||
|     eval { | ||||
|      $dom = $hypconn->get_domain_by_name($node); | ||||
|     }; | ||||
|     if ($subcommand eq "boot") { | ||||
|         my $currstate=getpowstate($dom); | ||||
|         $retstring=$currstate." "; | ||||
|         if ($currstate eq "off") { | ||||
|             $subcommand="on"; | ||||
|         } elsif ($currstate eq "on") { | ||||
|             $subcommand="reset"; | ||||
|         } | ||||
|     } | ||||
|     if ($subcommand eq 'on') { | ||||
|         unless ($dom) { | ||||
|             my $xml=build_xmldesc($node); | ||||
|             eval { $dom=$hypconn->create_domain($xml); }; | ||||
|             if ($dom) { | ||||
|                 refresh_vm($dom); | ||||
|             } | ||||
|         } | ||||
|     } elsif ($subcommand eq 'off') { | ||||
|         if ($dom) { | ||||
|             $dom->destroy(); | ||||
|         } | ||||
|     } elsif ($subcommand eq 'softoff') { | ||||
|         if ($dom) { | ||||
|             $dom->shutdown(); | ||||
|         } | ||||
|     } else {  | ||||
|         unless ($subcommand =~ /^stat/) { | ||||
|             return (1,"Unsupported power directive '$subcommand'"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     $retstring.=getpowstate($dom); | ||||
|     return (0,$retstring); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -285,7 +324,7 @@ sub adopt { | ||||
| sub grab_table_data{ | ||||
|   my $noderange=shift; | ||||
|   my $callback=shift; | ||||
|   my $vmtab = xCAT::Table->new("vm"); | ||||
|   $vmtab = xCAT::Table->new("vm"); | ||||
|   unless ($vmtab) {  | ||||
|     $callback->({data=>["Cannot open vm table"]}); | ||||
|     return; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user