class PackerFiles::CentOS::CD
Public Instance Methods
get_check_sum_pattern()
click to toggle source
Override method for getting checksums
# File lib/PackerFiles/OS/CentOS/CD.rb, line 22 def get_check_sum_pattern 'md5sum.txt' end
get_check_sum_type()
click to toggle source
Override method for checksum type
# File lib/PackerFiles/OS/CentOS/CD.rb, line 27 def get_check_sum_type 'md5' end
get_iso_name_pattern()
click to toggle source
Override method for getting the ISO name
# File lib/PackerFiles/OS/CentOS/CD.rb, line 17 def get_iso_name_pattern 'CentOS-@release@.*-@arch@.*-DVD1.*.iso' end
index_urls()
click to toggle source
Override method for getting index URLs.
# File lib/PackerFiles/OS/CentOS/CD.rb, line 32 def index_urls mirrors = get_mirrors geo = get_matched_mirror_lines(mirrors) http = geo.map{|m| m[4].gsub('"', '')} http.map{|m| URI::join(m, '@release@/', 'isos/', '@arch@/').to_s} end
Private Instance Methods
get_matched_mirror_lines(mirrors)
click to toggle source
Get matched mirror entries, given a country code and region code
# File lib/PackerFiles/OS/CentOS/CD.rb, line 50 def get_matched_mirror_lines(mirrors) json = Utils::AutoZone.new.JSON country_code = json['country_code'] country_name = json['country'] region_code = json['region_code'] # Check if country code matches and if it does, then try to # match region code as well. cc = mirrors.select {|m| m[0] == '"' + country_code + '"'} if !cc.empty? region = cc.select {|m| m[1] == '"' + region_code + '"'} return region if !region.empty? return cc end # Country code does not match. Try matching country name cn = mirrors.select {|m| m[1] == '"' + country_name + '"'} return cn if !cn.empty? # OK. even that is not working. Let us try matching country name # on the first element cp = mirrors.select {|m| m[0] == '"' + country_name + '"'} if cp.empty? raise Core::EmptyArrayException.new('No Mirror for CentOS?') else return cp end end
get_mirrors()
click to toggle source
Read the full mirror list CSV file and convert it into a searchable array.
# File lib/PackerFiles/OS/CentOS/CD.rb, line 42 def get_mirrors content = open(@@index) {|f| f.read} top_arr = content.split("\n") top_arr.map {|line| line.split(",")} end