xcat-core/perl-xCAT/xCAT/VMCommon.pm

37 lines
1.2 KiB
Perl
Raw Normal View History

package xCAT::VMCommon;
use strict;
#Functions common to virtualization management (KVM, Xen, VMware)
sub grab_table_data{ #grab table data relevent to VM guest nodes
my $noderange=shift;
my $cfghash = shift;
my $callback=shift;
my $vmtab = xCAT::Table->new("vm");
my $hmtab = xCAT::Table->new("nodehm");
my $nttab = xCAT::Table->new("nodetype");
if ($hmtab) {
$cfghash->{nodehm} = $hmtab->getNodesAttribs($noderange,['serialspeed']);
}
if ($nttab) {
$cfghash->{nodetype} = $nttab->getNodesAttribs($noderange,['os','arch']); #allow us to guess RTC config
}
unless ($vmtab) {
$callback->({data=>["Cannot open vm table"]});
return;
}
$cfghash->{vm} = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','cfgstore','storage','memory','cpus','nics','bootorder','virtflags']);
my $mactab = xCAT::Table->new("mac",-create=>1);
my $nrtab= xCAT::Table->new("noderes",-create=>1);
$cfghash->{mac} = $mactab->getAllNodeAttribs(['mac'],1);
my $macs;
my $mac;
foreach (keys %{$cfghash->{mac}}) {
$macs=$cfghash->{mac}->{$_}->[0]->{mac};
foreach $mac (split /\|/,$macs) {
$mac =~ s/\!.*//;
$cfghash->{usedmacs}->{lc($mac)}=1;
}
}
}
1;