Class: PackerFiles::Ubuntu::Mirrors
- Inherits:
-
Object
- Object
- PackerFiles::Ubuntu::Mirrors
- Defined in:
- lib/PackerFiles/OS/Ubuntu/Mirrors.rb
Constant Summary collapse
- @@default =
default ubuntu mirror
'http://archive.ubuntu.com/ubuntu'
- @@mirrors =
Default ubuntu mirror list for any country.
'http://mirrors.ubuntu.com/@[email protected]'
- @@master =
Default Master archive mirror list
'https://launchpad.net/ubuntu/+archivemirrors'
Instance Attribute Summary collapse
-
#best ⇒ Object
readonly
Returns the value of attribute best.
-
#hosts ⇒ Object
readonly
accessors.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
Instance Method Summary collapse
-
#initialize ⇒ Mirrors
constructor
Constructor.
Constructor Details
#initialize ⇒ Mirrors
Constructor
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/PackerFiles/OS/Ubuntu/Mirrors.rb', line 29 def initialize # A Single web page get more than this (in seconds) is SLOW limit = 1 # No. of trials for a web page trials = 4 # Get the name of the http proxy @proxy = ENV['http_proxy'] # Get the host list of mirrors for this country code = Utils::AutoZone.new.country_code.upcase @hosts = country_mirror(code) if @hosts.empty? @hosts = [@@default] if @hosts.empty? @best = URI::parse(@@default) else @hosts = filter_status_unknown.compact f = Utils::FastestURL.new(limit, trials) all = f.best_urls(@hosts).flatten begin @best = URI::parse(all.first) rescue Exception => e puts "Exception: #{e}, All: #{all.to_s}" raise e end end end |
Instance Attribute Details
#best ⇒ Object (readonly)
Returns the value of attribute best.
25 26 27 |
# File 'lib/PackerFiles/OS/Ubuntu/Mirrors.rb', line 25 def best @best end |
#hosts ⇒ Object (readonly)
accessors
24 25 26 |
# File 'lib/PackerFiles/OS/Ubuntu/Mirrors.rb', line 24 def hosts @hosts end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
26 27 28 |
# File 'lib/PackerFiles/OS/Ubuntu/Mirrors.rb', line 26 def proxy @proxy end |