summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-04-28 20:34:32 +0000
committerGerrit Code Review <review@openstack.org>2017-04-28 20:34:33 +0000
commit9995f60d108103749f759fea72a545c72bcf4988 (patch)
tree317a1922f1b08fb7f5467d367516e5078f9b02dc
parent7453b8bf9dde97427b6e4bd80be4974413bee411 (diff)
parentae1c80f8fbd1d7156075a1dbf61e832b00852bb7 (diff)
Merge "Support a "mirror" method of apt-get"
-rw-r--r--deployment/puppet/osnailyfacter/lib/puppet/parser/functions/url_available.rb19
-rw-r--r--deployment/puppet/osnailyfacter/spec/functions/url_available_spec.rb1
2 files changed, 11 insertions, 9 deletions
diff --git a/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/url_available.rb b/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/url_available.rb
index 6baf959..42cd3f3 100644
--- a/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/url_available.rb
+++ b/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/url_available.rb
@@ -4,7 +4,13 @@ require 'net/http'
4require 'open-uri' 4require 'open-uri'
5require 'uri' 5require 'uri'
6 6
7Puppet::Parser::Functions::newfunction(:url_available, :doc => <<-EOS 7module URI
8 # Define 'mirror:' scheme
9 class MIRROR < HTTP; end
10 @@schemes['MIRROR'] = MIRROR
11end
12
13Puppet::Parser::Functions::newfunction(:url_available, :arity => -2, :doc => <<-EOS
8The url_available function attempts to make a http request to a url and throws 14The url_available function attempts to make a http request to a url and throws
9a puppet error if the URL is unavailable. The url_available function can take 15a puppet error if the URL is unavailable. The url_available function can take
10up to two paramters. The first paramter is the URL which is required and can be 16up 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
40EOS 46EOS
41) do |argv| 47) do |argv|
42 url = argv[0] 48 url, http_proxy = argv
43 http_proxy = argv[1]
44 threads_count = 16 49 threads_count = 16
45 Thread.abort_on_exception=true 50 Thread.abort_on_exception=true
46 51
@@ -54,12 +59,8 @@ EOS
54 59
55 # check the type of url being passed, if hash look for the uri key 60 # check the type of url being passed, if hash look for the uri key
56 if url.instance_of? Hash 61 if url.instance_of? Hash
57 if url.has_key?('uri') 62 uri = url.fetch 'uri', nil
58 uri = url['uri'] 63 http_proxy = url.fetch 'proxy', nil
59 end
60 if url.has_key?('proxy')
61 http_proxy = url['proxy']
62 end
63 elsif url.instance_of? String 64 elsif url.instance_of? String
64 uri = url 65 uri = url
65 else 66 else
diff --git a/deployment/puppet/osnailyfacter/spec/functions/url_available_spec.rb b/deployment/puppet/osnailyfacter/spec/functions/url_available_spec.rb
index 2308c76..3ee6932 100644
--- a/deployment/puppet/osnailyfacter/spec/functions/url_available_spec.rb
+++ b/deployment/puppet/osnailyfacter/spec/functions/url_available_spec.rb
@@ -7,6 +7,7 @@ describe 'url_available' do
7 http://archive.ubuntu.com/ubuntu/ 7 http://archive.ubuntu.com/ubuntu/
8 http://mirror.fuel-infra.org/mos/ubuntu/ 8 http://mirror.fuel-infra.org/mos/ubuntu/
9 http://apt.postgresql.org/pub/repos/apt/ 9 http://apt.postgresql.org/pub/repos/apt/
10 http://mirrors.ubuntu.com/mirrors.txt
10 ) 11 )
11 end 12 end
12 13