lib/puppet/reports/snmp.rb
def ip_address
    @ip_address ||= begin
      uri = URI(Puppet::Util::Puppetdb.config.server_urls.first)
      puppetdb = PuppetDB::Connection.new(uri.host, uri.port, uri.scheme == 'https')
      parser = PuppetDB::Parser.new
      query = parser.facts_query("fqdn='#{self.host}'", ['ipaddress'])
      results = puppetdb.query(:facts, query, :extract => :value).collect { |f| f['value'] }
      results[0]
    end
  end
# connect to PuppetDB to get ip for the node
connect to PuppetDB to get ip for the node
connect to PuppetDB to get ip for the node
def ip_address
    @ip_address ||= begin
      uri = URI(Puppet::Util::Puppetdb.config.server_urls.first)
      puppetdb = PuppetDB::Connection.new(uri.host, uri.port, uri.scheme == 'https')
      parser = PuppetDB::Parser.new
      query = parser.facts_query("fqdn='#{self.host}'", ['ipaddress'])
      results = puppetdb.query(:facts, query, :extract => :value).collect { |f| f['value'] }
      results[0]
    end
  end
def ip_address @ip_address ||= begin uri = URI ( Puppet :: Util :: Puppetdb . config . server_urls . first ) puppetdb = PuppetDB :: Connection . new ( uri . host , uri . port , uri . scheme == 'https' ) parser = PuppetDB :: Parser . new query = parser . facts_query ( "fqdn='#{self.host}'" , [ 'ipaddress' ] ) results = puppetdb . query ( :facts , query , :extract => :value ) . collect { | f | f [ 'value' ] } results [ 0 ] end end
connect to PuppetDB to get ip for the node
connect to PuppetDB to get ip for the node