one common get_tmpl_file_name() function is added into SvrUtils.pm, to replace the same function in anaconada.pm, sles.pm and windows.pm
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4155 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user