- From: Christine Draper <
>
- To: "
" <
>
- Subject: [chef] Re: Custom Ohai Plugin Weirdness
- Date: Sun, 7 Jun 2015 20:40:36 -0500
I suspect the http.request is throwing an exception (so it does not execute the subsequent lines).
Regards, Christine
On Jun 7, 2015, at 12:58 PM, Douglas Garstang <
">
> wrote:
I've been trying to write an ohai plugin to pull a piece of data from a URL. The plugin looks like this: require 'rexml/document' include REXML Ohai.plugin(:SliceLatestVersion) do provides "slice/latest_version" def create_objects slice Mash.new end collect_data(:default) do create_objects uri = URI.parse("https://172.30.1.213/artifactory/simple/slice-stable-local/com/slice/core/slice-dt/maven-metadata.xml") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) @data = "response.body xmldoc = Document.new data latest = XPath.first(xmldoc, "//metadata/versioning/latest") slice['latest_version'] = "B" #latest.text end end
Now, here's the weird part. The mash slice ends up being set to {}. This should not happen considering I'm setting it to a literal value there right at the end. If I remove all that HTTP code before it, the mash slice becomes { 'latest_version': 'B' }. How is this possible? Doug
|
Archive powered by MHonArc 2.6.16.