diff --git a/xCAT-server/lib/perl/xCAT/SvrUtils.pm b/xCAT-server/lib/perl/xCAT/SvrUtils.pm index fd8d81f33..8e864d6cf 100644 --- a/xCAT-server/lib/perl/xCAT/SvrUtils.pm +++ b/xCAT-server/lib/perl/xCAT/SvrUtils.pm @@ -341,5 +341,42 @@ sub getsynclistfile() } +sub get_tmpl_file_name { + my ($searchpath, $profile, $os, $arch, $genos) = @_; + #usally there're only 4 arguments passed for this function + #the $genos is only used for the Redhat family + + my $dotpos = rindex($os, "."); + my $osbase = substr($os, 0, $dotpos); + #handle the following ostypes: sles10.2, sles11.1, rhels5.3, rhels5.4, etc + + if (-r "$searchpath/$profile.$os.$arch.tmpl") { + return "$searchpath/$profile.$os.$arch.tmpl"; + } + elsif (-r "$searchpath/$profile.$osbase.$arch.tmpl") { + return "$searchpath/$profile.$osbase.$arch.tmpl"; + } + elsif (-r "$searchpath/$profile.$genos.$arch.tmpl") { + return "$searchpath/$profile.$genos.$arch.tmpl"; + } + elsif (-r "$searchpath/$profile.$os.tmpl") { + return "$searchpath/$profile.$os.tmpl"; + } + elsif (-r "$searchpath/$profile.$osbase.tmpl") { + return "$searchpath/$profile.$osbase.tmpl"; + } + elsif (-r "$searchpath/$profile.$genos.tmpl") { + return "$searchpath/$profile.$genos.tmpl"; + } + elsif (-r "$searchpath/$profile.$arch.tmpl") { + return "$searchpath/$profile.$arch.tmpl"; + } + elsif (-r "$searchpath/$profile.tmpl") { + return "$searchpath/$profile.tmpl"; + } + else { + return undef; + } +} 1; diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 0636e44bb..efa44d50e 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -462,7 +462,7 @@ sub mkinstall } my $genos = $os; $genos =~ s/\..*//; - if ($genos =~ /rh.s(\d*)/) + if ($genos =~ /rh.*s(\d*)/) { unless (-r "$installroot/custom/install/$platform/$profile.$genos.$arch.tmpl" or -r "/install/custom/install/$platform/$profile.$genos.tmpl" @@ -473,8 +473,8 @@ sub mkinstall } } - my $tmplfile=get_tmpl_file_name("$installroot/custom/install/$platform", $profile, $os, $arch, $genos); - if (! $tmplfile) { $tmplfile=get_tmpl_file_name("$::XCATROOT/share/xcat/install/$platform", $profile, $os, $arch, $genos); } + my $tmplfile=xCAT::SvrUtils::get_tmpl_file_name("$installroot/custom/install/$platform", $profile, $os, $arch, $genos); + if (! $tmplfile) { $tmplfile=xCAT::SvrUtils::get_tmpl_file_name("$::XCATROOT/share/xcat/install/$platform", $profile, $os, $arch, $genos); } unless ( -r "$tmplfile") { $callback->( @@ -852,34 +852,34 @@ sub copycd } } -sub get_tmpl_file_name { - my $base=shift; - my $profile=shift; - my $os=shift; - my $arch=shift; - my $genos=shift; - - if (-r "$base/$profile.$os.$arch.tmpl") { - return "$base/$profile.$os.$arch.tmpl"; - } - elsif (-r "$base/$profile.$genos.$arch.tmpl") { - return "$base/$profile.$genos.$arch.tmpl"; - } - elsif (-r "$base/$profile.$arch.tmpl") { - return "$base/$profile.$arch.tmpl"; - } - elsif ( -r "$base/$profile.$os.tmpl") { - return "$base/$profile.$os.tmpl"; - } - elsif (-r "$base/$profile.$genos.tmpl") { - return "$base/$profile.$genos.tmpl"; - } - elsif (-r "$base/$profile.tmpl") { - return "$base/$profile.tmpl"; - } - - return ""; -} +#sub get_tmpl_file_name { +# my $base=shift; +# my $profile=shift; +# my $os=shift; +# my $arch=shift; +# my $genos=shift; +# +# if (-r "$base/$profile.$os.$arch.tmpl") { +# return "$base/$profile.$os.$arch.tmpl"; +# } +# elsif (-r "$base/$profile.$genos.$arch.tmpl") { +# return "$base/$profile.$genos.$arch.tmpl"; +# } +# elsif (-r "$base/$profile.$arch.tmpl") { +# return "$base/$profile.$arch.tmpl"; +# } +# elsif ( -r "$base/$profile.$os.tmpl") { +# return "$base/$profile.$os.tmpl"; +# } +# elsif (-r "$base/$profile.$genos.tmpl") { +# return "$base/$profile.$genos.tmpl"; +# } +# elsif (-r "$base/$profile.tmpl") { +# return "$base/$profile.tmpl"; +# } +# +# return ""; +#} 1; diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index e2a1566af..b3df291f1 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -10,6 +10,7 @@ use Sys::Syslog; use File::Temp qw/tempdir/; use xCAT::Table; use xCAT::Utils; +use xCAT::SvrUtils; use xCAT::MsgUtils; use Data::Dumper; use Getopt::Long; @@ -272,8 +273,8 @@ sub mkinstall my $os = $ent->{os}; my $arch = $ent->{arch}; my $profile = $ent->{profile}; - my $tmplfile=get_tmpl_file_name("/install/custom/install/sles", $profile, $os, $arch); - if (! $tmplfile) { $tmplfile=get_tmpl_file_name("$::XCATROOT/share/xcat/install/sles", $profile, $os, $arch); } + my $tmplfile=xCAT::SvrUtils::get_tmpl_file_name("/install/custom/install/sles", $profile, $os, $arch); + if (! $tmplfile) { $tmplfile=xCAT::SvrUtils::get_tmpl_file_name("$::XCATROOT/share/xcat/install/sles", $profile, $os, $arch); } unless ( -r "$tmplfile") { $callback->( @@ -729,25 +730,25 @@ sub copycd } } -sub get_tmpl_file_name { - my $base=shift; - my $profile=shift; - my $os=shift; - my $arch=shift; - if (-r "$base/$profile.$os.$arch.tmpl") { - return "$base/$profile.$os.$arch.tmpl"; - } - elsif (-r "$base/$profile.$os.tmpl") { - return "$base/$profile.$os.tmpl"; - } - elsif (-r "$base/$profile.$arch.tmpl") { - return "$base/$profile.$arch.tmpl"; - } - elsif (-r "$base/$profile.tmpl") { - return "$base/$profile.tmpl"; - } - - return ""; -} +#sub get_tmpl_file_name { +# my $base=shift; +# my $profile=shift; +# my $os=shift; +# my $arch=shift; +# if (-r "$base/$profile.$os.$arch.tmpl") { +# return "$base/$profile.$os.$arch.tmpl"; +# } +# elsif (-r "$base/$profile.$os.tmpl") { +# return "$base/$profile.$os.tmpl"; +# } +# elsif (-r "$base/$profile.$arch.tmpl") { +# return "$base/$profile.$arch.tmpl"; +# } +# elsif (-r "$base/$profile.tmpl") { +# return "$base/$profile.tmpl"; +# } +# +# return ""; +#} 1; diff --git a/xCAT-server/lib/xcat/plugins/windows.pm b/xCAT-server/lib/xcat/plugins/windows.pm index 375b7e5fd..6c4c85d9d 100644 --- a/xCAT-server/lib/xcat/plugins/windows.pm +++ b/xCAT-server/lib/xcat/plugins/windows.pm @@ -10,6 +10,7 @@ use Sys::Syslog; use File::Temp qw/tempdir/; use xCAT::Table; use xCAT::Utils; +use xCAT::SvrUtils; use Socket; use xCAT::MsgUtils; use Data::Dumper; @@ -245,8 +246,8 @@ sub mkinstall next; } - my $tmplfile=get_tmpl_file_name("$installroot/custom/install/windows", $profile, $os, $arch); - if (! $tmplfile) { $tmplfile=get_tmpl_file_name("$::XCATROOT/share/xcat/install/windows", $profile, $os, $arch); } + my $tmplfile=xCAT::SvrUtils::get_tmpl_file_name("$installroot/custom/install/windows", $profile, $os, $arch); + if (! $tmplfile) { $tmplfile=xCAT::SvrUtils::get_tmpl_file_name("$::XCATROOT/share/xcat/install/windows", $profile, $os, $arch); } unless ( -r "$tmplfile") { $callback->( @@ -493,28 +494,26 @@ sub copycd } } -sub get_tmpl_file_name { - my $base=shift; - my $profile=shift; - my $os=shift; - my $arch=shift; - if (-r "$base/$profile.$os.$arch.tmpl") { - return "$base/$profile.$os.$arch.tmpl"; - } - elsif (-r "$base/$profile.$arch.tmpl") { - return "$base/$profile.$arch.tmpl"; - } - elsif (-r "$base/$profile.$os.tmpl") { - return "$base/$profile.$os.tmpl"; - } - elsif (-r "$base/$profile.tmpl") { - return "$base/$profile.tmpl"; - } - - return ""; -} - - +#sub get_tmpl_file_name { +# my $base=shift; +# my $profile=shift; +# my $os=shift; +# my $arch=shift; +# if (-r "$base/$profile.$os.$arch.tmpl") { +# return "$base/$profile.$os.$arch.tmpl"; +# } +# elsif (-r "$base/$profile.$arch.tmpl") { +# return "$base/$profile.$arch.tmpl"; +# } +# elsif (-r "$base/$profile.$os.tmpl") { +# return "$base/$profile.$os.tmpl"; +# } +# elsif (-r "$base/$profile.tmpl") { +# return "$base/$profile.tmpl"; +# } +# +# return ""; +#} 1;