diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index de40f3931..7d74d038c 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -603,11 +603,12 @@ notification => { }, }, osimage => { - cols => [qw(imagename profile imagetype provmethod rootfstype osname osvers osdistro osarch synclists postscripts postbootscripts comments disable)], + cols => [qw(imagename groups profile imagetype provmethod rootfstype osname osvers osdistro osarch synclists postscripts postbootscripts comments disable)], keys => [qw(imagename)], table_desc => 'Basic information about an operating system image that can be used to deploy cluster nodes.', descriptions => { imagename => 'The name of this xCAT OS image definition.', + groups => 'A comma-delimited list of groups this image is a member of. Group names are arbitrary.', imagetype => 'The type of operating system image this definition represents (linux,AIX).', provmethod => 'The provisioning method for node deployment. The valid values are install, netboot or statelite. It is not used by AIX.', rootfstype => 'The filesystem type for the rootfs is used when the provmethod is statelite. The valid values are nfs or ramdisk. The default value is nfs', @@ -1967,6 +1968,10 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs); tabentry => 'osimage.imagename', access_tabentry => 'osimage.imagename=attr:imagename', }, + {attr_name => 'groups', + tabentry => 'osimage.groups', + access_tabentry => 'osimage.imagename=attr:imagename', + }, {attr_name => 'imagetype', tabentry => 'osimage.imagetype', access_tabentry => 'osimage.imagename=attr:imagename', diff --git a/xCAT-server/lib/xcat/plugins/imgport.pm b/xCAT-server/lib/xcat/plugins/imgport.pm index 428f66f14..adbfc574d 100644 --- a/xCAT-server/lib/xcat/plugins/imgport.pm +++ b/xCAT-server/lib/xcat/plugins/imgport.pm @@ -605,12 +605,25 @@ sub make_bundle { $callback->({data=>["Getting litefile settings"]}); my @imageInfo; - # get the directories with no names - push @imageInfo, $lftab->getAttribs({image => ''}, ('file','options')); - # get the ALL directories - push @imageInfo, $lftab->getAttribs({image => 'ALL'}, ('file','options')); - # get for the image specific directories - push @imageInfo, $lftab->getAttribs({image => $imagename}, ('file','options')); + my @imagegroupsattr = ('groups'); + # Check if this image contains osimage.groups attribute. + # if so, means user wants to use specific directories to this image. + my $osimagetab = xCAT::Table->new("osimage",-create=>1); + my $imagegroups = $osimagetab->getAttribs({imagename => $imagename}, @imagegroupsattr); + if ($imagegroups and $imagegroups->{groups}) { + # get for the image groups specific directories + push @imageInfo, $lftab->getAttribs({image => $imagegroups->{groups}}, ('file','options')); + # get for the image specific directories + push @imageInfo, $lftab->getAttribs({image => $imagename}, ('file','options')); + } else { + # get the directories with no names + push @imageInfo, $lftab->getAttribs({image => ''}, ('file','options')); + # get the ALL directories + push @imageInfo, $lftab->getAttribs({image => 'ALL'}, ('file','options')); + # get for the image specific directories + push @imageInfo, $lftab->getAttribs({image => $imagename}, ('file','options')); + } + open(FILE,">$tpath/litefile.csv") or die "Could not open $tpath/litefile.csv"; foreach(@imageInfo){ my $file=$_->{file}; diff --git a/xCAT-server/lib/xcat/plugins/litetree.pm b/xCAT-server/lib/xcat/plugins/litetree.pm index c519c15d1..6c7b7c60d 100644 --- a/xCAT-server/lib/xcat/plugins/litetree.pm +++ b/xCAT-server/lib/xcat/plugins/litetree.pm @@ -302,6 +302,7 @@ sub getNodeData { my @imageInfo; my @attrs; + my @imagegroupsattr = ('groups'); if($type eq "dir"){ @attrs = ('priority', 'directory'); }elsif($type =~ /file|image/){ @@ -320,12 +321,23 @@ sub getNodeData { } else { - # get the directories with no names - push @imageInfo, $tab->getAttribs({image => ''}, @attrs); - # get the ALL directories - push @imageInfo, $tab->getAttribs({image => 'ALL'}, @attrs); - # get for the image specific directories - push @imageInfo, $tab->getAttribs({image => $image}, @attrs); + # Check if this image contains osimage.groups attribute. + # if so, means user wants to use specific directories to this image. + my $osimagetab = xCAT::Table->new("osimage",-create=>1); + my $imagegroups = $osimagetab->getAttribs({imagename => $image}, @imagegroupsattr); + if ($imagegroups and $imagegroups->{groups}) { + # get for the image groups specific directories + push @imageInfo, $tab->getAttribs({image => $imagegroups->{groups}}, @attrs); + # get for the image specific directories + push @imageInfo, $tab->getAttribs({image => $image}, @attrs); + } else { + # get the directories with no names + push @imageInfo, $tab->getAttribs({image => ''}, @attrs); + # get the ALL directories + push @imageInfo, $tab->getAttribs({image => 'ALL'}, @attrs); + # get for the image specific directories + push @imageInfo, $tab->getAttribs({image => $image}, @attrs); + } } # pass back a reference to the directory