In Files

Parent

Object

Public Instance Methods

get_address_after_token(output, token, return_first=false) click to toggle source

Cody Herriges

Used the ipaddress fact that is already part of Facter as a template.

    # File lib/facter/ipaddress6.rb, line 24
24: def get_address_after_token(output, token, return_first=false)
25:   ip = nil
26: 
27:   output.scan(/#{token} ((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each do |match|
28:     match = match.first
29:     unless match =~ /fe80.*/ or match == "::1"
30:       ip = match
31:       break if return_first
32:     end
33:   end
34: 
35:   ip
36: end
metadata(id = "") click to toggle source
    # File lib/facter/ec2.rb, line 4
 4: def metadata(id = "")
 5:   open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read.
 6:     split("\n").each do |o|
 7:     key = "#{id}#{o.gsub(/\=.*$/, '/')}"
 8:     if key[1..1] != '/'
 9:       value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read.
10:         split("\n")
11:       symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym
12:       Facter.add(symbol) { setcode { value.join(',') } }
13:     else
14:       metadata(key)
15:     end
16:   end
17: end
selinux_mount_point() click to toggle source

This supports the fact that the selinux mount point is not always in the same location — the selinux mount point is operating system specific.

    # File lib/facter/selinux.rb, line 17
17: def selinux_mount_point
18:   if FileTest.exists?('/proc/self/mountinfo')
19:     File.open('/proc/self/mountinfo') do |f|
20:       f.grep(/selinuxfs/) do |line|
21:         line.split[4]
22:       end
23:     end
24:   else
25:     "/selinux"
26:   end
27: end
userdata() click to toggle source
    # File lib/facter/ec2.rb, line 19
19: def userdata()
20:   begin
21:     value = open("http://169.254.169.254/2008-02-01/user-data/").read.split
22:     Facter.add(:ec2_userdata) { setcode { value } }
23:   rescue OpenURI::HTTPError
24:   end
25: end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.