From 247849065d53cfb03b53482f4faa00d62f2eb4ae Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sun, 16 May 2010 23:03:33 +0000 Subject: [PATCH] -Make persistent UUIDs for KVM guests git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6141 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Schema.pm | 3 ++- perl-xCAT/xCAT/VMCommon.pm | 4 ++++ xCAT-server/lib/xcat/plugins/kvm.pm | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index e744cbcc8..d0ff144e9 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -746,7 +746,7 @@ switch => { }, }, vpd => { - cols => [qw(node serial mtm side asset comments disable)], + cols => [qw(node serial mtm side asset uuid comments disable)], keys => [qw(node)], table_desc => 'The Machine type, Model, and Serial numbers of each node.', descriptions => { @@ -755,6 +755,7 @@ vpd => { mtm => 'The machine type and model number of the node. E.g. 7984-6BU', side => 'The side information for the BPA/FSP', asset => 'A field for administators to use to correlate inventory numbers they may have to accomodate', + uuid => 'The UUID applicable to the node', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", }, diff --git a/perl-xCAT/xCAT/VMCommon.pm b/perl-xCAT/xCAT/VMCommon.pm index 9f712a4b1..bff323e17 100644 --- a/perl-xCAT/xCAT/VMCommon.pm +++ b/perl-xCAT/xCAT/VMCommon.pm @@ -7,6 +7,7 @@ sub grab_table_data{ #grab table data relevent to VM guest nodes my $cfghash = shift; my $callback=shift; my $vmtab = xCAT::Table->new("vm"); + my $vpdtab = xCAT::Table->new("vpd"); my $hmtab = xCAT::Table->new("nodehm"); my $nttab = xCAT::Table->new("nodetype"); my $sitetab = xCAT::Table->new("site"); @@ -21,6 +22,9 @@ sub grab_table_data{ #grab table data relevent to VM guest nodes $callback->({data=>["Cannot open vm table"]}); return; } + if ($vpdtab) { + $cfghash->{vpd} = $vpdtab->getNodesAttribs($noderange,['uuid']); + } $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); diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index eae310c6f..f7170fd8f 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -213,14 +213,18 @@ sub build_diskstruct { } sub getNodeUUID { my $node = shift; + if ($confdata->{vpd}->{$node}->[0] and $confdata->{vpd}->{$node}->[0]->{uuid}) { + return $confdata->{vpd}->{$node}->[0]->{uuid}; + } if ($confdata->{mac}->{$node}->[0]) { #a uuidv1 is possible, generate that for absolute uniqueness guarantee my $mac = ($confdata->{mac}->{$node}->[0]; $mac =~ s/\|.*//; $mac =~ s/!.*//; - return xCAT::Utils::genUUID(mac=>$mac); + $updatetable->{vpd}->{$node}={uuid=>xCAT::Utils::genUUID(mac=>$mac)}; } else { - return xCAT::Utils::genUUID(); + $updatetable->{vpd}->{$node}={uuid=>xCAT::Utils::genUUID()}; } + return $updatetable->{vpd}->{$node}; } sub build_nicstruct {