Browse Source

Merge "Support a "mirror" method of apt-get"

changes/24/446524/12
Jenkins 2 years ago
parent
commit
9995f60d10

+ 10
- 9
deployment/puppet/osnailyfacter/lib/puppet/parser/functions/url_available.rb View File

@@ -4,7 +4,13 @@ require 'net/http'
4 4
 require 'open-uri'
5 5
 require 'uri'
6 6
 
7
-Puppet::Parser::Functions::newfunction(:url_available, :doc => <<-EOS
7
+module URI
8
+  # Define 'mirror:' scheme
9
+  class MIRROR < HTTP; end
10
+  @@schemes['MIRROR'] = MIRROR
11
+end
12
+
13
+Puppet::Parser::Functions::newfunction(:url_available, :arity => -2, :doc => <<-EOS
8 14
 The url_available function attempts to make a http request to a url and throws
9 15
 a puppet error if the URL is unavailable.  The url_available function can take
10 16
 up to two paramters. The first paramter is the URL which is required and can be
@@ -39,8 +45,7 @@ url_available({ 'uri'   => 'http://www.google.com',
39 45
 
40 46
 EOS
41 47
 ) do |argv|
42
-  url = argv[0]
43
-  http_proxy = argv[1]
48
+  url, http_proxy = argv
44 49
   threads_count = 16
45 50
   Thread.abort_on_exception=true
46 51
 
@@ -54,12 +59,8 @@ EOS
54 59
 
55 60
     # check the type of url being passed, if hash look for the uri key
56 61
     if url.instance_of? Hash
57
-      if url.has_key?('uri')
58
-        uri = url['uri']
59
-      end
60
-      if url.has_key?('proxy')
61
-        http_proxy = url['proxy']
62
-      end
62
+      uri = url.fetch 'uri', nil
63
+      http_proxy = url.fetch 'proxy', nil
63 64
     elsif url.instance_of? String
64 65
       uri = url
65 66
     else

+ 1
- 0
deployment/puppet/osnailyfacter/spec/functions/url_available_spec.rb View File

@@ -7,6 +7,7 @@ describe 'url_available' do
7 7
     http://archive.ubuntu.com/ubuntu/
8 8
     http://mirror.fuel-infra.org/mos/ubuntu/
9 9
     http://apt.postgresql.org/pub/repos/apt/
10
+    http://mirrors.ubuntu.com/mirrors.txt
10 11
     )
11 12
   end
12 13
 

Loading…
Cancel
Save