diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/indirector/rest.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index e6a7bd6cf..34596cad4 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -5,19 +5,19 @@ require 'uri' class Puppet::Indirector::REST < Puppet::Indirector::Terminus def rest_connection_details - { :host => '127.0.0.1', :port => 34343 } + { :host => '127.0.0.1', :port => 34343 } end def network_fetch(path) - Net::HTTP.start("127.0.0.1", 34343) {|x| x.get("/#{path}").body } + network {|conn| conn.get("/#{path}").body } end def network_delete(path) - Net::HTTP.start("127.0.0.1", 34343) {|x| x.delete("/#{path}").body } + network {|conn| conn.delete("/#{path}").body } end def network_put(path, data) - Net::HTTP.start("127.0.0.1", 34343) {|x| x.put("/#{path}", data).body } + network {|conn| conn.put("/#{path}", data).body } end def find(name, options = {}) @@ -46,6 +46,10 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus private + def network(&block) + Net::HTTP.start(rest_connection_details[:host], rest_connection_details[:port]) {|conn| yield(conn) } + end + def exception?(yaml_string) yaml_string =~ %r{--- !ruby/exception} end |