facter-1.7.5/0000755005276200011600000000000012276213023012656 5ustar jenkinsjenkinsfacter-1.7.5/LICENSE0000644005276200011600000000113112276213016013661 0ustar jenkinsjenkinsFacter - Host Fact Detection and Reporting Copyright 2005-2012 Puppet Labs Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. facter-1.7.5/lib/0000755005276200011600000000000012276213023013424 5ustar jenkinsjenkinsfacter-1.7.5/lib/facter/0000755005276200011600000000000012276213023014670 5ustar jenkinsjenkinsfacter-1.7.5/lib/facter/lsbdistcodename.rb0000644005276200011600000000102012276213016020350 0ustar jenkinsjenkins# Fact: lsbdistcodename # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsb_release system command # # Caveats: # Only works on Linux (and the kfreebsd derivative) systems. # Requires the lsb_release program, which may not be installed by default. # Also is as only as accurate as that program outputs. Facter.add(:lsbdistcodename) do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do Facter::Util::Resolution.exec('lsb_release -c -s 2>/dev/null') end end facter-1.7.5/lib/facter/lsbdistrelease.rb0000644005276200011600000000101612276213016020222 0ustar jenkinsjenkins# Fact: lsbdistrelease # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsb_release system command # # Caveats: # Only works on Linux (and the kfreebsd derivative) systems. # Requires the lsb_release program, which may not be installed by default. # Also is as only as accurate as that program outputs. Facter.add(:lsbdistrelease) do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do Facter::Util::Resolution.exec('lsb_release -r -s 2>/dev/null') end end facter-1.7.5/lib/facter/interfaces.rb0000644005276200011600000000215012276213016017340 0ustar jenkinsjenkins# Fact: interfaces # # Purpose: # # Resolution: # # Caveats: # # interfaces.rb # Try to get additional Facts about the machine's network interfaces # # Original concept Copyright (C) 2007 psychedelys # Update and *BSD support (C) 2007 James Turnbull # require 'facter/util/ip' # Note that most of this only works on a fixed list of platforms; notably, Darwin # is missing. Facter.add(:interfaces) do confine :kernel => Facter::Util::IP.supported_platforms setcode do Facter::Util::IP.get_interfaces.collect { |iface| Facter::Util::IP.alphafy(iface) }.join(",") end end Facter::Util::IP.get_interfaces.each do |interface| # Make a fact for each detail of each interface. Yay. # There's no point in confining these facts, since we wouldn't be able to create # them if we weren't running on a supported platform. %w{ipaddress ipaddress6 macaddress netmask mtu}.each do |label| Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do setcode do Facter::Util::IP.get_interface_value(interface, label) end end end end facter-1.7.5/lib/facter/domain.rb0000644005276200011600000000560412276213016016473 0ustar jenkinsjenkins# Fact: domain # # Purpose: # Return the host's primary DNS domain name. # # Resolution: # On UNIX (excluding Darwin), first try and use the hostname fact, # which uses the hostname system command, and then parse the output # of that. # Failing that it tries the dnsdomainname system command. # Failing that it uses /etc/resolv.conf and takes the domain from that, or as # a final resort, the search from that. # Otherwise returns nil. # # On Windows uses the win32ole gem and winmgmts to get the DNSDomain value # from the Win32 networking stack. # # Caveats: # Facter.add(:domain) do setcode do # Get the domain from various sources; the order of these # steps is important # In some OS 'hostname -f' will change the hostname to '-f' # We know that Solaris and HP-UX exhibit this behavior # On good OS, 'hostname -f' will return the FQDN which is preferable # Due to dangerous behavior of 'hostname -f' on old OS, we will explicitly opt-in # 'hostname -f' --hkenney May 9, 2012 basic_hostname = 'hostname 2> /dev/null' windows_hostname = 'hostname > NUL' full_hostname = 'hostname -f 2> /dev/null' can_do_hostname_f = Regexp.union /Linux/i, /FreeBSD/i, /Darwin/i hostname_command = if Facter.value(:kernel) =~ can_do_hostname_f full_hostname elsif Facter.value(:kernel) == "windows" windows_hostname else basic_hostname end if name = Facter::Util::Resolution.exec(hostname_command) \ and name =~ /.*?\.(.+$)/ return_value = $1 elsif Facter.value(:kernel) != "windows" and domain = Facter::Util::Resolution.exec('dnsdomainname 2> /dev/null') \ and domain =~ /.+/ return_value = domain elsif FileTest.exists?("/etc/resolv.conf") domain = nil search = nil File.open("/etc/resolv.conf") { |file| file.each { |line| if line =~ /^\s*domain\s+(\S+)/ domain = $1 elsif line =~ /^\s*search\s+(\S+)/ search = $1 end } } return_value ||= domain return_value ||= search end return_value = '' if return_value.nil? return_value.gsub(/\.$/, '') end end Facter.add(:domain) do confine :kernel => :windows setcode do require 'facter/util/registry' domain = "" regvalue = Facter::Util::Registry.hklm_read('SYSTEM\CurrentControlSet\Services\Tcpip\Parameters', 'Domain') domain = regvalue if regvalue if domain == "" require 'facter/util/wmi' Facter::Util::WMI.execquery("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").each { |nic| if nic.DNSDomain && nic.DNSDomain.length > 0 domain = nic.DNSDomain break end } end domain ||= '' domain.gsub(/\.$/, '') end end facter-1.7.5/lib/facter/zones.rb0000644005276200011600000000105712276213016016360 0ustar jenkinsjenkins# Fact: zones# # # Purpose: # Return the list of zones on the system and add one zones_ fact # for each zone with its state e.g. running, incomplete or installed. # # Resolution: # Uses 'usr/sbin/zoneadm list -cp' to get the list of zones in separate parsable # lines with delimeter being ':' which is used to split the line string and get # the zone details. # # Caveats: # We dont support below s10 where zones are not available. require 'facter/util/solaris_zones' if Facter.value(:kernel) == 'SunOS' Facter::Util::SolarisZones.add_facts end facter-1.7.5/lib/facter/timezone.rb0000644005276200011600000000031412276213016017047 0ustar jenkinsjenkins# Fact: timezone # # Purpose: Return the machine's time zone. # # Resolution: Uses's Ruby's Time module's Time.new call. # # Caveats: # Facter.add("timezone") do setcode do Time.new.zone end end facter-1.7.5/lib/facter/ps.rb0000644005276200011600000000114212276213016015637 0ustar jenkinsjenkins# Fact: ps # # Purpose: Internal fact for what to use to list all processes. Used by # Service{} type in Puppet. # # Resolution: # Assumes "ps -ef" for all operating systems other than BSD derivatives, where # it uses "ps auxwww" # # Caveats: # Facter.add(:ps) do setcode do 'ps -ef' end end Facter.add(:ps) do confine :operatingsystem => :OpenWrt setcode do 'ps www' end end Facter.add(:ps) do confine :operatingsystem => %w{FreeBSD NetBSD OpenBSD Darwin DragonFly} setcode do 'ps auxwww' end end Facter.add(:ps) do confine :operatingsystem => :windows setcode do 'tasklist.exe' end end facter-1.7.5/lib/facter/selinux.rb0000644005276200011600000000554012276213016016712 0ustar jenkinsjenkins# Fact: selinux # # Purpose: # # Resolution: # # Caveats: # # Fact for SElinux # Written by immerda admin team (admin(at)immerda.ch) sestatus_cmd = '/usr/sbin/sestatus' # This supports the fact that the selinux mount point is not always in the # same location -- the selinux mount point is operating system specific. def selinux_mount_point path = "/selinux" if FileTest.exists?('/proc/self/mounts') # Centos 5 shows an error in which having ruby use File.read to read # /proc/self/mounts combined with the puppet agent run with --listen causes # a hang. Reading from other parts of /proc does not seem to cause this problem. # The work around is to read the file in another process. # -- andy Fri Aug 31 2012 selinux_line = Facter::Util::Resolution.exec('cat /proc/self/mounts').lines.find { |line| line =~ /selinuxfs/ } if selinux_line path = selinux_line.split[1] end end path end Facter.add("selinux") do confine :kernel => :linux setcode do result = "false" if FileTest.exists?("#{selinux_mount_point}/enforce") if FileTest.exists?("/proc/self/attr/current") if (File.read("/proc/self/attr/current") != "kernel\0") result = "true" end end end result end end Facter.add("selinux_enforced") do confine :selinux => :true setcode do result = "false" if FileTest.exists?("#{selinux_mount_point}/enforce") and File.read("#{selinux_mount_point}/enforce") =~ /1/i result = "true" end result end end Facter.add("selinux_policyversion") do confine :selinux => :true setcode do result = 'unknown' if FileTest.exists?("#{selinux_mount_point}/policyvers") result = File.read("#{selinux_mount_point}/policyvers").chomp end result end end Facter.add("selinux_current_mode") do confine :selinux => :true setcode do result = 'unknown' mode = Facter::Util::Resolution.exec(sestatus_cmd) mode.each_line { |l| result = $1 if l =~ /^Current mode\:\s+(\w+)$/i } result.chomp end end Facter.add("selinux_config_mode") do confine :selinux => :true setcode do result = 'unknown' mode = Facter::Util::Resolution.exec(sestatus_cmd) mode.each_line { |l| result = $1 if l =~ /^Mode from config file\:\s+(\w+)$/i } result.chomp end end Facter.add("selinux_config_policy") do confine :selinux => :true setcode do result = 'unknown' mode = Facter::Util::Resolution.exec(sestatus_cmd) mode.each_line { |l| result = $1 if l =~ /^Policy from config file\:\s+(\w+)$/i } result.chomp end end # This is a legacy fact which returns the old selinux_mode fact value to prevent # breakages of existing manifests. It should be removed at the next major release. # See ticket #6677. Facter.add("selinux_mode") do confine :selinux => :true setcode do Facter.value(:selinux_config_policy) end end facter-1.7.5/lib/facter/memory.rb0000644005276200011600000001076712276213016016542 0ustar jenkinsjenkins# Fact: memory # # Purpose: Return information about memory and swap usage. # # Resolution: # On Linuxes, uses Facter::Memory.meminfo_number from # 'facter/util/memory.rb' # On AIX, parses "swap -l" for swap values only. # On OpenBSD, it parses "swapctl -l" for swap values, vmstat via a module for # free memory, and "sysctl hw.physmem" for maximum memory. # On FreeBSD, it parses "swapinfo -k" for swap values, and parses sysctl for # maximum memory. # On Solaris, use "swap -l" for swap values, and parsing prtconf for maximum # memory, and again, the vmstat module for free memory. # # Caveats: # Some BSD platforms aren't covered at all. AIX is missing memory values. # # memory.rb # Additional Facts for memory/swap usage # # Copyright (C) 2006 Mooter Media Ltd # Author: Matthew Palmer # # require 'facter/util/memory' [ "memorysize", "memoryfree", "swapsize", "swapfree" ].each do |fact| Facter.add(fact) do setcode do name = Facter.fact(fact + "_mb").value Facter::Memory.scale_number(name.to_f, "MB") if name end end end Facter.add("swapsize_mb") do setcode do swaptotal = Facter::Memory.swap_size "%.2f" % [swaptotal] if swaptotal end end Facter.add("swapfree_mb") do setcode do swapfree = Facter::Memory.swap_free "%.2f" % [swapfree] if swapfree end end Facter.add("memorysize_mb") do setcode do memtotal = Facter::Memory.mem_size "%.2f" % [memtotal] if memtotal end end Facter.add("memoryfree_mb") do setcode do memfree = Facter::Memory.mem_free "%.2f" % [memfree] if memfree end end { :memorysize_mb => "MemTotal", :memoryfree_mb => "MemFree", :swapsize_mb => "SwapTotal", :swapfree_mb => "SwapFree" }.each do |fact, name| Facter.add(fact) do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do meminfo = Facter::Memory.meminfo_number(name) "%.2f" % [meminfo] end end end if Facter.value(:kernel) == "Darwin" Facter.add("SwapEncrypted") do confine :kernel => :Darwin setcode do swap = Facter::Util::Resolution.exec('sysctl vm.swapusage') encrypted = false if swap =~ /\(encrypted\)/ then encrypted = true; end encrypted end end end if Facter.value(:kernel) == "SunOS" Facter.add("memorysize_mb") do confine :kernel => :sunos # Total memory size available from prtconf pconf = Facter::Util::Resolution.exec('/usr/sbin/prtconf 2>/dev/null') phymem = "" pconf.each_line do |line| if line =~ /^Memory size:\s+(\d+) Megabytes/ phymem = $1 end end setcode do "%.2f" % [phymem.to_f] end end end if Facter.value(:kernel) == "windows" require 'facter/util/wmi' Facter.add("memorysize_mb") do confine :kernel => :windows setcode do mem = 0 Facter::Util::WMI.execquery("select TotalPhysicalMemory from Win32_ComputerSystem").each do |comp| mem = comp.TotalPhysicalMemory break end "%.2f" % [(mem.to_f / 1024.0) / 1024.0] end end Facter.add("memoryfree_mb") do confine :kernel => :windows setcode do mem = 0 Facter::Util::WMI.execquery("select FreePhysicalMemory from Win32_OperatingSystem").each do |os| mem = os.FreePhysicalMemory break end "%.2f" % [mem.to_f / 1024.0] end end end Facter.add("swapsize_mb") do confine :kernel => :dragonfly setcode do page_size = Facter::Util::Resolution.exec("/sbin/sysctl -n hw.pagesize").to_f swaptotal = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size "%.2f" % [(swaptotal.to_f / 1024.0) / 1024.0] end end Facter.add("swapfree_mb") do confine :kernel => :dragonfly setcode do page_size = Facter::Util::Resolution.exec("/sbin/sysctl -n hw.pagesize").to_f swaptotal = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size swap_anon_use = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_anon_use").to_f * page_size swap_cache_use = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_cache_use").to_f * page_size swapfree = swaptotal - swap_anon_use - swap_cache_use "%.2f" % [(swapfree.to_f / 1024.0) / 1024.0] end end # http://projects.puppetlabs.com/issues/11436 # # Unifying naming for the amount of physical memory in a given host. # This fact is DEPRECATED and will be removed in Facter 2.0 per # http://projects.puppetlabs.com/issues/11466 Facter.add("MemoryTotal") do setcode do Facter.value("memorysize") end end facter-1.7.5/lib/facter/filesystems.rb0000644005276200011600000000234012276213016017565 0ustar jenkinsjenkins# # filesystems.rb # # This fact provides an alphabetic list of usable file systems that can # be used for block devices like hard drives, media cards and so on ... # Facter.add('filesystems') do confine :kernel => :linux setcode do # fuseblk can't be created and arguably isn't usable here. If you feel this # doesn't match your use-case please raise a bug. exclude = %w(fuseblk) # Make regular expression form our patterns ... exclude = Regexp.union(*exclude.collect { |i| Regexp.new(i) }) # We utilise rely on "cat" for reading values from entries under "/proc". # This is due to some problems with IO#read in Ruby and reading content of # the "proc" file system that was reported more than once in the past ... file_systems = [] Facter::Util::Resolution.exec('cat /proc/filesystems 2> /dev/null').each_line do |line| # Remove bloat ... line.strip! # Line of interest should not start with "nodev" ... next if line.empty? or line.match(/^nodev/) # We have something, so let us apply our device type filter ... next if line.match(exclude) file_systems << line end file_systems.sort.join(',') end end # vim: set ts=2 sw=2 et : # encoding: utf-8 facter-1.7.5/lib/facter/vlans.rb0000644005276200011600000000050612276213016016343 0ustar jenkinsjenkins# Fact: vlans # # Purpose: On Linux, return a list of all the VLANs on the system. # # Resolution: On Linux only, checks for and reads /proc/net/vlan/config and # parses it. # # Caveats: # require 'facter/util/vlans' Facter.add("vlans") do confine :kernel => :linux setcode do Facter::Util::Vlans.get_vlans end end facter-1.7.5/lib/facter/fqdn.rb0000644005276200011600000000100412276213016016142 0ustar jenkinsjenkins# Fact: fqdn # # Purpose: Returns the fully qualified domain name of the host. # # Resolution: Simply joins the hostname fact with the domain name fact. # # Caveats: No attempt is made to check that the two facts are accurate or that # the two facts go together. At no point is there any DNS resolution made # either. # Facter.add(:fqdn) do setcode do host = Facter.value(:hostname) domain = Facter.value(:domain) if host and domain [host, domain].join(".") else nil end end end facter-1.7.5/lib/facter/lsbmajdistrelease.rb0000644005276200011600000000112612276213016020714 0ustar jenkinsjenkins# Fact: lsbmajdistrelease # # Purpose: Returns the major version of the operation system version as gleaned # from the lsbdistrelease fact. # # Resolution: # Parses the lsbdistrelease fact for numbers followed by a period and # returns those, or just the lsbdistrelease fact if none were found. # # Caveats: # # lsbmajdistrelease.rb # require 'facter' Facter.add("lsbmajdistrelease") do confine :kernel => %w{Linux GNU/kFreeBSD} setcode do if /(\d*)\./i =~ Facter.value(:lsbdistrelease) result=$1 else result=Facter.value(:lsbdistrelease) end result end end facter-1.7.5/lib/facter/rubysitedir.rb0000644005276200011600000000026412276213016017566 0ustar jenkinsjenkins# Fact: rubysitedir # # Purpose: Returns Ruby's site library directory. # require 'rbconfig' Facter.add :rubysitedir do setcode do RbConfig::CONFIG["sitelibdir"] end end facter-1.7.5/lib/facter/util/0000755005276200011600000000000012276213023015645 5ustar jenkinsjenkinsfacter-1.7.5/lib/facter/util/composite_loader.rb0000644005276200011600000000040312276213016021521 0ustar jenkinsjenkins# A composite loader that allows for more than one # default directory loader class Facter::Util::CompositeLoader def initialize(loaders) @loaders = loaders end def load(collection) @loaders.each { |loader| loader.load(collection) } end end facter-1.7.5/lib/facter/util/config.rb0000644005276200011600000000214112276213016017437 0ustar jenkinsjenkinsrequire 'rbconfig' # A module to return config related data # module Facter::Util::Config def self.ext_fact_loader @ext_fact_loader || Facter::Util::DirectoryLoader.default_loader end def self.ext_fact_loader=(loader) @ext_fact_loader = loader end def self.is_mac? RbConfig::CONFIG['host_os'] =~ /darwin/i end # Returns true if OS is windows def self.is_windows? RbConfig::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i end def self.windows_data_dir if Dir.const_defined? 'COMMON_APPDATA' then Dir::COMMON_APPDATA else nil end end def self.external_facts_dirs if Facter::Util::Root.root? windows_dir = windows_data_dir if windows_dir.nil? then ["/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"] else [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')] end else [File.expand_path(File.join("~", ".facter", "facts.d"))] end end end if Facter::Util::Config.is_windows? require 'win32/dir' require 'facter/util/windows_root' else require 'facter/util/unix_root' end facter-1.7.5/lib/facter/util/solaris_zones.rb0000644005276200011600000001122412276213016021066 0ustar jenkinsjenkinsrequire 'facter/util/resolution' module Facter module Util ## # Provide a set of utility methods to interact with Solaris zones. This class # is expected to be instantiated once per set of resolutions in order to # cache the output of the zoneadm command, which can be quite expensive. # # @api private class SolarisZones attr_reader :zone_hash attr_reader :zoneadm_cmd attr_reader :zoneadm_output attr_reader :zoneadm_keys ## # add_facts defines all of the facts for solaris zones, for example `zones`, # `zone_global_id`, `zone_global_status`, etc... This method defines the # static fact named `zones`. The value of this fact is the numver of zones # reported by the zoneadm system command. The `zones` fact also defines # all of the dynamic facts describing the following seven attribute values # for each zone. # # Zones may be added to the system while Facter is loaded. In order to # define new dynamic facts that reflect this new information, the `virtual` # will define new facts as a side effect of refreshing it's own value. # # @api private def self.add_facts model = new model.refresh model.add_dynamic_facts Facter.add("zones") do setcode do model.refresh if model.flushed? model.add_dynamic_facts model.count end on_flush do model.flush! end end end ## # @param [Hash] opts the options to create the instance with # @option opts [String] :zoneadm_cmd ('/usr/sbin/zoneadm list -cp') the # system command to inspect zones # @option opts [String] :zoneadm_output (nil) the cached output of the # zoneadm_cmd def initialize(opts = {}) @zoneadm_keys = [:id, :name, :status, :path, :uuid, :brand, :iptype] @zoneadm_cmd = opts[:zoneadm_cmd] || '/usr/sbin/zoneadm list -cp' if opts[:zoneadm_output] @zoneadm_output = opts[:zoneadm_output] end end ## # add_dynamic_facts defines all of the dynamic facts derived from parsing # the output of the zoneadm command. The zone facts are dynamic, so this # method has the behavior of figuring out what dynamic zone facts need to # be defined and how they should be resolved. # # @param model [SolarisZones] the model used to store data from the system # # @api private def add_dynamic_facts model = self zone_hash.each_pair do |zone, attr_hsh| attr_hsh.keys.each do |attr| Facter.add("zone_#{zone}_#{attr}") do setcode do model.refresh if model.flushed? # Don't resolve if the zone has since been deleted if zone_hsh = model.zone_hash[zone] zone_hsh[attr] # the value end end on_flush do model.flush! end end end end end ## # refresh executes the zoneadm_cmd and stores the output data. # # @api private # # @return [Hash] the parsed output of the zoneadm command def refresh @zoneadm_output = Facter::Util::Resolution.exec(zoneadm_cmd) parse! end ## # parse! parses the string stored in {@zoneadm_output} and stores the # resulting Hash data structure in {@zone_hash} # # @api private def parse! if @zoneadm_output rows = @zoneadm_output.split("\n").collect { |line| line.split(':') } else Facter.debug "Cannot parse zone facts, #{zoneadm_cmd} returned no output" rows = [] end @zone_hash = rows.inject({}) do |memo, fields| zone = fields[1].intern # Transform the row into a hash with keys named by the column names memo[zone] = Hash[*@zoneadm_keys.zip(fields).flatten] memo end end private :parse! ## # count returns the number of running zones, including the global zone. # This method is intended to be used from the setcode block of the `zones` # fact. # # @api private # # @return [Fixnum, nil] the number of running zones or nil if the number # could not be determined. def count if @zone_hash @zone_hash.size end end ## # flush! purges the saved data from the zoneadm_cmd output # # @api private def flush! @zoneadm_output = nil @zone_hash = nil end ## # flushed? returns true if the instance has no parsed data accessible via # the {zone_hash} method. # # @api private # # @return [Boolean] true if there is no parsed data, false otherwise def flushed? !@zone_hash end end end end facter-1.7.5/lib/facter/util/memory.rb0000644005276200011600000001421012276213016017502 0ustar jenkinsjenkins## memory.rb ## Support module for memory related facts ## module Facter::Memory def self.meminfo_number(tag) memsize = "" size = [0] File.readlines("/proc/meminfo").each do |l| size = $1.to_f if l =~ /^#{tag}:\s+(\d+)\s+\S+/ if tag == "MemFree" && l =~ /^(?:Buffers|Cached):\s+(\d+)\s+\S+/ size += $1.to_f end end size / 1024.0 end def self.scale_number(size, multiplier) suffixes = ['', 'kB', 'MB', 'GB', 'TB'] s = suffixes.shift while s != multiplier s = suffixes.shift end while size > 1024.0 size /= 1024.0 s = suffixes.shift end "%.2f %s" % [size, s] end def self.vmstat_find_free_memory(args = []) cmd = 'vmstat' cmd += (' ' + args.join(' ')) unless args.empty? row = Facter::Util::Resolution.exec(cmd).split("\n")[-1] if row =~ /^\s*\d+\s*\d+\s*\d+\s*\d+\s*(\d+)/ memfree = $1 end end # Darwin had to be different. It's generally opaque with how much RAM it is # using, and this figure could be improved upon too I fear. # Parses the output of "vm_stat", takes the pages free & pages speculative # and multiples that by the page size (also given in output). Ties in with # what activity monitor outputs for free memory. def self.vmstat_darwin_find_free_memory() memfree = 0 pagesize = 0 memspecfree = 0 vmstats = Facter::Util::Resolution.exec('vm_stat') vmstats.each_line do |vmline| case when vmline =~ /page\ssize\sof\s(\d+)\sbytes/ pagesize = $1.to_i when vmline =~ /^Pages\sfree:\s+(\d+)\./ memfree = $1.to_i when vmline =~ /^Pages\sspeculative:\s+(\d+)\./ memspecfree = $1.to_i end end freemem = ( memfree + memspecfree ) * pagesize end # on AIX use svmon to get the free memory: # it's the third value on the line starting with memory # svmon can be run by non root users def self.svmon_aix_find_free_memory() Facter::Util::Resolution.exec("/usr/bin/svmon -O unit=KB") =~ /^memory\s+\d+\s+\d+\s+(\d+)\s+/ $1 end def self.mem_free(kernel = Facter.value(:kernel)) output = mem_free_info(kernel) scale_mem_free_value output, kernel end def self.mem_free_info(kernel = Facter.value(:kernel)) case kernel when /OpenBSD/i, /SunOS/i, /Dragonfly/i vmstat_find_free_memory() when /FreeBSD/i vmstat_find_free_memory(["-H"]) when /Darwin/i vmstat_darwin_find_free_memory() when /AIX/i svmon_aix_find_free_memory() end end def self.scale_mem_free_value (value, kernel) case kernel when /OpenBSD/i, /FreeBSD/i, /SunOS/i, /Dragonfly/i, /AIX/i value.to_f / 1024.0 when /Darwin/i value.to_f / 1024.0 / 1024.0 else value.to_f end end def self.mem_size(kernel = Facter.value(:kernel)) output = mem_size_info(kernel) scale_mem_size_value output, kernel end def self.mem_size_info(kernel = Facter.value(:kernel)) case kernel when /OpenBSD/i Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2") when /FreeBSD/i Facter::Util::Resolution.exec("sysctl -n hw.physmem") when /Darwin/i Facter::Util::Resolution.exec("sysctl -n hw.memsize") when /Dragonfly/i Facter::Util::Resolution.exec("sysctl -n hw.physmem") when /AIX/i if Facter::Util::Resolution.exec("/usr/bin/svmon -O unit=KB") =~ /^memory\s+(\d+)\s+/ $1 end end end def self.scale_mem_size_value(value, kernel) case kernel when /OpenBSD/i, /FreeBSD/i, /Darwin/i, /Dragonfly/i value.to_f / 1024.0 / 1024.0 when /AIX/i value.to_f / 1024.0 else value.to_f end end def self.swap_size(kernel = Facter.value(:kernel)) output = swap_info(kernel) parse_swap output, kernel, :size if output end def self.swap_free(kernel = Facter.value(:kernel)) output = swap_info(kernel) parse_swap output, kernel, :free if output end def self.swap_info(kernel = Facter.value(:kernel)) case kernel when /AIX/i (Facter.value(:id) == "root") ? Facter::Util::Resolution.exec('swap -l 2>/dev/null') : nil when /OpenBSD/i Facter::Util::Resolution.exec('swapctl -s') when /FreeBSD/i Facter::Util::Resolution.exec('swapinfo -k') when /Darwin/i Facter::Util::Resolution.exec('sysctl vm.swapusage') when /SunOS/i Facter::Util::Resolution.exec('/usr/sbin/swap -l 2>/dev/null') end end def self.parse_swap (output, kernel = Facter.value(:kernel), size_or_free = :size) value_in_mb = 0.0 value = 0 is_size = size_or_free == :size unless output.nil? output.each_line do |line| value += parse_swap_line(line, kernel, is_size) end end value_in_mb = scale_swap_value(value, kernel) end # There is a lot of duplication here because of concern over being able to add # new platforms in a reasonable manner. For all of these platforms the first # regex corresponds to the swap size value and the second corresponds to the swap # free value, but this may not always be the case. In Ruby 1.9.3 it is possible # to give these names, but sadly 1.8.7 does not support this. def self.parse_swap_line(line, kernel, is_size) case kernel when /AIX/i if line =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/ (is_size) ? $1.to_i : $2.to_i else 0 end when /OpenBSD/i if line =~ /^total: (\d+)k bytes allocated = \d+k used, (\d+)k available$/ (is_size) ? $1.to_i : $2.to_i else 0 end when /FreeBSD/i if line =~ /\S+\s+(\d+)\s+\d+\s+(\d+)\s+\d+%$/ (is_size) ? $1.to_i : $2.to_i else 0 end when /Darwin/i if line =~ /total\s=\s(\S+)M\s+used\s=\s\S+M\s+free\s=\s(\S+)M\s/ (is_size) ? $1.to_i : $2.to_i else 0 end when /SunOS/i if line =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/ (is_size) ? $1.to_i : $2.to_i else 0 end end end def self.scale_swap_value(value, kernel) case kernel when /OpenBSD/i, /FreeBSD/i value.to_f / 1024.0 when /SunOS/i value.to_f / 2 / 1024.0 else value.to_f end end end facter-1.7.5/lib/facter/util/fact.rb0000644005276200011600000000610712276213016017115 0ustar jenkinsjenkinsrequire 'facter' require 'facter/util/resolution' class Facter::Util::Fact TIMEOUT = 5 attr_accessor :name, :ldapname # Create a new fact, with no resolution mechanisms. def initialize(name, options = {}) @name = name.to_s.downcase.intern # LAK:NOTE: This is slow for many options, but generally we won't have any and at # worst we'll have one. If we add more, this should be made more efficient. options.each do |name, value| case name when :ldapname; self.ldapname = value else raise ArgumentError, "Invalid fact option '%s'" % name end end @ldapname ||= @name.to_s @resolves = [] @searching = false @value = nil end # Add a new resolution mechanism. This requires a block, which will then # be evaluated in the context of the new mechanism. def add(value = nil, &block) begin resolve = Facter::Util::Resolution.new(@name) resolve.instance_eval(&block) if block @resolves << resolve resolve rescue => e Facter.warn "Unable to add resolve for #{@name}: #{e}" nil end end ## # Flush any cached values. If the resolver has a callback block defined # using the on_flush DSL method, then invoke that block by sending a message # to Resolution#flush. def flush @resolves.each { |r| r.flush } @value = nil end # Return the value for a given fact. Searches through all of the mechanisms # and returns either the first value or nil. def value return @value if @value if @resolves.empty? Facter.debug "No resolves for %s" % @name return nil end searching do suitable_resolutions = sort_by_weight(find_suitable_resolutions(@resolves)) @value = find_first_real_value(suitable_resolutions) announce_when_no_suitable_resolution(suitable_resolutions) announce_when_no_value_found(@value) @value end end private # Are we in the midst of a search? def searching? @searching end # Lock our searching process, so we never ge stuck in recursion. def searching raise RuntimeError, "Caught recursion on #{@name}" if searching? # If we've gotten this far, we're not already searching, so go ahead and do so. @searching = true begin yield ensure @searching = false end end def find_suitable_resolutions(resolutions) resolutions.find_all{ |resolve| resolve.suitable? } end def sort_by_weight(resolutions) resolutions.sort { |a, b| b.weight <=> a.weight } end def find_first_real_value(resolutions) resolutions.each do |resolve| value = normalize_value(resolve.value) if not value.nil? return value end end nil end def announce_when_no_suitable_resolution(resolutions) if resolutions.empty? Facter.debug "Found no suitable resolves of %s for %s" % [@resolves.length, @name] end end def announce_when_no_value_found(value) if value.nil? Facter.debug("value for %s is still nil" % @name) end end def normalize_value(value) value == "" ? nil : value end end facter-1.7.5/lib/facter/util/vlans.rb0000644005276200011600000000104612276213016017320 0ustar jenkinsjenkins# A module to gather vlan facts # module Facter::Util::Vlans def self.get_vlan_config output = "" if File.exists?('/proc/net/vlan/config') and File.readable?('/proc/net/vlan/config') output = File.open('/proc/net/vlan/config').read end output end def self.get_vlans vlans = Array.new if self.get_vlan_config self.get_vlan_config.each_line do |line| if line =~ /^([0-9A-Za-z]+)\.([0-9]+) / vlans.insert(-1, $~[2]) if $~[2] end end end vlans.join(',') end end facter-1.7.5/lib/facter/util/confine.rb0000644005276200011600000000164512276213016017623 0ustar jenkinsjenkins# A restricting tag for fact resolution mechanisms. The tag must be true # for the resolution mechanism to be suitable. require 'facter/util/values' class Facter::Util::Confine attr_accessor :fact, :values include Facter::Util::Values # Add the restriction. Requires the fact name, an operator, and the value # we're comparing to. def initialize(fact, *values) raise ArgumentError, "The fact name must be provided" unless fact raise ArgumentError, "One or more values must be provided" if values.empty? @fact = fact @values = values end def to_s return "'%s' '%s'" % [@fact, @values.join(",")] end # Evaluate the fact, returning true or false. def true? unless fact = Facter[@fact] Facter.debug "No fact for %s" % @fact return false end value = convert(fact.value) return false if value.nil? return @values.any? { |v| convert(v) === value } end end facter-1.7.5/lib/facter/util/monkey_patches.rb0000644005276200011600000000153612276213016021212 0ustar jenkinsjenkins# This provides an alias for RbConfig to Config for versions of Ruby older then # version 1.8.5. This allows us to use RbConfig in place of the older Config in # our code and still be compatible with at least Ruby 1.8.1. require 'rbconfig' require 'enumerator' unless defined? ::RbConfig ::RbConfig = ::Config end module Facter module Util module MonkeyPatches module Lines def lines(separator = $/) if block_given? self.each_line(separator) {|line| yield line } return self else return enum_for(:each_line, separator) end end end end end end public class String unless method_defined? :lines include Facter::Util::MonkeyPatches::Lines end end class IO unless method_defined? :lines include Facter::Util::MonkeyPatches::Lines end end facter-1.7.5/lib/facter/util/directory_loader.rb0000644005276200011600000000412012276213016021523 0ustar jenkinsjenkins# A Facter plugin that loads external facts. # # Default Unix Directories: # /etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d" # # Default Windows Direcotires: # C:\ProgramData\Puppetlabs\facter\facts.d (2008) # C:\Documents and Settings\All Users\Application Data\Puppetlabs\facter\facts.d (2003) # # Can also load from command-line specified directory # # Facts can be in the form of JSON, YAML or Text files # and any executable that returns key=value pairs. require 'facter' require 'facter/util/config' require 'facter/util/composite_loader' require 'facter/util/parser' require 'yaml' class Facter::Util::DirectoryLoader class NoSuchDirectoryError < Exception end # This value makes it highly likely that external facts will take # precedence over all other facts EXTERNAL_FACT_WEIGHT = 10000 # Directory for fact loading attr_reader :directory def initialize(dir) @directory = dir end def self.loader_for(dir) if File.directory?(dir) Facter::Util::DirectoryLoader.new(dir) else raise NoSuchDirectoryError end end def self.default_loader loaders = Facter::Util::Config.external_facts_dirs.collect do |dir| Facter::Util::DirectoryLoader.new(dir) end Facter::Util::CompositeLoader.new(loaders) end # Load facts from files in fact directory using the relevant parser classes to # parse them. def load(collection) entries.each do |file| parser = Facter::Util::Parser.parser_for(file) if parser == nil next end data = parser.results if data == false Facter.warn "Could not interpret fact file #{file}" elsif data == {} or data == nil Facter.warn "Fact file #{file} was parsed but returned an empty data set" else data.each { |p,v| collection.add(p, :value => v) { has_weight(EXTERNAL_FACT_WEIGHT) } } end end end private def entries Dir.entries(directory).find_all { |f| should_parse?(f) }.sort.map { |f| File.join(directory, f) } rescue Errno::ENOENT => detail [] end def should_parse?(file) not file =~ /^\./ end end facter-1.7.5/lib/facter/util/parser.rb0000644005276200011600000000774512276213016017505 0ustar jenkinsjenkins# This class acts as the factory and parent class for parsed # facts such as scripts, text, json and yaml files. # # Parsers must subclass this class and provide their own #results method. require 'facter' require 'yaml' module Facter::Util::Parser @parsers = [] # For support mutliple extensions you can pass an array of extensions as # +ext+. def self.extension_matches?(filename, ext) extension = case ext when String ext.downcase when Enumerable ext.collect {|x| x.downcase } end [extension].flatten.to_a.include?(file_extension(filename).downcase) end def self.file_extension(filename) File.extname(filename).sub(".", '') end def self.register(klass, &suitable) @parsers << [klass, suitable] end def self.parser_for(filename) registration = @parsers.detect { |k| k[1].call(filename) } if registration.nil? NothingParser.new else registration[0].new(filename) end end class Base attr_reader :filename def initialize(filename, content = nil) @filename = filename @content = content end def content @content ||= File.read(filename) end # results on the base class is really meant to be just an exception handler # wrapper. def results parse_results rescue Exception => detail Facter.warn("Failed to handle #{filename} as #{self.class} facts") Facter.warn("detail: #{detail.class}: #{detail.message}") Facter.debug(detail.backtrace.join("\n\t")) nil end def parse_results raise ArgumentError, "Subclasses must respond to parse_results" end end module KeyValuePairOutputFormat def self.parse(output) return {} if output.nil? result = {} re = /^(.+?)=(.+)$/ output.each_line do |line| if match_data = re.match(line.chomp) result[match_data[1]] = match_data[2] end end result end end class YamlParser < Base def parse_results YAML.load(content) end end register(YamlParser) do |filename| extension_matches?(filename, "yaml") end class TextParser < Base def parse_results KeyValuePairOutputFormat.parse content end end register(TextParser) do |filename| extension_matches?(filename, "txt") end class JsonParser < Base def parse_results if Facter.json? JSON.load(content) else Facter.warnonce "Cannot parse JSON data file #{filename} without the json library." Facter.warnonce "Suggested next step is `gem install json` to install the json library." nil end end end register(JsonParser) do |filename| extension_matches?(filename, "json") end class ScriptParser < Base def parse_results KeyValuePairOutputFormat.parse Facter::Util::Resolution.exec(quote(filename)) end private def quote(filename) filename.index(' ') ? "\"#{filename}\"" : filename end end register(ScriptParser) do |filename| if Facter::Util::Config.is_windows? extension_matches?(filename, %w{bat cmd com exe}) && File.file?(filename) else File.executable?(filename) && File.file?(filename) && ! extension_matches?(filename, %w{bat cmd com exe}) end end # Executes and parses the key value output of Powershell scripts class PowershellParser < Base # Returns a hash of facts from powershell output def parse_results shell_command = "powershell -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{filename}\"" KeyValuePairOutputFormat.parse Facter::Util::Resolution.exec(shell_command) end end register(PowershellParser) do |filename| Facter::Util::Config.is_windows? && extension_matches?(filename, "ps1") && File.file?(filename) end # A parser that is used when there is no other parser that can handle the file # The return from results indicates to the caller the file was not parsed correctly. class NothingParser def results nil end end end facter-1.7.5/lib/facter/util/registry.rb0000644005276200011600000000035212276213016020044 0ustar jenkinsjenkinsmodule Facter::Util::Registry class << self def hklm_read(key, value) require 'win32/registry' reg = Win32::Registry::HKEY_LOCAL_MACHINE.open(key) rval = reg[value] reg.close rval end end end facter-1.7.5/lib/facter/util/uptime.rb0000644005276200011600000000405412276213016017502 0ustar jenkinsjenkinsrequire 'time' # A module to gather uptime facts # module Facter::Util::Uptime def self.get_uptime_seconds_unix uptime_proc_uptime or uptime_sysctl or uptime_executable end def self.get_uptime_seconds_win require 'facter/util/wmi' last_boot = "" Facter::Util::WMI.execquery("select * from Win32_OperatingSystem").each do |x| last_boot = x.LastBootupTime end self.compute_uptime(Time.parse(last_boot.split('.').first)) end private def self.uptime_proc_uptime if output = Facter::Util::Resolution.exec("/bin/cat #{uptime_file} 2>/dev/null") output.chomp.split(" ").first.to_i end end def self.uptime_sysctl if output = Facter::Util::Resolution.exec("#{uptime_sysctl_cmd} 2>/dev/null") compute_uptime(Time.at(output.match(/\d+/)[0].to_i)) end end def self.uptime_executable if output = Facter::Util::Resolution.exec("#{uptime_executable_cmd} 2>/dev/null") up=0 if output =~ /(\d+) day(?:s|\(s\))?,\s+(\d+):(\d+)/ # Regexp handles Solaris, AIX, HP-UX, and Tru64. # 'day(?:s|\(s\))?' says maybe 'day', 'days', # or 'day(s)', and don't set $2. up=86400*$1.to_i + 3600*$2.to_i + 60*$3.to_i elsif output =~ /(\d+) day(?:s|\(s\))?,\s+(\d+) hr(?:s|\(s\))?,/ up=86400*$1.to_i + 3600*$2.to_i elsif output =~ /(\d+) day(?:s|\(s\))?,\s+(\d+) min(?:s|\(s\))?,/ up=86400*$1.to_i + 60*$2.to_i elsif output =~ /(\d+) day(?:s|\(s\))?,/ up=86400*$1.to_i elsif output =~ /up\s+(\d+):(\d+),/ # must anchor to 'up' to avoid matching time of day # at beginning of line. up=3600*$1.to_i + 60*$2.to_i elsif output =~ /(\d+) hr(?:s|\(s\))?,/ up=3600*$1.to_i elsif output =~ /(\d+) min(?:s|\(s\))?,/ up=60*$1.to_i end up end end def self.compute_uptime(time) (Time.now - time).to_i end def self.uptime_file "/proc/uptime" end def self.uptime_sysctl_cmd 'sysctl -n kern.boottime' end def self.uptime_executable_cmd "uptime" end end facter-1.7.5/lib/facter/util/macaddress.rb0000644005276200011600000000202212276213016020276 0ustar jenkinsjenkins# A module to gather macaddress facts # module Facter::Util::Macaddress def self.standardize(macaddress) return nil unless macaddress macaddress.split(":").map{|x| "0#{x}"[-2..-1]}.join(":") end module Darwin def self.macaddress iface = default_interface Facter.warn "Could not find a default route. Using first non-loopback interface" if iface.empty? macaddress = `#{ifconfig_command} #{iface} | /usr/bin/awk '/ether/{print $2;exit}'`.chomp macaddress.empty? ? nil : macaddress end def self.default_interface `#{netstat_command} | /usr/bin/awk '/^default/{print $6;exit}'`.chomp end private def self.netstat_command '/usr/sbin/netstat -rn' end def self.ifconfig_command '/sbin/ifconfig' end end module Windows def macaddress require 'facter/util/ip/windows' adapter = Facter::Util::IP::Windows.get_preferred_ipv4_adapters.first adapter ? adapter.MACAddress : nil end module_function :macaddress end end facter-1.7.5/lib/facter/util/manufacturer.rb0000644005276200011600000000556312276213016020701 0ustar jenkinsjenkins# mamufacturer.rb # Support methods for manufacturer specific facts module Facter::Manufacturer def self.get_dmi_table() case Facter.value(:kernel) when 'Linux', 'GNU/kFreeBSD' return nil unless FileTest.exists?("/usr/sbin/dmidecode") output=%x{/usr/sbin/dmidecode 2>/dev/null} when 'FreeBSD' return nil unless FileTest.exists?("/usr/local/sbin/dmidecode") output=%x{/usr/local/sbin/dmidecode 2>/dev/null} when 'NetBSD', 'DragonFly' return nil unless FileTest.exists?("/usr/pkg/sbin/dmidecode") output=%x{/usr/pkg/sbin/dmidecode 2>/dev/null} when 'SunOS' return nil unless FileTest.exists?("/usr/sbin/smbios") output=%x{/usr/sbin/smbios 2>/dev/null} else output=nil end return output end def self.dmi_find_system_info(name) splitstr= Facter.value(:kernel) == 'SunOS' ? "ID SIZE TYPE" : /^Handle/ output = self.get_dmi_table() return if output.nil? name.each_pair do |key,v| v.each do |v2| v2.each_pair do |value,facterkey| output.split(splitstr).each do |line| if line =~ /#{key}/ and line =~ /\n\s+#{value} (.+)\n/ result = $1.strip Facter.add(facterkey) do confine :kernel => [ :linux, :freebsd, :netbsd, :sunos, :"gnu/kfreebsd", :dragonfly ] setcode do result end end end end end end end end def self.sysctl_find_system_info(name) name.each do |sysctlkey,facterkey| Facter.add(facterkey) do confine :kernel => [:openbsd, :darwin] setcode do Facter::Util::Resolution.exec("sysctl -n #{sysctlkey} 2>/dev/null") end end end end def self.prtdiag_sparc_find_system_info() # Parses prtdiag for a SPARC architecture string, won't work with Solaris x86 output = Facter::Util::Resolution.exec('/usr/sbin/prtdiag 2>/dev/null') # System Configuration: Sun Microsystems sun4u Sun SPARC Enterprise M3000 Server if output and output =~ /^System Configuration:\s+(.+?)\s+(sun\d+\S+)\s+(.+)/ Facter.add('manufacturer') do setcode do $1 end end Facter.add('productname') do setcode do $3 end end end Facter.add('serialnumber') do setcode do Facter::Util::Resolution.exec("/usr/sbin/sneep") end end end def self.win32_find_system_info(name) require 'facter/util/wmi' value = "" wmi = Facter::Util::WMI.connect() name.each do |facterkey, win32key| query = wmi.ExecQuery("select * from Win32_#{win32key.last}") Facter.add(facterkey) do confine :kernel => :windows setcode do query.each { |x| value = x.__send__( (win32key.first).to_sym) } value end end end end end facter-1.7.5/lib/facter/util/file_read.rb0000644005276200011600000000216412276213016020111 0ustar jenkinsjenkinsmodule Facter module Util ## # {Facter::Util::FileRead} is a utility module intended to provide easily # mockable methods that delegate to simple file read methods. The intent is to # avoid the need to execute the `cat` system command or `File.read` directly in # Ruby, as mocking these behaviors can have wide-ranging effects. # # All Facter facts are encouraged to use this method instead of File.read or # Facter::Util::Resolution.exec('cat ...') # # @api public module FileRead ## # read returns the raw content of a file as a string. If the file does not # exist, or the process does not have permission to read the file then nil is # returned. # # @api public # # @return [String] the raw contents of the file at {path} or {nil} if the # file cannot be read because it does not exist or the process does not have # permission to read the file. def self.read(path) File.read(path) rescue Errno::ENOENT, Errno::EACCES => detail Facter.debug "Could not read #{path}: #{detail.message}" nil end def self.read_binary(path) File.open(path, "rb") { |contents| contents.read } end end end end facter-1.7.5/lib/facter/util/unix_root.rb0000644005276200011600000000011212276213016020214 0ustar jenkinsjenkinsmodule Facter::Util::Root def self.root? Process.uid == 0 end end facter-1.7.5/lib/facter/util/macosx.rb0000644005276200011600000000440512276213016017471 0ustar jenkinsjenkins## macosx.rb ## Support methods for Apple OSX facts ## ## Copyright (C) 2007 Jeff McCune ## Author: Jeff McCune ## module Facter::Util::Macosx require 'thread' require 'facter/util/cfpropertylist' require 'facter/util/resolution' Plist_Xml_Doctype = '' # JJM I'd really like to dynamically generate these methods # by looking at the _name key of the _items dict for each _dataType def self.profiler_xml(data_field) Facter::Util::Resolution.exec("/usr/sbin/system_profiler -xml #{data_field}") end def self.intern_xml(xml) return nil unless xml bad_xml_doctype = /^.* e fail("A plist file could not be properly read by Facter::Util::CFPropertyList: #{e.inspect}") end Facter::Util::CFPropertyList.native_types(plist.value) end # Return an xml result, modified as we need it. def self.profiler_data(data_field) begin return nil unless parsed_xml = intern_xml(profiler_xml(data_field)) return nil unless data = parsed_xml[0]['_items'][0] data.delete '_name' data rescue return nil end end def self.hardware_overview profiler_data("SPHardwareDataType") end def self.os_overview profiler_data("SPSoftwareDataType") end def self.sw_vers ver = Hash.new [ "productName", "productVersion", "buildVersion" ].each do |option| ver["macosx_#{option}"] = Facter::Util::Resolution.exec("/usr/bin/sw_vers -#{option}").strip end productversion = ver["macosx_productVersion"] if not productversion.nil? versions = productversion.scan(/(\d+)\.(\d+)\.*(\d*)/)[0] ver["macosx_productversion_major"] = "#{versions[0]}.#{versions[1]}" if versions[2].empty? # 10.x should be treated as 10.x.0 versions[2] = "0" end ver["macosx_productversion_minor"] = versions[2] end ver end end facter-1.7.5/lib/facter/util/loader.rb0000644005276200011600000000617212276213016017450 0ustar jenkinsjenkinsrequire 'facter' require 'pathname' require 'facter/util/directory_loader' # Load facts on demand. class Facter::Util::Loader def initialize @loaded = [] @valid_path = {} end # Load all resolutions for a single fact. def load(fact) # Now load from the search path shortname = fact.to_s.downcase load_env(shortname) filename = shortname + ".rb" search_path.each do |dir| # Load individual files file = File.join(dir, filename) load_file(file) if FileTest.exist?(file) # And load any directories matching the name factdir = File.join(dir, shortname) load_dir(factdir) if FileTest.directory?(factdir) end end # Load all facts from all directories. def load_all return if defined?(@loaded_all) load_env search_path.each do |dir| next unless FileTest.directory?(dir) Dir.entries(dir).sort.each do |file| path = File.join(dir, file) if File.directory?(path) load_dir(path) elsif file =~ /\.rb$/ load_file(File.join(dir, file)) end end end @loaded_all = true end # The list of directories we're going to search through for facts. def search_path result = [] result += $LOAD_PATH.collect { |d| File.join(d, "facter") } if ENV.include?("FACTERLIB") result += ENV["FACTERLIB"].split(File::PATH_SEPARATOR) end # This allows others to register additional paths we should search. result += Facter.search_path result.select do |dir| good = valid_search_path? dir Facter.debugonce("Relative directory #{dir} removed from search path.") unless good good end end def valid_search_path?(path) return @valid_path[path] unless @valid_path[path].nil? return @valid_path[path] = Pathname.new(path).absolute? end private :valid_search_path? private def load_dir(dir) return if dir =~ /\/\.+$/ or dir =~ /\/util$/ or dir =~ /\/lib$/ Dir.entries(dir).find_all { |f| f =~ /\.rb$/ }.sort.each do |file| load_file(File.join(dir, file)) end end def load_file(file) return if @loaded.include? file # We have to specify Kernel.load, because we have a load method. begin # Store the file path so we don't try to reload it @loaded << file Kernel.load(file) rescue ScriptError => detail # Don't store the path if the file can't be loaded # in case it's loadable later on. @loaded.delete(file) Facter.warn "Error loading fact #{file} #{detail}" end end # Load facts from the environment. If no name is provided, # all will be loaded. def load_env(fact = nil) # Load from the environment, if possible ENV.each do |name, value| # Skip anything that doesn't match our regex. next unless name =~ /^facter_?(\w+)$/i env_name = $1 # If a fact name was specified, skip anything that doesn't # match it. next if fact and env_name != fact Facter.add($1) do has_weight 1_000_000 setcode { value } end # Short-cut, if we are only looking for one value. break if fact end end end facter-1.7.5/lib/facter/util/cfpropertylist.rb0000644005276200011600000000017312276213016021266 0ustar jenkinsjenkins# -*- coding: utf-8 -*- require File.join(File.dirname(__FILE__), 'cfpropertylist', 'lib', 'rbCFPropertyList.rb') # eof facter-1.7.5/lib/facter/util/ip.rb0000644005276200011600000002327212276213016016612 0ustar jenkinsjenkins# A base module for collecting IP-related # information from all kinds of platforms. module Facter::Util::IP # A map of all the different regexes that work for # a given platform or set of platforms. REGEX_MAP = { :linux => { :ipaddress => /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, :ipaddress6 => /inet6 (?:addr: )?((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, :macaddress => /(?:ether|HWaddr)\s+((\w{1,2}:){5,}\w{1,2})/, :netmask => /(?:Mask:|netmask )([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, :mtu => /MTU:(\d+)/ }, :bsd => { :aliases => [:openbsd, :netbsd, :freebsd, :darwin, :"gnu/kfreebsd", :dragonfly], :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/, :netmask => /netmask\s+0x(\w{8})/, :mtu => /mtu\s+(\d+)/ }, :sunos => { :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/, :netmask => /netmask\s+(\w{8})/, :mtu => /mtu\s+(\d+)/ }, :"hp-ux" => { :ipaddress => /\s+inet (\S+)\s.*/, :macaddress => /(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/, :netmask => /.*\s+netmask (\S+)\s.*/ }, :windows => {} } # Convert an interface name into purely alphanumeric characters. def self.alphafy(interface) interface.gsub(/[^a-z0-9_]/i, '_') end def self.convert_from_hex?(kernel) kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin, :"hp-ux", :"gnu/kfreebsd", :dragonfly] kernels_to_convert.include?(kernel) end def self.supported_platforms REGEX_MAP.inject([]) do |result, tmp| key, map = tmp if map[:aliases] result += map[:aliases] else result << key end result end end def self.get_interfaces if Facter.value(:kernel) == 'windows' require 'facter/util/ip/windows' return Facter::Util::IP::Windows.interfaces end return [] unless output = Facter::Util::IP.get_all_interface_output() # Our regex appears to be stupid, in that it leaves colons sitting # at the end of interfaces. So, we have to trim those trailing # characters. I tried making the regex better but supporting all # platforms with a single regex is probably a bit too much. output.scan(/^\S+/).collect { |i| i.sub(/:$/, '') }.uniq end def self.get_all_interface_output case Facter.value(:kernel) when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD', 'DragonFly' output = Facter::Util::IP.exec_ifconfig(["-a","2>/dev/null"]) when 'SunOS' output = Facter::Util::IP.exec_ifconfig(["-a"]) when 'HP-UX' # (#17487)[https://projects.puppetlabs.com/issues/17487] # Handle NIC bonding where asterisks and virtual NICs are printed. if output = hpux_netstat_in output.gsub!(/\*/, "") # delete asterisks. output.gsub!(/^[^\n]*none[^\n]*\n/, "") # delete lines with 'none' instead of IPs. output.sub!(/^[^\n]*\n/, "") # delete the header line. output end end output end ## # exec_ifconfig uses the ifconfig command # # @return [String] the output of `ifconfig #{arguments} 2>/dev/null` or nil def self.exec_ifconfig(additional_arguments=[]) Facter::Util::Resolution.exec("#{self.get_ifconfig} #{additional_arguments.join(' ')}") end ## # get_ifconfig looks up the ifconfig binary # # @return [String] path to the ifconfig binary def self.get_ifconfig common_paths=["/bin/ifconfig","/sbin/ifconfig","/usr/sbin/ifconfig"] common_paths.select{|path| File.executable?(path)}.first end ## # hpux_netstat_in is a delegate method that allows us to stub netstat -in # without stubbing exec. def self.hpux_netstat_in Facter::Util::Resolution.exec("/bin/netstat -in") end def self.get_infiniband_macaddress(interface) if File.exists?("/sys/class/net/#{interface}/address") then ib_mac_address = `cat /sys/class/net/#{interface}/address`.chomp elsif File.exists?("/sbin/ip") then ip_output = %x{/sbin/ip link show #{interface}} ib_mac_address = ip_output.scan(%r{infiniband\s+((\w{1,2}:){5,}\w{1,2})}) else ib_mac_address = "FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF" Facter.debug("ip.rb: nothing under /sys/class/net/#{interface}/address and /sbin/ip not available") end ib_mac_address end def self.ifconfig_interface(interface) output = Facter::Util::IP.exec_ifconfig([interface,"2>/dev/null"]) end def self.get_single_interface_output(interface) output = "" case Facter.value(:kernel) when 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD', 'DragonFly' output = Facter::Util::IP.ifconfig_interface(interface) when 'Linux' ifconfig_output = Facter::Util::IP.ifconfig_interface(interface) if interface =~ /^ib/ then real_mac_address = get_infiniband_macaddress(interface) output = ifconfig_output.sub(%r{(?:ether|HWaddr)\s+((\w{1,2}:){5,}\w{1,2})}, "HWaddr #{real_mac_address}") else output = ifconfig_output end when 'SunOS' output = Facter::Util::IP.exec_ifconfig([interface]) when 'HP-UX' mac = "" ifc = hpux_ifconfig_interface(interface) hpux_lanscan.scan(/(\dx\S+).*UP\s+(\w+\d+)/).each {|i| mac = i[0] if i.include?(interface) } mac = mac.sub(/0x(\S+)/,'\1').scan(/../).join(":") output = ifc + "\n" + mac end output end def self.hpux_ifconfig_interface(interface) Facter::Util::IP.exec_ifconfig([interface]) end def self.hpux_lanscan Facter::Util::Resolution.exec("/usr/sbin/lanscan") end def self.get_output_for_interface_and_label(interface, label) return get_single_interface_output(interface) unless Facter.value(:kernel) == 'windows' require 'facter/util/ip/windows' output = Facter::Util::IP::Windows.value_for_interface_and_label(interface, label) output ? output : "" end def self.get_bonding_master(interface) if Facter.value(:kernel) != 'Linux' return nil end # We need ip instead of ifconfig because it will show us # the bonding master device. if not FileTest.executable?("/sbin/ip") return nil end # A bonding interface can never be an alias interface. Alias # interfaces do have a colon in their name and the ip link show # command throws an error message when we pass it an alias # interface. if interface =~ /:/ return nil end regex = /SLAVE[,>].* (bond[0-9]+)/ ethbond = regex.match(%x{/sbin/ip link show #{interface}}) if ethbond device = ethbond[1] else device = nil end device end ## # get_interface_value obtains the value of a specific attribute of a specific # interface. # # @param interface [String] the interface identifier, e.g. "eth0" or "bond0" # # @param label [String] the attribute of the interface to obtain a value for, # e.g. "netmask" or "ipaddress" # # @api private # # @return [String] representing the requested value. An empty array is # returned if the kernel is not supported by the REGEX_MAP constant. def self.get_interface_value(interface, label) if Facter.value(:kernel) == 'windows' require 'facter/util/ip/windows' return Facter::Util::IP::Windows.value_for_interface_and_label(interface, label) end tmp1 = [] kernel = Facter.value(:kernel).downcase.to_sym # If it's not directly in the map or aliased in the map, then we don't know how to deal with it. unless map = REGEX_MAP[kernel] || REGEX_MAP.values.find { |tmp| tmp[:aliases] and tmp[:aliases].include?(kernel) } return [] end # Pull the correct regex out of the map. regex = map[label.to_sym] # Linux changes the MAC address reported via ifconfig when an ethernet interface # becomes a slave of a bonding device to the master MAC address. # We have to dig a bit to get the original/real MAC address of the interface. bonddev = get_bonding_master(interface) if label == 'macaddress' and bonddev bondinfo = read_proc_net_bonding("/proc/net/bonding/#{bonddev}") re = /^Slave Interface: #{interface}\b.*?\bPermanent HW addr: (([0-9A-F]{2}:?)*)$/im if match = re.match(bondinfo) value = match[1].upcase end else output_int = get_output_for_interface_and_label(interface, label) output_int.each_line do |s| if s =~ regex value = $1 if label == 'netmask' && convert_from_hex?(kernel) value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.') end tmp1.push(value) end end if tmp1 value = tmp1.shift end end end ## # read_proc_net_bonding is a seam method for mocking purposes. # # @param path [String] representing the path to read, e.g. "/proc/net/bonding/bond0" # # @api private # # @return [String] modeling the raw file read def self.read_proc_net_bonding(path) File.read(path) if File.exists?(path) end private_class_method :read_proc_net_bonding def self.get_network_value(interface) require 'ipaddr' ipaddress = get_interface_value(interface, "ipaddress") netmask = get_interface_value(interface, "netmask") if ipaddress && netmask ip = IPAddr.new(ipaddress, Socket::AF_INET) subnet = IPAddr.new(netmask, Socket::AF_INET) network = ip.mask(subnet.to_s).to_s end end end facter-1.7.5/lib/facter/util/ip/0000755005276200011600000000000012276213023016255 5ustar jenkinsjenkinsfacter-1.7.5/lib/facter/util/ip/windows.rb0000644005276200011600000001443212276213016020302 0ustar jenkinsjenkins# encoding: UTF-8 require 'facter/util/wmi' require 'facter/util/ip' class Facter::Util::IP::Windows # The WMI query used to return ip information # # @return [String] # # @api private WMI_IP_INFO_QUERY = 'SELECT Description, ServiceName, IPAddress, IPConnectionMetric, InterfaceIndex, Index, IPSubnet, MACAddress, MTU, SettingID FROM Win32_NetworkAdapterConfiguration WHERE IPConnectionMetric IS NOT NULL AND IPEnabled = TRUE' # Mapping fact names to WMI properties of the Win32_NetworkAdapterConfiguration # # @api private WINDOWS_LABEL_WMI_MAP = { :ipaddress => 'IPAddress', :ipaddress6 => 'IPAddress', :macaddress => 'MACAddress', :netmask => 'IPSubnet' } def self.to_s 'windows' end # Windows doesn't display netmask in hex. # # @return [Boolean] false by default # # @api private def self.convert_netmask_from_hex? false end # Retrieves a list of unique interfaces names. # # @return [Array] # # @api private def self.interfaces interface_names = [] network_adapter_configurations.map do |nic| Facter::Util::WMI.execquery("SELECT * FROM Win32_NetworkAdapter WHERE Index = #{nic.Index} AND NetEnabled = TRUE").each do |nic| interface_names << nic.NetConnectionId unless nic.NetConnectionId.nil? or nic.NetConnectionId.empty? end end interface_names.uniq end # Get the value of an interface and label. For example, you may want to find # the MTU for eth0. # # @param [String] interface the name of the interface returned by the {#interfaces} method. # @param [String] label the type of value to return, e.g. ipaddress # @return [String] the value, or nil if not defined # # @api private def self.value_for_interface_and_label(interface, label) wmi_value = WINDOWS_LABEL_WMI_MAP[label.downcase.to_sym] label_value = nil Facter::Util::WMI.execquery("SELECT Index FROM Win32_NetworkAdapter WHERE NetConnectionID = '#{interface}'").each do |nic| Facter::Util::WMI.execquery("SELECT #{wmi_value} FROM Win32_NetworkAdapterConfiguration WHERE Index = #{nic.Index}").each do |nic_config| case label.downcase.to_sym when :ipaddress nic_config.IPAddress.any? do |addr| label_value = addr if valid_ipv4_address?(addr) label_value end when :ipaddress6 nic_config.IPAddress.any? do |addr| label_value = addr if Facter::Util::IP::Windows.valid_ipv6_address?(addr) label_value end when :netmask nic_config.IPSubnet.any? do |addr| label_value = addr if Facter::Util::IP::Windows.valid_ipv4_address?(addr) label_value end when :macaddress label_value = nic_config.MACAddress end end end label_value end # Returns an array of partial Win32_NetworkAdapterConfiguration objects. # # @return [Array] objects # # @api private def self.network_adapter_configurations nics = [] # WIN32OLE doesn't implement Enumerable Facter::Util::WMI.execquery(WMI_IP_INFO_QUERY).each do |nic| nics << nic end nics end # Gets a list of active IPv4 network adapter configurations sorted by the # lowest IP connection metric. If two configurations have the same metric, # then the IPv4 specific binding order as specified in the registry will # be used. # # @return [Array] # # @api private def self.get_preferred_ipv4_adapters get_preferred_network_adapters(Bindings4.new) end # Gets a list of active IPv6 network adapter configurations sorted by the # lowest IP connection metric. If two configurations have the same metric, # then the IPv6 specific binding order as specified in the registry will # be used. # # @return [Array] # # @api private def self.get_preferred_ipv6_adapters get_preferred_network_adapters(Bindings6.new) end # Gets a list of active network adapter configurations sorted by the lowest # IP connection metric. If two configurations have the same metric, then # the adapter binding order as specified in the registry will be used. # Note the order may different for IPv4 vs IPv6 addresses. # # @see http://support.microsoft.com/kb/894564 # @return [Array] # # @api private def self.get_preferred_network_adapters(bindings) network_adapter_configurations.select do |nic| bindings.bindings.include?(nic.SettingID) end.sort do |nic_left,nic_right| cmp = nic_left.IPConnectionMetric <=> nic_right.IPConnectionMetric if cmp == 0 bindings.bindings[nic_left.SettingID] <=> bindings.bindings[nic_right.SettingID] else cmp end end end class Bindings4 def initialize @key = 'SYSTEM\CurrentControlSet\Services\Tcpip\Linkage' end def bindings require 'facter/util/registry' bindings = {} Facter::Util::Registry.hklm_read(@key, 'Bind').each_with_index do |entry, index| match_data = entry.match(/\\Device\\(\{.*\})/) unless match_data.nil? bindings[match_data[1]] = index end end bindings rescue {} end end class Bindings6 < Bindings4 def initialize @key = 'SYSTEM\CurrentControlSet\Services\Tcpip6\Linkage' end end # Determines if the value passed in is a valid ipv4 address. # # @param [String] ip_address the IPv4 address to validate # @return [Boolean] # # @api private def self.valid_ipv4_address?(ip_address) String(ip_address).scan(/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/).each do |match| # excluding 169.254.x.x in Windows - this is the DHCP APIPA # meaning that if the node cannot get an ip address from the dhcp server, # it auto-assigns a private ip address unless match == "127.0.0.1" or match =~ /^169.254.*/ return !!match end end false end # Determines if the value passed in is a valid ipv6 address. # # @param [String] ip_address the IPv6 address to validate # @return [Boolean] # # @api private def self.valid_ipv6_address?(ip_address) String(ip_address).scan(/(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4}/).each do |match| unless match =~ /fe80.*/ or match == "::1" return !!match end end false end end facter-1.7.5/lib/facter/util/virtual.rb0000644005276200011600000001060312276213016017662 0ustar jenkinsjenkinsrequire 'facter/util/file_read' module Facter::Util::Virtual ## # virt_what is a delegating helper method intended to make it easier to stub # the system call without affecting other calls to # Facter::Util::Resolution.exec # # Per https://bugzilla.redhat.com/show_bug.cgi?id=719611 when run as a # non-root user the virt-what command may emit an error message on stdout, # and later versions of virt-what may emit this message on stderr. This # method ensures stderr is redirected and that error messages are stripped # from stdout. def self.virt_what(command = "virt-what") command = Facter::Util::Resolution.which(command) return unless command if Facter.value(:kernel) == 'windows' redirected_cmd = "#{command} 2>NUL" else redirected_cmd = "#{command} 2>/dev/null" end output = Facter::Util::Resolution.exec redirected_cmd output.gsub(/^virt-what: .*$/, '') if output end ## # lspci is a delegating helper method intended to make it easier to stub the # system call without affecting other calls to Facter::Util::Resolution.exec def self.lspci(command = "lspci 2>/dev/null") Facter::Util::Resolution.exec command end def self.openvz? FileTest.directory?("/proc/vz") and not self.openvz_cloudlinux? end # So one can either have #6728 work on OpenVZ or Cloudlinux. Whoo. def self.openvz_type return false unless self.openvz? return false unless FileTest.exists?( '/proc/self/status' ) envid = Facter::Util::Resolution.exec( 'grep "envID" /proc/self/status' ) if envid =~ /^envID:\s+0$/i return 'openvzhn' elsif envid =~ /^envID:\s+(\d+)$/i return 'openvzve' end end # Cloudlinux uses OpenVZ to a degree, but always has an empty /proc/vz/ and # has /proc/lve/list present def self.openvz_cloudlinux? FileTest.file?("/proc/lve/list") or Dir.glob('/proc/vz/*').empty? end def self.zone? return true if FileTest.directory?("/.SUNWnative") z = Facter::Util::Resolution.exec("/sbin/zonename") return false unless z return z.chomp != 'global' end def self.vserver? return false unless FileTest.exists?("/proc/self/status") txt = File.open("/proc/self/status", "rb").read if txt.respond_to?(:encode!) txt.encode!('UTF-16', 'UTF-8', :invalid => :replace) txt.encode!('UTF-8', 'UTF-16') end return true if txt =~ /^(s_context|VxID):[[:blank:]]*[0-9]/ return false end def self.vserver_type if self.vserver? if FileTest.exists?("/proc/virtual") "vserver_host" else "vserver" end end end def self.xen? ["/proc/sys/xen", "/sys/bus/xen", "/proc/xen" ].detect do |f| FileTest.exists?(f) end end def self.kvm? txt = if FileTest.exists?("/proc/cpuinfo") File.read("/proc/cpuinfo") elsif ["FreeBSD", "OpenBSD"].include? Facter.value(:kernel) Facter::Util::Resolution.exec("/sbin/sysctl -n hw.model") end (txt =~ /QEMU Virtual CPU/) ? true : false end def self.virtualbox? File.read("/sys/devices/virtual/dmi/id/product_name") =~ /VirtualBox/ rescue false end def self.kvm_type # TODO Tell the difference between kvm and qemu # Can't work out a way to do this at the moment that doesn't # require a special binary if self.kvm? "kvm" end end def self.rhev? File.read("/sys/devices/virtual/dmi/id/product_name") =~ /RHEV Hypervisor/ rescue false end def self.ovirt? File.read("/sys/devices/virtual/dmi/id/product_name") =~ /oVirt Node/ rescue false end def self.jail? path = case Facter.value(:kernel) when "FreeBSD" then "/sbin" when "GNU/kFreeBSD" then "/bin" end Facter::Util::Resolution.exec("#{path}/sysctl -n security.jail.jailed") == "1" end def self.hpvm? Facter::Util::Resolution.exec("/usr/bin/getconf MACHINE_MODEL").chomp =~ /Virtual Machine/ end def self.zlinux? "zlinux" end ## # read_sysfs Reads the raw data as per the documentation at [Detecting if You # Are Running in Google Compute # Engine](https://developers.google.com/compute/docs/instances#dmi) This # method is intended to provide an easy seam to mock. # # @api public # # @return [String] or nil if the path does not exist def self.read_sysfs_dmi_entries(path="/sys/firmware/dmi/entries/1-0/raw") if File.exists?(path) Facter::Util::FileRead.read_binary(path) end end end facter-1.7.5/lib/facter/util/netmask.rb0000644005276200011600000000232612276213016017641 0ustar jenkinsjenkinsmodule Facter::NetMask def self.get_netmask netmask = nil; ipregex = %r{(\d{1,3}\.){3}\d{1,3}} ops = nil case Facter.value(:kernel) when 'Linux' ops = { :ifconfig_opts => ['2>/dev/null'], :regex => %r{#{Facter.ipaddress}.*?(?:Mask:|netmask)\s*(#{ipregex})}x, :munge => nil, } when 'SunOS' ops = { :ifconfig_opts => ['-a'], :regex => %r{\s+ inet \s #{Facter.ipaddress} \s netmask \s (\w{8})}x, :munge => Proc.new { |mask| mask.scan(/../).collect do |byte| byte.to_i(16) end.join('.') } } when 'FreeBSD','NetBSD','OpenBSD', 'Darwin', 'GNU/kFreeBSD', 'DragonFly' ops = { :ifconfig_opts => ['-a'], :regex => %r{\s+ inet \s #{Facter.ipaddress} \s netmask \s 0x(\w{8})}x, :munge => Proc.new { |mask| mask.scan(/../).collect do |byte| byte.to_i(16) end.join('.') } } end String(Facter::Util::IP.exec_ifconfig(ops[:ifconfig_opts])).split(/\n/).collect do |line| matches = line.match(ops[:regex]) if !matches.nil? if ops[:munge].nil? netmask = matches[1] else netmask = ops[:munge].call(matches[1]) end end end netmask end end facter-1.7.5/lib/facter/util/resolution.rb0000644005276200011600000002566512276213016020415 0ustar jenkinsjenkins# An actual fact resolution mechanism. These are largely just chunks of # code, with optional confinements restricting the mechanisms to only working on # specific systems. Note that the confinements are always ANDed, so any # confinements specified must all be true for the resolution to be # suitable. require 'facter/util/confine' require 'facter/util/config' require 'timeout' class Facter::Util::Resolution attr_accessor :interpreter, :code, :name, :timeout attr_writer :value, :weight INTERPRETER = Facter::Util::Config.is_windows? ? "cmd.exe" : "/bin/sh" # Returns the locations to be searched when looking for a binary. This # is currently determined by the +PATH+ environment variable plus # /sbin and /usr/sbin when run on unix def self.search_paths if Facter::Util::Config.is_windows? ENV['PATH'].split(File::PATH_SEPARATOR) else # Make sure facter is usable even for non-root users. Most commands # in /sbin (like ifconfig) can be run as non priviledged users as # long as they do not modify anything - which we do not do with facter ENV['PATH'].split(File::PATH_SEPARATOR) + [ '/sbin', '/usr/sbin' ] end end # Determine the full path to a binary. If the supplied filename does not # already describe an absolute path then different locations (determined # by self.search_paths) will be searched for a match. # # Returns nil if no matching executable can be found otherwise returns # the expanded pathname. def self.which(bin) if absolute_path?(bin) return bin if File.executable?(bin) if Facter::Util::Config.is_windows? and File.extname(bin).empty? exts = ENV['PATHEXT'] exts = exts ? exts.split(File::PATH_SEPARATOR) : %w[.COM .EXE .BAT .CMD] exts.each do |ext| destext = bin + ext if File.executable?(destext) Facter.warnonce("Using Facter::Util::Resolution.which with an absolute path like #{bin} but no fileextension is deprecated. Please add the correct extension (#{ext})") return destext end end end else search_paths.each do |dir| dest = File.join(dir, bin) if Facter::Util::Config.is_windows? dest.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File.extname(dest).empty? exts = ENV['PATHEXT'] exts = exts ? exts.split(File::PATH_SEPARATOR) : %w[.COM .EXE .BAT .CMD] exts.each do |ext| destext = dest + ext return destext if File.executable?(destext) end end end return dest if File.executable?(dest) end end nil end # Determine in a platform-specific way whether a path is absolute. This # defaults to the local platform if none is specified. def self.absolute_path?(path, platform=nil) # Escape once for the string literal, and once for the regex. slash = '[\\\\/]' name = '[^\\\\/]+' regexes = { :windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i, :posix => %r!^/!, } platform ||= Facter::Util::Config.is_windows? ? :windows : :posix !! (path =~ regexes[platform]) end # Expand the executable of a commandline to an absolute path. The executable # is the first word of the commandline. If the executable contains spaces, # it has be but in double quotes to be properly recognized. # # Returns the commandline with the expanded binary or nil if the binary # can't be found. If the path to the binary contains quotes, the whole binary # is put in quotes. def self.expand_command(command) if match = /^"(.+?)"(?:\s+(.*))?/.match(command) exe, arguments = match.captures exe = which(exe) and [ "\"#{exe}\"", arguments ].compact.join(" ") elsif match = /^'(.+?)'(?:\s+(.*))?/.match(command) and not Facter::Util::Config.is_windows? exe, arguments = match.captures exe = which(exe) and [ "'#{exe}'", arguments ].compact.join(" ") else exe, arguments = command.split(/ /,2) if exe = which(exe) # the binary was not quoted which means it contains no spaces. But the # full path to the binary may do so. exe = "\"#{exe}\"" if exe =~ /\s/ and Facter::Util::Config.is_windows? exe = "'#{exe}'" if exe =~ /\s/ and not Facter::Util::Config.is_windows? [ exe, arguments ].compact.join(" ") end end end # # Call this method with a block of code for which you would like to temporarily modify # one or more environment variables; the specified values will be set for the duration # of your block, after which the original values (if any) will be restored. # # [values] a Hash containing the key/value pairs of any environment variables that you # would like to temporarily override def self.with_env(values) old = {} values.each do |var, value| # save the old value if it exists if old_val = ENV[var] old[var] = old_val end # set the new (temporary) value for the environment variable ENV[var] = value end # execute the caller's block, capture the return value rv = yield # use an ensure block to make absolutely sure we restore the variables ensure # restore the old values values.each do |var, value| if old.include?(var) ENV[var] = old[var] else # if there was no old value, delete the key from the current environment variables hash ENV.delete(var) end end # return the captured return value rv end # Execute a program and return the output of that program. # # Returns nil if the program can't be found, or if there is a problem # executing the code. # def self.exec(code, interpreter = nil) Facter.warnonce "The interpreter parameter to 'exec' is deprecated and will be removed in a future version." if interpreter ## Set LANG to force i18n to C for the duration of this exec; this ensures that any code that parses the ## output of the command can expect it to be in a consistent / predictable format / locale with_env "LANG" => "C" do if expanded_code = expand_command(code) # if we can find the binary, we'll run the command with the expanded path to the binary code = expanded_code else # if we cannot find the binary return nil on posix. On windows we'll still try to run the # command in case it is a shell-builtin. In case it is not, windows will raise Errno::ENOENT return nil unless Facter::Util::Config.is_windows? return nil if absolute_path?(code) end out = nil begin out = %x{#{code}}.chomp Facter.warnonce "Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass \"cmd /c your_builtin\" as a command (command responsible for this message was \"#{code}\")" unless expanded_code rescue Errno::ENOENT => detail # command not found on Windows return nil rescue => detail Facter.warn(detail) return nil end if out == "" return nil else return out end end end # Add a new confine to the resolution mechanism. def confine(confines) confines.each do |fact, values| @confines.push Facter::Util::Confine.new(fact, *values) end end def has_weight(weight) @weight = weight end # Create a new resolution mechanism. def initialize(name) @name = name @confines = [] @value = nil @timeout = 0 @weight = nil end # Return the importance of this resolution. def weight if @weight @weight else @confines.length end end # We need this as a getter for 'timeout', because some versions # of ruby seem to already have a 'timeout' method and we can't # seem to override the instance methods, somehow. def limit @timeout end # Set our code for returning a value. def setcode(string = nil, interp = nil, &block) Facter.warnonce "The interpreter parameter to 'setcode' is deprecated and will be removed in a future version." if interp if string @code = string @interpreter = interp || INTERPRETER else unless block_given? raise ArgumentError, "You must pass either code or a block" end @code = block end end ## # on_flush accepts a block and executes the block when the resolution's value # is flushed. This makes it possible to model a single, expensive system # call inside of a Ruby object and then define multiple dynamic facts which # resolve by sending messages to the model instance. If one of the dynamic # facts is flushed then it can, in turn, flush the data stored in the model # instance to keep all of the dynamic facts in sync without making multiple, # expensive, system calls. # # Please see the Solaris zones fact for an example of how this feature may be # used. # # @see Facter::Util::Fact#flush # @see Facter::Util::Resolution#flush # # @api public def on_flush(&block) @on_flush_block = block end ## # flush executes the block, if any, stored by the {on_flush} method # # @see Facter::Util::Fact#flush # @see Facter::Util::Resolution#on_flush # # @api private def flush @on_flush_block.call if @on_flush_block end def interpreter Facter.warnonce "The 'Facter::Util::Resolution.interpreter' method is deprecated and will be removed in a future version." @interpreter end def interpreter=(interp) Facter.warnonce "The 'Facter::Util::Resolution.interpreter=' method is deprecated and will be removed in a future version." @interpreter = interp end # Is this resolution mechanism suitable on the system in question? def suitable? unless defined? @suitable @suitable = ! @confines.detect { |confine| ! confine.true? } end return @suitable end def to_s return self.value() end # How we get a value for our resolution mechanism. def value return @value if @value result = nil return result if @code == nil starttime = Time.now.to_f begin Timeout.timeout(limit) do if @code.is_a?(Proc) result = @code.call() else result = Facter::Util::Resolution.exec(@code) end end rescue Timeout::Error => detail Facter.warn "Timed out seeking value for %s" % self.name # This call avoids zombies -- basically, create a thread that will # dezombify all of the child processes that we're ignoring because # of the timeout. Thread.new { Process.waitall } return nil rescue => details Facter.warn "Could not retrieve %s: %s" % [self.name, details] return nil end finishtime = Time.now.to_f ms = (finishtime - starttime) * 1000 Facter.show_time "#{self.name}: #{"%.2f" % ms}ms" return nil if result == "" return result end end facter-1.7.5/lib/facter/util/plist.rb0000644005276200011600000000130012276213016017321 0ustar jenkinsjenkins#-- ############################################################## # Copyright 2006, Ben Bleything and # # Patrick May # # # # Distributed under the MIT license. # ############################################################## #++ # = Plist # # This is the main file for plist. Everything interesting happens in Plist and Plist::Emit. require 'base64' require 'cgi' require 'stringio' require 'facter/util/plist/generator' require 'facter/util/plist/parser' module Plist VERSION = '3.0.0' end # $Id: plist.rb 1781 2006-10-16 01:01:35Z luke $ facter-1.7.5/lib/facter/util/processor.rb0000644005276200011600000002103712276213016020216 0ustar jenkinsjenkinsmodule Facter module Util module Processor ## # aix_processor_list is intended to generate a list of values for the # processorX facts. The behavior is as follows from # [#11609](http://projects.puppetlabs.com/issues/11609) # # 1. Take a list of all the processor identifiers for the platform, # represented as system-native identifiers in strings. # 2. Sort the list # 3. Assign an incrementing from 0 integer index to each identifier. # 4. Store the value of the system identifier in the processorX fact where X # is the incrementing index. # # Returns an Array, sorted, containing the values for the facts. def self.aix_processor_list return_value = [] aix_proc_id_list = [] if output = lsdev then output.split("\n").each do |line| if match = line.match(/proc\d+/) aix_proc_id_list << match[0] end end end # Generalized alphanumeric sort to put "proc12" behind "proc4" padding = 8 aix_proc_id_list = aix_proc_id_list.sort do |a,b| a,b = [a,b].map do |s| s.gsub(/\d+/) { |m| "0"*(padding - m.size) + m } end a<=>b end aix_proc_id_list.each do |proc_id| if output = lsattr("lsattr -El #{proc_id} -a type") if match = output.match(/type\s+([^\s]+)\s+Processor/i) return_value << match[1] end end end return_value end ## # lsdev is intended to directly delegate to Facter::Util::Resolution.exec in an # effort to make the processorX facts easier to test by stubbing only the # behaviors we need to stub to get the output of the system command. def self.lsdev(command="lsdev -Cc processor") Facter::Util::Resolution.exec(command) end ## # lsattr is intended to directly delegate to Facter::Util::Resolution.exec in # an effort to make the processorX facts easier to test. See also the # {lsdev} method. def self.lsattr(command="lsattr -El proc0 -a type") Facter::Util::Resolution.exec(command) end ## # kernel_fact_value is intended to directly delegate to Facter.value(:kernel) # to make it easier to stub the kernel fact without affecting the entire # system. def self.kernel_fact_value Facter.value(:kernel) end ## # hpux_processor_list is intended to generate a list of values for the # processorX facts. def self.hpux_processor_list return_value = [] hpux_proc_id_list = [] cpu = "" ## # first, try parsing machinfo output. if output = machinfo then output.split("\n").each do |line| if line.match(/processor model:\s+\d+\s+(.*)/) then cpu = $1.to_s elsif line.match(/\d+\s+((?:PA-RISC|Intel).*processors.*)/) then cpu = $1.to_s cpu.sub!(/processors/, "processor") elsif line.match(/\s+(Intel.*Processor.*)/) then cpu = $1.to_s end end end ## # if that fails, try looking using model command and cross referencing against # sched.models, which could be in three places. This file only catered for # PA-RISC. Unfortunately, the file is not up to date sometimes. if cpu.empty? then m = model m.sub!(/\s+$/, "") m.sub!(/.*\//, "") m.sub!(/.*\s+/, "") if sched_models_lines = read_sched_models sched_models_lines.each do |l| if l.match(m) and l.match(/^\S+\s+\d+\.\d+\s+(\S+)/) then cpu = "PA-RISC " + $1.to_s.sub!(/^PA/, "") + " processor" break # we assume first match is the only match. end end end end ## # if that also fails, report the CPU version based on unistd.h and chip type based on getconf. if cpu.empty? then cpu_version = getconf_cpu_version cpu_chip_type = getconf_cpu_chip_type cpu_string = "" if lines = read_unistd_h("/usr/include/sys/unistd.h") then lines.each do |l| if l.match(/define.*0x#{cpu_version.to_i.to_s(16)}.*\/\*\s+(.*)\s+\*\//) then cpu_string = $1.to_s break end end end if cpu_string.empty? then cpu_string = "CPU v" + cpu_version end cpu = cpu_string + " CHIP TYPE #" + cpu_chip_type end ## # now count (logical) CPUs using ioscan. We set processorX for X in 0..processorcount # to cpu as worked out above. HP-UX does not support more than one installed CPU # model. if output = ioscan then output.split("\n").each do |line| if line.match(/processor/) then hpux_proc_id_list << cpu end end end hpux_proc_id_list end ## # read_sched_models is intended to be stubbed instead of File.readlines # @return [Array] of strings containing the lines of the file or nil if the # sched.models file could not be located. def self.read_sched_models path = if File.exists?("/usr/lib/sched.models") "/usr/lib/sched.models" elsif File.exists?("/usr/sam/lib/mo/sched.models") "/usr/sam/lib/mo/sched.models" elsif File.exists?("/opt/langtools/lib/sched.models") "/opt/langtools/lib/sched.models" end if path File.readlines(path) end end private_class_method :read_sched_models ## # read_unistd_h is intended to be stubbed instead of File.readlines # @return [Array] of Strings or nil if the file does not exist. def self.read_unistd_h(path) if File.exists?(path) then File.readlines(path) end end private_class_method :read_unistd_h ## # machinfo delegates directly to Facter::Util::Resolution.exec, as with lsdev # above. def self.machinfo(command="/usr/contrib/bin/machinfo") Facter::Util::Resolution.exec(command) end ## # model delegates directly to Facter::Util::Resolution.exec. def self.model(command="model") Facter::Util::Resolution.exec(command) end ## # ioscan delegates directly to Facter::Util::Resolution.exec. def self.ioscan(command="ioscan -fknCprocessor") Facter::Util::Resolution.exec(command) end ## # getconf_cpu_version delegates directly to Facter::Util::Resolution.exec. def self.getconf_cpu_version(command="getconf CPU_VERSION") Facter::Util::Resolution.exec(command) end ## # getconf_cpu_chip_type delegates directly to Facter::Util::Resolution.exec. def self.getconf_cpu_chip_type(command="getconf CPU_CHIP_TYPE") Facter::Util::Resolution.exec(command) end def self.enum_cpuinfo processor_num = -1 processor_list = [] cpuinfo = "/proc/cpuinfo" if File.exists?(cpuinfo) model = Facter.value(:architecture) case model when "x86_64", "amd64", "i386", "x86", /parisc/, "hppa", "ia64" File.readlines(cpuinfo).each do |l| if l =~ /processor\s+:\s+(\d+)/ processor_num = $1.to_i elsif l =~ /model name\s+:\s+(.*)\s*$/ processor_list[processor_num] = $1 unless processor_num == -1 processor_num = -1 elsif l =~ /processor\s+(\d+):\s+(.*)/ processor_num = $1.to_i processor_list[processor_num] = $2 unless processor_num == -1 end end when "ppc64" File.readlines(cpuinfo).each do |l| if l =~ /processor\s+:\s+(\d+)/ processor_num = $1.to_i elsif l =~ /cpu\s+:\s+(.*)\s*$/ processor_list[processor_num] = $1 unless processor_num == -1 processor_num = -1 end end when /arm/ File.readlines(cpuinfo).each do |l| if l =~ /Processor\s+:\s+(.+)/ processor_num += 1 processor_list[processor_num] = $1.chomp elsif l =~ /processor\s+:\s+(\d+)\s*$/ proc_num = $1.to_i if proc_num != 0 processor_num += 1 processor_list[processor_num] = processor_list[processor_num-1] end end end when /sparc/ File.readlines(cpuinfo).each do |l| if l =~ /cpu\s+:\s+(.*)\s*$/ processor_num += 1 processor_list[processor_num] = $1 end end end end processor_list end def self.enum_kstat processor_num = -1 processor_list = [] Thread::exclusive do kstat = Facter::Util::Resolution.exec('/usr/bin/kstat cpu_info') if kstat kstat.each_line do |l| if l =~ /cpu_info(\d+)/ processor_num = $1.to_i elsif l =~ /brand\s+(.*)\s*$/ processor_list[processor_num] = $1 unless processor_num == -1 processor_num = -1 end end end end processor_list end end end end facter-1.7.5/lib/facter/util/ec2.rb0000644005276200011600000000576312276213016016660 0ustar jenkinsjenkinsrequire 'timeout' require 'open-uri' # Provide a set of utility static methods that help with resolving the EC2 # fact. module Facter::Util::EC2 class << self # Test if we can connect to the EC2 api. Return true if able to connect. # On failure this function fails silently and returns false. # # The +wait_sec+ parameter provides you with an adjustable timeout. # def can_connect?(wait_sec=2) url = "http://169.254.169.254:80/" Timeout::timeout(wait_sec) {open(url)} return true rescue Timeout::Error return false rescue return false end # Test if this host has a mac address used by Eucalyptus clouds, which # normally is +d0:0d+. def has_euca_mac? !!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:}) end # Test if this host has a mac address used by OpenStack, which # normally starts with FA:16:3E (older versions of OpenStack # may generate mac addresses starting with 02:16:3E) def has_openstack_mac? !!(Facter.value(:macaddress) =~ %r{^(02|[fF][aA]):16:3[eE]}) end # Test if the host has an arp entry in its cache that matches the EC2 arp, # which is normally +fe:ff:ff:ff:ff:ff+. def has_ec2_arp? kernel = Facter.value(:kernel) mac_address_re = case kernel when /Windows/i /fe-ff-ff-ff-ff-ff/i else /fe:ff:ff:ff:ff:ff/i end arp_command = case kernel when /Windows/i, /SunOS/i "arp -a" else "arp -an" end if arp_table = Facter::Util::Resolution.exec(arp_command) return true if arp_table.match(mac_address_re) end return false end end ## # userdata returns a single string containing the body of the response of the # GET request for the URI http://169.254.169.254/latest/user-data/ If the # metadata server responds with a 404 Not Found error code then this method # retuns `nil`. # # @param version [String] containing the API version for the request. # Defaults to "latest" and other examples are documented at # http://aws.amazon.com/archives/Amazon%20EC2 # # @api public # # @return [String] containing the response body or `nil` def self.userdata(version="latest") uri = "http://169.254.169.254/#{version}/user-data/" begin read_uri(uri) rescue OpenURI::HTTPError => detail case detail.message when /404 Not Found/i Facter.debug "No user-data present at #{uri}: server responded with #{detail.message}" return nil else raise detail end end end ## # read_uri provides a seam method to easily test the HTTP client # functionality of a HTTP based metadata server. # # @api private # # @return [String] containing the body of the response def self.read_uri(uri) open(uri).read end private_class_method :read_uri end facter-1.7.5/lib/facter/util/architecture.rb0000644005276200011600000000115612276213016020661 0ustar jenkinsjenkins# A module to help test architecture facts on non-AIX test hardware module Facter::Util::Architecture ## # lsattr is intended to directly delegate to Facter::Util::Resolution.exec in # an effort to make the processorX facts easier to test. See also the # {lsdev} method. def self.lsattr(command="lsattr -El proc0 -a type") Facter::Util::Resolution.exec(command) end ## # kernel_fact_value is intended to directly delegate to Facter.value(:kernel) # to make it easier to stub the kernel fact without affecting the entire # system. def self.kernel_fact_value Facter.value(:kernel) end end facter-1.7.5/lib/facter/util/plist/0000755005276200011600000000000012276213023017000 5ustar jenkinsjenkinsfacter-1.7.5/lib/facter/util/plist/parser.rb0000644005276200011600000001143112276213016020623 0ustar jenkinsjenkins#--########################################################### # Copyright 2006, Ben Bleything and # # Patrick May # # # # Distributed under the MIT license. # ############################################################## #++ # Plist parses Mac OS X xml property list files into ruby data structures. # # === Load a plist file # This is the main point of the library: # # r = Plist::parse_xml( filename_or_xml ) module Plist # Note that I don't use these two elements much: # # + Date elements are returned as DateTime objects. # + Data elements are implemented as Tempfiles # # Plist::parse_xml will blow up if it encounters a data element. # If you encounter such an error, or if you have a Date element which # can't be parsed into a Time object, please send your plist file to # plist@hexane.org so that I can implement the proper support. def Plist::parse_xml( filename_or_xml ) listener = Listener.new #parser = REXML::Parsers::StreamParser.new(File.new(filename), listener) parser = StreamParser.new(filename_or_xml, listener) parser.parse listener.result end class Listener #include REXML::StreamListener attr_accessor :result, :open def initialize @result = nil @open = Array.new end def tag_start(name, attributes) @open.push PTag::mappings[name].new end def text( contents ) @open.last.text = contents if @open.last end def tag_end(name) last = @open.pop if @open.empty? @result = last.to_ruby else @open.last.children.push last end end end class StreamParser def initialize( filename_or_xml, listener ) @filename_or_xml = filename_or_xml @listener = listener end TEXT = /([^<]+)/ XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/um DOCTYPE_PATTERN = /\s*)/um COMMENT_START = /\A/um def parse plist_tags = PTag::mappings.keys.join('|') start_tag = /<(#{plist_tags})([^>]*)>/i end_tag = /<\/(#{plist_tags})[^>]*>/i require 'strscan' contents = ( if (File.exists? @filename_or_xml) File.open(@filename_or_xml) {|f| f.read} else @filename_or_xml end ) @scanner = StringScanner.new( contents ) until @scanner.eos? if @scanner.scan(COMMENT_START) @scanner.scan(COMMENT_END) elsif @scanner.scan(XMLDECL_PATTERN) elsif @scanner.scan(DOCTYPE_PATTERN) elsif @scanner.scan(start_tag) @listener.tag_start(@scanner[1], nil) if (@scanner[2] =~ /\/$/) @listener.tag_end(@scanner[1]) end elsif @scanner.scan(TEXT) @listener.text(@scanner[1]) elsif @scanner.scan(end_tag) @listener.tag_end(@scanner[1]) else raise "Unimplemented element" end end end end class PTag @@mappings = { } def PTag::mappings @@mappings end def PTag::inherited( sub_class ) key = sub_class.to_s.downcase key.gsub!(/^plist::/, '' ) key.gsub!(/^p/, '') unless key == "plist" @@mappings[key] = sub_class end attr_accessor :text, :children def initialize @children = Array.new end def to_ruby raise "Unimplemented: " + self.class.to_s + "#to_ruby on #{self.inspect}" end end class PList < PTag def to_ruby children.first.to_ruby if children.first end end class PDict < PTag def to_ruby dict = Hash.new key = nil children.each do |c| if key.nil? key = c.to_ruby else dict[key] = c.to_ruby key = nil end end dict end end class PKey < PTag def to_ruby CGI::unescapeHTML(text || '') end end class PString < PTag def to_ruby CGI::unescapeHTML(text || '') end end class PArray < PTag def to_ruby children.collect do |c| c.to_ruby end end end class PInteger < PTag def to_ruby text.to_i end end class PTrue < PTag def to_ruby true end end class PFalse < PTag def to_ruby false end end class PReal < PTag def to_ruby text.to_f end end require 'date' class PDate < PTag def to_ruby DateTime.parse(text) end end require 'base64' class PData < PTag def to_ruby data = Base64.decode64(text.gsub(/\s+/, '')) begin return Marshal.load(data) rescue Exception => e io = StringIO.new io.write data io.rewind return io end end end end # $Id: parser.rb 1781 2006-10-16 01:01:35Z luke $ facter-1.7.5/lib/facter/util/plist/generator.rb0000644005276200011600000001575712276213016021334 0ustar jenkinsjenkins#--########################################################### # Copyright 2006, Ben Bleything and # # Patrick May # # # # Distributed under the MIT license. # ############################################################## #++ # See Plist::Emit. module Plist # === Create a plist # You can dump an object to a plist in one of two ways: # # * Plist::Emit.dump(obj) # * obj.to_plist # * This requires that you mixin the Plist::Emit module, which is already done for +Array+ and +Hash+. # # The following Ruby classes are converted into native plist types: # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false # * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the and containers (respectively). # * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a element. # * User classes may implement +to_plist_node+ to dictate how they should be serialized; otherwise the object will be passed to Marshal.dump and the result placed in a element. # # For detailed usage instructions, refer to USAGE[link:files/docs/USAGE.html] and the methods documented below. module Emit # Helper method for injecting into classes. Calls Plist::Emit.dump with +self+. def to_plist(envelope = true) return Plist::Emit.dump(self, envelope) end # Helper method for injecting into classes. Calls Plist::Emit.save_plist with +self+. def save_plist(filename) Plist::Emit.save_plist(self, filename) end # The following Ruby classes are converted into native plist types: # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time # # Write us (via RubyForge) if you think another class can be coerced safely into one of the expected plist classes. # # +IO+ and +StringIO+ objects are encoded and placed in elements; other objects are Marshal.dump'ed unless they implement +to_plist_node+. # # The +envelope+ parameters dictates whether or not the resultant plist fragment is wrapped in the normal XML/plist header and footer. Set it to false if you only want the fragment. def self.dump(obj, envelope = true) output = plist_node(obj) output = wrap(output) if envelope return output end # Writes the serialized object's plist to the specified filename. def self.save_plist(obj, filename) File.open(filename, 'wb') do |f| f.write(obj.to_plist) end end private def self.plist_node(element) output = '' if element.respond_to? :to_plist_node output << element.to_plist_node else case element when Array if element.empty? output << "\n" else output << tag('array') { element.collect {|e| plist_node(e)} } end when Hash if element.empty? output << "\n" else inner_tags = [] element.keys.sort.each do |k| v = element[k] inner_tags << tag('key', CGI::escapeHTML(k.to_s)) inner_tags << plist_node(v) end output << tag('dict') { inner_tags } end when true, false output << "<#{element}/>\n" when Time output << tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ')) when Date # also catches DateTime output << tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ')) when String, Symbol, Fixnum, Bignum, Integer, Float output << tag(element_type(element), CGI::escapeHTML(element.to_s)) when IO, StringIO element.rewind contents = element.read # note that apple plists are wrapped at a different length then # what ruby's base64 wraps by default. # I used #encode64 instead of #b64encode (which allows a length arg) # because b64encode is b0rked and ignores the length arg. data = "\n" Base64::encode64(contents).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" } output << tag('data', data) else output << comment( 'The element below contains a Ruby object which has been serialized with Marshal.dump.' ) data = "\n" Base64::encode64(Marshal.dump(element)).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" } output << tag('data', data ) end end return output end def self.comment(content) return "\n" end def self.tag(type, contents = '', &block) out = nil if block_given? out = IndentedString.new out << "<#{type}>" out.raise_indent out << block.call out.lower_indent out << "" else out = "<#{type}>#{contents.to_s}\n" end return out.to_s end def self.wrap(contents) output = '' output << '' + "\n" output << '' + "\n" output << '' + "\n" output << contents output << '' + "\n" return output end def self.element_type(item) return case item when String, Symbol; 'string' when Fixnum, Bignum, Integer; 'integer' when Float; 'real' else raise "Don't know about this data type... something must be wrong!" end end private class IndentedString #:nodoc: attr_accessor :indent_string @@indent_level = 0 def initialize(str = "\t") @indent_string = str @contents = '' end def to_s return @contents end def raise_indent @@indent_level += 1 end def lower_indent @@indent_level -= 1 if @@indent_level > 0 end def <<(val) if val.is_a? Array val.each do |f| self << f end else # if it's already indented, don't bother indenting further unless val =~ /\A#{@indent_string}/ indent = @indent_string * @@indent_level @contents << val.gsub(/^/, indent) else @contents << val end # it already has a newline, don't add another @contents << "\n" unless val =~ /\n$/ end end end end end # we need to add this so sorting hash keys works properly class Symbol #:nodoc: def <=> (other) self.to_s <=> other.to_s end end class Array #:nodoc: include Plist::Emit end class Hash #:nodoc: include Plist::Emit end # $Id: generator.rb 1781 2006-10-16 01:01:35Z luke $ facter-1.7.5/lib/facter/util/values.rb0000644005276200011600000000044512276213016017476 0ustar jenkinsjenkins# A util module for facter containing helper methods module Facter module Util module Values module_function def convert(value) value = value.to_s if value.is_a?(Symbol) value = value.downcase if value.is_a?(String) value end end end end facter-1.7.5/lib/facter/util/xendomains.rb0000644005276200011600000000052012276213016020336 0ustar jenkinsjenkins# A module to gather running Xen Domains # module Facter::Util::Xendomains def self.get_domains if xm_list = Facter::Util::Resolution.exec('/usr/sbin/xm list 2>/dev/null') domains = xm_list.split("\n").reject { |line| line =~ /^(Name|Domain-0)/ } domains.map { |line| line.split(/\s/)[0] }.join(',') end end end facter-1.7.5/lib/facter/util/collection.rb0000644005276200011600000000640012276213016020327 0ustar jenkinsjenkinsrequire 'facter' require 'facter/util/fact' require 'facter/util/loader' # Manage which facts exist and how we access them. Largely just a wrapper # around a hash of facts. class Facter::Util::Collection def initialize(internal_loader, external_loader) @facts = Hash.new @internal_loader = internal_loader @external_loader = external_loader end # Return a fact object by name. If you use this, you still have to call # 'value' on it to retrieve the actual value. def [](name) value(name) end # Add a resolution mechanism for a named fact. This does not distinguish # between adding a new fact and adding a new way to resolve a fact. def add(name, options = {}, &block) name = canonicalize(name) unless fact = @facts[name] fact = Facter::Util::Fact.new(name) @facts[name] = fact end # Set any fact-appropriate options. options.each do |opt, value| method = opt.to_s + "=" if fact.respond_to?(method) fact.send(method, value) options.delete(opt) end end if block_given? resolve = fact.add(&block) else resolve = fact.add end # Set any resolve-appropriate options if resolve # If the resolve was actually added, set any resolve-appropriate options options.each do |opt, value| method = opt.to_s + "=" if resolve.respond_to?(method) resolve.send(method, value) options.delete(opt) end end end unless options.empty? raise ArgumentError, "Invalid facter option(s) %s" % options.keys.collect { |k| k.to_s }.join(",") end return fact end include Enumerable # Iterate across all of the facts. def each load_all @facts.each do |name, fact| value = fact.value unless value.nil? yield name.to_s, value end end end # Return a fact by name. def fact(name) name = canonicalize(name) # Try to load the fact if necessary load(name) unless @facts[name] # Try HARDER internal_loader.load_all unless @facts[name] if @facts.empty? Facter.warnonce("No facts loaded from #{internal_loader.search_path.join(File::PATH_SEPARATOR)}") end @facts[name] end # Flush all cached values. def flush @facts.each { |name, fact| fact.flush } @external_facts_loaded = nil end # Return a list of all of the facts. def list load_all return @facts.keys end def load(name) internal_loader.load(name) load_external_facts end # Load all known facts. def load_all internal_loader.load_all load_external_facts end def internal_loader @internal_loader end def external_loader @external_loader end # Return a hash of all of our facts. def to_hash @facts.inject({}) do |h, ary| value = ary[1].value if ! value.nil? # For backwards compatibility, convert the fact name to a string. h[ary[0].to_s] = value end h end end def value(name) if fact = fact(name) fact.value end end private def canonicalize(name) name.to_s.downcase.to_sym end def load_external_facts if ! @external_facts_loaded @external_facts_loaded = true external_loader.load(self) end end end facter-1.7.5/lib/facter/util/wmi.rb0000644005276200011600000000052212276213016016767 0ustar jenkinsjenkinsmodule Facter::Util::WMI class << self def connect(uri = wmi_resource_uri) require 'win32ole' WIN32OLE.connect(uri) end def wmi_resource_uri( host = '.' ) "winmgmts:{impersonationLevel=impersonate}!//#{host}/root/cimv2" end def execquery(query) connect().execquery(query) end end end facter-1.7.5/lib/facter/util/windows_root.rb0000644005276200011600000000162212276213016020732 0ustar jenkinsjenkinsrequire 'windows/system_info' require 'windows/security' require 'sys/admin' module Facter::Util::Root extend ::Windows::SystemInfo extend ::Windows::Security def self.root? # if Vista or later, check for unrestricted process token return Win32::Security.elevated_security? unless windows_version < 6.0 # otherwise 2003 or less check_token_membership end def self.check_token_membership sid = 0.chr * 80 size = [80].pack('L') member = 0.chr * 4 unless CreateWellKnownSid(Windows::Security::WinBuiltinAdministratorsSid, nil, sid, size) raise "Failed to create administrators SID" end unless IsValidSid(sid) raise "Invalid SID" end unless CheckTokenMembership(nil, sid, member) raise "Failed to check membership" end # Is administrators SID enabled in calling thread's access token? member.unpack('L')[0] == 1 end end facter-1.7.5/lib/facter/util/cfpropertylist/0000755005276200011600000000000012276213023020736 5ustar jenkinsjenkinsfacter-1.7.5/lib/facter/util/cfpropertylist/THANKS0000644005276200011600000000023512276213016021653 0ustar jenkinsjenkinsSpecial thanks to: Steve Madsen for providing a lot of performance patches and bugfixes! Have a look at his Github account: facter-1.7.5/lib/facter/util/cfpropertylist/LICENSE0000644005276200011600000000206412276213016021747 0ustar jenkinsjenkinsCopyright (c) 2010 Christian Kruse, Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. facter-1.7.5/lib/facter/util/cfpropertylist/lib/0000755005276200011600000000000012276213023021504 5ustar jenkinsjenkinsfacter-1.7.5/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb0000644005276200011600000002771112276213016025260 0ustar jenkinsjenkins# -*- coding: utf-8 -*- require 'kconv' require 'date' require 'time' # # Facter::Util::CFPropertyList implementation # # class to read, manipulate and write both XML and binary property list # files (plist(5)) as defined by Apple. Have a look at Facter::Util::CFPropertyList::List # for more documentation. # # == Example # require 'cfpropertylist' # # # create a arbitrary data structure of basic data types # data = { # 'name' => 'John Doe', # 'missing' => true, # 'last_seen' => Time.now, # 'friends' => ['Jane Doe','Julian Doe'], # 'likes' => { # 'me' => false # } # } # # # create Facter::Util::CFPropertyList::List object # plist = Facter::Util::CFPropertyList::List.new # # # call Facter::Util::CFPropertyList.guess() to create corresponding CFType values # # pass in optional :convert_unknown_to_string => true to convert things like symbols into strings. # plist.value = Facter::Util::CFPropertyList.guess(data) # # # write plist to file # plist.save("example.plist", Facter::Util::CFPropertyList::List::FORMAT_BINARY) # # # … later, read it again # plist = Facter::Util::CFPropertyList::List.new(:file => "example.plist") # data = Facter::Util::CFPropertyList.native_types(plist.value) # # Author:: Christian Kruse (mailto:cjk@wwwtech.de) # Copyright:: Copyright (c) 2010 # License:: MIT License module Facter::Util::CFPropertyList # interface class for PList parsers class ParserInterface # load a plist def load(opts={}) return "" end # convert a plist to string def to_str(opts={}) return true end end class XMLParserInterface < ParserInterface def new_node(name) end def new_text(val) end def append_node(parent, child) end end end class String unless("".respond_to?(:blob) && "".respond_to?(:blob=)) then # The blob status of this string (to set to true if a binary string) attr_accessor :blob end unless("".respond_to?(:blob?)) then # Returns whether or not +str+ is a blob. # @return [true,false] If true, this string contains binary data. If false, its a regular string def blob? blob end end unless("".respond_to?(:bytesize)) then def bytesize self.length end end end dirname = File.dirname(__FILE__) require dirname + '/rbCFPlistError.rb' require dirname + '/rbCFTypes.rb' require dirname + '/rbBinaryCFPropertyList.rb' require 'iconv' unless "".respond_to?("encode") begin Enumerable::Enumerator.new([]) rescue NameError => e module Enumerable class Enumerator end end end begin require dirname + '/rbLibXMLParser.rb' try_nokogiri = false rescue LoadError => e try_nokogiri = true end if try_nokogiri then begin require dirname + '/rbNokogiriParser.rb' rescue LoadError => e require dirname + '/rbREXMLParser.rb' end end module Facter::Util::CFPropertyList # Create CFType hierarchy by guessing the correct CFType, e.g. # # x = { # 'a' => ['b','c','d'] # } # cftypes = Facter::Util::CFPropertyList.guess(x) # # pass optional options hash. Only possible value actually: # +convert_unknown_to_string+:: Convert unknown objects to string calling to_str() # +converter_method+:: Convert unknown objects to known objects calling +method_name+ # # cftypes = Facter::Util::CFPropertyList.guess(x,:convert_unknown_to_string => true,:converter_method => :to_hash, :converter_with_opts => true) def guess(object, options = {}) case object when Fixnum, Integer then CFInteger.new(object) when Float then CFReal.new(object) when TrueClass, FalseClass then CFBoolean.new(object) when String object.blob? ? CFData.new(object, CFData::DATA_RAW) : CFString.new(object) when Time, DateTime, Date then CFDate.new(object) when Array, Enumerator, Enumerable::Enumerator ary = Array.new object.each do |o| ary.push Facter::Util::CFPropertyList.guess(o, options) end CFArray.new(ary) when Hash hsh = Hash.new object.each_pair do |k,v| k = k.to_s if k.is_a?(Symbol) hsh[k] = Facter::Util::CFPropertyList.guess(v, options) end CFDictionary.new(hsh) else case when Object.const_defined?('BigDecimal') && object.is_a?(BigDecimal) CFReal.new(object) when object.respond_to?(:read) raw_data = object.read # treat the data as a bytestring (ASCII-8BIT) if Ruby supports it. Do this by forcing # the encoding, on the assumption that the bytes were read correctly, and just tagged with # an inappropriate encoding, rather than transcoding. raw_data.force_encoding(Encoding::ASCII_8BIT) if raw_data.respond_to?(:force_encoding) CFData.new(raw_data, CFData::DATA_RAW) when options[:converter_method] && object.respond_to?(options[:converter_method]) if options[:converter_with_opts] Facter::Util::CFPropertyList.guess(object.send(options[:converter_method],options),options) else Facter::Util::CFPropertyList.guess(object.send(options[:converter_method]),options) end when options[:convert_unknown_to_string] CFString.new(object.to_s) else raise CFTypeError.new("Unknown class #{object.class.to_s}. Try using :convert_unknown_to_string if you want to use unknown object types!") end end end # Converts a CFType hiercharchy to native Ruby types def native_types(object,keys_as_symbols=false) return if object.nil? if(object.is_a?(CFDate) || object.is_a?(CFString) || object.is_a?(CFInteger) || object.is_a?(CFReal) || object.is_a?(CFBoolean)) then return object.value elsif(object.is_a?(CFData)) then return object.decoded_value elsif(object.is_a?(CFArray)) then ary = [] object.value.each do |v| ary.push Facter::Util::CFPropertyList.native_types(v) end return ary elsif(object.is_a?(CFDictionary)) then hsh = {} object.value.each_pair do |k,v| k = k.to_sym if keys_as_symbols hsh[k] = Facter::Util::CFPropertyList.native_types(v) end return hsh end end module_function :guess, :native_types # Class representing a Facter::Util::CFPropertyList. Instanciate with #new class List # Format constant for binary format FORMAT_BINARY = 1 # Format constant for XML format FORMAT_XML = 2 # Format constant for automatic format recognizing FORMAT_AUTO = 0 @@parsers = [Binary,XML] # Path of PropertyList attr_accessor :filename # Path of PropertyList attr_accessor :format # the root value in the plist file attr_accessor :value # initialize a new Facter::Util::CFPropertyList, arguments are: # # :file:: Parse a file # :format:: Format is one of FORMAT_BINARY or FORMAT_XML. Defaults to FORMAT_AUTO # :data:: Parse a string # # All arguments are optional def initialize(opts={}) @filename = opts[:file] @format = opts[:format] || FORMAT_AUTO @data = opts[:data] load(@filename) unless @filename.nil? load_str(@data) unless @data.nil? end # Load an XML PropertyList # filename = nil:: The filename to read from; if nil, read from the file defined by instance variable +filename+ def load_xml(filename=nil) load(filename,List::FORMAT_XML) end # read a binary plist file # filename = nil:: The filename to read from; if nil, read from the file defined by instance variable +filename+ def load_binary(filename=nil) load(filename,List::FORMAT_BINARY) end # load a plist from a XML string # str:: The string containing the plist def load_xml_str(str=nil) load_str(str,List::FORMAT_XML) end # load a plist from a binary string # str:: The string containing the plist def load_binary_str(str=nil) load_str(str,List::FORMAT_BINARY) end # load a plist from a string # str = nil:: The string containing the plist # format = nil:: The format of the plist def load_str(str=nil,format=nil) str = @data if str.nil? format = @format if format.nil? @value = {} case format when List::FORMAT_BINARY, List::FORMAT_XML then prsr = @@parsers[format-1].new @value = prsr.load({:data => str}) when List::FORMAT_AUTO then # what we now do is ugly, but neccessary to recognize the file format filetype = str[0..5] version = str[6..7] prsr = nil if filetype == "bplist" then raise CFFormatError.new("Wong file version #{version}") unless version == "00" prsr = Binary.new else prsr = XML.new end @value = prsr.load({:data => str}) end end # Read a plist file # file = nil:: The filename of the file to read. If nil, use +filename+ instance variable # format = nil:: The format of the plist file. Auto-detect if nil def load(file=nil,format=nil) file = @filename if file.nil? format = @format if format.nil? @value = {} raise IOError.new("File #{file} not readable!") unless File.readable? file case format when List::FORMAT_BINARY, List::FORMAT_XML then prsr = @@parsers[format-1].new @value = prsr.load({:file => file}) when List::FORMAT_AUTO then # what we now do is ugly, but neccessary to recognize the file format magic_number = IO.read(file,8) filetype = magic_number[0..5] version = magic_number[6..7] prsr = nil if filetype == "bplist" then raise CFFormatError.new("Wong file version #{version}") unless version == "00" prsr = Binary.new else prsr = XML.new end @value = prsr.load({:file => file}) end end # Serialize Facter::Util::CFPropertyList object to specified format and write it to file # file = nil:: The filename of the file to write to. Uses +filename+ instance variable if nil # format = nil:: The format to save in. Uses +format+ instance variable if nil def save(file=nil,format=nil,opts={}) format = @format if format.nil? file = @filename if file.nil? raise CFFormatError.new("Format #{format} not supported, use List::FORMAT_BINARY or List::FORMAT_XML") if format != FORMAT_BINARY && format != FORMAT_XML if(!File.exists?(file)) then raise IOError.new("File #{file} not writable!") unless File.writable?(File.dirname(file)) elsif(!File.writable?(file)) then raise IOError.new("File #{file} not writable!") end opts[:root] = @value prsr = @@parsers[format-1].new content = prsr.to_str(opts) File.open(file, 'wb') { |fd| fd.write content } end # convert plist to string # format = List::FORMAT_BINARY:: The format to save the plist # opts={}:: Pass parser options def to_str(format=List::FORMAT_BINARY,opts={}) prsr = @@parsers[format-1].new opts[:root] = @value return prsr.to_str(opts) end end end class Array # convert an array to plist format def to_plist(options={}) options[:plist_format] ||= Facter::Util::CFPropertyList::List::FORMAT_BINARY plist = Facter::Util::CFPropertyList::List.new plist.value = Facter::Util::CFPropertyList.guess(self, options) plist.to_str(options[:plist_format]) end end class Enumerator # convert an array to plist format def to_plist(options={}) options[:plist_format] ||= Facter::Util::CFPropertyList::List::FORMAT_BINARY plist = Facter::Util::CFPropertyList::List.new plist.value = Facter::Util::CFPropertyList.guess(self, options) plist.to_str(options[:plist_format]) end end class Hash # convert a hash to plist format def to_plist(options={}) options[:plist_format] ||= Facter::Util::CFPropertyList::List::FORMAT_BINARY plist = Facter::Util::CFPropertyList::List.new plist.value = Facter::Util::CFPropertyList.guess(self, options) plist.to_str(options[:plist_format]) end end # eof facter-1.7.5/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb0000644005276200011600000000013112276213016025117 0ustar jenkinsjenkins# -*- coding: utf-8 -*- require File.dirname(__FILE__) + '/rbCFPropertyList.rb' # eof facter-1.7.5/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb0000644005276200011600000000642212276213016024627 0ustar jenkinsjenkins# -*- coding: utf-8 -*- require 'libxml' module Facter::Util::CFPropertyList # XML parser class XML < XMLParserInterface # read a XML file # opts:: # * :file - The filename of the file to load # * :data - The data to parse def load(opts) if(opts.has_key?(:file)) then doc = LibXML::XML::Document.file(opts[:file],:options => LibXML::XML::Parser::Options::NOBLANKS|LibXML::XML::Parser::Options::NOENT) else doc = LibXML::XML::Document.string(opts[:data],:options => LibXML::XML::Parser::Options::NOBLANKS|LibXML::XML::Parser::Options::NOENT) end root = doc.root.first return import_xml(root) end # serialize Facter::Util::CFPropertyList object to XML # opts = {}:: Specify options: :formatted - Use indention and line breaks def to_str(opts={}) doc = LibXML::XML::Document.new doc.root = LibXML::XML::Node.new('plist') doc.encoding = LibXML::XML::Encoding::UTF_8 doc.root['version'] = '1.0' doc.root << opts[:root].to_xml(self) # ugly hack, but there's no other possibility I know str = doc.to_s(:indent => opts[:formatted]) str1 = String.new first = false str.each_line do |line| str1 << line unless(first) then str1 << "\n" if line =~ /^\s*<\?xml/ end first = true end str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding) return str1 end def new_node(name) LibXML::XML::Node.new(name) end def new_text(val) LibXML::XML::Node.new_text(val) end def append_node(parent, child) parent << child end protected # get the value of a DOM node def get_value(n) content = if n.children? n.first.content else n.content end content.force_encoding('UTF-8') if content.respond_to?(:force_encoding) content end # import the XML values def import_xml(node) ret = nil case node.name when 'dict' hsh = Hash.new key = nil if node.children? then node.children.each do |n| next if n.text? # avoid a bug of libxml next if n.comment? if n.name == "key" then key = get_value(n) else raise CFFormatError.new("Format error!") if key.nil? hsh[key] = import_xml(n) key = nil end end end ret = CFDictionary.new(hsh) when 'array' ary = Array.new if node.children? then node.children.each do |n| ary.push import_xml(n) end end ret = CFArray.new(ary) when 'true' ret = CFBoolean.new(true) when 'false' ret = CFBoolean.new(false) when 'real' ret = CFReal.new(get_value(node).to_f) when 'integer' ret = CFInteger.new(get_value(node).to_i) when 'string' ret = CFString.new(get_value(node)) when 'data' ret = CFData.new(get_value(node)) when 'date' ret = CFDate.new(CFDate.parse_date(get_value(node))) end return ret end end end # eof facter-1.7.5/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb0000644005276200011600000000626612276213016024435 0ustar jenkinsjenkins# -*- coding: utf-8 -*- require 'rexml/document' module Facter::Util::CFPropertyList # XML parser class XML < ParserInterface # read a XML file # opts:: # * :file - The filename of the file to load # * :data - The data to parse def load(opts) if(opts.has_key?(:file)) then File.open(opts[:file], "rb") { |fd| doc = REXML::Document.new(fd) } else doc = REXML::Document.new(opts[:data]) end root = doc.root.elements[1] return import_xml(root) end # serialize Facter::Util::CFPropertyList object to XML # opts = {}:: Specify options: :formatted - Use indention and line breaks def to_str(opts={}) doc = REXML::Document.new @doc = doc doc.context[:attribute_quote] = :quote doc.add_element 'plist', {'version' => '1.0'} doc.root << opts[:root].to_xml(self) formatter = if opts[:formatted] then f = REXML::Formatters::Pretty.new(2) f.compact = true f else REXML::Formatters::Default.new end str = formatter.write(doc.root, "") str1 = "\n\n" + str + "\n" str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding) return str1 end def new_node(name) #LibXML::XML::Node.new(name) REXML::Element.new(name) end def new_text(val) val end def append_node(parent, child) if child.is_a?(String) then parent.add_text child else parent.elements << child end parent end protected # get the value of a DOM node def get_value(n) content = n.text content.force_encoding('UTF-8') if content.respond_to?(:force_encoding) content end # import the XML values def import_xml(node) ret = nil case node.name when 'dict' hsh = Hash.new key = nil if node.has_elements? then node.elements.each do |n| #print n.name + "\n" next if n.name == '#text' # avoid a bug of libxml next if n.name == '#comment' if n.name == "key" then key = get_value(n) else raise CFFormatError.new("Format error!") if key.nil? hsh[key] = import_xml(n) key = nil end end end ret = CFDictionary.new(hsh) when 'array' ary = Array.new if node.has_elements? then node.elements.each do |n| ary.push import_xml(n) end end ret = CFArray.new(ary) when 'true' ret = CFBoolean.new(true) when 'false' ret = CFBoolean.new(false) when 'real' ret = CFReal.new(get_value(node).to_f) when 'integer' ret = CFInteger.new(get_value(node).to_i) when 'string' ret = CFString.new(get_value(node)) when 'data' ret = CFData.new(get_value(node)) when 'date' ret = CFDate.new(CFDate.parse_date(get_value(node))) end return ret end end end # eof facter-1.7.5/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb0000644005276200011600000001354512276213016023704 0ustar jenkinsjenkins# -*- coding: utf-8 -*- # # CFTypes, e.g. CFString, CFInteger # needed to create unambiguous plists # # Author:: Christian Kruse (mailto:cjk@wwwtech.de) # Copyright:: Copyright (c) 2009 # License:: MIT License require 'base64' module Facter::Util::CFPropertyList # This class defines the base class for all CFType classes # class CFType # value of the type attr_accessor :value def initialize(value=nil) @value = value end def to_xml(parser) end def to_binary(bplist) end end # This class holds string values, both, UTF-8 and UTF-16BE # It will convert the value to UTF-16BE if necessary (i.e. if non-ascii char contained) class CFString < CFType # convert to XML def to_xml(parser) n = parser.new_node('string') n = parser.append_node(n, parser.new_text(@value)) unless @value.nil? n end # convert to binary def to_binary(bplist) bplist.string_to_binary(@value); end end # This class holds integer/fixnum values class CFInteger < CFType # convert to XML def to_xml(parser) n = parser.new_node('integer') n = parser.append_node(n, parser.new_text(@value.to_s)) n end # convert to binary def to_binary(bplist) bplist.num_to_binary(self) end end # This class holds float values class CFReal < CFType # convert to XML def to_xml(parser) n = parser.new_node('real') n = parser.append_node(n, parser.new_text(@value.to_s)) n end # convert to binary def to_binary(bplist) bplist.num_to_binary(self) end end # This class holds Time values. While Apple uses seconds since 2001, # the rest of the world uses seconds since 1970. So if you access value # directly, you get the Time class. If you access via get_value you either # geht the timestamp or the Apple timestamp class CFDate < CFType TIMESTAMP_APPLE = 0 TIMESTAMP_UNIX = 1; DATE_DIFF_APPLE_UNIX = 978307200 # create a XML date strimg from a time object def CFDate.date_string(val) # 2009-05-13T20:23:43Z val.getutc.strftime("%Y-%m-%dT%H:%M:%SZ") end # parse a XML date string def CFDate.parse_date(val) # 2009-05-13T20:23:43Z val =~ %r{^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$} year,month,day,hour,min,sec = $1, $2, $3, $4, $5, $6 return Time.utc(year,month,day,hour,min,sec).getlocal end # set value to defined state def initialize(value = nil,format=CFDate::TIMESTAMP_UNIX) if(value.is_a?(Time) || value.nil?) then @value = value.nil? ? Time.now : value elsif value.instance_of? Date @value = Time.utc(value.year, value.month, value.day, 0, 0, 0) elsif value.instance_of? DateTime @value = value.to_time.utc else set_value(value,format) end end # set value with timestamp, either Apple or UNIX def set_value(value,format=CFDate::TIMESTAMP_UNIX) if(format == CFDate::TIMESTAMP_UNIX) then @value = Time.at(value) else @value = Time.at(value + CFDate::DATE_DIFF_APPLE_UNIX) end end # get timestamp, either UNIX or Apple timestamp def get_value(format=CFDate::TIMESTAMP_UNIX) if(format == CFDate::TIMESTAMP_UNIX) then @value.to_i else @value.to_f - CFDate::DATE_DIFF_APPLE_UNIX end end # convert to XML def to_xml(parser) n = parser.new_node('date') n = parser.append_node(n, parser.new_text(CFDate::date_string(@value))) n end # convert to binary def to_binary(bplist) bplist.date_to_binary(@value) end end # This class contains a boolean value class CFBoolean < CFType # convert to XML def to_xml(parser) parser.new_node(@value ? 'true' : 'false') end # convert to binary def to_binary(bplist) bplist.bool_to_binary(@value); end end # This class contains binary data values class CFData < CFType # Base64 encoded data DATA_BASE64 = 0 # Raw data DATA_RAW = 1 # set value to defined state, either base64 encoded or raw def initialize(value=nil,format=DATA_BASE64) if(format == DATA_RAW) @raw_value = value @raw_value.blob = true else @value = value end end # get base64 encoded value def encoded_value @value ||= "\n#{Base64.encode64(@raw_value).gsub("\n", '').scan(/.{1,76}/).join("\n")}\n" end # get base64 decoded value def decoded_value @raw_value ||= String.new(Base64.decode64(@value)) @raw_value.blob = true @raw_value end # convert to XML def to_xml(parser) n = parser.new_node('data') n = parser.append_node(n, parser.new_text(encoded_value())) n end # convert to binary def to_binary(bplist) bplist.data_to_binary(decoded_value()) end end # This class contains an array of values class CFArray < CFType # create a new array CFType def initialize(val=[]) @value = val end # convert to XML def to_xml(parser) n = parser.new_node('array') @value.each do |v| n = parser.append_node(n, v.to_xml(parser)) end n end # convert to binary def to_binary(bplist) bplist.array_to_binary(self) end end # this class contains a hash of values class CFDictionary < CFType # Create new CFDictonary type. def initialize(value={}) @value = value end # convert to XML def to_xml(parser) n = parser.new_node('dict') @value.each_pair do |key, value| k = parser.append_node(parser.new_node('key'), parser.new_text(key.to_s)) n = parser.append_node(n, k) n = parser.append_node(n, value.to_xml(parser)) end n end # convert to binary def to_binary(bplist) bplist.dict_to_binary(self) end end end # eof facter-1.7.5/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb0000644005276200011600000000675412276213016025331 0ustar jenkinsjenkins# -*- coding: utf-8 -*- require 'nokogiri' module Facter::Util::CFPropertyList # XML parser class XML < ParserInterface # read a XML file # opts:: # * :file - The filename of the file to load # * :data - The data to parse def load(opts) if(opts.has_key?(:file)) then File.open(opts[:file], "rb") { |fd| doc = Nokogiri::XML::Document.parse(fd, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS|Nokogiri::XML::ParseOptions::NOENT) } else doc = Nokogiri::XML::Document.parse(opts[:data], nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS|Nokogiri::XML::ParseOptions::NOENT) end root = doc.root.children.first return import_xml(root) end # serialize Facter::Util::CFPropertyList object to XML # opts = {}:: Specify options: :formatted - Use indention and line breaks def to_str(opts={}) doc = Nokogiri::XML::Document.new @doc = doc doc.root = doc.create_element 'plist', :version => '1.0' doc.encoding = 'UTF-8' doc.root << opts[:root].to_xml(self) # ugly hack, but there's no other possibility I know s_opts = Nokogiri::XML::Node::SaveOptions::AS_XML s_opts |= Nokogiri::XML::Node::SaveOptions::FORMAT if opts[:formatted] str = doc.serialize(:save_with => s_opts) str1 = String.new first = false str.each_line do |line| str1 << line unless(first) then str1 << "\n" if line =~ /^\s*<\?xml/ end first = true end str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding) return str1 end def new_node(name) @doc.create_element name end def new_text(val) @doc.create_text_node val end def append_node(parent, child) parent << child end protected # get the value of a DOM node def get_value(n) content = if n.children.empty? n.content else n.children.first.content end content.force_encoding('UTF-8') if content.respond_to?(:force_encoding) content end # import the XML values def import_xml(node) ret = nil case node.name when 'dict' hsh = Hash.new key = nil children = node.children unless children.empty? then children.each do |n| next if n.text? # avoid a bug of libxml next if n.comment? if n.name == "key" then key = get_value(n) else raise CFFormatError.new("Format error!") if key.nil? hsh[key] = import_xml(n) key = nil end end end ret = CFDictionary.new(hsh) when 'array' ary = Array.new children = node.children unless children.empty? then children.each do |n| ary.push import_xml(n) end end ret = CFArray.new(ary) when 'true' ret = CFBoolean.new(true) when 'false' ret = CFBoolean.new(false) when 'real' ret = CFReal.new(get_value(node).to_f) when 'integer' ret = CFInteger.new(get_value(node).to_i) when 'string' ret = CFString.new(get_value(node)) when 'data' ret = CFData.new(get_value(node)) when 'date' ret = CFDate.new(CFDate.parse_date(get_value(node))) end return ret end end end # eof facter-1.7.5/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb0000644005276200011600000004236712276213016026431 0ustar jenkinsjenkins# -*- coding: utf-8 -*- module Facter::Util::CFPropertyList # Binary PList parser class class Binary # Read a binary plist file def load(opts) @unique_table = {} @count_objects = 0 @object_refs = 0 @written_object_count = 0 @object_table = [] @object_ref_size = 0 @offsets = [] fd = nil if(opts.has_key?(:file)) fd = File.open(opts[:file],"rb") file = opts[:file] else fd = StringIO.new(opts[:data],"rb") file = "" end # first, we read the trailer: 32 byte from the end fd.seek(-32,IO::SEEK_END) buff = fd.read(32) offset_size, object_ref_size, number_of_objects, top_object, table_offset = buff.unpack "x6CCx4Nx4Nx4N" # after that, get the offset table fd.seek(table_offset, IO::SEEK_SET) coded_offset_table = fd.read(number_of_objects * offset_size) raise CFFormatError.new("#{file}: Format error!") unless coded_offset_table.bytesize == number_of_objects * offset_size @count_objects = number_of_objects # decode offset table formats = ["","C*","n*","(H6)*","N*"] @offsets = coded_offset_table.unpack(formats[offset_size]) if(offset_size == 3) 0.upto(@offsets.size-1) { |i| @offsets[i] = @offsets[i].to_i(16) } end @object_ref_size = object_ref_size val = read_binary_object_at(file,fd,top_object) fd.close val end # Convert Facter::Util::CFPropertyList to binary format; since we have to count our objects we simply unique CFDictionary and CFArray def to_str(opts={}) @unique_table = {} @count_objects = 0 @object_refs = 0 @written_object_count = 0 @object_table = [] @offsets = [] binary_str = "bplist00" @object_refs = count_object_refs(opts[:root]) opts[:root].to_binary(self) next_offset = 8 offsets = @object_table.map do |object| offset = next_offset next_offset += object.bytesize offset end binary_str << @object_table.join table_offset = next_offset offset_size = Binary.bytes_needed(table_offset) if offset_size < 8 # Fast path: encode the entire offset array at once. binary_str << offsets.pack((%w(C n N N)[offset_size - 1]) + '*') else # Slow path: host may be little or big endian, must pack each offset # separately. offsets.each do |offset| binary_str << "#{Binary.pack_it_with_size(offset_size,offset)}" end end binary_str << [offset_size, object_ref_size(@object_refs)].pack("x6CC") binary_str << [@object_table.size].pack("x4N") binary_str << [0].pack("x4N") binary_str << [table_offset].pack("x4N") binary_str end def object_ref_size object_refs Binary.bytes_needed(object_refs) end # read a „null†type (i.e. null byte, marker byte, bool value) def read_binary_null_type(length) case length when 0 then 0 # null byte when 8 then CFBoolean.new(false) when 9 then CFBoolean.new(true) when 15 then 15 # fill type else raise CFFormatError.new("unknown null type: #{length}") end end protected :read_binary_null_type # read a binary int value def read_binary_int(fname,fd,length) if length > 3 raise CFFormatError.new("Integer greater than 8 bytes: #{length}") end nbytes = 1 << length buff = fd.read(nbytes) CFInteger.new( case length when 0 then buff.unpack("C")[0] when 1 then buff.unpack("n")[0] when 2 then buff.unpack("N")[0] when 3 hiword,loword = buff.unpack("NN") if (hiword & 0x80000000) != 0 # 8 byte integers are always signed, and are negative when bit 63 is # set. Decoding into either a Fixnum or Bignum is tricky, however, # because the size of a Fixnum varies among systems, and Ruby # doesn't consider the number to be negative, and won't sign extend. -(2**63 - ((hiword & 0x7fffffff) << 32 | loword)) else hiword << 32 | loword end end ) end protected :read_binary_int # read a binary real value def read_binary_real(fname,fd,length) raise CFFormatError.new("Real greater than 8 bytes: #{length}") if length > 3 nbytes = 1 << length buff = fd.read(nbytes) CFReal.new( case length when 0 # 1 byte float? must be an error raise CFFormatError.new("got #{length+1} byte float, must be an error!") when 1 # 2 byte float? must be an error raise CFFormatError.new("got #{length+1} byte float, must be an error!") when 2 then buff.reverse.unpack("f")[0] when 3 then buff.reverse.unpack("d")[0] else fail "unexpected length: #{length}" end ) end protected :read_binary_real # read a binary date value def read_binary_date(fname,fd,length) raise CFFormatError.new("Date greater than 8 bytes: #{length}") if length > 3 nbytes = 1 << length buff = fd.read(nbytes) CFDate.new( case length when 0 then # 1 byte CFDate is an error raise CFFormatError.new("#{length+1} byte CFDate, error") when 1 then # 2 byte CFDate is an error raise CFFormatError.new("#{length+1} byte CFDate, error") when 2 then buff.reverse.unpack("f")[0] when 3 then buff.reverse.unpack("d")[0] end, CFDate::TIMESTAMP_APPLE ) end protected :read_binary_date # Read a binary data value def read_binary_data(fname,fd,length) CFData.new(read_fd(fd, length), CFData::DATA_RAW) end protected :read_binary_data def read_fd fd, length length > 0 ? fd.read(length) : "" end # Read a binary string value def read_binary_string(fname,fd,length) buff = read_fd fd, length @unique_table[buff] = true unless @unique_table.has_key?(buff) CFString.new(buff) end protected :read_binary_string # Convert the given string from one charset to another def Binary.charset_convert(str,from,to="UTF-8") return str.clone.force_encoding(from).encode(to) if str.respond_to?("encode") Iconv.conv(to,from,str) end # Count characters considering character set def Binary.charset_strlen(str,charset="UTF-8") if str.respond_to?(:encode) size = str.length else utf8_str = Iconv.conv("UTF-8",charset,str) size = utf8_str.scan(/./mu).size end # UTF-16 code units in the range D800-DBFF are the beginning of # a surrogate pair, and count as one additional character for # length calculation. if charset =~ /^UTF-16/ if str.respond_to?(:encode) str.bytes.to_a.each_slice(2) { |pair| size += 1 if (0xd8..0xdb).include?(pair[0]) } else str.split('').each_slice(2) { |pair| size += 1 if ("\xd8".."\xdb").include?(pair[0]) } end end size end # Read a unicode string value, coded as UTF-16BE def read_binary_unicode_string(fname,fd,length) # The problem is: we get the length of the string IN CHARACTERS; # since a char in UTF-16 can be 16 or 32 bit long, we don't really know # how long the string is in bytes buff = fd.read(2*length) @unique_table[buff] = true unless @unique_table.has_key?(buff) CFString.new(Binary.charset_convert(buff,"UTF-16BE","UTF-8")) end protected :read_binary_unicode_string # Read an binary array value, including contained objects def read_binary_array(fname,fd,length) ary = [] # first: read object refs if(length != 0) buff = fd.read(length * @object_ref_size) objects = buff.unpack(@object_ref_size == 1 ? "C*" : "n*") # now: read objects 0.upto(length-1) do |i| object = read_binary_object_at(fname,fd,objects[i]) ary.push object end end CFArray.new(ary) end protected :read_binary_array # Read a dictionary value, including contained objects def read_binary_dict(fname,fd,length) dict = {} # first: read keys if(length != 0) then buff = fd.read(length * @object_ref_size) keys = buff.unpack(@object_ref_size == 1 ? "C*" : "n*") # second: read object refs buff = fd.read(length * @object_ref_size) objects = buff.unpack(@object_ref_size == 1 ? "C*" : "n*") # read real keys and objects 0.upto(length-1) do |i| key = read_binary_object_at(fname,fd,keys[i]) object = read_binary_object_at(fname,fd,objects[i]) dict[key.value] = object end end CFDictionary.new(dict) end protected :read_binary_dict # Read an object type byte, decode it and delegate to the correct reader function def read_binary_object(fname,fd) # first: read the marker byte buff = fd.read(1) object_length = buff.unpack("C*") object_length = object_length[0] & 0xF buff = buff.unpack("H*") object_type = buff[0][0].chr if(object_type != "0" && object_length == 15) then object_length = read_binary_object(fname,fd) object_length = object_length.value end case object_type when '0' # null, false, true, fillbyte read_binary_null_type(object_length) when '1' # integer read_binary_int(fname,fd,object_length) when '2' # real read_binary_real(fname,fd,object_length) when '3' # date read_binary_date(fname,fd,object_length) when '4' # data read_binary_data(fname,fd,object_length) when '5' # byte string, usually utf8 encoded read_binary_string(fname,fd,object_length) when '6' # unicode string (utf16be) read_binary_unicode_string(fname,fd,object_length) when 'a' # array read_binary_array(fname,fd,object_length) when 'd' # dictionary read_binary_dict(fname,fd,object_length) end end protected :read_binary_object # Read an object type byte at position $pos, decode it and delegate to the correct reader function def read_binary_object_at(fname,fd,pos) position = @offsets[pos] fd.seek(position,IO::SEEK_SET) read_binary_object(fname,fd) end protected :read_binary_object_at # pack an +int+ of +nbytes+ with size def Binary.pack_it_with_size(nbytes,int) case nbytes when 1 then [int].pack('c') when 2 then [int].pack('n') when 4 then [int].pack('N') when 8 [int >> 32, int & 0xFFFFFFFF].pack('NN') else raise CFFormatError.new("Don't know how to pack #{nbytes} byte integer") end end def Binary.pack_int_array_with_size(nbytes, array) case nbytes when 1 then array.pack('C*') when 2 then array.pack('n*') when 4 then array.pack('N*') when 8 array.map { |int| [int >> 32, int & 0xFFFFFFFF].pack('NN') }.join else raise CFFormatError.new("Don't know how to pack #{nbytes} byte integer") end end # calculate how many bytes are needed to save +count+ def Binary.bytes_needed(count) case when count < 2**8 then 1 when count < 2**16 then 2 when count < 2**32 then 4 when count < 2**64 then 8 else raise CFFormatError.new("Data size too large: #{count}") end end # Create a type byte for binary format as defined by apple def Binary.type_bytes(type, length) if length < 15 [(type << 4) | length].pack('C') else bytes = [(type << 4) | 0xF] if length <= 0xFF bytes.push(0x10, length).pack('CCC') # 1 byte length elsif length <= 0xFFFF bytes.push(0x11, length).pack('CCn') # 2 byte length elsif length <= 0xFFFFFFFF bytes.push(0x12, length).pack('CCN') # 4 byte length elsif length <= 0x7FFFFFFFFFFFFFFF bytes.push(0x13, length >> 32, length & 0xFFFFFFFF).pack('CCNN') # 8 byte length else raise CFFormatError.new("Integer too large: #{int}") end end end def count_object_refs(object) case object when CFArray contained_refs = 0 object.value.each do |element| if CFArray === element || CFDictionary === element contained_refs += count_object_refs(element) end end return object.value.size + contained_refs when CFDictionary contained_refs = 0 object.value.each_value do |value| if CFArray === value || CFDictionary === value contained_refs += count_object_refs(value) end end return object.value.keys.size * 2 + contained_refs else return 0 end end def Binary.ascii_string?(str) if str.respond_to?(:ascii_only?) str.ascii_only? else str !~ /[\x80-\xFF]/mn end end # Uniques and transforms a string value to binary format and adds it to the object table def string_to_binary(val) val = val.to_s @unique_table[val] ||= begin if !Binary.ascii_string?(val) utf8_strlen = Binary.charset_strlen(val, "UTF-8") val = Binary.charset_convert(val,"UTF-8","UTF-16BE") bdata = Binary.type_bytes(0b0110, Binary.charset_strlen(val,"UTF-16BE")) val.force_encoding("ASCII-8BIT") if val.respond_to?("encode") @object_table[@written_object_count] = bdata << val else utf8_strlen = val.bytesize bdata = Binary.type_bytes(0b0101,val.bytesize) @object_table[@written_object_count] = bdata << val end @written_object_count += 1 @written_object_count - 1 end end # Codes an integer to binary format def int_to_binary(value) nbytes = 0 nbytes = 1 if value > 0xFF # 1 byte integer nbytes += 1 if value > 0xFFFF # 4 byte integer nbytes += 1 if value > 0xFFFFFFFF # 8 byte integer nbytes = 3 if value < 0 # 8 byte integer, since signed Binary.type_bytes(0b0001, nbytes) << if nbytes < 3 [value].pack( if nbytes == 0 then "C" elsif nbytes == 1 then "n" else "N" end ) else # 64 bit signed integer; we need the higher and the lower 32 bit of the value high_word = value >> 32 low_word = value & 0xFFFFFFFF [high_word,low_word].pack("NN") end end # Codes a real value to binary format def real_to_binary(val) Binary.type_bytes(0b0010,3) << [val].pack("d").reverse end # Converts a numeric value to binary and adds it to the object table def num_to_binary(value) @object_table[@written_object_count] = if value.is_a?(CFInteger) int_to_binary(value.value) else real_to_binary(value.value) end @written_object_count += 1 @written_object_count - 1 end # Convert date value (apple format) to binary and adds it to the object table def date_to_binary(val) val = val.getutc.to_f - CFDate::DATE_DIFF_APPLE_UNIX # CFDate is a real, number of seconds since 01/01/2001 00:00:00 GMT @object_table[@written_object_count] = (Binary.type_bytes(0b0011, 3) << [val].pack("d").reverse) @written_object_count += 1 @written_object_count - 1 end # Convert a bool value to binary and add it to the object table def bool_to_binary(val) @object_table[@written_object_count] = val ? "\x9" : "\x8" # 0x9 is 1001, type indicator for true; 0x8 is 1000, type indicator for false @written_object_count += 1 @written_object_count - 1 end # Convert data value to binary format and add it to the object table def data_to_binary(val) @object_table[@written_object_count] = (Binary.type_bytes(0b0100, val.bytesize) << val) @written_object_count += 1 @written_object_count - 1 end # Convert array to binary format and add it to the object table def array_to_binary(val) saved_object_count = @written_object_count @written_object_count += 1 #@object_refs += val.value.size values = val.value.map { |v| v.to_binary(self) } bdata = Binary.type_bytes(0b1010, val.value.size) << Binary.pack_int_array_with_size(object_ref_size(@object_refs), values) @object_table[saved_object_count] = bdata saved_object_count end # Convert dictionary to binary format and add it to the object table def dict_to_binary(val) saved_object_count = @written_object_count @written_object_count += 1 #@object_refs += val.value.keys.size * 2 keys_and_values = val.value.keys.map { |k| CFString.new(k).to_binary(self) } keys_and_values.concat(val.value.values.map { |v| v.to_binary(self) }) bdata = Binary.type_bytes(0b1101,val.value.size) << Binary.pack_int_array_with_size(object_ref_size(@object_refs), keys_and_values) @object_table[saved_object_count] = bdata return saved_object_count end end end # eof facter-1.7.5/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb0000644005276200011600000000106312276213016024675 0ustar jenkinsjenkins# -*- coding: utf-8 -*- # # Exceptions used: # CFPlistError:: General base exception # CFFormatError:: Format error # CFTypeError:: Type error # # Easy and simple :-) # # Author:: Christian Kruse (mailto:cjk@wwwtech.de) # Copyright:: Copyright (c) 2010 # License:: MIT License # general plist error. All exceptions thrown are derived from this class. class CFPlistError < Exception end # Exception thrown when format errors occur class CFFormatError < CFPlistError end # Exception thrown when type errors occur class CFTypeError < CFPlistError end # eof facter-1.7.5/lib/facter/util/cfpropertylist/Rakefile0000644005276200011600000000242412276213016022407 0ustar jenkinsjenkinsrequire 'rubygems' require 'rubygems/package_task' require 'rdoc/task' require 'rake/testtask' spec = Gem::Specification.new do |s| s.name = "CFPropertyList" s.version = "2.1" s.author = "Christian Kruse" s.email = "cjk@wwwtech.de" s.homepage = "http://github.com/ckruse/CFPropertyList" s.platform = Gem::Platform::RUBY s.summary = "Read, write and manipulate both binary and XML property lists as defined by apple" s.description = "This is a module to read, write and manipulate both binary and XML property lists as defined by apple." s.files = FileList["lib/*"].to_a s.require_path = "lib" #s.autorequire = "name" #s.test_files = FileList["{test}/**/*test.rb"].to_a s.has_rdoc = true s.extra_rdoc_files = ["README"] s.add_development_dependency("rake",">=0.7.0") end desc 'Generate RDoc documentation for the CFPropertyList module.' Rake::RDocTask.new do |rdoc| files = ['README', 'LICENSE', 'lib/*.rb'] rdoc.rdoc_files.add(files) rdoc.main = 'README' rdoc.title = 'CFPropertyList RDoc' rdoc.rdoc_dir = 'doc' rdoc.options << '--line-numbers' << '--inline-source' << '-c utf8' end Gem::PackageTask.new(spec) do |pkg| pkg.need_tar = true end Rake::TestTask.new do |test| test.libs << 'test' test.test_files = Dir.glob('test/test*.rb') end # eof facter-1.7.5/lib/facter/util/cfpropertylist/README0000644005276200011600000000223712276213016021624 0ustar jenkinsjenkinsCFPropertyList implementation class to read, manipulate and write both XML and binary property list files (plist(5)) as defined by Apple. Have a look at CFPropertyList::List for more documentation. == Installation You could either use ruby gems and install it via gem install CFPropertyList or you could clone this repository and place it somewhere in your load path. == Example require 'cfpropertylist' # create a arbitrary data structure of basic data types data = { 'name' => 'John Doe', 'missing' => true, 'last_seen' => Time.now, 'friends' => ['Jane Doe','Julian Doe'], 'likes' => { 'me' => false } } # create CFPropertyList::List object plist = CFPropertyList::List.new # call CFPropertyList.guess() to create corresponding CFType values plist.value = CFPropertyList.guess(data) # write plist to file plist.save("example.plist", CFPropertyList::List::FORMAT_BINARY) # … later, read it again plist = CFPropertyList::List.new(:file => "example.plist") data = CFPropertyList.native_types(plist.value) Author:: Christian Kruse (mailto:cjk@wwwtech.de) Copyright:: Copyright (c) 2010 License:: MIT License facter-1.7.5/lib/facter/util/nothing_loader.rb0000644005276200011600000000034412276213016021171 0ustar jenkinsjenkins# An external fact loader that doesn't load anything # This makes it possible to disable loading # of external facts module Facter module Util class NothingLoader def load(collection) end end end end facter-1.7.5/lib/facter/operatingsystem.rb0000644005276200011600000000637112276213016020463 0ustar jenkinsjenkins# Fact: operatingsystem # # Purpose: Return the name of the operating system. # # Resolution: # If the kernel is a Linux kernel, check for the existence of a selection of # files in /etc/ to find the specific flavour. # On SunOS based kernels, attempt to determine the flavour, otherwise return Solaris. # On systems other than Linux, use the kernel value. # # Caveats: # Facter.add(:operatingsystem) do confine :kernel => :sunos setcode do # Use uname -v because /etc/release can change in zones under SmartOS. # It's apparently not trustworthy enough to rely on for this fact. output = Facter::Util::Resolution.exec('uname -v') if output =~ /^joyent_/ "SmartOS" elsif output =~ /^oi_/ "OpenIndiana" elsif output =~ /^omnios-/ "OmniOS" elsif FileTest.exists?("/etc/debian_version") "Nexenta" else "Solaris" end end end Facter.add(:operatingsystem) do confine :kernel => :linux setcode do if Facter.value(:lsbdistid) == "Ubuntu" "Ubuntu" elsif FileTest.exists?("/etc/debian_version") "Debian" elsif FileTest.exists?("/etc/openwrt_release") "OpenWrt" elsif FileTest.exists?("/etc/gentoo-release") "Gentoo" elsif FileTest.exists?("/etc/fedora-release") "Fedora" elsif FileTest.exists?("/etc/mandriva-release") "Mandriva" elsif FileTest.exists?("/etc/mandrake-release") "Mandrake" elsif FileTest.exists?("/etc/meego-release") "MeeGo" elsif FileTest.exists?("/etc/arch-release") "Archlinux" elsif FileTest.exists?("/etc/oracle-release") "OracleLinux" elsif FileTest.exists?("/etc/enterprise-release") if FileTest.exists?("/etc/ovs-release") "OVS" else "OEL" end elsif FileTest.exists?("/etc/vmware-release") "VMWareESX" elsif FileTest.exists?("/etc/redhat-release") txt = File.read("/etc/redhat-release") if txt =~ /centos/i "CentOS" elsif txt =~ /CERN/ "SLC" elsif txt =~ /scientific/i "Scientific" elsif txt =~ /^cloudlinux/i "CloudLinux" elsif txt =~ /^Parallels Server Bare Metal/i "PSBM" elsif txt =~ /Ascendos/i "Ascendos" elsif txt =~ /^XenServer/i "XenServer" else "RedHat" end elsif FileTest.exists?("/etc/SuSE-release") txt = File.read("/etc/SuSE-release") if txt =~ /^SUSE LINUX Enterprise Server/i "SLES" elsif txt =~ /^SUSE LINUX Enterprise Desktop/i "SLED" elsif txt =~ /^openSUSE/i "OpenSuSE" else "SuSE" end elsif FileTest.exists?("/etc/bluewhite64-version") "Bluewhite64" elsif FileTest.exists?("/etc/slamd64-version") "Slamd64" elsif FileTest.exists?("/etc/slackware-version") "Slackware" elsif FileTest.exists?("/etc/alpine-release") "Alpine" elsif FileTest.exists?("/etc/mageia-release") "Mageia" elsif FileTest.exists?("/etc/system-release") "Amazon" end end end Facter.add(:operatingsystem) do confine :kernel => "VMkernel" setcode do "ESXi" end end Facter.add(:operatingsystem) do # Default to just returning the kernel as the operating system setcode do Facter[:kernel].value end end facter-1.7.5/lib/facter/version.rb0000644005276200011600000000632612276213016016713 0ustar jenkinsjenkinsmodule Facter if not defined? FACTERVERSION then FACTERVERSION = '1.7.5' end ## # version is a public API method intended to always provide a fast and # lightweight way to determine the version of Facter. # # The intent is that software external to Facter be able to determine the # Facter version with no side-effects. The expected use is: # # require 'facter/version' # version = Facter.version # # This function has the following ordering precedence. This precedence list # is designed to facilitate automated packaging tasks by simply writing to # the VERSION file in the same directory as this source file. # # 1. If a version has been explicitly assigned using the Facter.version= # method, return that version. # 2. If there is a VERSION file, read the contents, trim any # trailing whitespace, and return that version string. # 3. Return the value of the Facter::FACTERVERSION constant hard-coded into # the source code. # # If there is no VERSION file, the method must return the version string of # the nearest parent version that is an officially released version. That is # to say, if a branch named 3.1.x contains 25 patches on top of the most # recent official release of 3.1.1, then the version method must return the # string "3.1.1" if no "VERSION" file is present. # # By design the version identifier is _not_ intended to vary during the life # a process. There is no guarantee provided that writing to the VERSION file # while a Puppet process is running will cause the version string to be # updated. On the contrary, the contents of the VERSION are cached to reduce # filesystem accesses. # # The VERSION file is intended to be used by package maintainers who may be # applying patches or otherwise changing the software version in a manner # that warrants a different software version identifier. The VERSION file is # intended to be managed and owned by the release process and packaging # related tasks, and as such should not reside in version control. The # FACTERVERSION constant is intended to be version controlled in history. # # Ideally, this behavior will allow package maintainers to precisely specify # the version of the software they're packaging as in the following example: # # $ git describe > lib/facter/VERSION # $ ruby -r facter -e 'puts Facter.version' # 1.6.14-6-g66f2c99 # # @api public # # @return [String] containing the facter version, e.g. "1.6.14" def self.version version_file = File.join(File.dirname(__FILE__), 'VERSION') return @facter_version if @facter_version if version = read_version_file(version_file) @facter_version = version end @facter_version ||= FACTERVERSION end def self.version=(version) @facter_version = version end ## # read_version_file reads the content of the "VERSION" file that lives in the # same directory as this source code file. # # @api private # # @return [String] for example: "1.6.14-6-gea42046" or nil if the VERSION # file does not exist. def self.read_version_file(path) if File.exists?(path) File.read(path).chomp end end private_class_method :read_version_file end facter-1.7.5/lib/facter/physicalprocessorcount.rb0000644005276200011600000000540012276213016022043 0ustar jenkinsjenkins# Fact: physicalprocessorcount # # Purpose: Return the number of physical processors. # # Resolution: # # Attempts to use sysfs to get the physical IDs of the processors. Falls # back to /proc/cpuinfo and "physical id" if sysfs is not available. # # Caveats: # Facter.add('physicalprocessorcount') do confine :kernel => :linux setcode do sysfs_cpu_directory = '/sys/devices/system/cpu' # This should always be there ... if File.exists?(sysfs_cpu_directory) # # We assume that the sysfs file system has the correct number of entries # under the "/sys/device/system/cpu" directory and if so then we process # content of the file "physical_package_id" located inside the "topology" # directory in each of the per-CPU sub-directories. # # As per Linux Kernel documentation and the file "cputopology.txt" located # inside the "/usr/src/linux/Documentation" directory we can find following # short explanation: # # (...) # # 1) /sys/devices/system/cpu/cpuX/topology/physical_package_id: # # physical package id of cpuX. Typically corresponds to a physical # socket number, but the actual value is architecture and platform # dependent. # # (...) # lookup_pattern = "#{sysfs_cpu_directory}" + "/cpu*/topology/physical_package_id" Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")}.uniq.size else # # Try to count number of CPUs using the proc file system next ... # # We assume that /proc/cpuinfo has what we need and is so then we need # to make sure that we only count unique entries ... # str = Facter::Util::Resolution.exec("grep 'physical.\\+:' /proc/cpuinfo") if str then str.scan(/\d+/).uniq.size; end end end end Facter.add('physicalprocessorcount') do confine :kernel => :windows setcode do require 'facter/util/wmi' Facter::Util::WMI.execquery("select Name from Win32_Processor").Count end end Facter.add('physicalprocessorcount') do confine :kernel => :sunos setcode do # (#16526) The -p flag was not added until Solaris 8. Our intent is to # split the kernel release fact value on the dot, take the second element, # and disable the -p flag for values < 8 when. kernelrelease = Facter.value(:kernelrelease) (major_version, minor_version) = kernelrelease.split(".").map { |str| str.to_i } cmd = "/usr/sbin/psrinfo" result = nil if (major_version > 5) or (major_version == 5 and minor_version >= 8) then result = Facter::Util::Resolution.exec("#{cmd} -p") else output = Facter::Util::Resolution.exec(cmd) result = output.split("\n").length.to_s end end end facter-1.7.5/lib/facter/Cfkey.rb0000644005276200011600000000162012276213016016257 0ustar jenkinsjenkins# Fact: Cfkey # # Purpose: Return the public key(s) for CFengine. # # Resolution: # Tries each file of standard localhost.pub & cfkey.pub locations, # checks if they appear to be a public key, and then join them all together. # # Caveats: # ## Cfkey.rb ## Facts related to cfengine ## Facter.add(:Cfkey) do setcode do value = nil ["/usr/local/etc/cfkey.pub", "/etc/cfkey.pub", "/var/cfng/keys/localhost.pub", "/var/cfengine/ppkeys/localhost.pub", "/var/lib/cfengine/ppkeys/localhost.pub", "/var/lib/cfengine2/ppkeys/localhost.pub" ].each do |file| if FileTest.file?(file) File.open(file) { |openfile| value = openfile.readlines.reject { |line| line =~ /PUBLIC KEY/ }.collect { |line| line.chomp }.join("") } end if value break end end value end end facter-1.7.5/lib/facter/osfamily.rb0000644005276200011600000000164312276213016017046 0ustar jenkinsjenkins# Fact: osfamily # # Purpose: Returns the operating system # # Resolution: # Maps operating systems to operating system families, such as linux # distribution derivatives. Adds mappings from specific operating systems # to kernels in the case that it is relevant. # # Caveats: # This fact is completely reliant on the operatingsystem fact, and no # heuristics are used # Facter.add(:osfamily) do setcode do case Facter.value(:operatingsystem) when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon", "XenServer" "RedHat" when "Ubuntu", "Debian" "Debian" when "SLES", "SLED", "OpenSuSE", "SuSE" "Suse" when "Solaris", "Nexenta", "OmniOS", "OpenIndiana", "SmartOS" "Solaris" when "Gentoo" "Gentoo" when "Archlinux" "Archlinux" else Facter.value("kernel") end end end facter-1.7.5/lib/facter/uptime_days.rb0000644005276200011600000000041412276213016017541 0ustar jenkinsjenkins# Fact: uptime_days # # Purpose: Return purely number of days of uptime. # # Resolution: Divides uptime_hours fact by 24. # # Caveats: # Facter.add(:uptime_days) do setcode do hours = Facter.value(:uptime_hours) hours && hours / 24 # hours in day end end facter-1.7.5/lib/facter/kernelrelease.rb0000644005276200011600000000166712276213016020052 0ustar jenkinsjenkins# Fact: kernelrelease # # Purpose: Return the operating system's release number. # # Resolution: # On AIX returns the output from the "oslevel -s" system command. # On Windows based systems, uses the win32ole gem to query Windows Management # for the 'Win32_OperatingSystem' value. # Otherwise uses the output of "uname -r" system command. # # Caveats: # Facter.add(:kernelrelease) do setcode 'uname -r' end Facter.add(:kernelrelease) do confine :kernel => "aix" setcode 'oslevel -s' end Facter.add(:kernelrelease) do confine :kernel => "hp-ux" setcode do version = Facter::Util::Resolution.exec('uname -r') version[2..-1] end end Facter.add(:kernelrelease) do confine :kernel => "windows" setcode do require 'facter/util/wmi' version = "" Facter::Util::WMI.execquery("SELECT Version from Win32_OperatingSystem").each do |ole| version = "#{ole.Version}" break end version end end facter-1.7.5/lib/facter/path.rb0000644005276200011600000000026312276213016016154 0ustar jenkinsjenkins# Fact: path # # Purpose: Returns the $PATH variable. # # Resolution: Gets $PATH from the environment. # # Caveats: # Facter.add(:path) do setcode do ENV['PATH'] end end facter-1.7.5/lib/facter/ipaddress6.rb0000644005276200011600000000405312276213016017265 0ustar jenkinsjenkins# Fact: ipaddress6 # # Purpose: Returns the "main" IPv6 IP address of a system. # # Resolution: # OS dependant code that parses the output of various networking # tools and currently not very intelligent. Returns the first # non-loopback and non-linklocal address found in the ouput unless # a default route can be mapped to a routeable interface. Guessing # an interface is currently only possible with BSD type systems # to many assumptions have to be made on other platforms to make # this work with the current code. Most code ported or modeled # after the ipaddress fact for the sake of similar functionality # and familiar mechanics. # # Caveats: # # Cody Herriges # # Used the ipaddress fact that is already part of # Facter as a template. require 'facter/util/ip' def get_address_after_token(output, token, return_first=false) ip = nil String(output).scan(/#{token}\s?((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each do |match| match = match.first unless match =~ /fe80.*/ or match == "::1" ip = match break if return_first end end ip end Facter.add(:ipaddress6) do confine :kernel => :linux setcode do output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"]) get_address_after_token(output, 'inet6(?: addr:)?') end end Facter.add(:ipaddress6) do confine :kernel => %w{SunOS} setcode do output = Facter::Util::IP.exec_ifconfig(["-a"]) get_address_after_token(output, 'inet6') end end Facter.add(:ipaddress6) do confine :kernel => %w{Darwin FreeBSD OpenBSD} setcode do output = Facter::Util::IP.exec_ifconfig(["-a"]) get_address_after_token(output, 'inet6', true) end end Facter.add(:ipaddress6) do confine :kernel => :windows setcode do require 'facter/util/ip/windows' ipaddr = nil adapters = Facter::Util::IP::Windows.get_preferred_ipv6_adapters adapters.find do |nic| nic.IPAddress.any? do |addr| ipaddr = addr if Facter::Util::IP::Windows.valid_ipv6_address?(addr) ipaddr end end ipaddr end end facter-1.7.5/lib/facter/operatingsystemmajrelease.rb0000644005276200011600000000171412276213016022510 0ustar jenkinsjenkins# Fact: operatingsystemmajrelease # # Purpose: Returns the major release of the operating system. # # Resolution: splits down the operatingsystemrelease fact at decimal point for # osfamily RedHat derivatives and Debian. # # This should be the same as lsbmajdistrelease, but on minimal systems there # are too many dependencies to use LSB # # List of operatingsystems at time of writing: #"Alpine" "Amazon" "Archlinux" "Ascendos" "Bluewhite64" "CentOS" "CloudLinux" #"Debian" "Fedora" "Gentoo" "Mandrake" "Mandriva" "MeeGo" "OEL" "OpenSuSE" #"OracleLinux" "OVS" "PSBM" "RedHat" "Scientific" "Slackware" "Slamd64" "SLC" #"SLED" "SLES" "SuSE" "Ubuntu" "VMWareESX" Facter.add(:operatingsystemmajrelease) do confine :operatingsystem => [ :Amazon, :CentOS, :CloudLinux, :Debian, :Fedora, :OEL, :OracleLinux, :OVS, :RedHat, :Scientific, :SLC ] setcode do Facter.value('operatingsystemrelease').split('.').first end end facter-1.7.5/lib/facter/application.rb0000644005276200011600000001220312276213016017520 0ustar jenkinsjenkinsmodule Facter module Application require 'facter/util/nothing_loader' def self.create_directory_loader(dir) begin Facter::Util::Config.ext_fact_loader = Facter::Util::DirectoryLoader.loader_for(dir) rescue Facter::Util::DirectoryLoader::NoSuchDirectoryError => error $stderr.puts "Specified external facts directory #{dir} does not exist." exit(1) end end def self.create_nothing_loader Facter::Util::Config.ext_fact_loader = Facter::Util::NothingLoader.new end def self.run(argv) require 'optparse' require 'facter' options = parse(argv) # Accept fact names to return from the command line names = argv # Change location of external facts dir # Check here for valid ext_dir and exit program # Create the facts hash that is printed to standard out. unless names.empty? facts = {} names.each do |name| begin facts[name] = Facter.value(name) rescue => error $stderr.puts "Could not retrieve #{name}: #{error}" exit 10 end end end # Print everything if they didn't ask for specific facts. facts ||= Facter.to_hash # Print the facts as YAML and exit if options[:yaml] require 'yaml' puts YAML.dump(facts) exit(0) end # Print the facts as JSON and exit if options[:json] begin require 'json' puts JSON.dump(facts) exit(0) rescue LoadError $stderr.puts "You do not have JSON support in your version of Ruby. JSON output disabled" exit(1) end end # Print the value of a single fact, otherwise print a list sorted by fact # name and separated by "=>" if facts.length == 1 if value = facts.values.first puts value end else facts.sort_by{ |fact| fact.first }.each do |name,value| puts "#{name} => #{value}" end end rescue => e if options && options[:trace] raise e else $stderr.puts "Error: #{e}" exit(12) end end private # Parses the given argument array destructively to return an options hash # (and possibly perform side effects such as changing settings). # # @param [Array] argv command line arguments # @return [Hash] options hash def self.parse(argv) options = {} parser = OptionParser.new do |opts| opts.banner = <<-BANNER Synopsis ======== Collect and display facts about the system. Usage ===== facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [--external-dir DIR] [--no-external-dir] [fact] [fact] [...] Description =========== Collect and display facts about the current system. The library behind Facter is easy to expand, making Facter an easy way to collect information about a system from within the shell or within Ruby. If no facts are specifically asked for, then all facts will be returned. EXAMPLE ======= facter kernel AUTHOR ====== Luke Kanies COPYRIGHT ========= Copyright (c) 2011-2012 Puppet Labs, Inc Licensed under the Apache 2.0 license USAGE ===== BANNER opts.on("-y", "--yaml", "Emit facts in YAML format.") { |v| options[:yaml] = v } opts.on("-j", "--json", "Emit facts in JSON format.") { |v| options[:json] = v } opts.on("--trace", "Enable backtraces.") { |v| options[:trace] = v } opts.on("--external-dir DIR", "The directory to use for external facts.") { |v| create_directory_loader(v) } opts.on("--no-external-dir", "Turn off external facts.") { |v| create_nothing_loader } opts.on("-d", "--debug", "Enable debugging.") { |v| Facter.debugging(1) } opts.on("-t", "--timing", "Enable timing.") { |v| Facter.timing(1) } opts.on("-p", "--puppet", "Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.") { |v| load_puppet } opts.on_tail("-v", "--version", "Print the version and exit.") do puts Facter.version exit(0) end opts.on_tail("-h", "--help", "Print this help message.") do puts parser exit(0) end end parser.parse!(argv) options rescue OptionParser::InvalidOption => e $stderr.puts e.message exit(12) end def self.load_puppet require 'puppet' Puppet.parse_config # If you've set 'vardir' but not 'libdir' in your # puppet.conf, then the hook to add libdir to $: # won't get triggered. This makes sure that it's setup # correctly. unless $LOAD_PATH.include?(Puppet[:libdir]) $LOAD_PATH << Puppet[:libdir] end rescue LoadError => detail $stderr.puts "Could not load Puppet: #{detail}" end end end facter-1.7.5/lib/facter/uptime.rb0000644005276200011600000000121412276213016016520 0ustar jenkinsjenkins# Fact: uptime # # Purpose: return the system uptime in a human readable format. # # Resolution: # Does basic maths on the "uptime_seconds" fact to return a count of # days, hours and minutes of uptime # # Caveats: # require 'facter/util/uptime' Facter.add(:uptime) do setcode do seconds = Facter.fact(:uptime_seconds).value unless seconds "unknown" else days = seconds / (60 * 60 * 24) hours = seconds / (60 * 60) % 24 minutes = seconds / 60 % 60 case days when 0 then "#{hours}:#{"%02d" % minutes} hours" when 1 then '1 day' else "#{days} days" end end end end facter-1.7.5/lib/facter/macaddress.rb0000644005276200011600000000511312276213016017325 0ustar jenkinsjenkins# Fact: macaddress # # Purpose: # # Resolution: # # Caveats: # require 'facter/util/macaddress' require 'facter/util/ip' Facter.add(:macaddress) do confine :kernel => 'Linux' has_weight 10 # about an order of magnitude faster setcode do begin Dir.glob('/sys/class/net/*').reject {|x| x[-3..-1] == '/lo' }.first path and File.read(path + '/address') rescue Exception nil end end end Facter.add(:macaddress) do confine :kernel => 'Linux' setcode do ether = [] output = Facter::Util::IP.exec_ifconfig(["-a","2>/dev/null"]) String(output).each_line do |s| ether.push($1) if s =~ /(?:ether|HWaddr) ((\w{1,2}:){5,}\w{1,2})/ end Facter::Util::Macaddress.standardize(ether[0]) end end Facter.add(:macaddress) do confine :kernel => %w{SunOS GNU/kFreeBSD} setcode do ether = [] output = Facter::Util::IP.exec_ifconfig(["-a"]) output.each_line do |s| ether.push($1) if s =~ /(?:ether|HWaddr) ((\w{1,2}:){5,}\w{1,2})/ end Facter::Util::Macaddress.standardize(ether[0]) end end Facter.add(:macaddress) do confine :osfamily => "Solaris" setcode do ether = [] output = Facter::Util::Resolution.exec("/usr/bin/netstat -np") output.each_line do |s| ether.push($1) if s =~ /(?:SPLA)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/ end Facter::Util::Macaddress.standardize(ether[0]) end end Facter.add(:macaddress) do confine :operatingsystem => %w{FreeBSD OpenBSD DragonFly} setcode do ether = [] output = Facter::Util::IP.exec_ifconfig output.each_line do |s| if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ ether.push($1) end end Facter::Util::Macaddress.standardize(ether[0]) end end Facter.add(:macaddress) do confine :kernel => :darwin setcode { Facter::Util::Macaddress::Darwin.macaddress } end Facter.add(:macaddress) do confine :kernel => %w{AIX} setcode do ether = [] ip = nil output = Facter::Util::IP.exec_ifconfig(["-a"]) output.each_line do |str| if str =~ /([a-z]+\d+): flags=/ devname = $1 unless devname =~ /lo0/ output2 = %x{/usr/bin/entstat #{devname}} output2.each_line do |str2| if str2 =~ /^Hardware Address: (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ ether.push($1) end end end end end Facter::Util::Macaddress.standardize(ether[0]) end end Facter.add(:macaddress) do confine :kernel => %w(windows) setcode do Facter::Util::Macaddress::Windows.macaddress end end facter-1.7.5/lib/facter/hardwaremodel.rb0000644005276200011600000000505112276213016020036 0ustar jenkinsjenkins# Fact: hardwaremodel # # Purpose: # Returns the hardware model of the system. # # Resolution: # Uses purely "uname -m" on all platforms other than AIX and Windows. # On AIX uses the parsed "modelname" output of "lsattr -El sys0 -a modelname". # On Windows uses the 'host_cpu' pulled out of Ruby's config. # # Caveats: # Facter.add(:hardwaremodel) do setcode 'uname -m' end Facter.add(:hardwaremodel) do confine :operatingsystem => :aix setcode do model = Facter::Util::Resolution.exec('lsattr -El sys0 -a modelname') if model =~ /modelname\s(\S+)\s/ $1 end end end Facter.add(:hardwaremodel) do confine :operatingsystem => :windows setcode do # The cryptic windows cpu architecture models are documented in these places: # http://source.winehq.org/source/include/winnt.h#L568 # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394373(v=vs.85).aspx # http://msdn.microsoft.com/en-us/library/windows/desktop/windows.system.processorarchitecture.aspx # http://linux.derkeiler.com/Mailing-Lists/Kernel/2008-05/msg12924.html (anything over 6 is still i686) # Also, arm and neutral are included because they are valid for the upcoming # windows 8 release. --jeffweiss 23 May 2012 require 'facter/util/wmi' model = "" architecture_level = nil Facter::Util::WMI.execquery("select Architecture, Level, AddressWidth from Win32_Processor").each do |cpu| architecture_level = (cpu.Level > 5) ? 6 : cpu.Level; model = case cpu.Architecture when 11 then 'neutral' # PROCESSOR_ARCHITECTURE_NEUTRAL when 10 then 'i686' # PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 when 9 then # PROCESSOR_ARCHITECTURE_AMD64 cpu.AddressWidth == 32 ? "i#{architecture_level}86" : 'x64' # 32 bit OS on 64 bit CPU when 8 then 'msil' # PROCESSOR_ARCHITECTURE_MSIL when 7 then 'alpha64' # PROCESSOR_ARCHITECTURE_ALPHA64 when 6 then 'ia64' # PROCESSOR_ARCHITECTURE_IA64 when 5 then 'arm' # PROCESSOR_ARCHITECTURE_ARM when 4 then 'shx' # PROCESSOR_ARCHITECTURE_SHX when 3 then 'powerpc' # PROCESSOR_ARCHITECTURE_PPC when 2 then 'alpha' # PROCESSOR_ARCHITECTURE_ALPHA when 1 then 'mips' # PROCESSOR_ARCHITECTURE_MIPS when 0 then "i#{architecture_level}86" # PROCESSOR_ARCHITECTURE_INTEL else 'unknown' # PROCESSOR_ARCHITECTURE_UNKNOWN end break end model end end facter-1.7.5/lib/facter/manufacturer.rb0000644005276200011600000000376312276213016017724 0ustar jenkinsjenkins# Fact: manufacturer # # Purpose: Return the hardware manufacturer information about the hardware. # # Resolution: # On OpenBSD, queries sysctl values, via a util class. # On SunOS Sparc, uses prtdiag via a util class. # On Windows, queries the system via a util class. # Uses the 'util/manufacturer.rb' for fallback parsing. # # Caveats: # # manufacturer.rb # Facts related to hardware manufacturer # # require 'facter/util/manufacturer' if Facter.value(:kernel) == "OpenBSD" mfg_keys = { 'hw.vendor' => 'manufacturer', 'hw.product' => 'productname', 'hw.serialno' => 'serialnumber' } Facter::Manufacturer.sysctl_find_system_info(mfg_keys) elsif Facter.value(:kernel) == "Darwin" mfg_keys = { 'hw.model' => 'productname' } Facter::Manufacturer.sysctl_find_system_info(mfg_keys) elsif Facter.value(:kernel) == "SunOS" and Facter.value(:hardwareisa) == "sparc" Facter::Manufacturer.prtdiag_sparc_find_system_info() elsif Facter.value(:kernel) == "windows" win32_keys = { 'manufacturer' => ['Manufacturer', 'Bios'], 'serialNumber' => ['Serialnumber', 'Bios'], 'productname' => ['Name', 'ComputerSystemProduct'] } Facter::Manufacturer.win32_find_system_info(win32_keys) else query = { '[Bb]ase [Bb]oard [Ii]nformation' => [ { 'Manufacturer:' => 'boardmanufacturer' }, { 'Product(?: Name)?:' => 'boardproductname' }, { 'Serial Number:' => 'boardserialnumber' } ], '[Bb][Ii][Oo][Ss] [Ii]nformation' => [ { '[Vv]endor:' => 'bios_vendor' }, { '[Vv]ersion:' => 'bios_version' }, { '[Rr]elease [Dd]ate:' => 'bios_release_date' } ], '[Ss]ystem [Ii]nformation' => [ { 'Manufacturer:' => 'manufacturer' }, { 'Product(?: Name)?:' => 'productname' }, { 'Serial Number:' => 'serialnumber' }, { 'UUID:' => 'uuid' } ], '(Chassis Information|system enclosure or chassis)' => [ { '(?:Chassis )?Type:' => 'type' } ] } Facter::Manufacturer.dmi_find_system_info(query) end facter-1.7.5/lib/facter/ipaddress.rb0000644005276200011600000000746412276213016017210 0ustar jenkinsjenkins# Fact: ipaddress # # Purpose: Return the main IP address for a host. # # Resolution: # On the Unixes does an ifconfig, and returns the first non 127.0.0.0/8 # subnetted IP it finds. # On Windows, it attempts to use the socket library and resolve the machine's # hostname via DNS. # # On LDAP based hosts it tries to use either the win32/resolv library to # resolve the hostname to an IP address, or on Unix, it uses the resolv # library. # # As a fall back for undefined systems, it tries to run the "host" command to # resolve the machine's hostname using the system DNS. # # Caveats: # DNS resolution relies on working DNS infrastructure and resolvers on the # host system. # The ifconfig parsing purely takes the first IP address it finds without any # checking this is a useful IP address. # require 'facter/util/ip' Facter.add(:ipaddress) do confine :kernel => :linux setcode do ip = nil output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"]) if output regexp = /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ output.split("\n").each do |line| match = regexp.match(line) if match and not /^127\./.match(match[1]) ip = match[1] break end end end ip end end Facter.add(:ipaddress) do confine :kernel => %w{FreeBSD OpenBSD Darwin DragonFly} setcode do ip = nil output = Facter::Util::IP.exec_ifconfig output.split(/^\S/).each { |str| if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ tmp = $1 unless tmp =~ /^127\./ ip = tmp break end end } ip end end Facter.add(:ipaddress) do confine :kernel => %w{NetBSD SunOS} setcode do ip = nil output = Facter::Util::IP.exec_ifconfig(["-a"]) output.split(/^\S/).each { |str| if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ tmp = $1 unless tmp =~ /^127\./ or tmp == "0.0.0.0" ip = tmp break end end } ip end end Facter.add(:ipaddress) do confine :kernel => %w{AIX} setcode do ip = nil output = Facter::Util::IP.exec_ifconfig(["-a"]) output.split(/^\S/).each { |str| if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ tmp = $1 unless tmp =~ /^127\./ ip = tmp break end end } ip end end Facter.add(:ipaddress) do confine :kernel => %w{windows} setcode do require 'facter/util/ip/windows' ipaddr = nil adapters = Facter::Util::IP::Windows.get_preferred_ipv4_adapters adapters.find do |nic| nic.IPAddress.any? do |addr| ipaddr = addr if Facter::Util::IP::Windows.valid_ipv4_address?(addr) ipaddr end end ipaddr end end Facter.add(:ipaddress, :ldapname => "iphostnumber", :timeout => 2) do setcode do if Facter.value(:kernel) == 'windows' require 'win32/resolv' else require 'resolv' end begin if hostname = Facter.value(:hostname) if Facter.value(:kernel) == 'windows' ip = Win32::Resolv.get_resolv_info.last[0] else ip = Resolv.getaddress(hostname) end unless ip == "127.0.0.1" ip end else nil end rescue Resolv::ResolvError nil rescue NoMethodError # i think this is a bug in resolv.rb? nil end end end Facter.add(:ipaddress, :timeout => 2) do setcode do if hostname = Facter.value(:hostname) # we need Hostname to exist for this to work host = nil if host = Facter::Util::Resolution.exec("host #{hostname}") list = host.chomp.split(/\s/) if defined? list[-1] and list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ list[-1] end else nil end else nil end end end facter-1.7.5/lib/facter/zpool_version.rb0000644005276200011600000000044312276213016020130 0ustar jenkinsjenkinsrequire 'facter' Facter.add('zpool_version') do setcode do if Facter::Util::Resolution.which('zpool') zpool_v = Facter::Util::Resolution.exec('zpool upgrade -v') zpool_version = zpool_v.match(/ZFS pool version (\d+)./).captures.first unless zpool_v.nil? end end end facter-1.7.5/lib/facter/zfs_version.rb0000644005276200011600000000041012276213016017561 0ustar jenkinsjenkinsrequire 'facter' Facter.add('zfs_version') do setcode do if Facter::Util::Resolution.which('zfs') zfs_v = Facter::Util::Resolution.exec('zfs upgrade -v') zfs_version = zfs_v.scan(/^\s+(\d+)\s+/m).flatten.last unless zfs_v.nil? end end end facter-1.7.5/lib/facter/zonename.rb0000644005276200011600000000014212276213016017030 0ustar jenkinsjenkinsrequire 'facter' Facter.add('zonename') do confine :kernel => :sunos setcode('zonename') end facter-1.7.5/lib/facter/lsbrelease.rb0000644005276200011600000000100612276213016017335 0ustar jenkinsjenkins# Fact: lsbrelease # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsb_release system command # # Caveats: # Only works on Linux (and the kfreebsd derivative) systems. # Requires the lsb_release program, which may not be installed by default. # Also is as only as accurate as that program outputs. Facter.add(:lsbrelease) do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do Facter::Util::Resolution.exec('lsb_release -v -s 2>/dev/null') end end facter-1.7.5/lib/facter/puppetversion.rb0000644005276200011600000000051012276213016020136 0ustar jenkinsjenkins# Fact: puppetversion # # Purpose: Return the version of puppet installed. # # Resolution: # Requres puppet via Ruby and returns it's version constant. # # Caveats: # Facter.add(:puppetversion) do setcode do begin require 'puppet' Puppet::PUPPETVERSION.to_s rescue LoadError nil end end end facter-1.7.5/lib/facter/macosx.rb0000644005276200011600000000235612276213016016517 0ustar jenkinsjenkins# Fact: macosx # # Purpose: # Returns a number of Mac specific facts, from system profiler and # sw_vers. # # Resolution: # Uses util/macosx.rb to do the fact reconnaissance, then outputs them # preceded by 'sp_' # # Caveats: # # # macosx.rb # Additional Facts coming from Mac OS X system_profiler command # # Copyright (C) 2007 Jeff McCune # Author: Jeff McCune # # Jeff McCune # There's a lot more information coming out of system_profiler -xml # We could add quite a bit more, but I didn't want to overload facter # at this point in time. # In particular, Installed Software might be an interesting addition. require 'facter/util/macosx' if Facter.value(:kernel) == "Darwin" Facter::Util::Macosx.hardware_overview.each do |fact, value| Facter.add("sp_#{fact}") do confine :kernel => :darwin setcode do value.to_s end end end Facter::Util::Macosx.os_overview.each do |fact, value| Facter.add("sp_#{fact}") do confine :kernel => :darwin setcode do value.to_s end end end Facter::Util::Macosx.sw_vers.each do |fact, value| Facter.add(fact) do confine :kernel => :darwin setcode do value end end end end facter-1.7.5/lib/facter/rubyversion.rb0000644005276200011600000000031412276213016017604 0ustar jenkinsjenkins# Fact: rubyversion # # Purpose: Returns the version of Ruby facter is running under. # # Resolution: Returns RUBY_VERSION. # # Caveats: # Facter.add(:rubyversion) do setcode { RUBY_VERSION.to_s } end facter-1.7.5/lib/facter/augeasversion.rb0000644005276200011600000000143012276213016020070 0ustar jenkinsjenkins# Fact: augeasversion # # Purpose: Report the version of the Augeas library # # Resolution: # Loads ruby-augeas and reports the value of /augeas/version, the version of # the underlying Augeas library. # # Caveats: # The library version may not indicate the presence of certain lenses, # depending on the system packages updated, nor the version of ruby-augeas # which may affect support for the Puppet Augeas provider. # Versions prior to 0.3.6 cannot be interrogated for their version. # Facter.add(:augeasversion) do setcode do begin require 'augeas' aug = Augeas::open('/', nil, Augeas::NO_MODL_AUTOLOAD) ver = aug.get('/augeas/version') aug.close ver rescue Exception Facter.debug('ruby-augeas not available') end end end facter-1.7.5/lib/facter/iphostnumber.rb0000644005276200011600000000120012276213016017727 0ustar jenkinsjenkins# Fact: iphostnumber # # Purpose: On selected versions of Darwin, returns the host's IP address. # # Resolution: # Uses either the scutil program to get the localhost name, or parses output # of ifconfig for a MAC address. # # Caveats: # Facter.add(:iphostnumber) do confine :kernel => :darwin, :kernelrelease => "R6" setcode do %x{/usr/sbin/scutil --get LocalHostName} end end Facter.add(:iphostnumber) do confine :kernel => :darwin, :kernelrelease => "R6" setcode do ether = nil output = Facter::Util::IP.exec_ifconfig output =~ /HWaddr (\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ ether = $1 ether end end facter-1.7.5/lib/facter/virtual.rb0000644005276200011600000001726012276213016016713 0ustar jenkinsjenkins# Fact: virtual # # Purpose: Determine if the system's hardware is real or virtualised. # # Resolution: # Assumes physical unless proven otherwise. # # On Darwin, use the macosx util module to acquire the SPDisplaysDataType, # from that parse it to see if it's VMWare or Parallels pretending to be the # display. # # On Linux, BSD, Solaris and HPUX: # Much of the logic here is obscured behind util/virtual.rb, which rather # than document here, which would encourage drift, just refer to it. # The Xen tests in here rely on /sys and /proc, and check for the presence and # contents of files in there. # If after all the other tests, it's still seen as physical, then it tries to # parse the output of the "lspci", "dmidecode" and "prtdiag" and parses them # for obvious signs of being under VMWare, Parallels or VirtualBox. # Finally it checks for the existence of vmware-vmx, which would hint it's # VMWare. # # Caveats: # Many checks rely purely on existence of files. # require 'facter/util/virtual' Facter.add("virtual") do confine :kernel => "Darwin" setcode do require 'facter/util/macosx' result = "physical" output = Facter::Util::Macosx.profiler_data("SPDisplaysDataType") if output.is_a?(Hash) result = "parallels" if output["spdisplays_vendor-id"] =~ /0x1ab8/ result = "parallels" if output["spdisplays_vendor"] =~ /[Pp]arallels/ result = "vmware" if output["spdisplays_vendor-id"] =~ /0x15ad/ result = "vmware" if output["spdisplays_vendor"] =~ /VM[wW]are/ result = "virtualbox" if output["spdisplays_vendor-id"] =~ /0x80ee/ end result end end Facter.add("virtual") do confine :kernel => ["FreeBSD", "GNU/kFreeBSD"] has_weight 10 setcode do "jail" if Facter::Util::Virtual.jail? end end Facter.add("virtual") do confine :kernel => 'SunOS' has_weight 10 setcode do next "zone" if Facter::Util::Virtual.zone? resolver = Facter::Util::Resolution.new('prtdiag') resolver.timeout = 6 resolver.setcode('prtdiag') output = resolver.value if output lines = output.split("\n") next "parallels" if lines.any? {|l| l =~ /Parallels/ } next "vmware" if lines.any? {|l| l =~ /VM[wW]are/ } next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ } next "xenhvm" if lines.any? {|l| l =~ /HVM domU/ } end end end Facter.add("virtual") do confine :kernel => 'HP-UX' has_weight 10 setcode do "hpvm" if Facter::Util::Virtual.hpvm? end end Facter.add("virtual") do confine :architecture => 's390x' has_weight 10 setcode do "zlinux" if Facter::Util::Virtual.zlinux? end end Facter.add("virtual") do confine :kernel => 'OpenBSD' has_weight 10 setcode do output = Facter::Util::Resolution.exec('sysctl -n hw.product 2>/dev/null') if output lines = output.split("\n") next "parallels" if lines.any? {|l| l =~ /Parallels/ } next "vmware" if lines.any? {|l| l =~ /VMware/ } next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ } next "xenhvm" if lines.any? {|l| l =~ /HVM domU/ } end end end Facter.add("virtual") do confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX GNU/kFreeBSD} setcode do next Facter::Util::Virtual.openvz_type if Facter::Util::Virtual.openvz? next Facter::Util::Virtual.vserver_type if Facter::Util::Virtual.vserver? if Facter::Util::Virtual.xen? next "xen0" if FileTest.exists?("/dev/xen/evtchn") next "xenu" if FileTest.exists?("/proc/xen") end next "virtualbox" if Facter::Util::Virtual.virtualbox? next Facter::Util::Virtual.kvm_type if Facter::Util::Virtual.kvm? next "rhev" if Facter::Util::Virtual.rhev? next "ovirt" if Facter::Util::Virtual.ovirt? # Parse lspci output = Facter::Util::Virtual.lspci if output lines = output.split("\n") next "vmware" if lines.any? {|l| l =~ /VM[wW]are/ } next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ } next "parallels" if lines.any? {|l| l =~ /1ab8:|[Pp]arallels/ } next "xenhvm" if lines.any? {|l| l =~ /XenSource/ } next "hyperv" if lines.any? {|l| l =~ /Microsoft Corporation Hyper-V/ } next "gce" if lines.any? {|l| l =~ /Class 8007: Google, Inc/ } end # Parse dmidecode output = Facter::Util::Resolution.exec('dmidecode 2> /dev/null') if output lines = output.split("\n") next "parallels" if lines.any? {|l| l =~ /Parallels/ } next "vmware" if lines.any? {|l| l =~ /VMware/ } next "virtualbox" if lines.any? {|l| l =~ /VirtualBox/ } next "xenhvm" if lines.any? {|l| l =~ /HVM domU/ } next "hyperv" if lines.any? {|l| l =~ /Product Name: Virtual Machine/ } next "rhev" if lines.any? {|l| l =~ /Product Name: RHEV Hypervisor/ } next "ovirt" if lines.any? {|l| l =~ /Product Name: oVirt Node/ } end # Sample output of vmware -v `VMware Server 1.0.5 build-80187` output = Facter::Util::Resolution.exec("vmware -v") if output mdata = output.match /(\S+)\s+(\S+)/ next "#{mdata[1]}_#{mdata[2]}".downcase if mdata end # Default to 'physical' next 'physical' end end Facter.add("virtual") do confine :kernel => "windows" setcode do require 'facter/util/wmi' result = nil Facter::Util::WMI.execquery("SELECT manufacturer, model FROM Win32_ComputerSystem").each do |computersystem| case computersystem.model when /VirtualBox/ result = "virtualbox" when /Virtual Machine/ result = "hyperv" if computersystem.manufacturer =~ /Microsoft/ when /VMware/ result = "vmware" when /KVM/ result = "kvm" when /Bochs/ result = "bochs" end if result.nil? and computersystem.manufacturer =~ /Xen/ result = "xen" end break end result ||= "physical" result end end ## # virtual fact based on virt-what command. # # The output is mapped onto existing known values for the virtual fact in an # effort to preserve consistency. This fact has a high weight becuase the # virt-what tool is expected to be maintained upstream. # # If the virt-what command is not available, this fact will not resolve to a # value and lower-weight virtual facts will be attempted. # # Only the last line of the virt-what command is returned Facter.add("virtual") do has_weight 500 setcode do if output = Facter::Util::Virtual.virt_what case output when 'linux_vserver' Facter::Util::Virtual.vserver_type when /xen-hvm/i 'xenhvm' when /xen-dom0/i 'xen0' when /xen-domU/i 'xenu' when /ibm_systemz/i 'zlinux' else output.to_s.split("\n").last end end end end ## # virtual fact specific to Google Compute Engine's Linux sysfs entry. Facter.add("virtual") do has_weight 600 confine :kernel => "Linux" setcode do if dmi_data = Facter::Util::Virtual.read_sysfs_dmi_entries case dmi_data when /Google/ "gce" end end end end # Fact: is_virtual # # Purpose: returning true or false for if a machine is virtualised or not. # # Resolution: Hypervisors and the like may be detected as a virtual type, but # are not actual virtual machines, or should not be treated as such. This # determines if the host is actually virtualized. # # Caveats: # Facter.add("is_virtual") do confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin GNU/kFreeBSD windows} setcode do physical_types = %w{physical xen0 vmware_server vmware_workstation openvzhn vserver_host} if physical_types.include? Facter.value(:virtual) "false" else "true" end end end facter-1.7.5/lib/facter/uptime_hours.rb0000644005276200011600000000044512276213016017745 0ustar jenkinsjenkins# Fact: uptime_hours # # Purpose: Return purely number of hours of uptime. # # Resolution: Divides uptime_seconds fact by 3600. # # Caveats: # Facter.add(:uptime_hours) do setcode do seconds = Facter.value(:uptime_seconds) seconds && seconds / (60 * 60) # seconds in hour end end facter-1.7.5/lib/facter/hostname.rb0000644005276200011600000000135012276213016017034 0ustar jenkinsjenkins# Fact: hostname # # Purpose: Return the system's short hostname. # # Resolution: # On all system bar Darwin, parses the output of the "hostname" system command # to everything before the first period. # On Darwin, uses the system configuration util to get the LocalHostName # variable. # # Caveats: # Facter.add(:hostname, :ldapname => "cn") do setcode do hostname = nil if name = Facter::Util::Resolution.exec('hostname') if name =~ /(.*?)\./ hostname = $1 else hostname = name end end hostname end end Facter.add(:hostname) do confine :kernel => :darwin, :kernelrelease => "R7" setcode do Facter::Util::Resolution.exec('/usr/sbin/scutil --get LocalHostName') end end facter-1.7.5/lib/facter/netmask.rb0000644005276200011600000000171512276213016016665 0ustar jenkinsjenkins# Fact: netmask # # Purpose: Returns the netmask for the main interfaces. # # Resolution: Uses the facter/util/netmask library routines. # # Caveats: # # netmask.rb # Find the netmask of the primary ipaddress # Copyright (C) 2007 David Schmitt # Copyright (C) 2007 Mark 'phips' Phillips # # idea and originial source by Mark 'phips' Phillips # require 'facter/util/netmask' Facter.add("netmask") do confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly ] setcode do Facter::NetMask.get_netmask end end Facter.add(:netmask) do confine :kernel => :windows setcode do require 'facter/util/ip/windows' mask = nil adapters = Facter::Util::IP::Windows.get_preferred_ipv4_adapters adapters.find do |nic| nic.IPSubnet.any? do |subnet| mask = subnet if Facter::Util::IP::Windows.valid_ipv4_address?(subnet) mask end end mask end end facter-1.7.5/lib/facter/id.rb0000644005276200011600000000067612276213016015624 0ustar jenkinsjenkins# Fact: id # # Purpose: Internal fact used to specity the program to return the currently # running user id. # # Resolution: # On all Unixes bar Solaris, just returns "whoami". # On Solaris, parses the output of the "id" command to grab the username, as # Solaris doesn't have the whoami command. # # Caveats: # Facter.add(:id) do setcode "whoami" end Facter.add(:id) do confine :kernel => :SunOS setcode "/usr/xpg4/bin/id -un" end facter-1.7.5/lib/facter/blockdevices.rb0000644005276200011600000000561312276213016017661 0ustar jenkinsjenkins# Fact: blockdevice__size # # Purpose: # Return the size of a block device in bytes # # Resolution: # Parse the contents of /sys/block//size to receive the size (multiplying by 512 to correct for blocks-to-bytes) # # Caveats: # Only supports Linux 2.6+ at this time, due to the reliance on sysfs # # Fact: blockdevice__vendor # # Purpose: # Return the vendor name of block devices attached to the system # # Resolution: # Parse the contents of /sys/block//device/vendor to retrieve the vendor for a device # # Caveats: # Only supports Linux 2.6+ at this time, due to the reliance on sysfs # # Fact: blockdevice__model # # Purpose: # Return the model name of block devices attached to the system # # Resolution: # Parse the contents of /sys/block//device/model to retrieve the model name/number for a device # # Caveats: # Only supports Linux 2.6+ at this time, due to the reliance on sysfs # # Fact: blockdevices # # Purpose: # Return a comma seperated list of block devices # # Resolution: # Retrieve the block devices that were identified and iterated over in the creation of the blockdevice_ facts # # Caveats: # Block devices must have been identified using sysfs information # # Author: Jason Gill require 'facter' # Only Linux 2.6+ kernels support sysfs which is required to easily get device details if Facter.value(:kernel) == 'Linux' sysfs_block_directory = '/sys/block/' blockdevices = [] # This should prevent any non-2.6 kernels or odd machines without sysfs support from being investigated further if File.exist?(sysfs_block_directory) # Iterate over each file in the /sys/block/ directory and skip ones that do not have a device subdirectory Dir.entries(sysfs_block_directory).each do |device| sysfs_device_directory = sysfs_block_directory + device + "/device" next unless File.exist?(sysfs_device_directory) # Add the device to the blockdevices list, which is returned as it's own fact later on blockdevices << device sizefile = sysfs_block_directory + device + "/size" vendorfile = sysfs_device_directory + "/vendor" modelfile = sysfs_device_directory + "/model" if File.exist?(sizefile) Facter.add("blockdevice_#{device}_size".to_sym) do setcode { IO.read(sizefile).strip.to_i * 512 } end end if File.exist?(vendorfile) Facter.add("blockdevice_#{device}_vendor".to_sym) do setcode { IO.read(vendorfile).strip } end end if File.exist?(modelfile) Facter.add("blockdevice_#{device}_model".to_sym) do setcode { IO.read(modelfile).strip } end end end end # Return a comma-seperated list of block devices found unless blockdevices.empty? Facter.add(:blockdevices) do setcode { blockdevices.sort.join(',') } end end end facter-1.7.5/lib/facter/processor.rb0000644005276200011600000001066412276213016017245 0ustar jenkinsjenkins# Fact: processor # # Purpose: # Additional Facts about the machine's CPUs. # # Resolution: # On Linux and kFreeBSD, parse '/proc/cpuinfo' for each processor. # On AIX, parse the output of 'lsdev' for its processor section. # On Solaris, parse the output of 'kstat' for each processor. # On OpenBSD, use 'uname -p' and the sysctl variable for 'hw.ncpu' for CPU # count. # # Caveats: # # processor.rb # # Copyright (C) 2006 Mooter Media Ltd # Author: Matthew Palmer # require 'thread' require 'facter/util/processor' ## We have to enumerate these outside a Facter.add block to get the processorN descriptions iteratively ## (but we need them inside the Facter.add block above for tests on processorcount to work) processor_list = case Facter::Util::Processor.kernel_fact_value when "AIX" Facter::Util::Processor.aix_processor_list when "HP-UX" Facter::Util::Processor.hpux_processor_list when "SunOS" Facter::Util::Processor.enum_kstat else Facter::Util::Processor.enum_cpuinfo end processor_list.each_with_index do |desc, i| Facter.add("Processor#{i}") do confine :kernel => [ :aix, :"hp-ux", :sunos, :linux, :"gnu/kfreebsd" ] setcode do desc end end end Facter.add("ProcessorCount") do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do processor_list = Facter::Util::Processor.enum_cpuinfo ## If this returned nothing, then don't resolve the fact if processor_list.length != 0 processor_list.length.to_s end end end Facter.add("ProcessorCount") do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do ## The method above is preferable since it provides the description of the CPU as well ## but if that returned 0, then we enumerate sysfs sysfs_cpu_directory = '/sys/devices/system/cpu' if File.exists?(sysfs_cpu_directory) lookup_pattern = "#{sysfs_cpu_directory}" + "/cpu[0-9]*" cpuCount = Dir.glob(lookup_pattern).length cpuCount.to_s end end end Facter.add("ProcessorCount") do confine :kernel => :aix setcode do processor_list = Facter::Util::Processor.aix_processor_list processor_list.length.to_s end end Facter.add("ProcessorCount") do confine :kernel => :"hp-ux" setcode do processor_list = Facter::Util::Processor.hpux_processor_list processor_list.length.to_s end end Facter.add("Processor") do confine :kernel => :openbsd setcode do Facter::Util::Resolution.exec("uname -p") end end Facter.add("ProcessorCount") do confine :kernel => :openbsd setcode do Facter::Util::Resolution.exec("sysctl -n hw.ncpu") end end Facter.add("ProcessorCount") do confine :kernel => :Darwin setcode do Facter::Util::Resolution.exec("sysctl -n hw.ncpu") end end if Facter.value(:kernel) == "windows" processor_list = [] Thread::exclusive do require 'facter/util/wmi' # get each physical processor Facter::Util::WMI.execquery("select * from Win32_Processor").each do |proc| # not supported before 2008 if proc.respond_to?(:NumberOfLogicalProcessors) processor_num = proc.NumberOfLogicalProcessors else processor_num = 1 end processor_num.times do |i| processor_list << proc.Name.squeeze(" ") end end end processor_list.each_with_index do |name, i| Facter.add("Processor#{i}") do confine :kernel => :windows setcode do name end end end Facter.add("ProcessorCount") do confine :kernel => :windows setcode do processor_list.length.to_s end end end Facter.add("Processor") do confine :kernel => [:dragonfly,:freebsd] setcode do Facter::Util::Resolution.exec("sysctl -n hw.model") end end Facter.add("ProcessorCount") do confine :kernel => [:dragonfly,:freebsd] setcode do Facter::Util::Resolution.exec("sysctl -n hw.ncpu") end end Facter.add("ProcessorCount") do confine :kernel => :sunos setcode do kernelrelease = Facter.value(:kernelrelease) (major_version, minor_version) = kernelrelease.split(".").map { |str| str.to_i } result = nil if (major_version > 5) or (major_version == 5 and minor_version >= 8) then if kstat = Facter::Util::Resolution.exec("/usr/bin/kstat cpu_info") result = kstat.scan(/\bcore_id\b\s+\d+/).uniq.length end else if output = Facter::Util::Resolution.exec("/usr/sbin/psrinfo") then result = output.split("\n").length end end result end end facter-1.7.5/lib/facter/ec2.rb0000644005276200011600000000166712276213016015702 0ustar jenkinsjenkinsrequire 'facter/util/ec2' require 'open-uri' def metadata(id = "") open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read. split("\n").each do |o| key = "#{id}#{o.gsub(/\=.*$/, '/')}" if key[-1..-1] != '/' value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read. split("\n") symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym Facter.add(symbol) { setcode { value.join(',') } } else metadata(key) end end rescue => details Facter.warn "Could not retrieve ec2 metadata: #{details.message}" end def userdata() Facter.add(:ec2_userdata) do setcode do if userdata = Facter::Util::EC2.userdata userdata.split end end end end if (Facter::Util::EC2.has_euca_mac? || Facter::Util::EC2.has_openstack_mac? || Facter::Util::EC2.has_ec2_arp?) && Facter::Util::EC2.can_connect? metadata userdata else Facter.debug "Not an EC2 host" end facter-1.7.5/lib/facter/lsbdistid.rb0000644005276200011600000000100412276213016017173 0ustar jenkinsjenkins# Fact: lsbdistid # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsb_release system command # # Caveats: # Only works on Linux (and the kfreebsd derivative) systems. # Requires the lsb_release program, which may not be installed by default. # Also is as only as accurate as that program outputs. Facter.add(:lsbdistid) do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do Facter::Util::Resolution.exec('lsb_release -i -s 2>/dev/null') end end facter-1.7.5/lib/facter/uptime_seconds.rb0000644005276200011600000000107112276213016020237 0ustar jenkinsjenkins# Fact: uptime_seconds # # Purpose: Return purely number of seconds of uptime. # # Resolution: # Using the 'facter/util/uptime.rb' module, try a verity of methods to acquire # the uptime on Unix. # # On Windows, the module calculates the uptime by the "LastBootupTime" Windows # management value. # # Caveats: # require 'facter/util/uptime' Facter.add(:uptime_seconds) do setcode { Facter::Util::Uptime.get_uptime_seconds_unix } end Facter.add(:uptime_seconds) do confine :kernel => :windows setcode { Facter::Util::Uptime.get_uptime_seconds_win } end facter-1.7.5/lib/facter/ldom.rb0000644005276200011600000000256412276213016016161 0ustar jenkinsjenkinsif Facter.value(:kernel) == 'SunOS' virtinfo = Facter::Util::Resolution.exec('virtinfo -ap') # Convert virtinfo parseable output format to array of arrays. # DOMAINROLE|impl=LDoms|control=true|io=true|service=true|root=true # DOMAINNAME|name=primary # DOMAINUUID|uuid=8e0d6ec5-cd55-e57f-ae9f-b4cc050999a4 # DOMAINCONTROL|name=san-t2k-6 # DOMAINCHASSIS|serialno=0704RB0280 # # For keys containing multiple value such as domain role: # ldom_{key}_{subkey} = value # Otherwise the fact will simply be: # ldom_{key} = value unless virtinfo.nil? virt_array = virtinfo.split("\n").select{|l| l =~ /^DOMAIN/ }. collect{|l| l.split('|')} virt_array.each do |x| key = x[0] value = x[1..x.size] if value.size == 1 Facter.add("ldom_#{key.downcase}") do setcode { value.first.split('=')[1] } end else value.each do |y| k = y.split('=')[0] v = y.split('=')[1] Facter.add("ldom_#{key.downcase}_#{k.downcase}") do setcode { v } end end end end # When ldom domainrole control = false, the system is a guest, so we mark it # as a virtual system: Facter.add("virtual") do confine :ldom_domainrole_control => 'false' has_weight 10 setcode do Facter.value(:ldom_domainrole_impl) end end end end facter-1.7.5/lib/facter/architecture.rb0000644005276200011600000000212112276213016017675 0ustar jenkinsjenkins# Fact: architecture # # Purpose: # Return the CPU hardware architecture. # # Resolution: # On non-AIX IBM, OpenBSD, Linux and Debian's kfreebsd, use the hardwaremodel fact. # On AIX get the arch value from lsattr -El proc0 -a type # Gentoo and Debian call "x86_86" "amd64". # Gentoo also calls "i386" "x86". # # Caveats: # require 'facter/util/architecture' Facter.add(:architecture) do setcode do model = Facter.value(:hardwaremodel) case model # most linuxen use "x86_64" when /IBM*/ case Facter.value(:operatingsystem) when "AIX" arch = Facter::Util::Architecture.lsattr if (match = arch.match /type\s(\S+)\s/) match[1] end else model end when "x86_64" case Facter.value(:operatingsystem) when "Debian", "Gentoo", "GNU/kFreeBSD", "Ubuntu" "amd64" else model end when /(i[3456]86|pentium)/ case Facter.value(:operatingsystem) when "Gentoo", "windows" "x86" else "i386" end else model end end end facter-1.7.5/lib/facter/kernel.rb0000644005276200011600000000066712276213016016510 0ustar jenkinsjenkins# Fact: kernel # # Purpose: Returns the operating system's name. # # Resolution: # Uses Ruby's rbconfig to find host_os, if that is a Windows derivative, the # returns 'windows', otherwise returns "uname -s" verbatim. # # Caveats: # Facter.add(:kernel) do setcode do require 'facter/util/config' if Facter::Util::Config.is_windows? 'windows' else Facter::Util::Resolution.exec("uname -s") end end end facter-1.7.5/lib/facter/hardwareisa.rb0000644005276200011600000000065412276213016017516 0ustar jenkinsjenkins# Fact: hardwareisa # # Purpose: # Returns hardware processor type. # # Resolution: # On Solaris, AIX, Linux and the BSDs simply uses the output of "uname -p" # On HP-UX, "uname -m" gives us the same information. # # Caveats: # Some linuxes return unknown to uname -p with relative ease. # Facter.add(:hardwareisa) do if Facter.value(:kernel) == 'HP-UX' setcode 'uname -m' else setcode 'uname -p' end end facter-1.7.5/lib/facter/facterversion.rb0000644005276200011600000000036712276213016020077 0ustar jenkinsjenkins# Fact: facterversion # # Purpose: returns the version of the facter module. # # Resolution: Uses the Facter.version method. # # Caveats: # Facter.add(:facterversion) do setcode do require 'facter/version' Facter.version.to_s end end facter-1.7.5/lib/facter/network.rb0000644005276200011600000000067512276213016016720 0ustar jenkinsjenkins# Fact: network # # Purpose: # Get IP, network and netmask information for available network # interfacs. # # Resolution: # Uses 'facter/util/ip' to enumerate interfaces and return their information. # # Caveats: # require 'facter/util/ip' Facter::Util::IP.get_interfaces.each do |interface| Facter.add("network_" + Facter::Util::IP.alphafy(interface)) do setcode do Facter::Util::IP.get_network_value(interface) end end end facter-1.7.5/lib/facter/kernelversion.rb0000644005276200011600000000077312276213016020114 0ustar jenkinsjenkins# Fact: kernelversion # # Purpose: Return the operating system's kernel version. # # Resolution: # On Solaris and SunOS based machines, returns the output of "uname -v". # Otherwise returns the 'kernerlversion' fact up to the first '-'. This may be # the entire 'kernelversion' fact in many cases. # # Caveats: # Facter.add("kernelversion") do setcode do Facter['kernelrelease'].value.split('-')[0] end end Facter.add("kernelversion") do confine :kernel => :sunos setcode 'uname -v' end facter-1.7.5/lib/facter/lsbdistdescription.rb0000644005276200011600000000121012276213016021121 0ustar jenkinsjenkins# Fact: lsbdistdescription # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsb_release system command # # Caveats: # Only works on Linux (and the kfreebsd derivative) systems. # Requires the lsb_release program, which may not be installed by default. # Also is as only as accurate as that program outputs. Facter.add(:lsbdistdescription) do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do if output = Facter::Util::Resolution.exec('lsb_release -d -s 2>/dev/null') # the output may be quoted (at least it is on gentoo) output.sub(/^"(.*)"$/,'\1') end end end facter-1.7.5/lib/facter/xendomains.rb0000644005276200011600000000063212276213016017365 0ustar jenkinsjenkins# Fact: xendomains # # Purpose: Return the list of Xen domains on the Dom0. # # Resolution: # On a Xen Dom0 host, return a list of Xen domains using the 'util/xendomains' # library. # # Caveats: # require 'facter/util/xendomains' Facter.add("xendomains") do confine :kernel => %w{Linux FreeBSD OpenBSD SunOS} confine :virtual => 'xen0' setcode do Facter::Util::Xendomains.get_domains end end facter-1.7.5/lib/facter/kernelmajversion.rb0000644005276200011600000000050512276213016020575 0ustar jenkinsjenkins# Fact: kernelmajversion # # Purpose: Return the operating system's release number's major value. # # Resolution: # Takes the first 2 elements of the kernel version as delimited by periods. # # Caveats: # Facter.add("kernelmajversion") do setcode do Facter.value(:kernelversion).split('.')[0..1].join('.') end end facter-1.7.5/lib/facter/operatingsystemrelease.rb0000644005276200011600000001222512276213016022017 0ustar jenkinsjenkins# Fact: operatingsystemrelease # # Purpose: Returns the release of the operating system. # # Resolution: # On RedHat derivatives, returns their '/etc/-release' file. # On Debian, returns '/etc/debian_version'. # On Ubuntu, parses '/etc/lsb-release' for the release version. # On Suse, derivatives, parses '/etc/SuSE-release' for a selection of version # information. # On Slackware, parses '/etc/slackware-version'. # On Amazon Linux, returns the 'lsbdistrelease' value. # On Mageia, parses '/etc/mageia-release' for the release version. # # On all remaining systems, returns the 'kernelrelease' value. # # Caveats: # require 'facter/util/file_read' Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC Ascendos CloudLinux PSBM} setcode do case Facter.value(:operatingsystem) when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "XenServer" releasefile = "/etc/redhat-release" when "Fedora" releasefile = "/etc/fedora-release" when "MeeGo" releasefile = "/etc/meego-release" when "OracleLinux" releasefile = "/etc/oracle-release" when "OEL", "oel" releasefile = "/etc/enterprise-release" when "OVS", "ovs" releasefile = "/etc/ovs-release" end if release = Facter::Util::FileRead.read(releasefile) line = release.split("\n").first.chomp if match = /\(Rawhide\)$/.match(line) "Rawhide" elsif match = /release (\d[\d.]*)/.match(line) match[1] end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{Debian} setcode do if release = Facter::Util::FileRead.read('/etc/debian_version') release.sub!(/\s*$/, '') release end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{Ubuntu} setcode do if release = Facter::Util::FileRead.read('/etc/lsb-release') if match = release.match(/DISTRIB_RELEASE=((\d+.\d+)(\.(\d+))?)/) # Return only the major and minor version numbers. This behavior must # be preserved for compatibility reasons. match[2] end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{SLES SLED OpenSuSE} setcode do if release = Facter::Util::FileRead.read('/etc/SuSE-release') if match = /^VERSION\s*=\s*(\d+)/.match(release) releasemajor = match[1] if match = /^PATCHLEVEL\s*=\s*(\d+)/.match(release) releaseminor = match[1] elsif match = /^VERSION\s=.*.(\d+)/.match(release) releaseminor = match[1] else releaseminor = "0" end releasemajor + "." + releaseminor else "unknown" end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{OpenWrt} setcode do if release = Facter::Util::FileRead.read('/etc/openwrt_version') if match = /^(\d+\.\d+.*)/.match(release) match[1] end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{Slackware} setcode do if release = Facter::Util::FileRead.read('/etc/slackware-version') if match = /Slackware ([0-9.]+)/.match(release) match[1] end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{Mageia} setcode do if release = Facter::Util::FileRead.read('/etc/mageia-release') if match = /Mageia release ([0-9.]+)/.match(release) match[1] end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{Bluewhite64} setcode do if release = Facter::Util::FileRead.read('/etc/bluewhite64-version') if match = /^\s*\w+\s+(\d+)\.(\d+)/.match(release) match[1] + "." + match[2] else "unknown" end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{VMwareESX} setcode do release = Facter::Util::Resolution.exec('vmware -v') if match = /VMware ESX .*?(\d.*)/.match(release) match[1] end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{Slamd64} setcode do if release = Facter::Util::FileRead.read('/etc/slamd64-version') if match = /^\s*\w+\s+(\d+)\.(\d+)/.match(release) match[1] + "." + match[2] else "unknown" end end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => :Alpine setcode do if release = Facter::Util::FileRead.read('/etc/alpine-release') release.sub!(/\s*$/, '') release end end end Facter.add(:operatingsystemrelease) do confine :operatingsystem => %W{Amazon} setcode do Facter[:lsbdistrelease].value end end Facter.add(:operatingsystemrelease) do confine :osfamily => :solaris setcode do if release = Facter::Util::FileRead.read('/etc/release') line = release.split("\n").first.chomp if match = /\s+s(\d+)[sx]?(_u\d+)?.*(?:SPARC|X86)/.match(line) match.captures.join('') end end end end Facter.add(:operatingsystemrelease) do setcode do Facter[:kernelrelease].value end end facter-1.7.5/lib/facter/uniqueid.rb0000644005276200011600000000014612276213016017043 0ustar jenkinsjenkinsFacter.add(:uniqueid) do setcode 'hostid' confine :kernel => %w{SunOS Linux AIX GNU/kFreeBSD} end facter-1.7.5/lib/facter/ssh.rb0000644005276200011600000000271212276213016016016 0ustar jenkinsjenkins# Fact: ssh # # Purpose: # # Resolution: # # Caveats: # ## ssh.rb ## Facts related to SSH ## {"SSHDSAKey" => { :file => "ssh_host_dsa_key.pub", :sshfprrtype => 2 } , "SSHRSAKey" => { :file => "ssh_host_rsa_key.pub", :sshfprrtype => 1 }, "SSHECDSAKey" => { :file => "ssh_host_ecdsa_key.pub", :sshfprrtype => 3 } }.each do |name,key| Facter.add(name) do setcode do value = nil [ "/etc/ssh", "/usr/local/etc/ssh", "/etc", "/usr/local/etc", "/etc/opt/ssh", ].each do |dir| filepath = File.join(dir,key[:file]) if FileTest.file?(filepath) begin value = File.read(filepath).chomp.split(/\s+/)[1] break rescue value = nil end end end value end end Facter.add('SSHFP_' + name[3..-4]) do setcode do ssh = Facter.fact(name).value value = nil if ssh && key[:sshfprrtype] begin require 'digest/sha1' require 'base64' digest = Base64.decode64(ssh) value = 'SSHFP ' + key[:sshfprrtype].to_s + ' 1 ' + Digest::SHA1.hexdigest(digest) begin require 'digest/sha2' value += "\nSSHFP " + key[:sshfprrtype].to_s + ' 2 ' + Digest::SHA256.hexdigest(digest) rescue end rescue value = nil end end value end end end facter-1.7.5/lib/facter.rb0000644005276200011600000001330312276213016015217 0ustar jenkinsjenkins# Facter - Host Fact Detection and Reporting # # Copyright 2011 Puppet Labs Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'facter/version' module Facter # This is just so the other classes have the constant. module Util; end require 'facter/util/fact' require 'facter/util/collection' require 'facter/util/monkey_patches' include Comparable include Enumerable # = Facter # Functions as a hash of 'facts' you might care about about your # system, such as mac address, IP address, Video card, etc. # returns them dynamically # == Synopsis # # Generally, treat Facter as a hash: # == Example # require 'facter' # puts Facter['operatingsystem'] # GREEN = "" RESET = "" @@debug = 0 @@timing = 0 @@messages = {} @@debug_messages = {} # module methods def self.collection unless defined?(@collection) and @collection @collection = Facter::Util::Collection.new( Facter::Util::Loader.new, Facter::Util::Config.ext_fact_loader) end @collection end # Add some debugging def self.debug(string) if string.nil? return end if self.debugging? puts GREEN + string + RESET end end # Debug once. def self.debugonce(msg) if msg and not msg.empty? and @@debug_messages[msg].nil? @@debug_messages[msg] = true debug(msg) end end def self.debugging? @@debug != 0 end # show the timing information def self.show_time(string) puts "#{GREEN}#{string}#{RESET}" if string and Facter.timing? end def self.timing? @@timing != 0 end # Facter.json? is meant to provide a lightweight way to check if the JSON # "feature" is available. def self.json? begin require 'json' true rescue LoadError false end end # Return a fact object by name. If you use this, you still have to call # 'value' on it to retrieve the actual value. def self.[](name) collection.fact(name) end class << self [:fact, :flush, :list, :value].each do |method| define_method(method) do |*args| collection.send(method, *args) end end [:list, :to_hash].each do |method| define_method(method) do |*args| collection.load_all collection.send(method, *args) end end end # Add a resolution mechanism for a named fact. This does not distinguish # between adding a new fact and adding a new way to resolve a fact. def self.add(name, options = {}, &block) collection.add(name, options, &block) end def self.each # Make sure all facts are loaded. collection.load_all collection.each do |*args| yield(*args) end end class << self # Allow users to call fact names directly on the Facter class, # either retrieving the value or comparing it to an existing value. def method_missing(name, *args) question = false if name.to_s =~ /\?$/ question = true name = name.to_s.sub(/\?$/,'') end if fact = collection.fact(name) if question value = fact.value.downcase args.each do |arg| if arg.to_s.downcase == value return true end end # If we got this far, there was no match. return false else return fact.value end else # Else, fail like a normal missing method. raise NoMethodError, "Could not find fact '%s'" % name end end end # Clear all facts. Mostly used for testing. def self.clear Facter.flush Facter.reset end # Clear all messages. Used only in testing. Can't add to self.clear # because we don't want to warn multiple times for items that are warnonce'd def self.clear_messages @@messages.clear end # Set debugging on or off. def self.debugging(bit) if bit case bit when TrueClass; @@debug = 1 when FalseClass; @@debug = 0 when Fixnum if bit > 0 @@debug = 1 else @@debug = 0 end when String; if bit.downcase == 'off' @@debug = 0 else @@debug = 1 end else @@debug = 0 end else @@debug = 0 end end # Set timing on or off. def self.timing(bit) if bit case bit when TrueClass; @@timing = 1 when Fixnum if bit > 0 @@timing = 1 else @@timing = 0 end end else @@timing = 0 end end def self.warn(msg) if Facter.debugging? and msg and not msg.empty? msg = [msg] unless msg.respond_to? :each msg.each { |line| Kernel.warn line } end end # Warn once. def self.warnonce(msg) if msg and not msg.empty? and @@messages[msg].nil? @@messages[msg] = true Kernel.warn(msg) end end # Remove them all. def self.reset @collection = nil end # Load all of the default facts, and then everything from disk. def self.loadfacts collection.load_all end @search_path = [] # Register a directory to search through. def self.search(*dirs) @search_path += dirs end # Return our registered search directories. def self.search_path @search_path.dup end end facter-1.7.5/libexec/0000755005276200011600000000000012276213023014271 5ustar jenkinsjenkinsfacter-1.7.5/libexec/ext/0000755005276200011600000000000012276213023015071 5ustar jenkinsjenkinsfacter-1.7.5/libexec/ext/README0000644005276200011600000000022612276213016015753 0ustar jenkinsjenkinsThis directory is for external facts. For more information see the documentation available here: http://docs.puppetlabs.com/guides/custom_facts.html facter-1.7.5/Rakefile0000644005276200011600000000402012276213016014321 0ustar jenkinsjenkins# Rakefile for facter # We need access to the Puppet.version method $LOAD_PATH.unshift(File.expand_path("lib")) require 'facter/version' $LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks') require 'rake' begin load File.join(File.dirname(__FILE__), 'ext', 'packaging', 'packaging.rake') rescue LoadError end ['rubygems', 'rspec', 'rspec/core/rake_task', 'rcov',].each do |lib| begin require lib rescue LoadError end end Dir['tasks/**/*.rake'].each { |t| load t } build_defs_file = 'ext/build_defaults.yaml' if File.exist?(build_defs_file) begin require 'yaml' @build_defaults ||= YAML.load_file(build_defs_file) rescue Exception => e STDERR.puts "Unable to load yaml from #{build_defs_file}:" STDERR.puts e end @packaging_url = @build_defaults['packaging_url'] @packaging_repo = @build_defaults['packaging_repo'] raise "Could not find packaging url in #{build_defs_file}" if @packaging_url.nil? raise "Could not find packaging repo in #{build_defs_file}" if @packaging_repo.nil? namespace :package do desc "Bootstrap packaging automation, e.g. clone into packaging repo" task :bootstrap do if File.exist?("ext/#{@packaging_repo}") puts "It looks like you already have ext/#{@packaging_repo}. If you don't like it, blow it away with package:implode." else cd 'ext' do %x{git clone #{@packaging_url}} end end end desc "Remove all cloned packaging automation" task :implode do rm_rf "ext/#{@packaging_repo}" end end end task :default do sh %{rake -T} end if defined?(RSpec::Core::RakeTask) desc "Run all specs" RSpec::Core::RakeTask.new do |t| t.pattern ='spec/{unit,integration}/**/*_spec.rb' t.fail_on_error = true end RSpec::Core::RakeTask.new('spec:rcov') do |t| t.pattern ='spec/{unit,integration}/**/*_spec.rb' t.fail_on_error = true if defined?(Rcov) t.rcov = true t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*'] end end end facter-1.7.5/documentation/0000755005276200011600000000000012276213023015527 5ustar jenkinsjenkinsfacter-1.7.5/documentation/index.page0000644005276200011600000000120212276213016017471 0ustar jenkinsjenkins--- inMenu: false directoryName: Facter --- A cross-platform Ruby library for retrieving facts from operating systems. Supports multiple resolution mechanisms, any of which can be restricted to working only on certain operating systems or environments. Facter is especially useful for retrieving things like operating system names, IP addresses, MAC addresses, and SSH keys. It is easy to extend Facter to include your own [custom facts](custom.html) or to include additional mechanisms for retrieving facts. * [Downloads](/downloads/facter/) * [Bug Tracking](/cgi-bin/facter.cgi) * [API Documentation](/downloads/facter/apidocs/) *$Id$* facter-1.7.5/documentation/custom.page0000644005276200011600000000131512276213016017701 0ustar jenkinsjenkins--- inMenu: true directoryName: Custom Facts --- Facter does everything it can to make adding custom facts easy. It will autoload any files it finds in a ``facter/`` directory in its search path, so you don't need to modify the package files. Also, Facter will search through your environment for any variables whose names start with 'FACTER_' (case insensitive) and automatically add those facts. As a simple example, here is how I publish my home directory to Puppet: Facter.add("home") do setcode do ENV['HOME'] end end I have ~/lib/ruby in my $RUBYLIB environment variable, so I just created ~/lib/ruby/facter and dropped the above code into a ``home.rb`` file within that directory. facter-1.7.5/install.rb0000755005276200011600000002730212276213016014662 0ustar jenkinsjenkins#! /usr/bin/env ruby #-- # Copyright 2004 Austin Ziegler # Install utility. Based on the original installation script for rdoc by the # Pragmatic Programmers. # # This program is free software. It may be redistributed and/or modified under # the terms of the GPL version 2 (or later) or the Ruby licence. # # Usage # ----- # In most cases, if you have a typical project layout, you will need to do # absolutely nothing to make this work for you. This layout is: # # bin/ # executable files -- "commands" # lib/ # the source of the library # # The default behaviour: # 1) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd), # all .rb files in lib/, ./README, ./ChangeLog, and ./Install. # 2) Build ri documentation from all files in bin/ (excluding .bat and .cmd), # and all .rb files in lib/. This is disabled by default on Win32. # 3) Install commands from bin/ into the Ruby bin directory. On Windows, if a # if a corresponding batch file (.bat or .cmd) exists in the bin directory, # it will be copied over as well. Otherwise, a batch file (always .bat) will # be created to run the specified command. # 4) Install all library files ending in .rb from lib/ into Ruby's # site_lib/version directory. # #++ require 'rbconfig' require 'find' require 'fileutils' require 'optparse' require 'ostruct' require 'tempfile' begin require 'rdoc/rdoc' $haverdoc = true rescue LoadError puts "Missing rdoc; skipping documentation" $haverdoc = false end begin if $haverdoc rst2man = %x{which rst2man.py} $haveman = true else $haveman = false end rescue puts "Missing rst2man; skipping man page creation" $haveman = false end $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib'))) require 'facter' @operatingsystem = Facter[:operatingsystem].value PREREQS = %w{cgi} InstallOptions = OpenStruct.new def glob(list) g = list.map { |i| Dir.glob(i) } g.flatten! g.compact! g end def do_bins(bins, target, strip = 's?bin/') bins.each do |bf| obf = bf.gsub(/#{strip}/, '') install_binfile(bf, obf, target) end end def do_libs(libs, strip = 'lib/') libs.each do |lf| olf = File.join(InstallOptions.site_dir, lf.gsub(/^#{strip}/, '')) op = File.dirname(olf) FileUtils.makedirs(op, {:mode => 0755, :verbose => true}) FileUtils.chmod(0755, op) FileUtils.install(lf, olf, {:mode => 0644, :preserve => true, :verbose => true}) end end def do_man(man, strip = 'man/') if (InstallOptions.man == true) man.each do |mf| omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) om = File.dirname(omf) FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) FileUtils.chmod(0755, om) FileUtils.install(mf, omf, {:mode => 0644, :preserve => true, :verbose => true}) gzip = %x{which gzip} gzip.chomp! %x{#{gzip} -f #{omf}} end else puts "Skipping Man Page Generation" end end # Verify that all of the prereqs are installed def check_prereqs PREREQS.each { |pre| begin require pre rescue LoadError puts "Could not load #{pre} Ruby library; cannot install" exit -1 end } end def is_windows? @operatingsystem == 'windows' end ## # Prepare the file installation. # def prepare_installation # Only try to do docs if we're sure they have rdoc if $haverdoc InstallOptions.rdoc = true if is_windows? InstallOptions.ri = false else InstallOptions.ri = true end else InstallOptions.rdoc = false InstallOptions.ri = false end if $haveman InstallOptions.man = true if is_windows? InstallOptions.man = false end else InstallOptions.man = false end ARGV.options do |opts| opts.banner = "Usage: #{File.basename($0)} [options]" opts.separator "" opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc| InstallOptions.rdoc = onrdoc end opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri| InstallOptions.ri = onri end opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman| InstallOptions.man = onman end opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default off.') do |ontest| InstallOptions.tests = ontest warn "The tests flag has never worked in Facter, is deprecated as of Nov 29, 2012, and will be removed in a future release of Facter." end opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| InstallOptions.destdir = destdir end opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir| InstallOptions.bindir = bindir end opts.on('--ruby[=OPTIONAL]', 'Ruby interpreter to use with installation', 'overrides ruby used to call install.rb') do |ruby| InstallOptions.ruby = ruby end opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides RbConfig::CONFIG["sitelibdir"]') do |sitelibdir| InstallOptions.sitelibdir = sitelibdir end opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides RbConfig::CONFIG["mandir"]') do |mandir| InstallOptions.mandir = mandir end opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| InstallOptions.rdoc = false InstallOptions.ri = false end opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| InstallOptions.rdoc = true InstallOptions.ri = true end opts.separator("") opts.on_tail('--help', "Shows this help text.") do $stderr.puts opts exit end opts.parse! end version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".") libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version) # Mac OS X 10.5 and higher declare bindir # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin # which is not generally where people expect executables to be installed # These settings are appropriate defaults for all OS X versions. if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ RbConfig::CONFIG['bindir'] = "/usr/bin" end if not InstallOptions.bindir.nil? bindir = InstallOptions.bindir else bindir = RbConfig::CONFIG['bindir'] end if not InstallOptions.sitelibdir.nil? sitelibdir = InstallOptions.sitelibdir else sitelibdir = RbConfig::CONFIG["sitelibdir"] if sitelibdir.nil? sitelibdir = $:.find { |x| x =~ /site_ruby/ } if sitelibdir.nil? sitelibdir = File.join(libdir, "site_ruby") elsif sitelibdir !~ Regexp.quote(version) sitelibdir = File.join(sitelibdir, version) end end end if not InstallOptions.mandir.nil? mandir = InstallOptions.mandir else mandir = RbConfig::CONFIG['mandir'] end # To be deprecated once people move over to using --destdir option if (destdir = ENV['DESTDIR']) warn "DESTDIR is deprecated. Use --destdir instead." bindir = join(destdir, bindir) mandir = join(destdir, mandir) sitelibdir = join(destdir, sitelibdir) FileUtils.makedirs(bindir) FileUtils.makedirs(mandir) FileUtils.makedirs(sitelibdir) # This is the new way forward elsif (destdir = InstallOptions.destdir) bindir = join(destdir, bindir) mandir = join(destdir, mandir) sitelibdir = join(destdir, sitelibdir) FileUtils.makedirs(bindir) FileUtils.makedirs(mandir) FileUtils.makedirs(sitelibdir) end InstallOptions.site_dir = sitelibdir InstallOptions.bin_dir = bindir InstallOptions.lib_dir = libdir InstallOptions.man_dir = mandir end ## # Join two paths. On Windows, dir must be converted to a relative path, # by stripping the drive letter, but only if the basedir is not empty. # def join(basedir, dir) return "#{basedir}#{dir[2..-1]}" if is_windows? and basedir.length > 0 and dir.length > 2 "#{basedir}#{dir}" end ## # Build the rdoc documentation. Also, try to build the RI documentation. # def build_rdoc(files) return unless $haverdoc begin r = RDoc::RDoc.new r.document(["--main", "README", "--title", "Puppet -- Site Configuration Management", "--line-numbers"] + files) rescue RDoc::RDocError => e $stderr.puts e.message rescue Exception => e $stderr.puts "Couldn't build RDoc documentation\n#{e.message}" end end def build_ri(files) return unless $haverdoc begin ri = RDoc::RDoc.new #ri.document(["--ri-site", "--merge"] + files) ri.document(["--ri-site"] + files) rescue RDoc::RDocError => e $stderr.puts e.message rescue Exception => e $stderr.puts "Couldn't build Ri documentation\n#{e.message}" $stderr.puts "Continuing with install..." end end def build_man(bins) return unless $haveman begin # Locate rst2man rst2man = %x{which rst2man.py} rst2man.chomp! bins.each do |bin| b = bin.gsub( "bin/", "") %x{#{bin} --help > ./#{b}.rst} %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8} File.unlink("./#{b}.rst") end rescue SystemCallError $stderr.puts "Couldn't build man pages: " + $! $stderr.puts "Continuing with install..." end end ## # Install file(s) from ./bin to RbConfig::CONFIG['bindir']. Patch it on the way # to insert a #! line; on a Unix install, the command is named as expected # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under # windows, we add an '.rb' extension and let file associations do their stuff. def install_binfile(from, op_file, target) tmp_file = Tempfile.new('facter-binfile') if not InstallOptions.ruby.nil? ruby = InstallOptions.ruby else ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) end File.open(from) do |ip| File.open(tmp_file.path, "w") do |op| op.puts "#!#{ruby}" contents = ip.readlines contents.shift if contents[0] =~ /^#!/ op.write contents.join end end if is_windows? installed_wrapper = false if File.exists?("#{from}.bat") FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true) installed_wrapper = true end if File.exists?("#{from}.cmd") FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :preserve => true, :verbose => true) installed_wrapper = true end if not installed_wrapper tmp_file2 = Tempfile.new('facter-wrapper') cwv = <<-EOS @echo off setlocal set RUBY_BIN=%~dp0 set RUBY_BIN=%RUBY_BIN:\\=/% "%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%facter" %* EOS File.open(tmp_file2.path, "w") { |cw| cw.puts cwv } FileUtils.install(tmp_file2.path, File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true) tmp_file2.unlink installed_wrapper = true end end FileUtils.install(tmp_file.path, File.join(target, op_file), :mode => 0755, :preserve => true, :verbose => true) tmp_file.unlink end # Change directory into the facter root so we don't get the wrong files for install. FileUtils.cd File.dirname(__FILE__) do # Set these values to what you want installed. bins = glob(%w{bin/*}) rdoc = glob(%w{bin/* lib/**/*.rb README* }).reject { |e| e=~ /\.(bat|cmd)$/ } ri = glob(%w(bin/*.rb lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ } man = glob(%w{man/man8/*}) libs = glob(%w{lib/**/*.rb lib/**/*.py lib/**/LICENSE}) check_prereqs prepare_installation #build_rdoc(rdoc) if InstallOptions.rdoc #build_ri(ri) if InstallOptions.ri #build_man(bins) if InstallOptions.man do_bins(bins, InstallOptions.bin_dir) do_libs(libs) do_man(man) end facter-1.7.5/README.md0000644005276200011600000000161212276213016014137 0ustar jenkinsjenkinsFacter ====== This package is largely meant to be a library for collecting facts about your system. These facts are mostly strings (i.e., not numbers), and are things like the output of `uname`, public ssh and cfengine keys, the number of processors, etc. See `bin/facter` for an example of the interface. Running Facter -------------- Run the `facter` binary on the command for a full list of facts supported on your host. Adding your own facts --------------------- See the [Adding Facts](http://docs.puppetlabs.com/guides/custom_facts.html) page for details of how to add your own custom facts to Facter. Running Specs ------------- * bundle install --path .bundle/gems * bundle exec rake spec Note: external facts in the system facts.d directory can cause spec failures. Further Information ------------------- See http://www.puppetlabs.com/puppet/related-projects/facter for more details. facter-1.7.5/man/0000755005276200011600000000000012276213023013431 5ustar jenkinsjenkinsfacter-1.7.5/man/man8/0000755005276200011600000000000012276213023014274 5ustar jenkinsjenkinsfacter-1.7.5/man/man8/facter.80000644005276200011600000000230612276213016015634 0ustar jenkinsjenkins.TH "FACTER" "8" "September 2012" "Puppet Labs, Inc" "Facter manual" .SH NAME Facter - Collect and display facts about the system. . .SH SYNOPSIS .sp Collect and display facts about the system. .SH USAGE .INDENT 0.0 .INDENT 3.5 facter [\-d|\-\-debug] [\-h|\-\-help] [\-p|\-\-puppet] [\-v|\-\-version] [\-y|\-\-yaml] [\-j|\-\-json] [fact] [fact] [...] .UNINDENT .UNINDENT .SH DESCRIPTION .sp Collect and display facts about the current system. The library behind Facter is easy to expand, making Facter an easy way to collect information about a system from within the shell or within Ruby. .sp If no facts are specifically asked for, then all facts will be returned. .SH OPTIONS .sp yaml: Emit facts in YAML format. .sp json: Emit facts in JSON format. .sp puppet: Load the Puppet libraries, thus allowing Facter to load Puppet specific (custom) facts .sp version: Print the version and exit. .sp help: Print this help message. .sp debug: Enable debugging. .sp trace: Enable backtraces. .sp timing: Enable timing. .SH EXAMPLE .INDENT 0.0 .INDENT 3.5 facter kernel .UNINDENT .UNINDENT .SH AUTHOR .sp Luke Kanies .SH COPYRIGHT .sp Copyright (c) 2012 Puppet Labs, Inc Licensed under the Apache 2.0 license . facter-1.7.5/etc/0000755005276200011600000000000012276213023013431 5ustar jenkinsjenkinsfacter-1.7.5/etc/facter.conf0000644005276200011600000000010012276213016015535 0ustar jenkinsjenkinsHostname OperatingSystem OperatingSystemRelease SSHDSAKey CfKey facter-1.7.5/acceptance/0000755005276200011600000000000012276213023014744 5ustar jenkinsjenkinsfacter-1.7.5/acceptance/setup/0000755005276200011600000000000012276213023016104 5ustar jenkinsjenkinsfacter-1.7.5/acceptance/setup/01_TestSetup.rb0000755005276200011600000000177412276213016020707 0ustar jenkinsjenkinstest_name "Install packages and repositories on target machines..." do extend Beaker::DSL::InstallUtils SourcePath = Beaker::DSL::InstallUtils::SourcePath GitURI = Beaker::DSL::InstallUtils::GitURI GitHubSig = Beaker::DSL::InstallUtils::GitHubSig tmp_repositories = [] options[:install].each do |uri| raise(ArgumentError, "#{uri} is not recognized.") unless(uri =~ GitURI) tmp_repositories << extract_repo_info_from(uri) end repositories = order_packages(tmp_repositories) versions = {} hosts.each_with_index do |host, index| on host, "echo #{GitHubSig} >> $HOME/.ssh/known_hosts" repositories.each do |repository| step "Install #{repository[:name]}" install_from_git host, SourcePath, repository if index == 1 versions[repository[:name]] = find_git_repo_versions(host, SourcePath, repository) end end end end facter-1.7.5/acceptance/setup/00_EnvSetup.rb0000644005276200011600000000176412276213016020513 0ustar jenkinsjenkinstest_name "Setup environment" step "Ensure Git and Ruby" require 'puppet/acceptance/install_utils' extend Puppet::Acceptance::InstallUtils require 'beaker/dsl/install_utils' extend Beaker::DSL::InstallUtils PACKAGES = { :redhat => [ 'git', 'ruby', ], :debian => [ ['git', 'git-core'], 'ruby', ], :solaris => [ ['git', 'developer/versioning/git'], ['ruby', 'runtime/ruby-18'], ], :windows => [ 'git', ], } install_packages_on(hosts, PACKAGES, :check_if_exists => true) hosts.each do |host| if host['platform'] =~ /windows/ step "#{host} Install ruby from git" install_from_git(host, "/opt/puppet-git-repos", :name => 'puppet-win32-ruby', :path => 'git://github.com/puppetlabs/puppet-win32-ruby') on host, 'cd /opt/puppet-git-repos/puppet-win32-ruby; cp -r ruby/* /' on host, 'cd /lib; icacls ruby /grant "Everyone:(OI)(CI)(RX)"' on host, 'cd /lib; icacls ruby /reset /T' on host, 'ruby --version' on host, 'cmd /c gem list' end end facter-1.7.5/acceptance/lib/0000755005276200011600000000000012276213023015512 5ustar jenkinsjenkinsfacter-1.7.5/acceptance/lib/puppet/0000755005276200011600000000000012276213023017027 5ustar jenkinsjenkinsfacter-1.7.5/acceptance/lib/puppet/acceptance/0000755005276200011600000000000012276213023021115 5ustar jenkinsjenkinsfacter-1.7.5/acceptance/lib/puppet/acceptance/install_utils.rb0000644005276200011600000000410312276213016024330 0ustar jenkinsjenkinsrequire 'open-uri' module Puppet module Acceptance module InstallUtils PLATFORM_PATTERNS = { :redhat => /fedora|el|centos/, :debian => /debian|ubuntu/, :solaris => /solaris/, :windows => /windows/, }.freeze # Installs packages on the hosts. # # @param hosts [Array] Array of hosts to install packages to. # @param package_hash [Hash{Symbol=>Array>}] # Keys should be a symbol for a platform in PLATFORM_PATTERNS. Values # should be an array of package names to install, or of two element # arrays where a[0] is the command we expect to find on the platform # and a[1] is the package name (when they are different). # @param options [Hash{Symbol=>Boolean}] # @option options [Boolean] :check_if_exists First check to see if # command is present before installing package. (Default false) # @return true def install_packages_on(hosts, package_hash, options = {}) check_if_exists = options[:check_if_exists] hosts = [hosts] unless hosts.kind_of?(Array) hosts.each do |host| package_hash.each do |platform_key,package_list| if pattern = PLATFORM_PATTERNS[platform_key] if pattern.match(host['platform']) package_list.each do |cmd_pkg| if cmd_pkg.kind_of?(Array) command, package = cmd_pkg else command = package = cmd_pkg end if !check_if_exists || !host.check_for_package(command) host.logger.notify("Installing #{package}") additional_switches = '--allow-unauthenticated' if platform_key == :debian host.install_package(package, additional_switches) end end end else raise("Unknown platform '#{platform_key}' in package_hash") end end end return true end end end end facter-1.7.5/acceptance/config/0000755005276200011600000000000012276213023016211 5ustar jenkinsjenkinsfacter-1.7.5/acceptance/config/ubuntu-1004.cfg0000644005276200011600000000102512276213016020576 0ustar jenkinsjenkinsHOSTS: ubuntu-1004-64-1: roles: - master - database - agent platform: ubuntu-10.04-amd64 template: ubuntu-1004-x86_64 hypervisor: vcloud ubuntu-1004-32-1: roles: - agent platform: ubuntu-10.04-i386 template: ubuntu-1004-i386 hypervisor: vcloud CONFIG: nfs_server: none consoleport: 443 datastore: instance0 folder: Delivery/Quality Assurance/FOSS/Dynamic resourcepool: delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vcloud.delivery.puppetlabs.net/ facter-1.7.5/acceptance/config/fedora-18.cfg0000644005276200011600000000101412276213016020356 0ustar jenkinsjenkinsHOSTS: fedora-18-64-1: roles: - master - database - agent platform: fedora-18-x86_64 template: fedora-18-x86_64 hypervisor: vcloud fedora-18-64-2: roles: - agent platform: fedora-18-x86_64 template: fedora-18-x86_64 hypervisor: vcloud CONFIG: nfs_server: none consoleport: 443 datastore: instance0 folder: Delivery/Quality Assurance/FOSS/Dynamic resourcepool: delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vcloud.delivery.puppetlabs.net/ facter-1.7.5/acceptance/config/solaris-11.cfg0000644005276200011600000000103612276213016020567 0ustar jenkinsjenkinsHOSTS: centos-6-x86_64: roles: - master - database - agent - dashboard platform: el-6-x86_64 hypervisor: vcloud template: centos-6-x86_64 solaris-11-x86_64: roles: - agent platform: solaris-11-x86_64 hypervisor: vcloud template: solaris-11-x86_64 CONFIG: nfs_server: NONE consoleport: 443 datastore: instance0 folder: Delivery/Quality Assurance/FOSS/Dynamic resourcepool: delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vcloud.delivery.puppetlabs.net/ facter-1.7.5/acceptance/config/windows-2003.cfg0000644005276200011600000000102112276213016020742 0ustar jenkinsjenkinsHOSTS: centos-6-x86_64: roles: - master - database - agent - dashboard platform: el-6-x86_64 hypervisor: vcloud template: centos-6-x86_64 win2003-32: roles: - agent platform: windows-2003-32 hypervisor: vcloud template: win-2003-i386 CONFIG: nfs_server: NONE consoleport: 443 datastore: instance0 folder: Delivery/Quality Assurance/FOSS/Dynamic resourcepool: delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vcloud.delivery.puppetlabs.net/ facter-1.7.5/acceptance/config/redhat-6.cfg0000644005276200011600000000100412276213016020301 0ustar jenkinsjenkinsHOSTS: rhel-6-latest-64-1: roles: - master - database - agent platform: el-6-x86_64 template: redhat-6-x86_64 hypervisor: vcloud rhel-6-latest-32-1: roles: - agent platform: el-6-i386 template: redhat-6-i386 hypervisor: vcloud CONFIG: nfs_server: none consoleport: 443 datastore: instance0 folder: Delivery/Quality Assurance/FOSS/Dynamic resourcepool: delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vcloud.delivery.puppetlabs.net/ facter-1.7.5/acceptance/config/centos-5.cfg0000644005276200011600000000077512276213016020342 0ustar jenkinsjenkinsHOSTS: centos-55-64-1: roles: - master - database - agent platform: el-5-x86_64 template: centos-5-x86_64 hypervisor: vcloud centos-55-386-1: roles: - agent platform: el-5-i386 template: centos-5-i386 hypervisor: vcloud CONFIG: nfs_server: none consoleport: 443 datastore: instance0 folder: Delivery/Quality Assurance/FOSS/Dynamic resourcepool: delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vcloud.delivery.puppetlabs.net/ facter-1.7.5/acceptance/Gemfile0000644005276200011600000000024612276213016016243 0ustar jenkinsjenkinssource ENV['GEM_SOURCE'] || "https://rubygems.org" gem "beaker", "~> 1.3.1" if File.exists? "#{__FILE__}.local" eval(File.read("#{__FILE__}.local"), binding) end facter-1.7.5/acceptance/tests/0000755005276200011600000000000012276213023016106 5ustar jenkinsjenkinsfacter-1.7.5/acceptance/tests/runs_external_facts_once.rb0000644005276200011600000000266612276213016023524 0ustar jenkinsjenkinstest_name "#22944: Facter executes external executable facts many times" unix_content = <&2 echo "test=value" EOM win_content = <&2 echo "test=value" EOM agents.each do |agent| step "Agent #{agent}: create external executable fact" # assume we're running as root if agent['platform'] =~ /windows/ if on(agent, facter('kernelmajversion')).stdout.chomp.to_f < 6.0 factsd = 'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d' else factsd = 'C:/ProgramData/PuppetLabs/facter/facts.d' end ext = '.bat' content = win_content else factsd = '/etc/facter/facts.d' ext = '.sh' content = unix_content end step "Agent #{agent}: create facts.d directory" on(agent, "mkdir -p '#{factsd}'") step "Agent #{agent}: create external fact" ext_fact = "#{factsd}/external_fact#{ext}" teardown do on(agent, "rm -f '#{ext_fact}'") end create_remote_file(agent, ext_fact, content) step "Agent #{agent}: make it executable" on(agent, "chmod +x '#{ext_fact}'") step "Agent #{agent}: ensure it only executes once" on(agent, facter) do lines = stderr.split('\n') times = lines.count { |line| line =~ /SCRIPT CALLED/ } if times == 1 step "External executable fact executed once" else fail_test "External fact executed #{times} times, expected once: #{stderr}" end end end facter-1.7.5/acceptance/tests/ticket_7039_facter_multiple_facts_one_file.rb0000644005276200011600000000165112276213016026664 0ustar jenkinsjenkinstest_name "#7039: Facter having issue handling multiple facts in a single file" fact_file= %q{ Facter.add(:test_fact1) do setcode do "test fact 1" end end Facter.add(:test_fact2) do setcode do "test fact 2" end end } agents.each do |agent| step "Agent: Create fact file with multiple facts" dir = agent.tmpdir('facter7039') create_remote_file(agent, "#{dir}/test_facts.rb", fact_file) env = { 'FACTERLIB' => dir } step "Agent: Verify test_fact1 from #{dir}/test_facts.rb" on(agent, facter('--puppet', 'test_fact1', :environment => env)) do fail_test "Fact 1 not returned by facter --puppet test_fact1" unless stdout.include? 'test fact 1' end step "Agent: Verify test_fact2 from #{dir}/test_facts.rb" on(agent, facter('--puppet', 'test_fact2', :environment => env)) do fail_test "Fact 1 not returned by facter --puppet test_fact2" unless stdout.include? 'test fact 2' end end facter-1.7.5/acceptance/tests/operatingsystem_detection_after_clear_on_ubuntu.rb0000644005276200011600000000073412276213016030361 0ustar jenkinsjenkinstest_name "#7670: Facter should properly detect operatingsystem on Ubuntu after a clear" script_contents = <<-OS_DETECT require 'facter' Facter['operatingsystem'].value Facter.clear exit Facter['operatingsystem'].value == 'Ubuntu' OS_DETECT script_name = "/tmp/facter_os_detection_test_#{$$}" agents.each do |agent| next unless agent['platform'].include? 'ubuntu' create_remote_file(agent, script_name, script_contents) on(agent, "ruby #{script_name}") end facter-1.7.5/acceptance/tests/no_errors_on_stderr.rb0000644005276200011600000000040712276213016022525 0ustar jenkinsjenkinstest_name "Running facter should not output anything to stderr" on(hosts, facter) do |result| fail_test "Hostname fact is missing" unless stdout =~ /hostname\s*=>\s*\S*/ fail_test "Facter should not have written to stderr: #{stderr}" unless stderr == "" end facter-1.7.5/bin/0000755005276200011600000000000012276213023013426 5ustar jenkinsjenkinsfacter-1.7.5/bin/facter0000755005276200011600000000066212276213016014626 0ustar jenkinsjenkins#!/usr/bin/env ruby # Bundler and rubygems maintain a set of directories from which to # load gems. If Bundler is loaded, let it determine what can be # loaded. If it's not loaded, then use rubygems. But do this before # loading any facter code, so that our gem loading system is sane. if not defined? ::Bundler begin require 'rubygems' rescue LoadError end end require 'facter/application' Facter::Application.run(ARGV) facter-1.7.5/Gemfile0000644005276200011600000000201012276213016014144 0ustar jenkinsjenkinsif gem_source = ENV['GEM_SOURCE'] source gem_source else source "https://rubygems.org" end # C Ruby (MRI) or Rubinius, but NOT Windows platforms :ruby do gem 'watchr', :group => :development gem 'pry', :group => :development gem 'yard', :group => :development gem 'redcarpet', '<= 2.3.0', :group => :development end group :development, :test do gem 'rake' gem 'rspec', "~> 2.11.0" gem 'mocha', "~> 0.10.5" gem 'json', "~> 1.7", :platforms => :ruby gem 'puppetlabs_spec_helper' end platform :mswin, :mingw do gem "ffi", "1.9.0", :require => false gem "sys-admin", "1.5.6", :require => false gem "win32-api", "1.4.8", :require => false gem "win32-dir", "0.4.3", :require => false gem "windows-api", "0.4.2", :require => false gem "windows-pr", "1.2.2", :require => false gem "win32console", "1.3.2", :require => false end gem 'facter', ">= 1.0.0", :path => File.expand_path("..", __FILE__) if File.exists? "#{__FILE__}.local" eval(File.read("#{__FILE__}.local"), binding) end # vim:ft=ruby facter-1.7.5/CONTRIBUTING.md0000644005276200011600000002530512276213016015116 0ustar jenkinsjenkinsChecklist/Outline (The short version) ================================================= * Getting Started: - Make sure you have a [Redmine account](http://projects.puppetlabs.com) - Submit a ticket for your issue, assuming one does not already exist. - Decide what to base your work off of * `1.6.x`: bug fixes only * `2.x`: new features that are not breaking changes * `master`: new features that are breaking changes * Making Changes: - Make sure you have a [GitHub account](https://github.com/signup/free) - Fork the repository on GitHub - Make commits of logical units. - Check for unnecessary whitespace with "git diff --check" before committing. - Make sure your commit messages are in the proper format - Make sure you have added the necessary tests for your changes - Run _all_ the tests to assure nothing else was accidentally broken * Submitting Changes: - Sign the [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) - Push your changes to a topic branch in your fork of the repository. - Submit a pull request to the repository in the puppetlabs organization. - Update your Redmine ticket The long version ================ 0. Create a Redmine ticket for the change you'd like to make. It's very important that there be a Redmine ticket for the change you are making. Considering the number of contributions which are submitted, it is crucial that we know we can find the ticket on Redmine. Before making a ticket however, be sure that one does not already exist. You can do this by searching Redmine or by trying a Google search which includes `sites:projects.puppetlabs.com` in addition to some of the keywords related to your issue. If you do not find a ticket that that accurately describes the work you're going to be doing, go ahead and create one. But be sure to look for related tickets and add them to the 'related tickets' section. 1. Decide what to base your work on. In general, you should always base your work on the oldest branch that your change is relevant to, and it will be eventually merged up. Currently, branches will be merged up as follows: 1.6.x => 2.x => master Currently, this is how you should decide where to target your changes: A bug fix should be based off the the earliest place where it is relevant. If it first appears in `1.6.x`, then it should be targeted here and eventually merged up to `2.x` and master. New features which are _backwards compatible_ should be targeted at the next release, which currently is `2.x`. New features that are _breaking changes_ should be targeted at `master`. Part of deciding what to what your work should be based off of includes naming your topic branch to reflect this. Your branch name should have the following format: `ticket/target_branch/ticket_number_short_description_of_issuee` For example, if you are fixing a bug relating to a hostname problem on aix, which has Redmine ticket number 12345, then your branch should be named: `ticket/2.x/12345_fix_hostname_on_aix` There is a good chance that if you submit a pull request _from_ master _to_ master, Puppet Labs developers will suspect that you're not sure about the process. This is why clear naming of branches and basing your work off the right place will be extremely helpful in ensuring that your submission is reviewed and merged. Often times if your change is targeted at the wrong place, we will bounce it back to you and wait to review it until it has been retargeted. 2. Make separate commits for logically separate changes. Please break your commits down into logically consistent units which include new or changed tests relevent to the rest of the change. The goal of doing this is to make the diff easier to read for whoever is reviewing your code. In general, the easier your diff is to read, the more likely someone will be happy to review it and get it into the code base. If you're going to refactor a piece of code, please do so as a separate commit from your feature or bug fix changes. It's crucial that your changes include tests to make sure the bug isn't re-introduced, and that the feature isn't accidentally broken. Describe the technical detail of the change(s). If your description starts to get too long, that's a good sign that you probably need to split up your commit into more finely grained pieces. Commits which plainly describe the the things which help reviewers check the patch and future developers understand the code are much more likely to be merged in with a minimum of bike-shedding or requested changes. Ideally, the commit message would include information, and be in a form suitable for inclusion in the release notes for the version of Facter that includes them. Please also check that you are not introducing any trailing whitespaces or other "whitespace errors". You can do this by running "git diff --check" on your changes before you commit. When writing commit messages, please be sure they meet [these standards](https://github.com/erlang/otp/wiki/Writing-good-commit-messages), and please include the ticket number in your short summary. It should look something like this: `(#12345) Fix this issue in Facter` 3. Sign the Contributor License Agreement Before we can accept your changes, we do need a signed Puppet Labs Contributor License Agreement (CLA). You can access the CLA via the [Contributor License Agreement link](https://projects.puppetlabs.com/contributor_licenses/sign) in the top menu bar of our Redmine instance. Once you've signed the CLA, a badge will show up next to your name on the [Puppet Project Overview Page](http://projects.puppetlabs.com/projects/puppet?jump=welcome), and your name will be listed under "Contributor License Signers" section. If you have any questions about the CLA, please feel free to contact Puppet Labs via email at cla-submissions@puppetlabs.com. 4. Sending your patches To submit your changes via a GitHub pull request, you must have them on a topic branch, instead of directly on "master" or one of the release, or RC branches. It makes things much easier to keep track of, especially if you decide to work on another thing before your first change is merged in. GitHub has some pretty good [general documentation](http://help.github.com/) on using their site. They also have documentation on [creating pull requests](http://help.github.com/send-pull-requests/). In general, after pushing your topic branch up to your repository on GitHub, you'll switch to the branch in the GitHub UI and click "Pull Request" towards the top of the page in order to open a pull request. You'll want to make sure that you have the appropriate destination branch in the repository under the puppetlabs organization. This should be the same branch that you based your changes off of. 5. Update the related Redmine ticket. You should update the Redmine ticket associated with the change you submitted to include the location of your branch on the `branch` field of the ticket, and change the status to "In Topic Branch Pending Review", along with any other commentary you may wish to make. How to track the status of your change after it's been submitted ================================================================ Shortly after opening a pull request, there should be an automatic email sent via GitHub. This notification is used to let the Puppet development community know about your requested change to give them a chance to review, test, and comment on the change(s). We do our best to comment on or merge submitted changes within a about week. However, if there hasn't been any commentary on the pull request or mailed patches, and it hasn't been merged in after a week, then feel free to ask for an update by replying on the mailing list to the automatic notification or mailed patches. It probably wasn't intentional, and probably just slipped through the cracks. Additional Resources ==================== * [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) * [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) * [Bug tracker (Redmine)](http://projects.puppetlabs.com) * [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) If you have commit access to the repository =========================================== Even if you have commit access to the repository, you'll still need to go through the process above, and have someone else review and merge in your changes. The rule is that all changes must be reviewed by a developer on the project (that didn't write the code) to ensure that all changes go through a code review process. Having someone other than the author of the topic branch recorded as performing the merge is the record that they performed the code review. * Merging topic branches When merging code from a topic branch into the integration branch (Ex: master, 2.7.x, 1.6.x, etc.), there should always be a merge commit. You can accomplish this by always providing the `--no-ff` flag to `git merge`. git merge --no-ff --log tickets/master/1234-fix-something-broken The reason for always forcing this merge commit is that it provides a consistent way to look up what changes & commits were in a topic branch, whether that topic branch had one, or 500 commits. For example, if the merge commit had an abbreviated SHA-1 of `coffeebad`, then you could use the following `git log` invocation to show you which commits it brought in: git log coffeebad^1..coffeebad^2 The following would show you which changes were made on the topic branch: git diff coffeebad^1...coffeebad^2 Because we _always_ merge the topic branch into the integration branch the first parent (`^1`) of a merge commit will be the most recent commit on the integration branch from just before we merged in the topic, and the second parent (`^2`) will always be the most recent commit that was made in the topic branch. This also serves as the record of who performed the code review, as mentioned above. facter-1.7.5/ext/0000755005276200011600000000000012276213023013456 5ustar jenkinsjenkinsfacter-1.7.5/ext/ips/0000755005276200011600000000000012276213024014252 5ustar jenkinsjenkinsfacter-1.7.5/ext/ips/transforms0000644005276200011600000000126712276213016016402 0ustar jenkinsjenkins default facet.doc.man true> add restart_fmri svc:/application/man-index:default> # drop user drop> drop> drop> drop> drop> drop> drop> drop> drop> drop> # saner dependencies edit fmri "@[^ \t\n\r\f\v]*" ""> facter-1.7.5/ext/ips/rules0000755005276200011600000000042112276213016015330 0ustar jenkinsjenkins#!/usr/bin/make -f LIBDIR=$(shell /usr/bin/ruby18 -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') DESTDIR=$(CURDIR)/pkg/ips/proto binary-install/facter:: /usr/bin/ruby18 install.rb --destdir=$(DESTDIR) --bindir=/usr/bin --sitelibdir=$(LIBDIR) --mandir=/usr/share/man facter-1.7.5/ext/ips/facter.p5m0000644005276200011600000000115112276213024016137 0ustar jenkinsjenkinsset name=pkg.fmri value=pkg://puppetlabs.com/application/facter@1.7.5,13.0.0-0 set name=pkg.summary value="Facter, a system inventory tool" set name=pkg.human-version value="1.7.5" set name=pkg.description value="You can prove anything with facts!" set name=info.classification value="org.opensolaris.category.2008:Applications/System Utilities" set name=org.opensolaris.consolidation value="puppet" set name=description value="You can prove anything with facts!" set name=variant.opensolaris.zone value=global value=nonglobal set name=variant.arch value=sparc value=i386 license facter.license license="Apache v2.0" facter-1.7.5/ext/solaris/0000755005276200011600000000000012276213023015132 5ustar jenkinsjenkinsfacter-1.7.5/ext/solaris/pkginfo0000644005276200011600000000033712276213016016517 0ustar jenkinsjenkinsPKG=CSWfacter NAME=facter - System Fact Gatherer VERSION=1.6.3rc1 CATEGORY=application VENDOR=http://www.puppetlabs.com/puppet/related-projects/facter HOTLINE=http://puppetlabs.com/cgi-bin/facter.cgi EMAIL=luke@madstop.com facter-1.7.5/ext/osx/0000755005276200011600000000000012276213023014267 5ustar jenkinsjenkinsfacter-1.7.5/ext/osx/prototype.plist.erb0000644005276200011600000000212612276213016020163 0ustar jenkinsjenkins CFBundleIdentifier <%= @title %> CFBundleShortVersionString <%= @version %> IFMajorVersion <%= @package_major_version %> IFMinorVersion <%= @package_minor_version %> IFPkgBuildDate <%= @build_date %> IFPkgFlagAllowBackRev IFPkgFlagAuthorizationAction RootAuthorization IFPkgFlagDefaultLocation / IFPkgFlagFollowLinks IFPkgFlagInstallFat IFPkgFlagIsRequired IFPkgFlagOverwritePermissions IFPkgFlagRelocatable IFPkgFlagRestartAction <%= @pm_restart %> IFPkgFlagRootVolumeOnly IFPkgFlagUpdateInstalledLanguages facter-1.7.5/ext/osx/preflight.erb0000644005276200011600000000203112276213016016743 0ustar jenkinsjenkins#!/bin/bash # # Make sure that old facter cruft is removed # This also allows us to downgrade facter as # it's more likely that installing old versions # over new will cause issues. # # ${3} is the destination volume so that this works correctly # when being installed to volumes other than the current OS. <%- ["@apple_libdir", "@apple_sbindir", "@apple_bindir", "@apple_docdir", "@package_name"].each do |i| -%> <%- val = instance_variable_get(i) -%> <%- raise "Critical variable #{i} is unset!" if val.nil? or val.empty? -%> <%- end -%> # remove ruby library files <%- Dir.chdir("lib") do -%> <%- [@apple_old_libdir, @apple_libdir].compact.each do |libdir| -%> <%- Dir.glob("*").each do |file| -%> /bin/rm -Rf "${3}<%= libdir %>/<%= file %>" <%- end -%> <%- end -%> <%- end -%> # remove bin files <%- Dir.chdir("bin") do -%> <%- Dir.glob("*").each do |file| -%> /bin/rm -Rf "${3}<%= @apple_bindir %>/<%= file %>" <%- end -%> <%- end -%> # remove old doc files /bin/rm -Rf "${3}<%= @apple_docdir %>/<%= @package_name %>" facter-1.7.5/ext/osx/file_mapping.yaml0000644005276200011600000000074012276213016017610 0ustar jenkinsjenkinsdirectories: lib: path: 'Library/Ruby/Site' owner: 'root' group: 'wheel' perms: '0644' bin: path: 'usr/bin' owner: 'root' group: 'wheel' perms: '0755' facter: path: 'private/var/lib/facter' owner: 'root' group: 'wheel' perms: '0644' etc: path: 'private/etc' owner: 'root' group: 'wheel' perms: '0644' files: '[A-Z]*': path: 'usr/share/doc/facter' owner: 'root' group: 'wheel' perms: '0644' facter-1.7.5/ext/build_defaults.yaml0000644005276200011600000000253412276213016017336 0ustar jenkinsjenkins--- packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master' packaging_repo: 'packaging' default_cow: 'base-squeeze-i386.cow' cows: 'base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-raring-i386.cow base-raring-amd64.cow base-saucy-i386.cow base-saucy-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow base-testing-amd64.cow base-unstable-i386.cow base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow' pbuild_conf: '/etc/pbuilderrc' packager: 'puppetlabs' gpg_name: 'info@puppetlabs.com' gpg_key: '4BD6EC30' sign_tar: FALSE # a space separated list of mock configs final_mocks: 'pl-el-5-i386 pl-el-5-x86_64 pl-el-6-i386 pl-el-6-x86_64 pl-el-7-x86_64 pl-fedora-18-i386 pl-fedora-18-x86_64 pl-fedora-19-i386 pl-fedora-19-x86_64 pl-fedora-20-i386 pl-fedora-20-x86_64' yum_host: 'yum.puppetlabs.com' yum_repo_path: '/opt/repository/yum/' build_gem: TRUE build_dmg: TRUE build_ips: TRUE apt_host: 'apt.puppetlabs.com' apt_repo_url: 'http://apt.puppetlabs.com' apt_repo_path: '/opt/repository/incoming' ips_repo: '/var/pkgrepo' ips_store: '/opt/repository' ips_host: 'solaris-11-ips-repo.acctest.dc1.puppetlabs.net' tar_host: 'downloads.puppetlabs.com' facter-1.7.5/ext/project_data.yaml0000644005276200011600000000104612276213016017004 0ustar jenkinsjenkins--- project: 'facter' author: 'Puppet Labs' email: 'info@puppetlabs.com' homepage: 'https://github.com/puppetlabs/facter' summary: 'Facter, a system inventory tool' description: 'You can prove anything with facts!' version_file: 'lib/facter/version.rb' # files and gem_files are space separated lists files: '[A-Z]* acceptance bin documentation etc ext install.rb lib libexec man spec' gem_files: '[A-Z]* install.rb bin etc ext lib spec' gem_require_path: 'lib' gem_test_files: 'spec/**/*' gem_executables: 'facter' gem_default_executables: 'facter' facter-1.7.5/ext/debian/0000755005276200011600000000000012276213024014701 5ustar jenkinsjenkinsfacter-1.7.5/ext/debian/docs0000644005276200011600000000001212276213016015546 0ustar jenkinsjenkinsREADME.md facter-1.7.5/ext/debian/compat0000644005276200011600000000000212276213016016100 0ustar jenkinsjenkins7 facter-1.7.5/ext/debian/changelog0000644005276200011600000000444212276213024016557 0ustar jenkinsjenkinsfacter (1.7.5-1puppetlabs1) lucid unstable sid wheezy lucid squeeze precise quantal raring; urgency=low * Update to version -- Puppet Labs Release Mon, 10 Feb 2014 10:10:28 -0800 facter (1.7.2-1puppetlabs2) lucid unstable sid wheezy lucid squeeze precise; urgency=low * Remove dependenices on libssl-ruby from facter as they are not used -- Matthaus Owens Thu, 11 Jul 2013 13:11:30 +0000 facter (1.7.0-0.1rc1puppetlabs1) hardy lucid oneiric unstable sid wheezy lucid squeeze precise; urgency=low * Add dependency on virt-what to facter for better virutalization detection -- Matthaus Owens Mon, 01 Apr 2013 13:11:30 +0000 facter (1.6.8-1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low * Imported Upstream version 1.6.8 -- Moses Mendoza Mon, 23 Apr 2012 13:11:30 +0000 facter (1.6.7-1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low * Imported Upstream version 1.6.7 -- Moses Mendoza Thu, 29 Mar 2012 22:43:30 +0000 facter (1.6.6-1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid squeeze wheezy precise; urgency=low * (#12436) Adding pciutils as a dependency. -- Matthaus Litteken Fri, 10 Feb 2012 01:49:22 +0000 facter (1.6.5-1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid squeeze wheezy; urgency=low * Release facter 1.6.5 -- Matthaus Litteken Wed, 25 Jan 2012 11:46:48 -0700 facter (1.6.4-1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid squeeze wheezy; urgency=low * Release facter 1.6.4 -- Matthaus Litteken Wed, 7 Dec 2011 13:36:48 -0700 facter (1.6.3-1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid squeeze wheezy; urgency=low * Initial packaging for facter 1.6.3 -- Matthaus Litteken Thu, 10 Nov 2011 11:00:48 -0700 facter (1.6.2-1puppet1) hardy lucid maverick natty oneiric unstable lenny sid squeeze wheezy; urgency=low * Initial packaging for facter 1.6.2 -- Matthaus Litteken Fri, 21 Oct 2011 11:00:48 -0700 facter-1.7.5/ext/debian/source/0000755005276200011600000000000012276213023016200 5ustar jenkinsjenkinsfacter-1.7.5/ext/debian/source/format0000644005276200011600000000001412276213016017410 0ustar jenkinsjenkins3.0 (quilt) facter-1.7.5/ext/debian/rules0000755005276200011600000000067112276213016015766 0ustar jenkinsjenkins#!/usr/bin/make -f include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/rules/buildcore.mk LIBDIR=$(shell /usr/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]') BINDIR=$(shell /usr/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["bindir"]') binary-install/facter:: /usr/bin/ruby install.rb --sitelibdir=$(LIBDIR) --bindir=$(BINDIR) --ruby=/usr/bin/ruby --destdir=$(CURDIR)/debian/$(cdbs_curpkg) --quick --man facter-1.7.5/ext/debian/lintian-overrides0000644005276200011600000000000012276213016020251 0ustar jenkinsjenkinsfacter-1.7.5/ext/debian/copyright0000644005276200011600000000067212276213016016642 0ustar jenkinsjenkinsThis package was debianized by Jacob Helwig on Sat, 11 Dec 2010 21:11:11 -0800 It was downloaded from http://www.puppetlabs.com/ Upstream Author: Puppet Labs Copyright: Copyright 2010-2011 Puppet Labs License: ASL-2 http://www.apache.org/licenses/LICENSE-2.0 On a Debian system, the license can be found at /usr/share/common-licenses/Apache-2.0 . facter-1.7.5/ext/debian/control0000644005276200011600000000113012276213016016300 0ustar jenkinsjenkinsSource: facter Section: ruby Priority: optional Maintainer: Puppet Labs Build-Depends: cdbs, debhelper (>> 7), ruby | ruby-interpreter Standards-Version: 3.9.1 Homepage: http://www.puppetlabs.com Package: facter Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter, dmidecode [i386 amd64 ia64], virt-what, pciutils Description: Ruby module for collecting simple facts about a host operating system Some of the facts are preconfigured, such as the hostname and the operating system. Additional facts can be added through simple Ruby scripts. facter-1.7.5/ext/redhat/0000755005276200011600000000000012276213024014726 5ustar jenkinsjenkinsfacter-1.7.5/ext/redhat/facter.spec0000644005276200011600000001565712276213024017064 0ustar jenkinsjenkins# Fedora 17 ships with ruby 1.9, RHEL 7 with ruby 2.0, which use vendorlibdir instead # of sitelibdir %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 %global facter_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]') %else %global facter_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]') %endif # VERSION is subbed out during rake srpm process %global realversion 1.7.5 %global rpmversion 1.7.5 Summary: Ruby module for collecting simple facts about a host operating system Name: facter Version: %{rpmversion} Release: 1%{?dist} Epoch: 1 Vendor: %{?_host_vendor} License: ASL 2.0 Group: System Environment/Base URL: http://www.puppetlabs.com/puppet/related-projects/%{name} # Note this URL will only be valid at official tags from Puppet Labs Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{realversion}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: ruby >= 1.8.5 Requires: which # dmidecode and pciutils are not available on all arches %ifarch %ix86 x86_64 ia64 Requires: dmidecode Requires: pciutils %endif Requires: virt-what Requires: ruby >= 1.8.5 BuildRequires: ruby >= 1.8.5 # In Fedora 17+ or RHEL 7+ ruby-rdoc is called rubygem-rdoc %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 BuildRequires: rubygem-rdoc %else BuildRequires: ruby-rdoc %endif %description Ruby module for collecting simple facts about a host Operating system. Some of the facts are preconfigured, such as the hostname and the operating system. Additional facts can be added through simple Ruby scripts %prep %setup -q -n %{name}-%{realversion} %build %install rm -rf %{buildroot} ruby install.rb --destdir=%{buildroot} --quick --sitelibdir=%{facter_libdir} %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) %{_bindir}/facter %{facter_libdir}/facter.rb %{facter_libdir}/facter %{_mandir}/man8/facter.8.gz %doc LICENSE README.md %changelog * Mon Feb 10 2014 Puppet Labs Release - 1:1.7.5-1 - Build for 1.7.5 * Mon Apr 01 2013 Matthaus Owens - 1:1.7.0-0.1rc1 - Add dependency on virt-what to facter for better virutalization detection * Wed Aug 08 2012 Moses Mendoza - 1.6.11-2 - Use correct ruby libdir for fedora 17 / ruby 1.9 * Wed Aug 08 2012 Moses Mendoza - 1.6.11-1 - Update for 1.6.11 * Wed Aug 01 2012 Moses Mendoza - 1.6.11-0.1rc1 - Update for 1.6.11rc1 * Sat Jul 07 2012 Michael Stahnke - 1.6.10-2 - Attempt to build fro Ruby 1.9.3 * Tue May 22 2012 Moses Mendoza - 2.0.0-0.1rc3 - Update for 2.0.0rc3 release * Thu May 17 2012 Moses Mendoza - 2.0.0-0.1rc2 - Update for 2.0.0rc2 release * Tue May 15 2012 Matthaus Litteken - 2.0.0-0.1rc1 - Facter 2.0.0rc1 release * Thu May 10 2012 Matthaus Litteken - 1.6.9-0.1rc1 - Update for 1.6.9rc1 * Mon Apr 30 2012 Moses Mendoza - 1.6.8-1 - Update for 1.6.8, spec for arch-specific build, req ruby 1.8.5 * Thu Feb 23 2012 Michael Stahnke - 1.6.6-1 - Update for 1.6.6 * Wed Jan 25 2012 Matthaus Litteken - 1.6.5-1 - Update to 1.6.5 * Wed Nov 30 2011 Matthaus Litteken - 1.6.4-0.1rc1 - 1.6.4 rc1 * Mon Oct 31 2011 Michael Stahnke - 1.6.3-0.1rc1 - 1.6.3 rc1 * Mon Oct 10 2011 Michael Stahnke - 1.6.2-1 - Update to 1.6.2 * Mon Oct 03 2011 Michael Stahnke - 1.6.2-0.1rc1 - Updates for 1.6.2-0.1rc1 * Thu Jun 23 2011 Michael Stahnke - 1.6.0-1 - Update to 1.6.0 * Sat Aug 28 2010 Todd Zullinger - 1.5.8-1 - Update to 1.5.8 * Fri Sep 25 2009 Todd Zullinger - 1.5.7-1 - Update to 1.5.7 - Update #508037 patch from upstream ticket * Wed Aug 12 2009 Jeroen van Meeuwen - 1.5.5-3 - Fix #508037 or upstream #2355 * Fri Jul 24 2009 Fedora Release Engineering - 1.5.5-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild * Fri May 22 2009 Todd Zullinger - 1.5.5-1 - Update to 1.5.5 - Drop upstreamed libperms patch * Sat Feb 28 2009 Todd Zullinger - 1.5.4-1 - New version - Use upstream install script * Tue Feb 24 2009 Fedora Release Engineering - 1.5.2-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild * Tue Sep 09 2008 Todd Zullinger - 1.5.2-1 - New version - Simplify spec file checking for Fedora and RHEL versions * Mon Sep 8 2008 David Lutterkort - 1.5.1-1 - New version * Thu Jul 17 2008 David Lutterkort - 1.5.0-3 - Change 'mkdir' in install to 'mkdir -p' * Thu Jul 17 2008 David Lutterkort - 1.5.0-2 - Remove files that were listed twice in files section * Mon May 19 2008 James Turnbull - 1.5.0-1 - New version - Added util and plist files * Mon Sep 24 2007 David Lutterkort - 1.3.8-1 - Update license tag - Copy all of lib/ into ruby_sitelibdir * Thu Mar 29 2007 David Lutterkort - 1.3.7-1 - New version * Fri Jan 19 2007 David Lutterkort - 1.3.6-1 - New version * Thu Jan 18 2007 David Lutterkort - 1.3.5-3 - require which; facter is very unhappy without it * Mon Nov 20 2006 David Lutterkort - 1.3.5-2 - Make require ruby(abi) and buildarch: noarch conditional for fedora 5 or later to allow building on older fedora releases * Tue Oct 10 2006 David Lutterkort - 1.3.5-1 - New version * Tue Sep 26 2006 David Lutterkort - 1.3.4-1 - New version * Wed Sep 13 2006 David Lutterkort - 1.3.3-2 - Rebuilt for FC6 * Wed Jun 28 2006 David Lutterkort - 1.3.3-1 - Rebuilt * Fri Jun 19 2006 Luke Kanies - 1.3.0-1 - Fixed spec file to work again with the extra memory and processor files. - Require ruby(abi). Build as noarch * Fri Jun 9 2006 Luke Kanies - 1.3.0-1 - Added memory.rb and processor.rb * Mon Apr 17 2006 David Lutterkort - 1.1.4-4 - Rebuilt with changed upstream tarball * Tue Mar 21 2006 David Lutterkort - 1.1.4-3 - Do not rely on install.rb, it will be deleted upstream * Mon Mar 13 2006 David Lutterkort - 1.1.4-2 - Commented out noarch; requires fix for bz184199 * Mon Mar 6 2006 David Lutterkort - 1.1.4-1 - Removed unused macros * Mon Feb 6 2006 David Lutterkort - 1.1.1-2 - Fix BuildRoot. Add dist to release tag * Wed Jan 11 2006 David Lutterkort - 1.1.1-1 - Initial build. facter-1.7.5/ext/facter-diff0000755005276200011600000000311212276213016015555 0ustar jenkinsjenkins #!/usr/bin/env sh # # Output the difference between a facter command run on two different versions # of facter. Uses unified diff format. OPTIONS_SPEC="\ facter-diff [options] [fact]... Example: ./ext/facter-diff 1.5.7 1.0.2 -- h,help Display this help" . "$(git --exec-path)/git-sh-setup" eval "$(echo "$OPTIONS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)" trap 'err=$?; cleanup; exit $err' 0 cleanup() { test $origin && git checkout -q "$origin" } facter() { ruby -Ilib bin/facter "$@" } log_facter_run() { local ref=$1 && shift local tmpfile=$1 && shift git checkout -qf "$ref" || die "fatal: unable to checkout $ref" facter "$@" > $tmpfile } verify_revision() { git rev-parse --verify --quiet "$1" > /dev/null || die "fatal: '$1' is not a valid revision" } test $1 = "--" && shift # git rev-parse seems to leave the -- in test $# -eq 0 && usage test $# -gt 1 || die "fatal: must specify two revisions" status=$(git status -s) test -z "$status" || die "fatal: $0 cannot be used with a dirty working copy" origin=$(git rev-parse --symbolic-full-name HEAD) test "$origin" = "HEAD" && origin=$(git rev-parse HEAD) test -x "bin/facter" || die "fatal: $0 must be run from the project root" ref1="$1" && shift ref2="$1" && shift verify_revision $ref1 verify_revision $ref2 tmpfile1="/tmp/$(basename $0).$$.1.tmp" tmpfile2="/tmp/$(basename $0).$$.2.tmp" log_facter_run $ref1 $tmpfile1 $@ log_facter_run $ref2 $tmpfile2 $@ git checkout -f "$origin" > /dev/null 2>&1 diff --label "$ref1" --label "$ref2" -u $tmpfile1 $tmpfile2 facter-1.7.5/spec/0000755005276200011600000000000012276213024013611 5ustar jenkinsjenkinsfacter-1.7.5/spec/shared_contexts/0000755005276200011600000000000012276213023017005 5ustar jenkinsjenkinsfacter-1.7.5/spec/shared_contexts/platform.rb0000644005276200011600000000301012276213017021153 0ustar jenkinsjenkins# Contexts for stubbing platforms # In a describe or context block, adding :as_platform => :windows or # :as_platform => :posix will stub the relevant facter config, as well as # the behavior of Ruby's filesystem methods by changing File::ALT_SEPARATOR. # # # shared_context "windows", :as_platform => :windows do before :each do Facter.fact(:operatingsystem).stubs(:value).returns('Windows') Facter::Util::Config.stubs(:is_windows?).returns true end around do |example| file_alt_separator = File::ALT_SEPARATOR file_path_separator = File::PATH_SEPARATOR # prevent Ruby from warning about changing a constant with_verbose_disabled do File::ALT_SEPARATOR = '\\' File::PATH_SEPARATOR = ';' end begin example.run ensure with_verbose_disabled do File::ALT_SEPARATOR = file_alt_separator File::PATH_SEPARATOR = file_path_separator end end end end shared_context "posix", :as_platform => :posix do before :each do Facter::Util::Config.stubs(:is_windows?).returns false end around do |example| file_alt_separator = File::ALT_SEPARATOR file_path_separator = File::PATH_SEPARATOR # prevent Ruby from warning about changing a constant with_verbose_disabled do File::ALT_SEPARATOR = nil File::PATH_SEPARATOR = ':' end begin example.run ensure with_verbose_disabled do File::ALT_SEPARATOR = file_alt_separator File::PATH_SEPARATOR = file_path_separator end end end end facter-1.7.5/spec/lib/0000755005276200011600000000000012276213023014356 5ustar jenkinsjenkinsfacter-1.7.5/spec/lib/facter_spec/0000755005276200011600000000000012276213023016634 5ustar jenkinsjenkinsfacter-1.7.5/spec/lib/facter_spec/windows_network.rb0000644005276200011600000000242412276213017022431 0ustar jenkinsjenkinsrequire 'spec_helper' module FacterSpec::WindowsNetwork def settingId0 '{4AE6B55C-6DD6-427D-A5BB-13535D4BE926}' end def settingId1 '{38762816-7957-42AC-8DAA-3B08D0C857C7}' end def nic_bindings ["\\Device\\#{settingId0}", "\\Device\\#{settingId1}" ] end def macAddress0 '23:24:df:12:12:00' end def macAddress1 '00:0C:29:0C:9E:9F' end def ipAddress0 '12.123.12.12' end def ipAddress1 '12.123.12.13' end def subnet0 '255.255.255.0' end def subnet1 '255.255.0.0' end def ipv6Address0 '2011:0:4137:9e76:2087:77a:53ef:7527' end def ipv6Address1 '2013:0:4137:9e76:2087:77a:53ef:7527' end def ipv6LinkLocal 'fe80::2db2:5b42:4e30:b508' end def given_a_valid_windows_nic_with_ipv4_and_ipv6 stub('network0', :IPAddress => [ipAddress0, ipv6Address0], :SettingID => settingId0, :IPConnectionMetric => 10,:MACAddress => macAddress0,:IPSubnet => [subnet0, '48','2']) end def given_two_valid_windows_nics_with_ipv4_and_ipv6 { :nic0 => given_a_valid_windows_nic_with_ipv4_and_ipv6, :nic1 => stub('network1', :IPAddress => [ipAddress1, ipv6Address1], :SettingID => settingId1, :IPConnectionMetric => 10,:MACAddress => macAddress1,:IPSubnet => [subnet1, '48','2']) } end end facter-1.7.5/spec/lib/facter_spec/cpuinfo.rb0000644005276200011600000000046512276213017020634 0ustar jenkinsjenkinsrequire 'spec_helper' module FacterSpec::Cpuinfo def cpuinfo_fixtures(filename) fixtures('cpuinfo', filename) end def cpuinfo_fixture_read(filename) File.read(cpuinfo_fixtures(filename)) end def cpuinfo_fixture_readlines(filename) cpuinfo_fixture_read(filename).split(/\n/) end end facter-1.7.5/spec/puppetlabs_spec/0000755005276200011600000000000012276213023017001 5ustar jenkinsjenkinsfacter-1.7.5/spec/puppetlabs_spec/matchers.rb0000644005276200011600000000377012276213017021146 0ustar jenkinsjenkinsrequire 'stringio' ######################################################################## # Backward compatibility for Jenkins outdated environment. module RSpec module Matchers module BlockAliases alias_method :to, :should unless method_defined? :to alias_method :to_not, :should_not unless method_defined? :to_not alias_method :not_to, :should_not unless method_defined? :not_to end end end ######################################################################## # Custom matchers... RSpec::Matchers.define :have_matching_element do |expected| match do |actual| actual.any? { |item| item =~ expected } end end RSpec::Matchers.define :exit_with do |expected| actual = nil match do |block| begin block.call rescue SystemExit => e actual = e.status end actual and actual == expected end failure_message_for_should do |block| "expected exit with code #{expected} but " + (actual.nil? ? " exit was not called" : "we exited with #{actual} instead") end failure_message_for_should_not do |block| "expected that exit would not be called with #{expected}" end description do "expect exit with #{expected}" end end RSpec::Matchers.define :have_printed do |expected| match do |block| $stderr = $stdout = StringIO.new begin block.call ensure $stdout.rewind @actual = $stdout.read $stdout = STDOUT $stderr = STDERR end if @actual then case expected when String @actual.include? expected when Regexp expected.match @actual else raise ArgumentError, "No idea how to match a #{@actual.class.name}" end end end failure_message_for_should do |actual| if actual.nil? then "expected #{expected.inspect}, but nothing was printed" else "expected #{expected.inspect} to be printed; got:\n#{actual}" end end description do "expect #{expected.inspect} to be printed" end diffable end facter-1.7.5/spec/puppetlabs_spec/files.rb0000755005276200011600000000240012276213017020432 0ustar jenkinsjenkinsrequire 'fileutils' require 'tempfile' require 'pathname' # A support module for testing files. module PuppetlabsSpec::Files # This code exists only to support tests that run as root, pretty much. # Once they have finally been eliminated this can all go... --daniel 2011-04-08 def self.in_tmp(path) tempdir = Dir.tmpdir Pathname.new(path).ascend do |dir| return true if File.identical?(tempdir, dir) end false end def self.cleanup $global_tempfiles ||= [] while path = $global_tempfiles.pop do fail "Not deleting tmpfile #{path} outside regular tmpdir" unless in_tmp(path) begin FileUtils.rm_r path, :secure => true rescue Errno::ENOENT # nothing to do end end end def make_absolute(path) path = File.expand_path(path) path[0] = 'c' if Puppet.features.microsoft_windows? path end def tmpfilename(name) # Generate a temporary file, just for the name... source = Tempfile.new(name) path = source.path source.close! # ...record it for cleanup, $global_tempfiles ||= [] $global_tempfiles << File.expand_path(path) # ...and bam. path end def tmpdir(name) path = tmpfilename(name) FileUtils.mkdir_p(path) path end end facter-1.7.5/spec/puppetlabs_spec/fixtures.rb0000755005276200011600000000324112276213017021205 0ustar jenkinsjenkins# This module provides some helper methods to assist with fixtures. It's # methods are designed to help when you have a conforming fixture layout so we # get project consistency. module PuppetlabsSpec::Fixtures # Returns the joined path of the global FIXTURE_DIR plus any path given to it def fixtures(*rest) File.join(PuppetlabsSpec::FIXTURE_DIR, *rest) end # Returns the path to your relative fixture dir. So if your spec test is # /spec/unit/facter/foo_spec.rb then your relative dir will be # /spec/fixture/unit/facter/foo def my_fixture_dir callers = caller while line = callers.shift do next unless found = line.match(%r{/spec/(.*)_spec\.rb:}) return fixtures(found[1]) end fail "sorry, I couldn't work out your path from the caller stack!" end # Given a name, returns the full path of a file from your relative fixture # dir as returned by my_fixture_dir. def my_fixture(name) file = File.join(my_fixture_dir, name) unless File.readable? file then fail "fixture '#{name}' for #{my_fixture_dir} is not readable" end return file end # Return the contents of the file using read when given a name. Uses # my_fixture to work out the relative path. def my_fixture_read(name) File.read(my_fixture(name)) end # Provides a block mechanism for iterating across the files in your fixture # area. def my_fixtures(glob = '*', flags = 0) files = Dir.glob(File.join(my_fixture_dir, glob), flags) unless files.length > 0 then fail "fixture '#{glob}' for #{my_fixture_dir} had no files!" end block_given? and files.each do |file| yield file end files end end facter-1.7.5/spec/puppetlabs_spec/verbose.rb0000755005276200011600000000031712276213017021002 0ustar jenkinsjenkins# Support code for running stuff with warnings disabled. module Kernel def with_verbose_disabled verbose, $VERBOSE = $VERBOSE, nil result = yield $VERBOSE = verbose return result end end facter-1.7.5/spec/fixtures/0000755005276200011600000000000012276213023015461 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/ldom/0000755005276200011600000000000012276213023016414 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/ldom/ldom_v10000644005276200011600000000033312276213016017701 0ustar jenkinsjenkinsVERSION 1.0 DOMAINROLE|impl=LDoms|control=false|io=true|service=true|root=true DOMAINNAME|name=primary DOMAINUUID|uuid=8e0d6ec5-cd55-e57f-ae9f-b4cc050999a4 DOMAINCONTROL|name=san-t2k-6 DOMAINCHASSIS|serialno=0704RB0280 facter-1.7.5/spec/fixtures/netstat/0000755005276200011600000000000012276213023017143 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/netstat/darwin_10_6_40000644005276200011600000000320412276213016021323 0ustar jenkinsjenkinsRouting tables Internet: Destination Gateway Flags Refs Use Netif Expire default imana.puppetlabs.l UGSc 18 0 en1 127 localhost UCS 0 0 lo0 localhost localhost UH 2 161629 lo0 169.254 link#5 UCS 0 0 en1 172.16.38/24 link#9 UC 1 0 vmnet8 172.16.38.255 ff:ff:ff:ff:ff:ff UHLWbI 1 2 vmnet8 172.16.135/24 link#8 UC 1 0 vmnet1 172.16.135.255 ff:ff:ff:ff:ff:ff UHLWbI 0 2 vmnet1 192.168.100 link#5 UCS 17 0 en1 imana.puppetlabs.l 0:25:bc:e2:e:56 UHLWI 9 12 en1 1145 odys-iphone.puppet 5c:59:48:16:37:86 UHLWI 0 0 en1 1159 reinh.puppetlabs.l localhost UHS 0 0 lo0 192.168.100.255 ff:ff:ff:ff:ff:ff UHLWbI 0 2 en1 Internet6: Destination Gateway Flags Netif Expire localhost localhost UH lo0 fe80::%lo0 localhost Uc lo0 localhost link#1 UHL lo0 fe80::%en1 link#5 UC en1 fe80::226:b0ff:fef 0:26:b0:f9:ef:cb UHLW en1 reinh.local 58:b0:35:7f:25:b3 UHL lo0 ff01:: localhost Um lo0 ff02:: localhost UmC lo0 ff02:: link#5 UmC en1 facter-1.7.5/spec/fixtures/netstat/centos_5_50000644005276200011600000000052112276213016021031 0ustar jenkinsjenkinsKernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 0.0.0.0 100.100.100.1 0.0.0.0 UG 0 0 0 eth0 facter-1.7.5/spec/fixtures/netstat/darwin_9_8_00000644005276200011600000000342312276213016021254 0ustar jenkinsjenkinsRouting tables Internet: Destination Gateway Flags Refs Use Netif Expire default 100.100.107.1 UGSc 25 45789 en0 100.100.107/24 link#4 UCS 3 0 en0 100.100.107.1 0:26:f1:23:2d:0 UHLW 25 212733 en0 687 100.100.107.4 127.0.0.1 UHS 0 332 lo0 100.100.107.6 0:17:f2:6:e3:b0 UHLW 0 633 en0 1168 100.100.107.255 ff:ff:ff:ff:ff:ff UHLWb 0 6 en0 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 3 230 lo0 169.254 link#4 UCS 0 0 en0 192.168.61 link#8 UC 1 0 vmnet1 192.168.61.255 ff:ff:ff:ff:ff:ff UHLWb 0 6 vmnet1 192.168.210 link#7 UC 1 0 vmnet8 192.168.210.255 ff:ff:ff:ff:ff:ff UHLWb 0 6 vmnet8 Internet6: Destination Gateway Flags Netif Expire ::1 link#1 UHL lo0 fe80::%lo0/64 fe80::1%lo0 Uc lo0 fe80::1%lo0 link#1 UHL lo0 fe80::%en0/64 link#4 UC en0 fe80::217:f2ff:fe06:e42e%en0 0:17:f2:6:e4:2e UHL lo0 ff01::/32 ::1 U lo0 ff02::/32 fe80::1%lo0 UC lo0 ff02::/32 link#4 UC en0 facter-1.7.5/spec/fixtures/netstat/ubuntu_7_040000644005276200011600000000075512276213016021152 0ustar jenkinsjenkinsKernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 100.100.106.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 ath0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 0.0.0.0 100.100.106.1 0.0.0.0 UG 0 0 0 eth0 0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ath0 facter-1.7.5/spec/fixtures/netstat/darwin_10_3_00000644005276200011600000000470612276213016021324 0ustar jenkinsjenkinsRouting tables Internet: Destination Gateway Flags Refs Use Netif Expire default 100.100.104.1 UGSc 21 0 en0 100.100.104/24 link#4 UCS 11 0 en0 100.100.104.1 0:26:f1:23:2d:0 UHLWI 21 70927 en0 1188 100.100.104.12 127.0.0.1 UHS 2 109 lo0 100.100.104.16 0:1d:4f:44:cf:8 UHLWI 0 1369 en0 700 100.100.104.48 0:1d:4f:45:5a:8c UHLWI 0 2 en0 1173 100.100.104.52 0:1d:4f:44:ef:e0 UHLWI 0 184 en0 543 100.100.104.62 0:1d:4f:45:5f:8c UHLWI 0 4 en0 478 100.100.104.67 0:1d:4f:45:97:2c UHLWI 0 75 en0 851 100.100.104.71 0:1d:4f:45:4a:b4 UHLWI 0 12 en0 890 100.100.104.76 0:1d:4f:45:99:a8 UHLWI 0 2 en0 1056 100.100.104.154 0:25:64:c1:d6:35 UHLWI 0 2640 en0 1200 100.100.104.157 0:25:64:c1:cf:67 UHLWI 0 1 en0 1054 100.100.104.255 ff:ff:ff:ff:ff:ff UHLWbI 0 2 en0 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 0 10 lo0 169.254 link#4 UCS 0 0 en0 172.16.95/24 link#7 UC 0 0 vmnet8 172.16.201/24 link#8 UC 0 0 vmnet1 Internet6: Destination Gateway Flags Netif Expire ::1 ::1 UH lo0 fe80::%lo0/64 fe80::1%lo0 Uc lo0 fe80::1%lo0 link#1 UHL lo0 fe80::%en0/64 link#4 UC en0 fe80::217:f2ff:fe06:e3c2%en0 0:17:f2:6:e3:c2 UHL lo0 ff01::/32 ::1 Um lo0 ff02::/32 ::1 UmC lo0 ff02::/32 link#4 UmC en0 ff02::fb link#4 UHmLW en0 facter-1.7.5/spec/fixtures/netstat/open_solaris_100000644005276200011600000000206012276213016022063 0ustar jenkinsjenkinsRouting Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ---------- --------- default 192.168.2.1 UG 1 10 192.168.2.0 192.168.2.83 U 1 1022 hme0 224.0.0.0 192.168.2.83 U 1 0 hme0 127.0.0.1 127.0.0.1 UH 1 0 lo0 Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If --------------------------- --------------------------- ----- --- ------- ----- 2404:130:0:1000::/64 2404:130:0:1000:a00:20ff:fed1:6d79 U 1 0 hme0:1 fe80::/10 fe80::a00:20ff:fed1:6d79 U 1 0 hme0 ff00::/8 fe80::a00:20ff:fed1:6d79 U 1 0 hme0 default fe80::214:22ff:fe0a:1c46 UG 1 0 hme0 ::1 ::1 UH 1 140 lo0 facter-1.7.5/spec/fixtures/netstat/fedora_100000644005276200011600000000076112276213016020634 0ustar jenkinsjenkinsKernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 172.16.131.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1 192.168.183.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8 100.100.108.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 0.0.0.0 100.100.108.1 0.0.0.0 UG 0 0 0 eth0 facter-1.7.5/spec/fixtures/netstat/darwin_10_6_6_dualstack0000644005276200011600000000500312276213016023357 0ustar jenkinsjenkinsRouting tables Internet: Destination Gateway Flags Refs Use Netif Expire default 192.168.1.254 UGSc 38 0 en1 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 14 1044474 lo0 169.254 link#5 UCS 0 0 en1 192.168.1 link#5 UCS 2 0 en1 192.168.1.207 127.0.0.1 UHS 0 1 lo0 192.168.1.220 e0:f8:47:98:85:71 UHLWI 0 0 en1 135 192.168.1.254 0:4:ed:66:13:cc UHLWI 42 134 en1 1158 Internet6: Destination Gateway Flags Netif Expire default 2000:44b4:61::16e UGSc tun0 ::1 ::1 UH lo0 2000:44b4:61::16e 2000:44b4:61::16f UH tun0 2000:44b4:61::16f link#9 UHL lo0 2000:44b4:62:480::/64 link#5 UC en1 2000:44b4:62:480::/60 ::1 UGSc lo0 2000:44b4:62:480::1 0:25:0:48:19:ef UHL lo0 fe80::%lo0/64 fe80::1%lo0 Uc lo0 fe80::1%lo0 link#1 UHL lo0 fe80::%en1/64 link#5 UC en1 fe80::225:ff:fe48:19ef%en1 0:25:0:48:19:ef UHL lo0 fe80::a00:27ff:fe02:bcb5%en1 8:0:27:2:bc:b5 UHLW en1 fe80::a932:c76f:9c2e:ead8%en1 0:1e:2a:b3:9b:66 UHLW en1 fe80::e2f8:47ff:fe98:8571%en1 e0:f8:47:98:85:71 UHLW en1 fe80::225:4bff:feca:5672%tun0 link#9 UHL lo0 ff01::/32 ::1 Um lo0 ff02::/32 ::1 UmC lo0 ff02::/32 link#5 UmC en1 ff02::/32 fe80::225:4bff:feca:5672%tun0 UmC tun0 facter-1.7.5/spec/fixtures/netstat/open_solaris_b1320000644005276200011600000000217112276213016022315 0ustar jenkinsjenkinsRouting Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ---------- --------- default 202.78.241.102 UG 4 56215415 127.0.0.1 127.0.0.1 UH 2 15396 lo0 172.31.255.0 172.31.255.254 U 12 62487076 int0 202.78.241.96 202.78.241.97 U 6 2213722 bge0 Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If --------------------------- --------------------------- ----- --- ------- ----- ::1 ::1 UH 2 4 lo0 2404:130:40:10::/64 2404:130:40:10::ff:0 U 4 1050430 bge0 2404:130:40:18::/64 2404:130:40:18::ff:0 U 4 1302106 int0 fe80::/10 fe80::ff:0 U 3 16283 int0 fe80::/10 fe80::ff:0 U 5 314822 bge0 default fe80::20d:edff:fe9d:782e UG 2 420100 bge0 facter-1.7.5/spec/fixtures/hpux/0000755005276200011600000000000012276213023016445 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/hpux/unistd.h0000644005276200011600000017721712276213016020145 0ustar jenkinsjenkins/* @(#) unistd.h $Date: 2008/08/13 14:45:21 $Revision: r11.31/2 PATCH_11.31 (B11.31.0903LR) */ /* * (C) Copyright 1996-2008 Hewlett-Packard Development Company, L.P. * * BEGIN_DESC * * File: * @(#) common/include/sys/unistd.h $Revision: $ * * END_DESC */ #ifndef _SYS_UNISTD_INCLUDED #define _SYS_UNISTD_INCLUDED #ifndef _SYS_STDSYMS_INCLUDED # include #endif /* _SYS_STDSYMS_INCLUDED */ # include /* Types */ #ifdef _INCLUDE_POSIX_SOURCE # ifndef NULL # include # endif /* NULL */ #endif /* _INCLUDE_POSIX_SOURCE */ #if !defined(_INCLUDE_XOPEN_SOURCE) && !defined(_INCLUDE_XOPEN_SOURCE_EXTENDED) /* The return value on failure of the sbrk(2) system call */ #define SBRK_FAILED (void *)-1L #endif /* HP-UX supports 64-bit files on 32-bit systems */ #define _LFS64_STDIO 1 #define _LFS64_ASYNCHRONOUS_IO 1 #define _LFS_ASYNCHRONOUS_IO 1 #define _LFS_LARGEFILE 1 #define _LFS64_LARGEFILE 1 #if defined(_INCLUDE_XOPEN_SOURCE_EXTENDED) || defined(_INCLUDE_POSIX_SOURCE) # include #endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED || _INCLUDE_POSIX_SOURCE */ #ifdef _INCLUDE_HPUX_SOURCE # ifdef _KERNEL /* Structure for "utime" function moved to the unsupported section */ # else /* ! _KERNEL */ # include # endif /* ! _KERNEL */ #endif /* _INCLUDE_HPUX_SOURCE */ /* Function prototypes */ #ifndef _KERNEL #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #ifdef _INCLUDE_POSIX_SOURCE #if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ #pragma extern _exit, access, chdir, chown, close, ctermid #pragma extern dup, dup2, execl, execle, execlp, execv, execve, execvp #pragma extern fpathconf, getcwd, getgroups, getlogin #ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 #pragma extern cuserid #endif /* _INCLUDE_XOPEN_SOURCE_PRE_600 */ # ifdef _REENTRANT # pragma extern getlogin_r # endif /* _REENTRANT */ #pragma extern isatty, link # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) # pragma extern lseek # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ #pragma builtin read #pragma extern pathconf, pause, pipe, read, rmdir, setgid, setpgid #pragma extern setsid, setuid, sleep, sysconf, tcgetpgrp, tcsetpgrp #pragma extern ttyname # ifdef _REENTRANT # pragma extern ttyname_r # endif /* _REENTRANT */ #pragma builtin write #pragma extern unlink, write, alarm, fork, getuid, geteuid, getgid #pragma extern getegid, getpid, getpgrp, getppid #endif /* __ia64 && ! _LIBC */ extern void _exit __((int)); extern int access __((const char *, int)); extern int chdir __((const char *)); extern int chown __((const char *, uid_t, gid_t)); extern int close __((int)); extern char *ctermid __((char *)); #ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 extern char *cuserid __((char *)); #endif /* _INCLUDE_XOPEN_SOURCE_PRE_600 */ extern int dup __((int)); extern int dup2 __((int, int)); extern int execl __((const char *, const char *, ...)); extern int execle __((const char *, const char *, ...)); extern int execlp __((const char *, const char *, ...)); extern int execv __((const char *, char *const [])); extern int execve __((const char *, char *const [], char *const [])); extern int execvp __((const char *, char *const [])); extern long fpathconf __((int, int)); extern char *getcwd __((char *, __size_t)); extern int getgroups __((int, gid_t [])); extern char *getlogin __((void)); # ifdef _REENTRANT # ifndef _PTHREADS_DRAFT4 extern int getlogin_r __((char *, __size_t)); # else /* _PTHREADS_DRAFT4 */ extern int getlogin_r __((char *, int)); # endif /* _PTHREADS_DRAFT4 */ # endif extern int isatty __((int)); extern int link __((const char *, const char *)); # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) _LF_EXTERN off_t lseek __((int, off_t, int)); # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ extern long pathconf __((const char *, int)); extern int pause __((void)); extern int pipe __((int *)); extern ssize_t read __((int, void *, __size_t)); extern int rmdir __((const char *)); extern int setgid __((gid_t)); extern int setpgid __((pid_t, pid_t)); extern pid_t setsid __((void)); extern int setuid __((uid_t)); extern unsigned int sleep __((unsigned int)); extern long sysconf __((int)); extern pid_t tcgetpgrp __((int)); extern int tcsetpgrp __((int, pid_t)); extern char *ttyname __((int)); # ifdef _REENTRANT # ifndef _PTHREADS_DRAFT4 extern int ttyname_r __((int, char *, __size_t)); # else /* _PTHREADS_DRAFT4 */ extern int ttyname_r __((int, char *, int)); # endif /* _PTHREADS_DRAFT4 */ # endif extern int unlink __((const char *)); extern ssize_t write __((int, const void *, __size_t)); # ifdef _CLASSIC_POSIX_TYPES unsigned long alarm(); extern int fork(); extern unsigned short getuid(); extern unsigned short geteuid(); extern unsigned short getgid(); extern unsigned short getegid(); extern int getpid(); extern int getpgrp(); extern int getppid(); # else extern unsigned int alarm __((unsigned int)); extern pid_t fork __((void)); extern gid_t getegid __((void)); extern uid_t geteuid __((void)); extern gid_t getgid __((void)); extern pid_t getpgrp __((void)); extern pid_t getpid __((void)); extern pid_t getppid __((void)); extern uid_t getuid __((void)); # endif /* _CLASSIC_POSIX_TYPES */ #endif /* _INCLUDE_POSIX_SOURCE */ #ifdef _INCLUDE_POSIX2_SOURCE #if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern optarg, opterr, optind, optopt, getopt, confstr #endif /* __ia64 && ! _LIBC */ extern char *optarg; extern int opterr; extern int optind; extern int optopt; /* fnmatch() has moved to */ extern int getopt __((int, char * const [], const char *));/* was */ extern __size_t confstr __((int, char *, __size_t)); #endif /* _INCLUDE_POSIX2_SOURCE */ #ifdef _INCLUDE_POSIX1C_SOURCE # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern pthread_atfork # endif /* __ia64 && ! _LIBC */ # ifdef _PROTOTYPES extern int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); # else /* not _PROTOTYPES */ extern int pthread_atfork(); # endif /* _PROTOTYPES */ #endif /* _INCLUDE_POSIX1C_SOURCE */ #ifdef _INCLUDE_XOPEN_SOURCE # if defined(__ia64) && !defined(_LIBC) # /* pragmas needed to support -B protected */ # pragma extern crypt, encrypt, fsync, nice # ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 # pragma extern chroot, getpass # endif /* _INCLUDE_XOPEN_SOURCE_PRE_600 */ # if defined(_XPG3) || defined(_INCLUDE_HPUX_SOURCE) || defined(_SVID3) # pragma extern rename # endif /* _XPG3 || _INCLUDE_HPUX_SOURCE || _SVID3 */ # if !defined(_INCLUDE_AES_SOURCE) || defined(_INCLUDE_XOPEN_SOURCE_EXTENDED) # ifdef _BIND_LIBCALLS # pragma builtin_milli swab # endif /* _BIND_LIBCALLS */ # pragma extern swab # endif /* not _INCLUDE_AES_SOURCE || _INCLUDE_XOPEN_SOURCE_EXTENDED */ # endif /* __ia64 && ! _LIBC */ # ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 extern int chroot __((const char *)); extern char *getpass __((const char *)); # endif /* _INCLUDE_XOPEN_SOURCE_PRE_600 */ extern char *crypt __((const char *, const char *)); extern void encrypt __((char [64], int)); extern int fsync __((int)); extern int nice __((int)); # if defined(_XPG3) || defined(_INCLUDE_HPUX_SOURCE) || defined(_SVID3) # ifdef _NAMESPACE_STD namespace std { extern int rename __((const char *, const char *)); /* now in */ } using std::rename; # else /* !_NAMESPACE_STD */ extern int rename __((const char *, const char *)); /* now in */ # endif /* _NAMESPACE_STD */ # endif /* _XPG3 || _INCLUDE_HPUX_SOURCE || _SVID3 */ # if !defined(_INCLUDE_AES_SOURCE) || defined(_INCLUDE_XOPEN_SOURCE_EXTENDED) extern void swab __((const void * __restrict, void * __restrict, ssize_t)); # endif /* not _INCLUDE_AES_SOURCE || _INCLUDE_XOPEN_SOURCE_EXTENDED */ #endif /* _INCLUDE_XOPEN_SOURCE */ #ifdef _INCLUDE_AES_SOURCE # if !defined(_XPG4_EXTENDED) || defined(_INCLUDE_HPUX_SOURCE) /* Exclude from CASPEC but keep in HPUX */ # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern environ # endif /* __ia64 && ! _LIBC */ extern char **environ; # endif /* !_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE */ # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern readlink, fchown, symlink # endif /* __ia64 && ! _LIBC */ # ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED # ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 extern int readlink __((const char *, char *, __size_t)); /*XPG4_EXT, HPUX*/ # else /* _INCLUDE_XOPEN_SOURCE_600 */ extern ssize_t readlink __((const char * __restrict, char * __restrict, __size_t)); /*Unix 2003, HPUX*/ # endif /* _INCLUDE_XOPEN_SOURCE_PRE_600 */ # else /* ! _INCLUDE_XOPEN_SOURCE_EXTENDED */ extern int readlink __((const char *, char *, int)); /* AES */ # endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */ extern int fchown __((int, uid_t, gid_t)); # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern ftruncate, truncate # endif /* __ia64 && ! _LIBC */ _LF_EXTERN int ftruncate __((int, off_t)); _LF_EXTERN int truncate __((const char *, off_t)); # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ # if !defined(_XPG4_EXTENDED) || defined(_INCLUDE_HPUX_SOURCE) /* Exclude from CASPEC but keep in HPUX */ # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern setgroups # endif /* __ia64 && ! _LIBC */ extern int setgroups __((int, gid_t [])); # endif /* !_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE */ extern int symlink __((const char *, const char *)); #endif /* _INCLUDE_AES_SOURCE */ #ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED # ifdef _XPG4_EXTENDED # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern setpgrp # endif /* __ia64 && ! _LIBC */ extern pid_t setpgrp __((void)); # else /* !_XPG4_EXTENDED */ # ifndef _SVID3 # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern setpgrp # endif /* __ia64 && ! _LIBC */ # ifdef _CLASSIC_ID_TYPES extern int setpgrp(); # else /* ! _CLASSIC_ID_TYPES */ extern pid_t setpgrp __((void)); # endif /* _CLASSIC_ID_TYPES */ # endif /* ! _SVID3 */ # endif /* _XPG4_EXTENDED */ #if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern vfork #endif /* __ia64 && ! _LIBC */ # ifdef _CLASSIC_ID_TYPES extern int vfork(); # else /* not _CLASSIC_ID_TYPES */ extern pid_t vfork __((void)); # endif /* not _CLASSIC_ID_TYPES */ # if defined(_XPG4_EXTENDED) && !defined(_INCLUDE_HPUX_SOURCE) /* For CASPEC, look in stdlib.h for the _XPG4_EXTENDED definition */ /* But for _INCLUDE_HPUX_SOURCE, maintain definitions here */ # else /* !_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE*/ # ifndef _MKTEMP_DEFINED # define _MKTEMP_DEFINED # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern mkstemp, mktemp, ttyslot # endif /* __ia64 && ! _LIBC */ extern int mkstemp __((char *)); extern char *mktemp __((char *)); extern int ttyslot __((void)); # endif /*_MKTEMP_DEFINED */ # endif /* _XPG4_EXTENDED && !_INCLUDE_HPUX_SOURCE */ #if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern fchdir, gethostid, gethostname # pragma extern getpgid, getsid, getwd # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) # pragma extern lockf # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ # pragma extern lchown, setregid, setreuid, sync # pragma extern ualarm, usleep # ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 # pragma extern brk, sbrk, getdtablesize, getpagesize # endif /* _INCLUD_XOPEN_SOURCE_PRE_600 */ #endif /* __ia64 && ! _LIBC */ #ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 extern int brk __((void *)); extern int getdtablesize __((void)); extern int getpagesize __((void)); #endif /* _INCLUDE_XOPEN_SOURCE_PRE_600 */ extern int fchdir __((int)); # ifdef _XPG4_EXTENDED extern long gethostid __((void)); # else /* !_XPG4_EXTENDED */ extern int gethostid __((void)); # endif /* _XPG4_EXTENDED */ extern int gethostname __((char *, __size_t)); extern pid_t getpgid __((pid_t)); extern pid_t getsid __((pid_t)); extern char *getwd __((char *)); # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) _LF_EXTERN int lockf __((int, int, off_t)); # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ extern int lchown __((const char *, uid_t, gid_t)); # ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 # ifdef _CLASSIC_XOPEN_TYPES extern char *sbrk __((int)); # else /* not _CLASSIC_XOPEN_TYPES */ # ifdef _INCLUDE_XOPEN_SOURCE_PRE_500 extern void *sbrk __((int)); # else /* _INCLUDE_XOPEN_SOURCE_500 */ extern void *sbrk __((intptr_t)); # endif /* _INCLUDE_XOPEN_SOURCE_PRE_500 */ # endif /* not _CLASSIC_XOPEN_TYPES */ # endif /* _INCLUDE_XOPEN_SOURCE_PRE_600 */ extern int setregid __((gid_t, gid_t)); extern int setreuid __((uid_t, uid_t)); extern void sync __((void)); # ifdef _XPG4_EXTENDED extern useconds_t ualarm __((useconds_t, useconds_t)); extern int usleep __((useconds_t)); # else /* !_XPG4_EXTENDED */ extern unsigned int ualarm __((unsigned int, unsigned int)); extern int usleep __((unsigned int)); # endif /* _XPG4_EXTENDED */ #endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */ #if defined(_INCLUDE_XOPEN_SOURCE_500) # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern fdatasync # if !defined(_APP32_64BIT_OFF_T) # pragma extern pread, pwrite # endif /* !_APP32_64BIT_OFF_T */ # endif /* __ia64 && ! _LIBC */ # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) _LF_EXTERN ssize_t pread __((int, void *, size_t, off_t)); _LF_EXTERN ssize_t pwrite __((int, const void *, size_t, off_t)); # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ extern int fdatasync __((int)); # if defined(_LARGEFILE64_SOURCE) # ifdef __LP64__ # define pread64 pread # define pwrite64 pwrite # else /* __LP64__ */ # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern pread64, pwrite64 # endif /* __ia64 && ! _LIBC */ extern ssize_t pread64 __((int, void *, size_t, off64_t)); extern ssize_t pwrite64 __((int, const void *, size_t, off64_t)); # endif /* __LP64__ */ # endif /* _LARGEFILE64_SOURCE */ #endif /* _INCLUDE_XOPEN_SOURCE_500 */ #ifdef _INCLUDE_XOPEN_SOURCE_600 # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern setegid, seteuid # endif /* __ia64 && ! _LIBC */ extern int setegid __((gid_t)); extern int seteuid __((uid_t)); #endif /* _INCLUDE_XOPEN_SOURCE_600 */ #ifdef _INCLUDE_HPUX_SOURCE # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern endusershell, fsctl, getcdf, gethcwd, getpgrp2 # pragma extern getusershell, getresgid, getresuid, hidecdf, initgroups # ifndef _XPG4_EXTENDED # pragma extern ioctl # endif /* !_XPG4_EXTENDED */ # pragma extern logname, lsync # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) # pragma extern prealloc # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ # pragma extern sethostname, setpgrp2, setresgid, setresuid # pragma extern setusershell, sgetl, sputl, swapon, swapoff, ttyname # ifndef __STDC_32_MODE__ # pragma extern __sysconfx # endif /* __STDC_32_MODE__ */ # ifdef _REENTRANT # ifndef _PTHREADS_DRAFT4 # pragma extern ttyname_r # else # pragma extern ttyname_r, endusershell_r, getusershell_r # pragma extern setusershell_r # endif /* _PTHREADS_DRAFT4 */ # endif /* _REENTRANT */ # pragma extern set_userthreadid # endif /* __ia64 && ! _LIBC */ extern void endusershell __((void)); extern int fsctl __((int, int, void *, __size_t)); extern char *getcdf __((const char *, char *, __size_t)); extern char *gethcwd __((char *, __size_t)); extern int getpgrp2 __((pid_t)); extern char *getusershell __((void)); extern int getresgid __((gid_t *, gid_t *, gid_t *)); extern int getresuid __((uid_t *, uid_t *, uid_t *)); extern char *hidecdf __((const char *, char *, __size_t)); extern int initgroups __((const char *, gid_t)); # ifndef _XPG4_EXTENDED extern int ioctl __((int, int, ...)); # endif /* !_XPG4_EXTENDED */ extern char *logname __((void)); extern void lsync __((void)); # if !defined(__cplusplus) || !defined(_APP32_64BIT_OFF_T) _LF_EXTERN int prealloc __((int, off_t)); # endif /* !__cplusplus || !_APP32_64BIT_OFF_T */ extern int sethostname __((const char *, __size_t)); extern int setpgrp2 __((pid_t, pid_t)); extern int setresgid __((gid_t, gid_t, gid_t)); extern int setresuid __((uid_t, uid_t, uid_t)); extern void setusershell __((void)); extern long sgetl __((const char *)); extern void sputl __((long, char *)); extern int swapon __((const char *, ...)); extern int swapoff __((const char *, int)); extern char *ttyname __((int)); #ifndef __STDC_32_MODE__ extern int64_t __sysconfx __((int, int)); #endif /* __STDC_32_MODE__ */ # ifdef _REENTRANT # ifndef _PTHREADS_DRAFT4 extern int ttyname_r __((int, char *, __size_t)); # else /* _PTHREADS_DRAFT4 */ extern int ttyname_r __((int, char *, int)); extern void endusershell_r __((char **)); extern char *getusershell_r __((char **)); extern void setusershell_r __((char **)); # endif /* _PTHREADS_DRAFT4 */ # endif extern int set_userthreadid __((int)); #if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # ifdef _SVID3 # pragma extern gettxt # else # pragma extern setpgrp3 # endif /* _SVID3 */ #endif /* __ia64 && ! _LIBC */ # ifdef _CLASSIC_ID_TYPES # ifdef _SVID3 extern char *gettxt(); # endif /* _SVID3 */ # ifndef _SVID3 extern int setpgrp3(); # endif /* _SVID3 */ # else /* not _CLASSIC_ID_TYPES */ # ifdef _SVID3 extern char *gettxt __((const char *, const char *)); # endif /* _SVID3 */ # ifndef _SVID3 extern pid_t setpgrp3 __((void)); # endif /* _SVID3 */ # endif /* not _CLASSIC_ID_TYPES */ #endif /* _INCLUDE_HPUX_SOURCE */ # if defined(_LARGEFILE64_SOURCE) # ifdef __LP64__ # define prealloc64 prealloc # define lockf64 lockf # define truncate64 truncate # define ftruncate64 ftruncate # define lseek64 lseek # else /* __LP64__ */ # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern prealloc64, lockf64, truncate64, ftruncate64 # pragma extern lseek64 # endif /* __ia64 && ! _LIBC */ extern int prealloc64 __((int, off64_t)); extern int lockf64 __((int, int, off64_t)); extern int truncate64 __((const char *, off64_t)); extern int ftruncate64 __((int, off64_t)); extern off64_t lseek64 __((int, off64_t, int)); # endif /* __LP64 */ # endif /* _LARGEFILE64_SOURCE */ # ifdef _APP32_64BIT_OFF_T # if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ # pragma extern __prealloc64, __lockf64, __truncate64, __ftruncate64 # pragma extern __lseek64, __pread64, __pwrite64 # endif /* __ia64 && ! _LIBC */ extern int __prealloc64 __((int, off_t)); extern int __lockf64 __((int, int, off_t)); extern int __truncate64 __((const char *, off_t)); extern int __ftruncate64 __((int, off_t)); extern off64_t __lseek64 __((int, off_t, int)); extern ssize_t __pread64 __((int, void *, size_t, off64_t)); extern ssize_t __pwrite64 __((int, const void *, size_t, off64_t)); # ifndef __cplusplus static int truncate(a,b) __const char *a; off_t b; { return __truncate64(a,b); } static int prealloc(a,b) int a; off_t b; { return __prealloc64(a,b); } static int lockf(a,b,c) int a, b; off_t c; { return __lockf64(a,b,c); } static int ftruncate(a,b) int a; off_t b; { return __ftruncate64(a,b); } static off_t lseek(a,b,c) int a, c; off_t b; { return __lseek64(a,b,c); } static ssize_t pread(a,b,c,d) int a; void *b; size_t c; off64_t d; { return __pread64(a,b,c,d); } static ssize_t pwrite(a,b,c,d) int a; const void *b; size_t c; off64_t d; { return __pwrite64(a,b,c,d); } # endif /* __cplusplus */ # endif /* _APP32_64BIT_OFF_T */ #ifdef __cplusplus } #endif /* __cplusplus */ #if defined(__cplusplus) && defined(_APP32_64BIT_OFF_T) inline int prealloc __((int, off_t)); inline off_t lseek __((int, off_t, int)); inline int ftruncate __((int, off_t)); inline int truncate __((const char *, off_t)); inline int lockf __((int, int, off_t)); inline ssize_t pread __((int, void *, size_t, off64_t)); inline ssize_t pwrite __((int, const void *, size_t, off64_t)); inline int truncate(const char *a, off_t b) { return __truncate64(a,b); } inline int prealloc(int a, off_t b) { return __prealloc64(a,b); } inline int lockf(int a, int b, off_t c) { return __lockf64(a,b,c); } inline int ftruncate(int a, off_t b) { return __ftruncate64(a,b); } inline off_t lseek(int a, off_t b, int c) { return __lseek64(a,b,c); } inline ssize_t pread(int a, void *b, size_t c, off64_t d) { return __pread64(a,b,c,d); } inline ssize_t pwrite(int a, const void *b, size_t c, off64_t d) { return __pwrite64(a,b,c,d); } # endif /* __cplusplus && _APP32_64BIT_OFF_T */ #endif /* not _KERNEL */ /* Symbolic constants */ #if defined(_INCLUDE_POSIX_SOURCE) || defined(_INCLUDE_POSIX2_SOURCE) /* Symbolic constants for the access() function */ /* These must match the values found in */ # ifndef R_OK # define R_OK 4 /* Test for read permission */ # define W_OK 2 /* Test for write permission */ # define X_OK 1 /* Test for execute (search) permission */ # define F_OK 0 /* Test for existence of file */ # endif /* R_OK */ /* Symbolic constants for the lseek() function */ # ifndef SEEK_SET # define SEEK_SET 0 /* Set file pointer to "offset" */ # define SEEK_CUR 1 /* Set file pointer to current plus "offset" */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ # endif /* SEEK_SET */ /* Versions of POSIX.1 we support */ # define _POSIX1_VERSION_88 198808L /* We support POSIX.1-1988 */ # define _POSIX1_VERSION_90 199009L /* We support POSIX.1-1990 */ # define _POSIX1_VERSION_93 199309L /* We support POSIX.1b-1993 */ # define _POSIX1_VERSION_95 199506L /* We support POSIX.1-1995 */ # define _POSIX1_VERSION_01 200112L /* We support POSIX.1-2001 */ # ifdef _POSIX1_1988 # define _POSIX_VERSION _POSIX1_VERSION_88 # else /* not _POSIX1_1988 */ # if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 199309L) # define _POSIX_VERSION _POSIX1_VERSION_90 # else /* _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 199309L */ # if _POSIX_C_SOURCE < 199506L # define _POSIX_VERSION _POSIX1_VERSION_93 # else /* _POSIX_C_SOURCE >= 199506L */ # if _POSIX_C_SOURCE < 200112L # define _POSIX_VERSION _POSIX1_VERSION_95 # else /* _POSIX_C_SOURCE >= 200112L */ # define _POSIX_VERSION _POSIX1_VERSION_01 # endif /* _POSIX_C_SOURCE < 200112L */ # endif /* _POSIX_C_SOURCE < 199506L */ # endif /* _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 199309L */ # endif /* not _POSIX1_1988 */ # define STDIN_FILENO 0 # define STDOUT_FILENO 1 # define STDERR_FILENO 2 /* Compile-time symbolic constants */ # define _POSIX_SAVED_IDS 1 /* If defined, each process has a * saved set-user-ID and a saved * set_group-ID */ # define _POSIX_JOB_CONTROL 2 /* If defined, it indicates that the implementation supports job control */ # define _POSIX_VDISABLE 0xff /* Character which disables local TTY control character functions */ /* All the following macros are defined as 1 for Unix95 environment and 200112 for others */ #if defined(_INCLUDE_XOPEN_SOURCE_600) # define _POSIX_PRIORITY_SCHEDULING 200112L /* If defined, POSIX.1b Priority Scheduler extensions are supported */ # define _POSIX_TIMERS 200112L /* If defined, POSIX.1b Clocks & Timers extensions are supported */ # define _POSIX_SEMAPHORES 200112L /* If defined, POSIX.1b Semaphores are supported */ # define _POSIX_SYNCHRONIZED_IO 200112L /* If defined, POSIX.1b Synchronized IO option is supported */ # define _POSIX_FSYNC 200112L /* If defined, POSIX.1b File Synchronization option is supported. Must be defined if _POSIX_SYNCHRONIZED_IO is */ # define _POSIX_ASYNCHRONOUS_IO 200112L /* If defined, POSIX.1b Asynchronous IO option is supported */ # define _POSIX_MEMLOCK 200112L /* If defined, POSIX.1b mlockall and munlockall are supported */ # define _POSIX_MEMLOCK_RANGE 200112L /* If defined, POSIX.1b mlock and munlock are supported */ # define _POSIX_SHARED_MEMORY_OBJECTS 200112L /* If defined, POSIX.1b shm_open and shm_unlink are supported */ # define _POSIX_REALTIME_SIGNALS 200112L /* If defined, POSIX.1b Realtime Signals extension option is supported */ # define _POSIX_MESSAGE_PASSING 200112L /* if defined, POSIX.1b Message Passing extensions are supported */ # define _POSIX_THREAD_ATTR_STACKADDR 200112L /* if defined, thread stack address attribute option is supported */ # define _POSIX_THREAD_ATTR_STACKSIZE 200112L /* if defined, thread stack size attribute option is supported */ # define _POSIX_THREAD_PROCESS_SHARED 200112L /* if defined, process-shared synchronization is supported */ # define _POSIX_THREAD_SAFE_FUNCTIONS 200112L /* if defined, thread-safe functions are supported */ # define _POSIX_THREADS 200112L /* Base pthread functions are supported */ # define _POSIX_BARRIERS -1 # define _POSIX_CLOCK_SELECTION -1 # define _POSIX_IPV6 200112L # define _POSIX_MONOTONIC_CLOCK -1 # define _POSIX_RAW_SOCKETS -1 # define _POSIX_READER_WRITER_LOCKS 200112L # define _POSIX_SPAWN -1 # define _POSIX_SPIN_LOCKS -1 # define _POSIX_TIMEOUTS -1 # define _POSIX_ADVISORY_INFO -1 # define _POSIX_CPUTIME -1 # define _POSIX_THREAD_CPUTIME -1 # define _POSIX_MAPPED_FILES 200112L # define _POSIX_MEMORY_PROTECTION 200112L # define _POSIX_TYPED_MEMORY_OBJECTS -1 # define _POSIX_PRIORITIZED_IO -1 # define _POSIX_SPORADIC_SERVER -1 # define _POSIX_THREAD_PRIO_PROTECT -1 # define _POSIX_THREAD_PRIO_INHERIT -1 # define _POSIX_THREAD_SPORADIC_SERVER -1 /* Constants for tracing option */ # define _POSIX_TRACE -1 # define _POSIX_TRACE_EVENT_FILTER -1 # define _POSIX_TRACE_INHERIT -1 # define _POSIX_TRACE_LOG -1 /* Constants for the Batch Environment Services and Utilities option */ # define _POSIX2_PBS -1 # define _POSIX2_PBS_ACCOUNTING -1 # define _POSIX2_PBS_CHECKPOINT -1 # define _POSIX2_PBS_LOCATE -1 # define _POSIX2_PBS_MESSAGE -1 # define _POSIX2_PBS_TRACK -1 # define _POSIX_REGEXP 1 /* Supports POSIX Regular Expressions */ # define _POSIX_SHELL 1 /* Supports POSIX shell */ #else # define _POSIX_PRIORITY_SCHEDULING 1 /* If defined, POSIX.1b Priority Scheduler extensions are supported */ # define _POSIX_TIMERS 1 /* If defined, POSIX.1b Clocks & Timers extensions are supported */ # define _POSIX_SEMAPHORES 1 /* If defined, POSIX.1b Semaphores are supported */ # define _POSIX_SYNCHRONIZED_IO 1 /* If defined, POSIX.1b Synchronized IO option is supported */ # define _POSIX_FSYNC 1 /* If defined, POSIX.1b File Synchronization option is supported. Must be defined if _POSIX_SYNCHRONIZED_IO is */ # define _POSIX_ASYNCHRONOUS_IO 1 /* If defined, POSIX.1b Asynchronous IO option is supported */ # define _POSIX_MEMLOCK 1 /* If defined, POSIX.1b mlockall and munlockall are supported */ # define _POSIX_MEMLOCK_RANGE 1 /* If defined, POSIX.1b mlock and munlock are supported */ # define _POSIX_SHARED_MEMORY_OBJECTS 1 /* If defined, POSIX.1b shm_open and shm_unlink are supported */ # define _POSIX_REALTIME_SIGNALS 1 /* If defined, POSIX.1b Realtime Signals extension option is supported */ # define _POSIX_MESSAGE_PASSING 1 /* if defined, POSIX.1b Message Passing extensions are supported */ /* Added for POSIX.1c (threads extensions) */ # define _POSIX_THREAD_ATTR_STACKADDR 1 /* if defined, thread stack address attribute option is supported */ # define _POSIX_THREAD_ATTR_STACKSIZE 1 /* if defined, thread stack size attribute option is supported */ # define _POSIX_THREAD_PROCESS_SHARED 1 /* if defined, process-shared synchronization is supported */ # define _POSIX_THREAD_SAFE_FUNCTIONS 1 /* if defined, thread-safe functions are supported */ # define _POSIX_THREADS 1 /* Base pthread functions are supported */ #endif # ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 # define _POSIX_THREAD_PRIORITY_SCHEDULING 1 /* thread execution scheduling is supported */ # else # define _POSIX_THREAD_PRIORITY_SCHEDULING -1 # endif /*_INCLUDE_XOPEN_SOURCE_PRE_600 */ /* _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC and _POSIX_SYNC_IO are not * defined here since they are pathname-dependent. Use the pathconf() or * fpathconf() functions to query for these values. */ /* Symbolic constants for sysconf() variables defined by POSIX.1-1988: 0-7 */ # define _SC_ARG_MAX 0 /* ARG_MAX: Max length of argument to exec() including environment data */ # define _SC_CHILD_MAX 1 /* CHILD_MAX: Max # of processes per userid */ # define _SC_CLK_TCK 2 /* Number of clock ticks per second */ # define _SC_NGROUPS_MAX 3 /* NGROUPS_MAX: Max # of simultaneous supplementary group IDs per process */ # define _SC_OPEN_MAX 4 /* OPEN_MAX: Max # of files that one process can have open at any one time */ # define _SC_JOB_CONTROL 5 /* _POSIX_JOB_CONTROL: 1 iff supported */ # define _SC_SAVED_IDS 6 /* _POSIX_SAVED_IDS: 1 iff supported */ # define _SC_1_VERSION_88 7 /* _POSIX_VERSION: Date of POSIX.1-1988 */ /* Symbolic constants for sysconf() variables added by POSIX.1-1990: 100-199 */ # define _SC_STREAM_MAX 100 /* STREAM_MAX: Max # of open stdio FILEs */ # define _SC_TZNAME_MAX 101 /* TZNAME_MAX: Max length of timezone name */ # define _SC_1_VERSION_90 102 /* _POSIX_VERSION: Date of POSIX.1-1990 */ # define _SC_1_VERSION_93 103 /* _POSIX_VERSION: Date of POSIX.1b-1993 */ # define _SC_1_VERSION_95 104 # define _SC_1_VERSION_01 105 /* Pick appropriate value for _SC_VERSION symbolic constant */ # if (_POSIX_VERSION == _POSIX1_VERSION_88) # define _SC_VERSION _SC_1_VERSION_88 # else # if (_POSIX_VERSION == _POSIX1_VERSION_90) # define _SC_VERSION _SC_1_VERSION_90 # else # if (_POSIX_VERSION == _POSIX1_VERSION_93) # define _SC_VERSION _SC_1_VERSION_93 # else # if (_POSIX_VERSION == _POSIX1_VERSION_95) # define _SC_VERSION _SC_1_VERSION_95 # else # define _SC_VERSION _SC_1_VERSION_01 # endif # endif # endif # endif /* Symbolic constants for sysconf() variables added by POSIX.2: 200-299 */ # define _SC_BC_BASE_MAX 200 /* largest ibase & obase for bc */ # define _SC_BC_DIM_MAX 201 /* max array elements for bc */ # define _SC_BC_SCALE_MAX 202 /* max scale value for bc */ # define _SC_EXPR_NEST_MAX 204 /* max nesting of (...) for expr */ # define _SC_LINE_MAX 205 /* max length in bytes of input line */ # define _SC_RE_DUP_MAX 207 /* max regular expressions permitted */ # define _SC_2_VERSION 211 /* Current version of POSIX.2 */ # define _SC_2_C_BIND 212 /* C Language Bindings Option */ # define _SC_2_C_DEV 213 /* C Development Utilities Option */ # define _SC_2_FORT_DEV 214 /* FORTRAN Dev. Utilities Option */ # define _SC_2_SW_DEV 215 /* Software Dev. Utilities Option */ # define _SC_2_C_VERSION 216 /* version of POSIX.2 CLB supported */ # define _SC_2_CHAR_TERM 217 /* termianls exist where vi works */ # define _SC_2_FORT_RUN 218 /* FORTRAN Runtime Utilities Option */ # define _SC_2_LOCALEDEF 219 /* localedef(1M) can create locales */ # define _SC_2_UPE 220 /* User Portability Utilities Option */ # define _SC_BC_STRING_MAX 221 /* max scale value for bc */ # define _SC_COLL_WEIGHTS_MAX 222 /* max collation weights in locale */ /* The following are obsolete and will be removed in a future release */ # define _SC_COLL_ELEM_MAX 203 /* max bytes in collation element */ # define _SC_PASTE_FILES_MAX 206 /* max file operands for paste */ # define _SC_SED_PATTERN_MAX 208 /* max bytes of pattern space for sed */ # define _SC_SENDTO_MAX 209 /* max bytes of message for sendto */ # define _SC_SORT_LINE_MAX 210 /* max bytes of input line for sort */ /* Symbolic constants for sysconf() variables added by POSIX.4: 400-499 */ # define _SC_TIMER_MAX 400 /* max number of timers per process */ # define _SC_FSYNC 401 /* yes: POSIX.1b File Synchronization */ # define _SC_SYNCHRONIZED_IO 402 /* yes: POSIX.1b Synchronized IO */ # define _SC_PRIORITY_SCHEDULING 403 /* Priority scheduling supported */ # define _SC_TIMERS 404 /* POSIX.1b Clocks and Timers supported*/ # define _SC_DELAYTIMER_MAX 405 /* max timer overrun count */ /* these following POSIX.4 constants represent unsupported functionality */ # define _SC_ASYNCHRONOUS_IO 406 /* POSIX.1b asynchronous I/O supported */ # define _SC_MAPPED_FILES 407 /* POSIX.1b mapped files supported */ # define _SC_MEMLOCK 408 /* POSIX.1b memory locking supported */ # define _SC_MEMLOCK_RANGE 409 /* POSIX.1b memory range locking */ # define _SC_MEMORY_PROTECTION 410 /* POSIX.1b memory protection supported*/ # define _SC_MESSAGE_PASSING 411 /* POSIX.1b message queues supported */ # define _SC_PRIORITIZED_IO 412 /* POSIX.1b prioritized I/O supported */ # define _SC_REALTIME_SIGNALS 413 /* POSIX.1b realtime signals supported */ # define _SC_SEMAPHORES 414 /* POSIX.1b semaphores supported */ # define _SC_SHARED_MEMORY_OBJECTS 415 /* POSIX.1b shared memory supported */ # define _SC_AIO_LISTIO_MAX 416 /* max I/O ops in a list I/O call */ # define _SC_AIO_MAX 417 /* max outstanding async I/O ops */ # define _SC_AIO_PRIO_DELTA_MAX 418 /* max aio/scheduling prio delta */ # define _SC_MQ_OPEN_MAX 419 /* max open msg queues per process */ # define _SC_MQ_PRIO_MAX 420 /* max different message priorities */ # define _SC_RTSIG_MAX 421 /* # of realtime signals */ # define _SC_SEM_NSEMS_MAX 422 /* max open semaphores per process */ # define _SC_SEM_VALUE_MAX 423 /* max semaphore value */ # define _SC_SIGQUEUE_MAX 424 /* max queued signals pending/sender */ /* Symbolic constants for sysconf() variables added by POSIX.1c (threads) */ # define _SC_THREAD_DESTRUCTOR_ITERATIONS 430 /* PTHREAD_DESTRUCTOR_ITERATIONS: max trys to destroy thread- specific data on thrd exit */ # define _SC_THREAD_KEYS_MAX 431 /* PTHREAD_KEYS_MAX: max num data keys per proc */ # define _SC_THREAD_STACK_MIN 432 /* PTHREAD_STACK_MIN: min size of thread stack */ # define _SC_THREAD_THREADS_MAX 433 /* PTHREAD_THREADS_MAX: max threads per proc */ # define _SC_THREADS 434 /* _POSIX_THREADS: 1 iff POSIX threads supported */ # define _SC_THREAD_ATTR_STACKADDR 435 /* _POSIX_THREAD_ATTR_STACKADDR: 1 iff stack address attribute supported */ # define _SC_THREAD_ATTR_STACKSIZE 436 /* _POSIX_THREAD_ATTR_STACKSIZE: 1 iff stack size attribute supported */ # define _SC_THREAD_PRIORITY_SCHEDULING 437 /*_POSIX_THREAD_PRIORITY_SCHEDULING 1 iff thread execution scheduling supported */ # define _SC_THREAD_PRIO_INHERIT 438 /* _POSIX_THREAD_PRIO_INHERIT: 1 iff priority inheritance is supported */ # define _SC_THREAD_PRIO_PROTECT 439 /* _POSIX_THREAD_PRIO_PROTECT: 1 iff priority protection is supported */ # define _SC_THREAD_PROCESS_SHARED 440 /* _POSIX_THREAD_PROCESS_SHARED: 1 iff process-shared synchronization is supported */ # define _SC_THREAD_SAFE_FUNCTIONS 441 /* _POSIX_THREAD_SAFE_FUNCTIONS: 1 iff thread-safe functions are supported */ # define _SC_GETGR_R_SIZE_MAX 442 /* Maximum size of getgrgid_r() and and getgrnam_r() data buffers */ # define _SC_GETPW_R_SIZE_MAX 443 /* Maximum size of getpwuid_r() and and getpwnam_r() data buffers */ # define _SC_LOGIN_NAME_MAX 444 /* Value of LOGIN_NAME_MAX */ # define _SC_TTY_NAME_MAX 445 /* Value of TTY_NAME_MAX */ # define _SC_CACHE_LINE_SIZE 446 /* Size of Cache line in bytes*/ # define _SC_I_CACHE_SIZE 447 /* Size of I-Cache in bytes */ # define _SC_D_CACHE_SIZE 448 /* Size of D-Cache in bytes */ # define _SC_I_CACHE_LINE_SIZE 449 /* Size of I-Cache line in bytes */ # define _SC_D_CACHE_LINE_SIZE 450 /* Size of D-Cache line in bytes */ # define _SC_I_CACHE_WT 451 /* 0 means write-back I-Cache, 1 means write-through I-Cache */ # define _SC_D_CACHE_WT 452 /* 0 for write-back D-Cache, 1 for write-through D-Cache */ # define _SC_I_CACHE_CST 453 /* 0 means I-Cache is not issuing coherent operations, 1 means I-Cache is issuing coherent operations */ # define _SC_D_CACHE_CST 454 /* 0 means D-Cache is not issuing cohere operations, 1 means D-Cache is issuing coherent operations */ # define _SC_I_CACHE_F_SEL 455 /* tells software how to flush a range of address from the I_cache and has following meaning: 0 - Both FIC and FDC must be used 1 - Only need FDC 2 - Only need FIC 3 - Either FIC or FDC may be used */ # define _SC_D_CACHE_F_SEL 456 /* tells software how to flush a range of address from the D_cache and has following meaning: 0 - Both FIC and FDC must be used 1 - Only need FDC 2 - Only need FIC 3 - Either FIC or FDC may be used*/ # define _SC_I_CACHE_LOOP 457 /* intended for set-associative caches. It is used to force the FDCE instruction to be executed multiple times with the same address. Note that when it is 1, software can optimize out the inner loop of the C routine. */ # define _SC_D_CACHE_LOOP 458 /* same as _SC_I_CACHE_LOOP */ /* Symbolic constants for sysconf() variables added by POSIX.1,2003: 500-599 */ # define _SC_2_PBS 500 # define _SC_2_PBS_ACCOUNTING 501 # define _SC_2_PBS_CHECKPOINT 502 # define _SC_2_PBS_LOCATE 503 # define _SC_2_PBS_MESSAGE 504 # define _SC_2_PBS_TRACK 505 # define _SC_REGEXP 506 # define _SC_SHELL 507 # define _SC_HOST_NAME_MAX 508 # define _SC_SYMLOOP_MAX 509 # define _SC_ADVISORY_INFO 510 # define _SC_BARRIERS 511 # define _SC_CLOCK_SELECTION 512 # define _SC_CPUTIME 513 # define _SC_IPV6 515 # define _SC_MONOTONIC_CLOCK 516 # define _SC_RAW_SOCKETS 518 # define _SC_READER_WRITER_LOCKS 519 # define _SC_SPAWN 520 # define _SC_SPIN_LOCKS 521 # define _SC_SPORADIC_SERVER 522 # define _SC_THREAD_CPUTIME 523 # define _SC_THREAD_SPORADIC_SERVER 524 # define _SC_TIMEOUTS 525 # define _SC_TRACE 526 # define _SC_TRACE_EVENT_FILTER 527 # define _SC_TRACE_INHERIT 528 # define _SC_TRACE_LOG 529 # define _SC_TYPED_MEMORY_OBJECTS 530 # define _SC_XOPEN_REALTIME 531 # define _SC_XOPEN_REALTIME_THREADS 532 /* Symbolic constants for sysconf() variables defined by X/Open: 2000-2999 */ # define _SC_CLOCKS_PER_SEC 2000 /* CLOCKS_PER_SEC: Units/sec of clock() */ # define _SC_XPG3_VERSION 8 /* 3 */ # define _SC_XPG4_VERSION 2001 /* 4 */ # define _SC_PASS_MAX 9 /* Max # of bytes in password */ # define _SC_XOPEN_CRYPT 2002 /* Encryption feature group supported */ # define _SC_XOPEN_ENH_I18N 2003 /* Enhanced I18N feature group " */ # define _SC_XOPEN_SHM 2004 /* Shared memory feature group " */ # ifdef _XPG3 # define _SC_XOPEN_VERSION _SC_XPG3_VERSION /* Issue of XPG supported */ # else /* not _XPG3 */ # define _SC_XOPEN_VERSION _SC_XPG4_VERSION /* Issue of XPG supported */ # endif /* not _XPG3 */ /* Symbolic constants for sysconf() variables defined by XPG5 */ # define _SC_XBS5_ILP32_OFF32 2005 /* 32-bit int, long, pointer and off_t */ # define _SC_XBS5_ILP32_OFFBIG 2006 /* 32-bit int, long, pointer, and 64-bit off_t */ # define _SC_XBS5_LP64_OFF64 2007 /* 32-bit int, 64-bit long, pointer, off_t */ # define _SC_XBS5_LPBIG_OFFBIG 2008 /* at least 32-bit int, at least 64-bit long, pointer, off_t */ /* Symbolic constants for sysconf() variables defined for UNIX 2003 */ # define _SC_XOPEN_STREAMS 2009 # define _SC_XOPEN_LEGACY 2010 # define _SC_V6_ILP32_OFF32 _SC_XBS5_ILP32_OFF32 # define _SC_V6_ILP32_OFFBIG _SC_XBS5_ILP32_OFFBIG # define _SC_V6_LP64_OFF64 _SC_XBS5_LP64_OFF64 # define _SC_V6_LPBIG_OFFBIG _SC_XBS5_LPBIG_OFFBIG # define _SC_SS_REPL_MAX 2011 # define _SC_TRACE_EVENT_NAME_MAX 2012 # define _SC_TRACE_NAME_MAX 2013 # define _SC_TRACE_SYS_MAX 2014 # define _SC_TRACE_USER_EVENT_MAX 2015 /* Symbolic constants for sysconf() variables defined by OSF: 3000-3999 */ # define _SC_AES_OS_VERSION 3000 /* AES_OS_VERSION: Version of OSF/AES OS */ # define _SC_PAGE_SIZE 3001 /* PAGE_SIZE: Software page size */ # define _SC_ATEXIT_MAX 3002 /* ATEXIT_MAX: Max # of atexit() funcs */ /* Symbolic constants for sysconf() variables defined by SVID/3 */ # define _SC_PAGESIZE _SC_PAGE_SIZE /* Symbolic constants for sysconf() variables defined by HP-UX: 10000-19999 */ # define _SC_SECURITY_CLASS 10000 /* SECURITY_CLASS: DoD security level */ # define _SC_CPU_VERSION 10001 /* CPU type this program is running on */ # define _SC_IO_TYPE 10002 /* I/O system type this system supports */ # define _SC_MSEM_LOCKID 10003 /* msemaphore lock unique identifier */ # define _SC_MCAS_OFFSET 10004 /* Offset on gateway page of mcas_util() */ # define _SC_CPU_KEYBITS1 10005 /* hardware key bit information */ # define _SC_PROC_RSRC_MGR 10006 /* Process Resource Manager is configured */ # define _SC_SOFTPOWER 10007 /* Soft Power Switch Hardware exists */ # define _SC_EXEC_INTERPRETER_LENGTH 10008 /* for '#!' scripts, inclusive */ # define _SC_SLVM_MAXNODES 10009 /* Max num of nodes supported by SLVM */ # define _SC_SIGRTMIN 10010 /* First POSIX.4 Realtime Signal */ # define _SC_SIGRTMAX 10011 /* Last POSIX.4 Realtime Signal */ # define _SC_LIBC_VERSION 10012 /* Libc version */ # define _SC_KERNEL_BITS 10013 /* running kernel is 32 or 64bit */ # define _SC_KERNEL_IS_BIGENDIAN 10014 /* indicates kernel "big-endian" */ # define _SC_HW_32_64_CAPABLE 10015 /* indicates whether h/w is capable of running 32bit and/or 64bit OS */ # define _SC_INT_MIN 10016 /* minimum value an object of type int can hold */ # define _SC_INT_MAX 10017 /* maximum value an object of type int can hold */ # define _SC_LONG_MIN 10018 /* minimum value an object of type long can hold */ # define _SC_LONG_MAX 10019 /* maximum value an object of type long can hold */ # define _SC_SSIZE_MAX 10020 /* maximum value an object of type ssize_t can hold */ # define _SC_WORD_BIT 10021 /* number of bits in a word */ # define _SC_LONG_BIT 10022 /* number of bits in a long */ # define _SC_CPU_CHIP_TYPE 10023 /* encoded CPU chip type from PDC */ # define _SC_CCNUMA_PM 10024 /* CCNUMA Programming Model Exts Active */ # define _SC_CCNUMA_SUPPORT 10025 /* CCNUMA supported platform */ # define _SC_IPMI_INTERFACE 10026 /* ipmi interface type */ # define _SC_SPROFIL_MAX 10027 /* max number of profiled regions in sprofil system call */ # define _SC_NUM_CPUS 10028 /* number of cpus in use */ # define _SC_MEM_MBYTES 10029 /* Mbytes of memory */ /* reserve 10030 for private use */ # define _SC_PSET_RTE_SUPPORT 10031 /* RTE PSets Supported */ # define _SC_RTE_SUPPORT 10032 /* RTE Supported */ # define _SC_HG_SUPPORT 10034 /* HG (Project Mercury) supported */ # define _SC_INIT_PROCESS_ID 10035 /* PID of the INIT process */ # define _SC_SWAPPER_PROCESS_ID 10036 /* PID of the SWAPPER process */ # define _SC_VHAND_PROCESS_ID 10037 /* PID of the VHAND process */ # define _SC_HOST_NAME_MAX_2 10038 /* duplicate of _SC_HOST_NAME_MAX, for compatibility with 11.23 0409 */ # define _SC_SCALABLE_INIT 10039 /* Scalable init code is present */ # define _SC_HT_CAPABLE 10040 /* The hardware is capable of hyperthread */ # define _SC_HT_ENABLED 10041 /* The hardware is hyperthread enabled */ /* Macro to check if numeric username is enabled */ # define _SC_EXTENDED_LOGIN_NAME 10042 # define _SC_MINCORE 10043 /* mincore() system call support */ # define _SC_CELL_OLA_SUPPORT 11001 /* OS supports Online Cell Addition */ # define _SC_CELL_OLD_SUPPORT 11002 /* OS supports Online Cell Deletion */ # define _SC_CPU_OLA_SUPPORT 11003 /* OS supports Online CPU Addition */ # define _SC_CPU_OLD_SUPPORT 11004 /* OS supports Online CPU Deletion */ # define _SC_MEM_OLA_SUPPORT 11005 /* OS supports Online Memory Addition */ # define _SC_MEM_OLD_SUPPORT 11006 /* OS supports Online Memory Deletion */ # define _SC_LORA_MODE 11007 /* NUMA mode for the partition */ # define _SC_P2P 19500 /* p2p bcopy feature */ /* value(s) returned by sysconf(_SC_P2P) */ # define _SC_P2P_ENABLED 0x1 # define _SC_P2P_DATA_MOVER 0x2 # define _SC_GANG_SCHED 19501 /* gang scheduler feature */ # define _SC_PSET_SUPPORT 19502 /* Processor Set functionality support */ /* 20000-20999 reserved for private use */ /* Symbolic constants for pathconf() defined by POSIX.1: 0-99 */ # define _PC_LINK_MAX 0 /* LINK_MAX: Max # of links to a single file */ # define _PC_MAX_CANON 1 /* MAX_CANON: Max # of bytes in a terminal canonical input line */ # define _PC_MAX_INPUT 2 /* MAX_INPUT: Max # of bytes allowed in a terminal input queue */ # define _PC_NAME_MAX 3 /* NAME_MAX: Max # of bytes in a filename */ # define _PC_PATH_MAX 4 /* PATH_MAX: Max # of bytes in a pathname */ # define _PC_PIPE_BUF 5 /* PIPE_BUF: Max # of bytes for which pipe writes are atomic */ # define _PC_CHOWN_RESTRICTED 6 /* _POSIX_CHOWN_RESTRICTED: 1 iff only a privileged process can use chown() */ # define _PC_NO_TRUNC 7 /* _POSIX_NO_TRUNC: 1 iff an error is detected when exceeding NAME_MAX */ # define _PC_VDISABLE 8 /* _POSIX_VDISABLE: character setting which disables TTY local editing characters */ /* Symbolic constants for pathconf() defined by POSIX.1b */ # define _PC_SYNC_IO 100 /* SYNC_IO: 1 iff Synchronized IO may be performed for the associated file */ # define _PC_ASYNC_IO 101 /* Async I/O may be performed on this fd */ # define _PC_PRIO_IO 102 /* I/O Prioritization is done on this fd */ # define _PC_FILESIZEBITS 103 /* bits needed to represent file offset */ /* Symbolic constants for pathconf() defined by POSIX.1d or Unix2003 */ # define _PC_2_SYMLINKS 600 # define _PC_ALLOC_SIZE_MIN 601 # define _PC_REC_INCR_XFER_SIZE 602 # define _PC_REC_MAX_XFER_SIZE 603 # define _PC_REC_MIN_XFER_SIZE 604 # define _PC_REC_XFER_ALIGN 605 # define _PC_SYMLINK_MAX 606 #endif /* _INCLUDE_POSIX_SOURCE || _INCLUDE_POSIX2_SOURCE */ /* Issue(s) of X/Open Portability Guide we support */ #ifdef _INCLUDE_XOPEN_SOURCE # ifdef _XPG3 # define _XOPEN_VERSION 3 # else /* not _XPG3 */ # define _XOPEN_VERSION 4 # endif /* not _XPG3 */ # ifdef _XPG2 # define _XOPEN_XPG2 1 # else /* not _XPG2 */ # ifdef _XPG3 # define _XOPEN_XPG3 1 # else /* not _XPG3 */ # define _XOPEN_XPG4 1 # endif /* not _XPG3 */ # endif /* not _XPG2 */ # define _XOPEN_XCU_VERSION 3 /* X/Open Commands & Utilities */ /* XPG4 Feature Groups */ # define _XOPEN_CRYPT 1 /* Encryption and Decryption */ # define _XOPEN_ENH_I18N 1 /* Enhanced Internationalization */ /* _XOPEN_SHM is not defined because the Shared Memory routines can be configured in and out of the system. See uxgen(1M) or config(1M). */ # ifdef _INCLUDE_XOPEN_SOURCE_500 # define _XOPEN_SHM 1 # endif /* _INCLUDE_XOPEN_SOURCE_500 */ #endif /* _INCLUDE_XOPEN_SOURCE */ /* Revision of AES OS we support */ #ifdef _INCLUDE_AES_SOURCE # define _AES_OS_VERSION 1 #endif /* _INCLUDE_AES_SOURCE */ #ifdef _INCLUDE_POSIX2_SOURCE # define _POSIX2_VERSION_92 199209L /* We support POSIX.2-1992 */ # define _POSIX2_VERSION_01 200112L /* We support POSIX.2-2001 */ /* Conformance and options for POSIX.2 */ # ifdef _INCLUDE_XOPEN_SOURCE_PRE_600 # define _POSIX2_C_VERSION _POSIX2_VERSION_92 # ifdef _HPUX_SOURCE /* IEEE POSIX.2-2001 base standard */ # define _POSIX2_VERSION _POSIX2_VERSION_01 /* IEEE POSIX.2-2001 C language binding */ # define _SUPPORTED_POSIX2_OPTION _POSIX2_VERSION_01 # else /* !_HPUX_SOURCE */ /* IEEE POSIX.2-1992 base standard */ # define _POSIX2_VERSION _POSIX2_VERSION_92 /* IEEE POSIX.2-1992 C language binding */ # define _SUPPORTED_POSIX2_OPTION 1L # endif /* !_HPUX_SOURCE */ # else /* !_INCLUDE_XOPEN_SOURCE_PRE_600 */ /* IEEE POSIX.2-1992 base standard */ # define _POSIX2_VERSION _POSIX2_VERSION_01 # define _SUPPORTED_POSIX2_OPTION _POSIX2_VERSION_01 # endif /* !_INCLUDE_XOPEN_SOURCE_PRE_600 */ /* c89 finds POSIX.2 funcs by default */ # define _POSIX2_C_BIND _SUPPORTED_POSIX2_OPTION /* c89, lex, yacc, etc. are provided */ # define _POSIX2_C_DEV _SUPPORTED_POSIX2_OPTION /* make, ar, etc. are provided */ # define _POSIX2_SW_DEV _SUPPORTED_POSIX2_OPTION /* terminals exist where vi works */ # define _POSIX2_CHAR_TERM _SUPPORTED_POSIX2_OPTION /* User Portability Utilities supported */ # define _POSIX2_UPE _SUPPORTED_POSIX2_OPTION /* localedef(1M) can create locales */ # define _POSIX2_LOCALEDEF _SUPPORTED_POSIX2_OPTION /* fort77 is not provided */ # define _POSIX2_FORT_DEV -1L /* asa is not provided */ # define _POSIX2_FORT_RUN -1L /* Symbolic constants representing C-language compilation environments defined * by XPG5 */ # define _XBS5_ILP32_OFF32 32 /* 32-bit int, long, pointer, off_t */ # define _XBS5_ILP32_OFFBIG 32 /* 32-bit int, long, pointer, 64-bit off_t */ # define _XBS5_LP64_OFF64 64 /* 32-bit int, 64-bit long, pointer, off_t */ # define _XBS5_LPBIG_OFFBIG 64 /* 32-bit int, 64-bit long, pointer, off_t */ /* Symbolic constants for confstr() defined by POSIX.2: 200-299 */ # define _CS_PATH 200 /* Search path that finds all POSIX.2 utils */ /* Symbolic constants for confstr() defined by XPG5: 300-399 */ /* Initial compiler options, final compiler options, set of libraries and lint * options for 32-bit int, long, pointer, off_t. */ # define _CS_XBS5_ILP32_OFF32_CFLAGS 300 # define _CS_XBS5_ILP32_OFF32_LDFLAGS 301 # define _CS_XBS5_ILP32_OFF32_LIBS 302 # define _CS_XBS5_ILP32_OFF32_LINTFLAGS 303 /* Initial compiler options, final compiler options, set of libraries and lint * options for 32-bit int, long, pointer, 64-bit off_t. */ # define _CS_XBS5_ILP32_OFFBIG_CFLAGS 304 # define _CS_XBS5_ILP32_OFFBIG_LDFLAGS 305 # define _CS_XBS5_ILP32_OFFBIG_LIBS 306 # define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 307 /* Initial compiler options, final compiler options, set of libraries and lint * options for 32-bit int, 64-bit long, pointer, off_t. */ # define _CS_XBS5_LP64_OFF64_CFLAGS 308 # define _CS_XBS5_LP64_OFF64_LDFLAGS 309 # define _CS_XBS5_LP64_OFF64_LIBS 310 # define _CS_XBS5_LP64_OFF64_LINTFLAGS 311 /* Initial compiler options, final compiler options, set of libraries and lint * options for an int type using at least 32-bits, and long, pointer, and off_t * types using at least 64-bits. */ # define _CS_XBS5_LPBIG_OFFBIG_CFLAGS 312 # define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS 313 # define _CS_XBS5_LPBIG_OFFBIG_LIBS 314 # define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 315 /* Symbolic constants for confstr() defined by Unix2003 : 700 - 799 */ /* Initial C99 compiler options, final C99 compiler options, set of libraries * options for 32-bit int, long, pointer, off_t. */ # define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 700 # define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 701 # define _CS_POSIX_V6_ILP32_OFF32_LIBS 702 /* Initial C99 compiler options, final C99 compiler options, set of libraries * options for 32-bit int, long, pointer, 64-bit off_t. */ # define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 704 # define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 705 # define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 706 /* Initial C99 compiler options, final C99 compiler options, set of libraries * options for 32-bit int, 64-bit long, pointer, off_t. */ # define _CS_POSIX_V6_LP64_OFF64_CFLAGS 708 # define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 709 # define _CS_POSIX_V6_LP64_OFF64_LIBS 710 /* Initial compiler options, final compiler options, set of libraries and lint * options for an int type using at least 32-bits, and long, pointer, and off_t * types using at least 64-bits. */ # define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 712 # define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 713 # define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 714 # define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 716 /* Symbolic constants for confstr() defined by HP-UX: 10000-19999 */ # define _CS_MACHINE_MODEL 10000 /* system model name */ # define _CS_HW_CPU_SUPP_BITS 10001 /* OS configurations supported */ # define _CS_KERNEL_BITS 10002 /* kernel running is "32" or "64" bits */ # define _CS_MACHINE_IDENT 10003 /* Machine ID */ # define _CS_PARTITION_IDENT 10004 /* Partition ID */ # define _CS_MACHINE_SERIAL 10005 /* Machine serial number */ /* Symbolic constants for use with fnmatch() have been moved to */ #endif /* _INCLUDE_POSIX2_SOURCE */ # ifndef _XOPEN_UNIX # define _XOPEN_UNIX -1 # endif # define _XOPEN_CURSES 1 #ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED /* Symbolic constants for the "lockf" function: */ # define F_ULOCK 0 /* Unlock a previously locked region */ # define F_LOCK 1 /* Lock a region for exclusive use */ # define F_TLOCK 2 /* Test and lock a region for exclusive use */ # define F_TEST 3 /* Test a region for a previous lock */ /* Symbolic constants for sysconf() variables defined by XPG4_EXTENDED */ /* Continue with ones for XOPEN (2000-2999) */ # define _SC_IOV_MAX 2100 /* Max # of iovec structures for readv/writev */ # define _SC_XOPEN_UNIX 2101 /* Whether or not XOPEN_UNIX is supported */ #endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */ /* * Define _XOPEN_VERSION symbolic constant for unix98 * compliance. */ #ifdef _INCLUDE_XOPEN_SOURCE_500 # undef _XOPEN_VERSION # define _XOPEN_VERSION 500 #endif /* _INCLUDE_XOPEN_SOURCE_500 */ /* * Define _XOPEN_VERSION symbolic constant for unix03 * compliance. */ #if defined(_INCLUDE_XOPEN_SOURCE_600) # undef _XOPEN_VERSION # define _XOPEN_VERSION 600 # define _XOPEN_STREAMS 1 # define _XOPEN_REALTIME -1 # define _XOPEN_LEGACY -1 # define _POSIX_V6_ILP32_OFF32 32 # define _POSIX_V6_ILP32_OFFBIG 32 # define _POSIX_V6_LP64_OFF64 64 # define _POSIX_V6_LPBIG_OFFBIG 64 #endif /* _INCLUDE_XOPEN_SOURCE_600 */ #ifdef _INCLUDE_HPUX_SOURCE /* Symbolic constants for the passwd file and group file */ # define GF_PATH "/etc/group" /* Path name of the "group" file */ # define PF_PATH "/etc/passwd" /* Path name of the "passwd" file */ # define IN_PATH "/usr/include" /* Path name for <...> files */ /* Path on which all POSIX.2 utilities can be found */ # define CS_PATH \ "/usr/bin:/usr/ccs/bin:/opt/ansic/bin:/opt/langtools/bin:/opt/fortran/bin" # define CS_XBS5_ILP32_OFF32_CFLAGS "" # define CS_XBS5_ILP32_OFF32_LDFLAGS "" # define CS_XBS5_ILP32_OFF32_LIBS "" # define CS_XBS5_ILP32_OFF32_LINTFLAGS "" # define CS_XBS5_ILP32_OFFBIG_CFLAGS "-D_FILE_OFFSET_BITS=64" # define CS_XBS5_ILP32_OFFBIG_LDFLAGS "" # define CS_XBS5_ILP32_OFFBIG_LIBS "" # define CS_XBS5_ILP32_OFFBIG_LINTFLAGS "-D_FILE_OFFSET_BITS=64" #if defined(__ia64) # define CS_XBS5_LP64_OFF64_CFLAGS "+DD64" # define CS_XBS5_LPBIG_OFFBIG_CFLAGS "+DD64" #else # define CS_XBS5_LP64_OFF64_CFLAGS "+DA2.0W" # define CS_XBS5_LPBIG_OFFBIG_CFLAGS "+DA2.0W" #endif # define CS_XBS5_LP64_OFF64_LDFLAGS "" # define CS_XBS5_LP64_OFF64_LIBS "" # define CS_XBS5_LP64_OFF64_LINTFLAGS "" # define CS_XBS5_LPBIG_OFFBIG_LDFLAGS "" # define CS_XBS5_LPBIG_OFFBIG_LIBS "" # define CS_XBS5_LPBIG_OFFBIG_LINTFLAGS "" # define CS_POSIX_V6_ILP32_OFF32_CFLAGS "" # define CS_POSIX_V6_ILP32_OFF32_LDFLAGS "" # define CS_POSIX_V6_ILP32_OFF32_LIBS "" # define CS_POSIX_V6_ILP32_OFFBIG_CFLAGS "-D_FILE_OFFSET_BITS=64" # define CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS "" # define CS_POSIX_V6_ILP32_OFFBIG_LIBS "" # define CS_POSIX_V6_LP64_OFF64_CFLAGS "+DD64" # define CS_POSIX_V6_LP64_OFF64_LDFLAGS "" # define CS_POSIX_V6_LP64_OFF64_LIBS "" # define CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS "+DD64" # define CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS "" # define CS_POSIX_V6_LPBIG_OFFBIG_LIBS "" # define CS_POSIX_V6_WIDTH_RESTRICTED_ENVS "_POSIX_V6_ILP32_OFF32\n_POSIX_V6_ILP32_OFFBIG\n_POSIX_V6_LP64_OFF64\n_POSIX_V6_LPBIG_OFFBIG" /* Symbolic constants for values of sysconf(_SC_SECURITY_LEVEL) */ # define SEC_CLASS_NONE 0 /* default secure system */ # define SEC_CLASS_C2 1 /* C2 level security */ # define SEC_CLASS_B1 2 /* B1 level security */ /* Symbolic constants for values of sysconf(_SC_IO_TYPE) */ # define IO_TYPE_WSIO 01 # define IO_TYPE_SIO 02 # define IO_TYPE_CDIO 03 /* Symbolic constants for values of sysconf(_SC_CPU_KEYBITS1) */ #define HARITH 0x00000010 /* Halfword parallel add, subtract, average */ #define HSHIFTADD 0x00000020 /* Halfword parallel shift-and-add */ /* Symbolic constants for values of sysconf(_SC_CPU_VERSION) */ /* These are the same as the magic numbers defined in */ /* Symbolic constants for values of sysconf(_SC_CPU_VERSION) do not have to be monotonic. Values from 0x0210 through 0x02ff have been reserved for revisions of PA-RISC */ # define CPU_HP_MC68020 0x20C /* Motorola MC68020 */ # define CPU_HP_MC68030 0x20D /* Motorola MC68030 */ # define CPU_HP_MC68040 0x20E /* Motorola MC68040 */ # define CPU_PA_RISC1_0 0x20B /* HP PA-RISC1.0 */ # define CPU_PA_RISC1_1 0x210 /* HP PA-RISC1.1 */ # define CPU_PA_RISC1_2 0x211 /* HP PA-RISC1.2 */ # define CPU_PA_RISC2_0 0x214 /* HP PA-RISC2.0 */ # define CPU_PA_RISC_MAX 0x2FF /* Maximum value for HP PA-RISC systems */ # define CPU_IA64_ARCHREV_0 0x300 /* IA-64 archrev 0 */ /* Macro for detecting whether a given CPU version is an HP PA-RISC machine */ # define CPU_IS_PA_RISC(__x) \ ((__x) == CPU_PA_RISC1_0 || \ ((__x) >= CPU_PA_RISC1_1 && (__x) <= CPU_PA_RISC_MAX)) /* Macro for detecting whether a given CPU version is an HP MC680x0 machine */ # define CPU_IS_HP_MC68K(__x) \ ((__x) == CPU_HP_MC68020 || \ (__x) == CPU_HP_MC68030 || \ (__x) == CPU_HP_MC68040) /* Macros to interpret return value from sysconf(_SC_HW_32_64_CAPABLE) */ # define _SYSTEM_SUPPORTS_LP64OS(__x) ((__x) & 0x1) # define _SYSTEM_SUPPORTS_ILP32OS(__x) ((__x) & 0x2) #ifndef _KERNEL /* * serialize system call */ /* Function prototype */ #if defined(__ia64) && !defined(_LIBC) /* pragmas needed to support -B protected */ #pragma extern serialize #endif /* __ia64 && ! _LIBC */ extern int serialize __((int, pid_t)); #endif /* not _KERNEL */ #endif /* _INCLUDE_HPUX_SOURCE */ #ifdef _UNSUPPORTED /* * NOTE: The following header file contains information specific * to the internals of the HP-UX implementation. The contents of * this header file are subject to change without notice. Such * changes may affect source code, object code, or binary * compatibility between releases of HP-UX. Code which uses * the symbols contained within this header file is inherently * non-portable (even between HP-UX implementations). */ # include <.unsupp/sys/_unistd.h> #endif /* _UNSUPPORTED */ #endif /* _SYS_UNISTD_INCLUDED */ facter-1.7.5/spec/fixtures/hpux/machinfo/0000755005276200011600000000000012276213023020231 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/hpux/machinfo/superdome2-16s0000644005276200011600000000153312276213016022654 0ustar jenkinsjenkinsCPU info: Intel(R) Itanium(R) Processor 9340 (1.6 GHz, 15 MB) 4 cores, 8 logical processors per socket 4.79 GT/s QPI, CPU version E0 Active processor count: 2 sockets 6 cores (3 per socket) 12 logical processors (6 per socket) LCPU attribute is enabled Memory: 14332 MB (14 GB) Firmware info: Firmware revision: 004.044.000 FP SWA driver revision: 1.18 IPMI is supported on this system. BMC firmware revision: 2.53 Platform info: Model: "ia64 hp Superdome2 16s" Machine ID number: STRING_WITH_DASHES Machine serial number: STRING OS info: Nodename: HOSTNAME Release: HP-UX B.11.31 Version: U (unlimited-user license) Machine: ia64 ID Number: NUMBER vmunix _release_version: @(#) $Revision: vmunix: B.11.31_LR FLAVOR=perf facter-1.7.5/spec/fixtures/hpux/machinfo/hppa-rp44400000644005276200011600000000121712276213016022042 0ustar jenkinsjenkinsCPU info: 4 PA-RISC 8800 processors (1000 MHz, 64 MB) CPU version 5 8 logical processors (2 per socket) Memory: 24574 MB (24 GB) Firmware info: Firmware revision: 45.44 IPMI is supported on this system. BMC firmware revision: 3.52 Platform info: Model: "9000/800/rp4440 " Machine ID number: XXXXXXXXXXXXXXXXXXX Machine serial number: SGHXXXXXXX OS info: Nodename: myhost Release: HP-UX B.11.31 Version: U (unlimited-user license) Machine: 9000/800 ID Number: 97704309 vmunix _release_version: _release_version: @(#) $Revision: vmunix: B.11.31_LR FLAVOR=perf facter-1.7.5/spec/fixtures/hpux/machinfo/ia64-rx26200000644005276200011600000000313412276213016021663 0ustar jenkinsjenkinsCPU info: Number of CPUs = 2 Number of enabled CPUs = 2 Clock speed = 1600 MHz Bus speed = 400 MT/s CPUID registers vendor information = "GenuineIntel" processor serial number = 0x0000000000000000 processor version info = 0x000000001f020104 architecture revision: 0 processor family: 31 Intel(R) Itanium 2 Family Processors processor model: 2 Intel(R) Itanium 2 processor Bus features implemented = 0xbdf0000060000000 selected = 0x0000000040000000 Bus Lock Signal masked processor revision: 1 Stepping A1 largest CPUID reg: 4 processor capabilities = 0x0000000000000001 implements long branch: 1 Cache info: L1 Instruction: size = 16 KB, associativity = 4 L1 Data: size = 16 KB, associativity = 4 L2 Unified: size = 256 KB, associativity = 8 L3 Unified: size = 6144 KB, associativity = 12 Memory = 20468 MB (19.988281 GB) Firmware info: Firmware revision = 03.17 FP SWA driver revision: 1.18 IPMI is supported on this system. BMC version: 3.48 Platform info: model string = "ia64 hp server rx2620" machine id number = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx machine serial number = XXXXXXXXXX OS info: sysname = HP-UX nodename = myhost release = B.11.23 version = U (unlimited-user license) machine = ia64 idnumber = XXXXXXXXXX vmunix _release_version: @(#) $Revision: vmunix: B11.23_LR FLAVOR=perf Fri Aug 29 22:35:38 PDT 2003 $ facter-1.7.5/spec/fixtures/hpux/machinfo/superdome-server-SD32B0000644005276200011600000000350412276213016024242 0ustar jenkinsjenkinsCPU info: Number of CPUs = 8 Number of enabled CPUs = 2 Number of enabled sockets = 2 Cores per socket = 2 Clock speed = 1598 MHz Bus speed = 533 MT/s CPUID registers vendor information = "GenuineIntel" processor serial number = 0x0000000000000000 processor version info = 0x0000000020000704 architecture revision: 0 processor family: 32 Intel(R) Itanium 2 9000 series processor model: 1 Intel(R) Itanium 2 9000 series Bus features implemented = 0xbdf0000020000000 selected = 0x0020000000000000 Exclusive Bus Cache Line Replacement Enabled processor revision: 7 Stepping C2 largest CPUID reg: 4 processor capabilities = 0x0000000000000005 implements long branch: 1 implements 16-byte atomic operations: 1 Cache info (per core): L1 Instruction: size = 16 KB, associativity = 4 L1 Data: size = 16 KB, associativity = 4 L2 Instruction: size = 1024 KB, associativity = 8 L2 Data: size = 256 KB, associativity = 8 L3 Unified: size = 12288 KB, associativity = 12 Memory = 32700 MB (31.933594 GB) Firmware info: Firmware revision = 9.66 FP SWA driver revision: 1.18 IPMI is supported on this system. ERROR: Unable to obtain manageability firmware revision info. Platform info: model string = "ia64 hp superdome server SD32B" machine id number = STRING_WITH_DASHES machine serial number = STRING OS info: sysname = HP-UX nodename = HOSTNAME release = B.11.23 version = U (unlimited-user license) machine = ia64 idnumber = NUMBER vmunix _release_version: @(#) $Revision: vmunix: B11.23_LR FLAVOR=perf Fri Aug 29 22:35:38 PDT 2003 $ facter-1.7.5/spec/fixtures/hpux/machinfo/ia64-rx66000000644005276200011600000000132612276213016021666 0ustar jenkinsjenkinsCPU info: 4 Intel(R) Itanium 2 9100 series processors (1.59 GHz, 18 MB) 532 MT/s bus, CPU version A1 8 logical processors (2 per socket) Memory: 24542 MB (23.97 GB) Firmware info: Firmware revision: 04.11 FP SWA driver revision: 1.18 IPMI is supported on this system. BMC firmware revision: 5.24 Platform info: Model: "ia64 hp server rx6600" Machine ID number: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Machine serial number: XXXXXXXXXX OS info: Nodename: bt1353b6 Release: HP-UX B.11.31 Version: U (unlimited-user license) Machine: ia64 ID Number: XXXXXXXXXX vmunix _release_version: @(#) $Revision: vmunix: B.11.31_LR FLAVOR=perf facter-1.7.5/spec/fixtures/hpux/machinfo/ia64-rx86400000644005276200011600000000345412276213016021700 0ustar jenkinsjenkinsCPU info: Number of CPUs = 16 Number of enabled CPUs = 2 Number of enabled sockets = 2 Cores per socket = 2 Clock speed = 1598 MHz Bus speed = 533 MT/s CPUID registers vendor information = "GenuineIntel" processor serial number = 0x0000000000000000 processor version info = 0x0000000020010104 architecture revision: 0 processor family: 32 Intel(R) Itanium 2 9100 series processor model: 1 Intel(R) Itanium 2 9100 series Bus features implemented = 0xbdf0000020000000 selected = 0x0020000000000000 Exclusive Bus Cache Line Replacement Enabled processor revision: 1 Stepping A1 largest CPUID reg: 4 processor capabilities = 0x0000000000000005 implements long branch: 1 implements 16-byte atomic operations: 1 Cache info (per core): L1 Instruction: size = 16 KB, associativity = 4 L1 Data: size = 16 KB, associativity = 4 L2 Instruction: size = 1024 KB, associativity = 8 L2 Data: size = 256 KB, associativity = 8 L3 Unified: size = 9216 KB, associativity = 9 Memory = 4046 MB (3.951172 GB) Firmware info: Firmware revision = 9.048 FP SWA driver revision: 1.18 IPMI is supported on this system. BMC version: 4.01 Platform info: model string = "ia64 hp server rx8640" machine id number = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx machine serial number = XXXXXXXXXX OS info: sysname = HP-UX nodename = bakprdinfh001 release = B.11.23 version = U (unlimited-user license) machine = ia64 idnumber = XXXXXXXXXX vmunix _release_version: @(#) $Revision: vmunix: B11.23_LR FLAVOR=perf Fri Aug 29 22:35:38 PDT 2003 $ facter-1.7.5/spec/fixtures/hpux/sched.models0000644005276200011600000000604712276213016020751 0ustar jenkinsjenkins/* @(#) $Header: sched.models,v 73.22 2001/06/06 18:47:11 tkopren Exp $ */ A180 1.1e PA7300LC A180c 1.1e PA7300LC A400-36 2.0 PA8500 A400-44 2.0 PA8500 A400-5X 2.0 PA8600 A400-7X 2.0 PA8700 A400-8X 2.0 PA8700 A500-36 2.0 PA8500 A500-44 2.0 PA8500 A500-55 2.0 PA8600 A500-5X 2.0 PA8600 A500-7X 2.0 PA8700 A500-8X 2.0 PA8700 B1000 2.0 PA8500 B115 1.1e PA7300 B120 1.1e PA7300 B132L 1.1e PA7300 B160L 1.1e PA7300 B2000 2.0 PA8500 B2600 2.0 PA8700 C100 1.1d PA7200 C110 1.1d PA7200 C115 1.1e PA7300 C120 1.1e PA7300 C130 2.0 PA8000 C140 2.0 PA8000 C160 2.0 PA8000 C160L 1.1e PA7300 C180 2.0 PA8000 C180-XP 2.0 PA8000 C200+ 2.0 PA8200 C240+ 2.0 PA8200 C3000 2.0 PA8500 C360 2.0 PA8500 C3600 2.0 PA8600 C3700 2.0 PA8700 C3750 2.0 PA8700 D200 1.1c PA7100LC D210 1.1c PA7100LC D220 1.1e PA7300 D230 1.1e PA7300 D250 1.1d PA7200 D260 1.1d PA7200 D270 2.0 PA8000 D280 2.0 PA8000 D310 1.1c PA7100LC D320 1.1e PA7300 D330 1.1e PA7300 D350 1.1d PA7200 D360 1.1d PA7200 D370 2.0 PA8000 D380 2.0 PA8000 D390 2.0 PA8000 D410 1.1d PA7200 D650 2.0 PA8000 DX0 1.1c PA7100LC DX5 1.1c PA7100LC DXO 1.1c PA7100LC E25 1.1c PA7100LC E35 1.1c PA7100LC E45 1.1c PA7100LC E55 1.1c PA7100LC G50 1.1b PA7100 G60 1.1b PA7100 G70 1.1b PA7100 H50 1.1b PA7100 H60 1.1b PA7100 H70 1.1b PA7100 I50 1.1b PA7100 I60 1.1b PA7100 I70 1.1b PA7100 J200 1.1d PA7200 J210 1.1d PA7200 J210XC 1.1d PA7200 J220 2.0 PA8000 J2240 2.0 PA8200 J280 2.0 PA8000 J400 2.0 PA8000 J410 2.0 PA8000 J5000 2.0 PA8500 J5600 2.0 PA8600 J6000 2.0 PA8600 J6700 2.0 PA8700 J6750 2.0 PA8700 J7000 2.0 PA8500 J7600 2.0 PA8600 K100 1.1d PA7200 K200 1.1d PA7200 K210 1.1d PA7200 K220 1.1d PA7200 K230 1.1d PA7200 K250 2.0 PA8000 K260 2.0 PA8000 K260-EG 2.0 PA8000 K270 2.0 PA8200 K360 2.0 PA8000 K370 2.0 PA8200 K380 2.0 PA8200 K400 1.1d PA7200 K410 1.1d PA7200 K420 1.1d PA7200 K450 2.0 PA8000 K460 2.0 PA8000 K460-EG 2.0 PA8000 K460-XP 2.0 PA8000 K470 2.0 PA8200 K570 2.0 PA8200 K580 2.0 PA8200 L1000-36 2.0 PA8500 L1000-44 2.0 PA8500 L1000-5X 2.0 PA8600 L1000-8X 2.0 PA8700 L1500-6x 2.0 PA8700 L1500-7x 2.0 PA8700 L1500-8x 2.0 PA8700 L1500-9x 2.0 PA8700 L2000-36 2.0 PA8500 L2000-44 2.0 PA8500 L2000-5X 2.0 PA8600 L2000-8X 2.0 PA8700 L3000-55 2.0 PA8600 L3000-5x 2.0 PA8600 L3000-6x 2.0 PA8700 L3000-7x 2.0 PA8700 L3000-8x 2.0 PA8700 L3000-9x 2.0 PA8700 N4000-36 2.0 PA8500 N4000-44 2.0 PA8500 N4000-55 2.0 PA8600 N4000-5X 2.0 PA8600 N4000-6X 2.0 PA8700 N4000-7X 2.0 PA8700 N4000-8X 2.0 PA8700 N4000-8Y 2.0 PA8700 N4000-8Z 2.0 PA8700 N4000-9X 2.0 PA8700 R380 2.0 PA8000 R390 2.0 PA8000 S700i 1.1e PA7300 S715 1.1e PA7300 S744 1.1e PA7300 S760 1.1e PA7300 T500 1.1b PA7100 T520 1.1b PA7100 T540 2.0 PA8000 V2200 2.0 PA8200 V2250 2.0 PA8200 V2500 2.0 PA8500 V2600 2.0 PA8600 V2650 2.0 PA8700 V2700 2.0 PA8700 g4000 Itanium(TM) i2000 Itanium(TM) u16000 Itanium(TM) 715 1.1c PA7100LC 712 1.1c PA7100LC 722 1.1c PA7100LC 725 1.1c PA7100LC 728 1.1d PA7200 735 1.1b PA7100 742 1.1b PA7100 743 1.1c PA7100LC 744 1.1e PA7300 745 1.1b PA7100 747 1.1b PA7100 755 1.1b PA7100 770 1.1d PA7200 777 1.1d PA7200 778 1.1e PA7300 779 1.1e PA7300 780 2.0 PA8000 781 2.0 PA8000 782 2.0 PA8200 facter-1.7.5/spec/fixtures/cpuinfo/0000755005276200011600000000000012276213023017124 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/cpuinfo/amd64quad0000644005276200011600000000512712276213016020644 0ustar jenkinsjenkinsprocessor : 0 vendor_id : AuthenticAMD cpu family : 16 model : 4 model name : Quad-Core AMD Opteron(tm) Processor 2374 HE stepping : 2 cpu MHz : 1386667.908 cache size : 512 KB fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu de tsc msr pae cx8 cmov pat clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc pni cx16 popcnt lahf_lm cmp_legacy extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch bogomips : 4400.17 TLB size : 1024 4K pages clflush size : 64 cache_alignment : 64 address sizes : 48 bits physical, 48 bits virtual power management: ts ttp tm stc 100mhzsteps hwpstate processor : 1 vendor_id : AuthenticAMD cpu family : 16 model : 4 model name : Quad-Core AMD Opteron(tm) Processor 2374 HE stepping : 2 cpu MHz : 1386667.908 cache size : 512 KB fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu de tsc msr pae cx8 cmov pat clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc pni cx16 popcnt lahf_lm cmp_legacy extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch bogomips : 4400.17 TLB size : 1024 4K pages clflush size : 64 cache_alignment : 64 address sizes : 48 bits physical, 48 bits virtual power management: ts ttp tm stc 100mhzsteps hwpstate processor : 2 vendor_id : AuthenticAMD cpu family : 16 model : 4 model name : Quad-Core AMD Opteron(tm) Processor 2374 HE stepping : 2 cpu MHz : 1386667.908 cache size : 512 KB fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu de tsc msr pae cx8 cmov pat clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc pni cx16 popcnt lahf_lm cmp_legacy extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch bogomips : 4400.17 TLB size : 1024 4K pages clflush size : 64 cache_alignment : 64 address sizes : 48 bits physical, 48 bits virtual power management: ts ttp tm stc 100mhzsteps hwpstate processor : 3 vendor_id : AuthenticAMD cpu family : 16 model : 4 model name : Quad-Core AMD Opteron(tm) Processor 2374 HE stepping : 2 cpu MHz : 1386667.908 cache size : 512 KB fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu de tsc msr pae cx8 cmov pat clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc pni cx16 popcnt lahf_lm cmp_legacy extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch bogomips : 4400.17 TLB size : 1024 4K pages clflush size : 64 cache_alignment : 64 address sizes : 48 bits physical, 48 bits virtual power management: ts ttp tm stc 100mhzsteps hwpstate facter-1.7.5/spec/fixtures/cpuinfo/amd64twentyfour0000644005276200011600000004777612276213016022160 0ustar jenkinsjenkinsprocessor : 0 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 0 cpu cores : 6 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 1 cpu cores : 6 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 2 cpu cores : 6 apicid : 4 initial apicid : 4 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 8 cpu cores : 6 apicid : 16 initial apicid : 16 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 9 cpu cores : 6 apicid : 18 initial apicid : 18 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 10 cpu cores : 6 apicid : 20 initial apicid : 20 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 6 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 0 cpu cores : 6 apicid : 32 initial apicid : 32 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 7 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 1 cpu cores : 6 apicid : 34 initial apicid : 34 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 8 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 2 cpu cores : 6 apicid : 36 initial apicid : 36 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 9 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 8 cpu cores : 6 apicid : 48 initial apicid : 48 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 10 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 9 cpu cores : 6 apicid : 50 initial apicid : 50 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 11 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 10 cpu cores : 6 apicid : 52 initial apicid : 52 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 12 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 0 cpu cores : 6 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 13 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 1 cpu cores : 6 apicid : 3 initial apicid : 3 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 14 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 2 cpu cores : 6 apicid : 5 initial apicid : 5 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 15 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 8 cpu cores : 6 apicid : 17 initial apicid : 17 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 16 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 9 cpu cores : 6 apicid : 19 initial apicid : 19 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 17 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 0 siblings : 12 core id : 10 cpu cores : 6 apicid : 21 initial apicid : 21 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.05 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 18 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 0 cpu cores : 6 apicid : 33 initial apicid : 33 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 19 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 1 cpu cores : 6 apicid : 35 initial apicid : 35 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 20 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 2 cpu cores : 6 apicid : 37 initial apicid : 37 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 21 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 8 cpu cores : 6 apicid : 49 initial apicid : 49 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 22 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 9 cpu cores : 6 apicid : 51 initial apicid : 51 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 23 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5675 @ 3.07GHz stepping : 2 cpu MHz : 3068.000 cache size : 12288 KB physical id : 1 siblings : 12 core id : 10 cpu cores : 6 apicid : 53 initial apicid : 53 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt aes lahf_lm ida arat epb dts tpr_shadow vnmi flexpriority ept vpid bogomips : 6133.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: facter-1.7.5/spec/fixtures/cpuinfo/bbg3-armel0000644005276200011600000000045612276213016020771 0ustar jenkinsjenkinsProcessor : ARMv7 Processor rev 5 (v7l) BogoMIPS : 799.53 Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x2 CPU part : 0xc08 CPU revision : 5 Hardware : Freescale MX51 Babbage Board Revision : 51130 Serial : 0000000000000000 facter-1.7.5/spec/fixtures/cpuinfo/sparc0000644005276200011600000000036512276213016020165 0ustar jenkinsjenkinscpu : TI UltraSparc IIIi (Jalapeno) fpu : UltraSparc IIIi integrated FPU prom : OBP 4.16.2 2004/10/04 18:22 type : sun4u ncpus probed : 1 ncpus active : 1 D$ parity tl1 : 0 I$ parity tl1 : 0 Cpu0ClkTck : 000000004fa1be00 MMU Type : Cheetah+ facter-1.7.5/spec/fixtures/cpuinfo/panda-armel0000644005276200011600000000052712276213016021236 0ustar jenkinsjenkinsProcessor : ARMv7 Processor rev 2 (v7l) processor : 0 BogoMIPS : 2013.45 processor : 1 BogoMIPS : 1963.05 Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x1 CPU part : 0xc09 CPU revision : 2 Hardware : OMAP4430 Panda Board Revision : 0020 Serial : 0000000000000000 facter-1.7.5/spec/fixtures/cpuinfo/beaglexm-armel0000644005276200011600000000043312276213016021733 0ustar jenkinsjenkinsProcessor : ARMv7 Processor rev 2 (v7l) BogoMIPS : 506.27 Features : swp half thumb fastmult vfp edsp neon vfpv3 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x3 CPU part : 0xc08 CPU revision : 2 Hardware : OMAP3 Beagle Board Revision : 0020 Serial : 0000000000000000 facter-1.7.5/spec/fixtures/cpuinfo/ppc640000644005276200011600000000067612276213016020016 0ustar jenkinsjenkinsprocessor : 0 cpu : PPC970FX, altivec supported clock : 2000.000000MHz revision : 3.0 (pvr 003c 0300) processor : 1 cpu : PPC970FX, altivec supported clock : 2000.000000MHz revision : 3.0 (pvr 003c 0300) timebase : 33333333 platform : PowerMac model : RackMac3,1 machine : RackMac3,1 motherboard : RackMac3,1 MacRISC4 Power Macintosh detected as : 339 (XServe G5) pmac flags : 00000000 L2 cache : 512K unified pmac-generation : NewWorld facter-1.7.5/spec/fixtures/cpuinfo/amd64solo0000644005276200011600000000105212276213016020657 0ustar jenkinsjenkinsprocessor : 0 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz stepping : 10 cpu MHz : 600.825 cache size : 6144 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 constant_tsc up pni monitor ssse3 bogomips : 1201.65 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: facter-1.7.5/spec/fixtures/cpuinfo/amd64tri0000644005276200011600000000355212276213016020510 0ustar jenkinsjenkinsprocessor : 0 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz stepping : 10 cpu MHz : 910.177 cache size : 6144 KB physical id : 0 siblings : 3 core id : 0 cpu cores : 3 apicid : 0 initial apicid : 0 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht constant_tsc pni ssse3 bogomips : 1820.35 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz stepping : 10 cpu MHz : 910.177 cache size : 6144 KB physical id : 0 siblings : 3 core id : 1 cpu cores : 3 apicid : 1 initial apicid : 1 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht constant_tsc pni ssse3 bogomips : 1875.49 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz stepping : 10 cpu MHz : 910.177 cache size : 6144 KB physical id : 0 siblings : 3 core id : 2 cpu cores : 3 apicid : 2 initial apicid : 2 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht constant_tsc pni ssse3 bogomips : 1523.26 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: facter-1.7.5/spec/fixtures/cpuinfo/amd64dual0000644005276200011600000000236112276213016020634 0ustar jenkinsjenkinsprocessor : 0 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz stepping : 10 cpu MHz : 689.302 cache size : 6144 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht constant_tsc pni ssse3 bogomips : 1378.60 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz stepping : 10 cpu MHz : 689.302 cache size : 6144 KB physical id : 0 siblings : 2 core id : 1 cpu cores : 2 apicid : 1 initial apicid : 1 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht constant_tsc pni ssse3 bogomips : 1687.45 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: facter-1.7.5/spec/fixtures/virtual/0000755005276200011600000000000012276213023017147 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/virtual/proc_self_status/0000755005276200011600000000000012276213023022526 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/virtual/proc_self_status/vserver_2_3/0000755005276200011600000000000012276213023024665 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/virtual/proc_self_status/vserver_2_3/guest0000644005276200011600000000146712276213017025752 0ustar jenkinsjenkinsName: cat State: R (running) Tgid: 21149 Pid: 21149 PPid: 21142 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 64 Groups: 0 VmPeak: 1564 kB VmSize: 1564 kB VmLck: 0 kB VmHWM: 384 kB VmRSS: 384 kB VmData: 160 kB VmStk: 84 kB VmExe: 16 kB VmLib: 1284 kB VmPTE: 20 kB Threads: 1 SigQ: 0/71680 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000000000000 CapInh: 0000000000000000 CapPrm: fffffffffffffeff CapEff: fffffffffffffeff CapBnd: fffffffffffffeff Cpus_allowed: ff Cpus_allowed_list: 0-7 Mems_allowed: 1 Mems_allowed_list: 0 VxID: 40128 NxID: 40128 voluntary_ctxt_switches: 1 nonvoluntary_ctxt_switches: 0 facter-1.7.5/spec/fixtures/virtual/proc_self_status/vserver_2_3/host0000644005276200011600000000147312276213017025575 0ustar jenkinsjenkinsName: cat State: R (running) Tgid: 21074 Pid: 21074 PPid: 21020 TracerPid: 0 Uid: 47000 47000 47000 47000 Gid: 4733 4733 4733 4733 FDSize: 64 Groups: 0 4733 VmPeak: 3800 kB VmSize: 3800 kB VmLck: 0 kB VmHWM: 468 kB VmRSS: 468 kB VmData: 176 kB VmStk: 84 kB VmExe: 32 kB VmLib: 1432 kB VmPTE: 28 kB Threads: 1 SigQ: 0/71680 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000000000000 CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 CapBnd: fffffffffffffeff Cpus_allowed: ff Cpus_allowed_list: 0-7 Mems_allowed: 1 Mems_allowed_list: 0 VxID: 0 NxID: 0 voluntary_ctxt_switches: 2 nonvoluntary_ctxt_switches: 0 facter-1.7.5/spec/fixtures/virtual/proc_self_status/vserver_2_1/0000755005276200011600000000000012276213023024663 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/virtual/proc_self_status/vserver_2_1/guest0000644005276200011600000000137112276213017025742 0ustar jenkinsjenkinsName: cat State: R (running) SleepAVG: 58% Tgid: 24671 Pid: 24671 PPid: 24670 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 32 Groups: 0 VmPeak: 1580 kB VmSize: 1580 kB VmLck: 0 kB VmHWM: 372 kB VmRSS: 372 kB VmData: 152 kB VmStk: 88 kB VmExe: 16 kB VmLib: 1280 kB VmPTE: 12 kB Threads: 1 SigQ: 0/4294967295 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000000000000 CapInh: 0000000000000000 CapPrm: 00000000344c04ff CapEff: 00000000344c04ff s_context: 40074 ctxflags: 1602020010 initpid: 0 ipv4root: 4a00007f/ffffffff 4a24f6d5/00ffffff ipv4root_bcast: 00000000 facter-1.7.5/spec/fixtures/virtual/proc_self_status/vserver_2_1/host0000644005276200011600000000132412276213017025566 0ustar jenkinsjenkinsName: cat State: R (running) SleepAVG: 88% Tgid: 24625 Pid: 24625 PPid: 24618 TracerPid: 0 Uid: 47000 47000 47000 47000 Gid: 4733 4733 4733 4733 FDSize: 32 Groups: 0 4733 VmPeak: 1768 kB VmSize: 1768 kB VmLck: 0 kB VmHWM: 396 kB VmRSS: 396 kB VmData: 160 kB VmStk: 88 kB VmExe: 28 kB VmLib: 1468 kB VmPTE: 12 kB Threads: 1 SigQ: 0/4294967295 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000000000000 CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 s_context: 0 ctxflags: none initpid: none ipv4root: 0 ipv4root_bcast: 0 facter-1.7.5/spec/fixtures/unit/0000755005276200011600000000000012276213023016440 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/0000755005276200011600000000000012276213023017415 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/processor/0000755005276200011600000000000012276213023021434 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/processor/solaris-i86pc0000644005276200011600000000251412276213017023767 0ustar jenkinsjenkinsmodule: cpu_info instance: 0 name: cpu_info0 class: misc brand Intel(r) Core(tm) i5 CPU M 450 @ 2.40GHz cache_id 0 chip_id 0 clock_MHz 2375 clog_id 0 core_id 0 cpu_type i386 crtime 70.899819526 current_clock_Hz 2374891267 current_cstate 0 family 6 fpu_type i387 compatible implementation x86 (GenuineIntel family 6 model 37 step 5 clock 2375 MHz) model 37 ncore_per_chip 1 ncpu_per_chip 1 pg_id -1 pkg_core_id 0 snaptime 2279.514858392 state on-line state_begin 1329488796 stepping 5 supported_frequencies_Hz 2374891267 supported_max_cstates 1 vendor_id GenuineIntel facter-1.7.5/spec/fixtures/unit/util/processor/solaris-sun4u0000644005276200011600000001674612276213017024130 0ustar jenkinsjenkinsmodule: cpu_info instance: 0 name: cpu_info0 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 0 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 92.5418505 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 1 snaptime 15277456.9660361 state on-line state_begin 1314212380 supported_frequencies_Hz 2520000000 module: cpu_info instance: 1 name: cpu_info1 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 0 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 93.3416172 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 1 snaptime 15277456.9667477 state on-line state_begin 1314212381 supported_frequencies_Hz 2520000000 module: cpu_info instance: 2 name: cpu_info2 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 2 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 93.3433262 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 4 snaptime 15277456.9671387 state on-line state_begin 1314212381 supported_frequencies_Hz 2520000000 module: cpu_info instance: 3 name: cpu_info3 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 2 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 93.3449653 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 4 snaptime 15277456.9675197 state on-line state_begin 1314212381 supported_frequencies_Hz 2520000000 module: cpu_info instance: 4 name: cpu_info4 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 4 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 93.3465648 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 5 snaptime 15277456.9678953 state on-line state_begin 1314212381 supported_frequencies_Hz 2520000000 module: cpu_info instance: 5 name: cpu_info5 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 4 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 93.3481605 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 5 snaptime 15277456.968269 state on-line state_begin 1314212381 supported_frequencies_Hz 2520000000 module: cpu_info instance: 6 name: cpu_info6 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 6 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 93.3497654 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 6 snaptime 15277456.9686422 state on-line state_begin 1314212381 supported_frequencies_Hz 2520000000 module: cpu_info instance: 7 name: cpu_info7 class: misc brand SPARC64-VII chip_id 1024 clock_MHz 2520 core_id 6 cpu_fru hc:///component=/MBU_A cpu_type sparcv9 crtime 93.3513776 current_clock_Hz 2520000000 device_ID 175931055444225 fpu_type sparcv9 implementation SPARC64-VII (portid 1024 impl 0x7 ver 0x91 clock 2520 MHz) pg_id 6 snaptime 15277456.9690115 state on-line state_begin 1314212381 supported_frequencies_Hz 2520000000 facter-1.7.5/spec/fixtures/unit/util/processor/x86-pentium20000644005276200011600000000152512276213017023553 0ustar jenkinsjenkinsprocessor : 0 vendor_id : GenuineIntel cpu family : 6 model : 5 model name : Pentium II (Deschutes) stepping : 1 cpu MHz : 333.379 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr bogomips : 667.53 clflush size : 32 power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 5 model name : Pentium II (Deschutes) stepping : 1 cpu MHz : 333.379 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr bogomips : 666.44 clflush size : 32 power management: facter-1.7.5/spec/fixtures/unit/util/ec2/0000755005276200011600000000000012276213023020066 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/ec2/centos-arp-ec2.out0000644005276200011600000000006512276213016023344 0ustar jenkinsjenkins? (10.240.93.1) at FE:FF:FF:FF:FF:FF [ether] on eth0 facter-1.7.5/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out0000644005276200011600000000041212276213016024002 0ustar jenkinsjenkins? (46.4.106.97) at 00:26:88:75:c1:17 [ether] on eth0 ? (10.1.2.14) at 02:00:0a:01:02:0e [ether] on virbr1 ? (10.1.2.12) at 02:00:0a:01:02:0c [ether] on virbr1 ? (10.1.2.11) at 02:00:0a:01:02:0b [ether] on virbr1 ? (10.1.2.200) at 02:00:0a:01:02:0e [ether] on virbr1 facter-1.7.5/spec/fixtures/unit/util/ec2/solaris8_arp_a_not_ec2.out0000644005276200011600000000065612276213016025147 0ustar jenkinsjenkinsNet to Media Table: IPv4 Device IP Address Mask Flags Phys Addr ------ -------------------- --------------- ----- --------------- dnet0 pecan 255.255.255.255 08:00:20:05:21:33 dnet0 horseshoe 255.255.255.255 00:00:0c:e0:80:b1 dnet0 crab 255.255.255.255 SP 08:00:20:22:fd:51 dnet0 BASE-ADDRESS.MCAST.NET 240.0.0.0 SM 01:00:5e:00:00:00 facter-1.7.5/spec/fixtures/unit/util/ec2/linux-arp-ec2.out0000644005276200011600000000006512276213016023210 0ustar jenkinsjenkins? (10.240.93.1) at fe:ff:ff:ff:ff:ff [ether] on eth0 facter-1.7.5/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out0000644005276200011600000000074312276213016023704 0ustar jenkinsjenkins Interface: 10.32.123.54 --- 0xd Internet Address Physical Address Type 10.32.120.163 fe-ff-ff-ff-ff-ff dynamic 10.32.122.1 fe-ff-ff-ff-ff-ff dynamic 10.32.123.255 ff-ff-ff-ff-ff-ff static 169.254.169.254 fe-ff-ff-ff-ff-ff dynamic 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.252 01-00-5e-00-00-fc static 255.255.255.255 ff-ff-ff-ff-ff-ff static facter-1.7.5/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out0000644005276200011600000000037612276213016025153 0ustar jenkinsjenkins Interface: 192.168.5.4 --- 0xd Internet Address Physical Address Type 192.168.5.1 c8-02-14-0c-5d-18 dynamic 192.168.5.255 ff-ff-ff-ff-ff-ff static 255.255.255.255 ff-ff-ff-ff-ff-ff static facter-1.7.5/spec/fixtures/unit/util/xendomains/0000755005276200011600000000000012276213023021562 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/xendomains/xendomains0000644005276200011600000000047512276213017023663 0ustar jenkinsjenkinsName ID Mem VCPUs State Time(s) Domain-0 0 656 4 r----- 48140.9 web01 48 512 2 -b---- 97651.5 mailserver 53 512 4 -b---- 7536.1 facter-1.7.5/spec/fixtures/unit/util/loader/0000755005276200011600000000000012276213023020663 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/loader/nosuchfact.rb0000644005276200011600000000003212276213016023342 0ustar jenkinsjenkinsFacter.value(:nosuchfact) facter-1.7.5/spec/fixtures/unit/util/uptime/0000755005276200011600000000000012276213023020720 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin0000644005276200011600000000007012276213017026451 0ustar jenkinsjenkins{ sec = 1320011547, usec = 0 } Sun Oct 30 21:52:27 2011 facter-1.7.5/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd0000644005276200011600000000001312276213017026614 0ustar jenkinsjenkins1323465106 facter-1.7.5/spec/fixtures/unit/util/uptime/kstat_boot_time0000644005276200011600000000005312276213017024033 0ustar jenkinsjenkinsunix:0:system_misc:boot_time 1236919980 facter-1.7.5/spec/fixtures/unit/util/uptime/ubuntu_proc_uptime0000644005276200011600000000002712276213017024575 0ustar jenkinsjenkins5097686.63 40756306.43 facter-1.7.5/spec/fixtures/unit/util/vlans/0000755005276200011600000000000012276213023020540 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/vlans/linux_vlan_config0000644005276200011600000000027312276213017024174 0ustar jenkinsjenkinsVLAN Dev name | VLAN ID Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD eth0.400 | 400 | eth0 eth0.300 | 300 | eth0 eth0.200 | 200 | eth0 eth0.100 | 100 | eth0 facter-1.7.5/spec/fixtures/unit/util/virtual/0000755005276200011600000000000012276213023021103 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/virtual/invalid_unicode_dmi_entries0000644005276200011600000000011212276213017026541 0ustar jenkinsjenkinsÚÆˆóLö¼ qœ þ—„innotek GmbHVirtualBox1.20Virtual Machinefacter-1.7.5/spec/fixtures/unit/util/virtual/solaris10_proc_self_status10000644005276200011600000000216012276213017026365 0ustar jenkinsjenkins j"d"j"d"Ìh à Ø]ÁK,Z TSØ]ÂK,`*æþÃCC¢*æþÄðøþEÅñþ¬ðEÅñþ;‚¬ðC?ÿÿ;C€facter-1.7.5/spec/fixtures/unit/util/ip/0000755005276200011600000000000012276213023020025 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan00000644005276200011600000000016212276213016026065 0ustar jenkinsjenkinslan0: flags=843 inet 192.168.3.9 netmask ffffff00 broadcast 192.168.3.255 facter-1.7.5/spec/fixtures/unit/util/ip/linux_get_single_interface_ib00000644005276200011600000000100012276213016026052 0ustar jenkinsjenkinsib0 Link encap:InfiniBand HWaddr 80:00:00:4a:fe:80:00:00:00:00:00:00:00:02:c9:03:00:43:27:21 inet addr:10.6.193.12 Bcast:10.6.193.255 Mask:255.255.255.0 inet6 addr: fe80::202:c903:43:2721/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:65520 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1024 RX bytes:448 (448.0 b) TX bytes:0 (0.0 b) facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan40000644005276200011600000000017212276213016026516 0ustar jenkinsjenkinslan4: flags=1843 inet 192.168.32.75 netmask ffffff00 broadcast 192.168.32.255 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan10000644005276200011600000000017212276213016026513 0ustar jenkinsjenkinslan1: flags=1843 inet 192.168.30.32 netmask ffffff00 broadcast 192.168.30.255 facter-1.7.5/spec/fixtures/unit/util/ip/linux_get_single_interface_eth00000644005276200011600000000102312276213016026245 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:0c:29:52:15:e9 inet addr:172.16.15.133 Bcast:172.16.15.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe52:15e9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:173 errors:173 dropped:0 overruns:0 frame:0 TX packets:208 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:40970 (40.0 KB) TX bytes:24760 (24.1 KB) Interrupt:16 Base address:0x2024 facter-1.7.5/spec/fixtures/unit/util/ip/windows_netsh_single_interface60000644005276200011600000000115212276213016026313 0ustar jenkinsjenkins Address fe80::2087:77a:53ef:7527%12 Parameters --------------------------------------------------------- Interface Luid : Teredo Tunneling Pseudo-Interface Scope Id : 0.12 Valid Lifetime : infinite Preferred Lifetime : infinite DAD State : Preferred Address Type : Other Address 2001:0:4137:9e76:2087:77a:53ef:7527 Parameters --------------------------------------------------------- Interface Luid : Teredo Tunneling Pseudo-Interface Scope Id : 0.0 Valid Lifetime : infinite Preferred Lifetime : infinite DAD State : Preferred Address Type : Public facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lo00000644005276200011600000000012612276213016025725 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan00000644005276200011600000000017312276213016024162 0ustar jenkinsjenkinslan0: flags=1843 inet 192.168.30.152 netmask ffffff00 broadcast 192.168.30.255 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1111_netstat_in0000644005276200011600000000047412276213016023636 0ustar jenkinsjenkinsName Mtu Network Address Ipkts Opkts lan1 1500 10.1.1.0 10.1.1.6 435347580 1287271 lan0 1500 192.168.3.0 192.168.3.10 28101904 3569941319 lo0 4136 127.0.0.0 127.0.0.1 5071536 5071539 facter-1.7.5/spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces0000644005276200011600000000070012276213016031100 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 en0: flags=8863 mtu 1500 inet6 fe80::223:6cff:fe99:602b%en1 prefixlen 64 scopeid 0x5 inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255 ether 00:23:6c:99:60:2b media: autoselect status: active supported media: autoselect facter-1.7.5/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface0000644005276200011600000000027212276213016026654 0ustar jenkinsjenkinse1000g0: flags=201004843 mtu 1500 index 2 inet 172.16.15.138 netmask ffffff00 broadcast 172.16.15.255 ether 0:c:29:c1:70:2a facter-1.7.5/spec/fixtures/unit/util/ip/solaris_ifconfig_all_with_multiple_interfaces0000644005276200011600000000074312276213016031277 0ustar jenkinsjenkinslo0: flags=2001000849 mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0: flags=201004843 mtu 1500 index 2 inet 192.168.162.130 netmask ffffff00 broadcast 192.168.162.255 lo0: flags=2002000849 mtu 8252 index 1 inet6 ::1/128 e1000g0: flags=202004841 mtu 1500 index 2 inet6 fe80::20c:29ff:fe09:627e/10 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan10000644005276200011600000000015312276213016026066 0ustar jenkinsjenkinslan1: flags=842 inet 10.10.0.5 netmask ffffff00 broadcast 10.10.0.255 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_lanscan0000644005276200011600000000047612276213016023111 0ustar jenkinsjenkinsHardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI Path Address In# State NamePPA ID Type Support Mjr# 0/1/2/0 0x0012317D6209 0 UP lan0 snap0 1 ETHER Yes 119 0/6/1/0 0x0017FD2D2A57 1 UP lan1 snap1 2 ETHER Yes 119 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lo00000644005276200011600000000012612276213016026351 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-1.7.5/spec/fixtures/unit/util/ip/linux_ifconfig_ib00000644005276200011600000000100012276213016023476 0ustar jenkinsjenkinsib0 Link encap:InfiniBand HWaddr 80:00:00:4A:FE:80:00:00:00:00:00:00:00:00:00:00:00:00:00:00 inet addr:10.6.193.12 Bcast:10.6.193.255 Mask:255.255.255.0 inet6 addr: fe80::202:c903:43:2721/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:65520 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1024 RX bytes:448 (448.0 b) TX bytes:0 (0.0 b) facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan10000644005276200011600000000015412276213016024160 0ustar jenkinsjenkinslan1: flags=843 inet 10.1.1.6 netmask ffffff00 broadcast 10.1.1.255 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan00000644005276200011600000000016312276213016024157 0ustar jenkinsjenkinslan0: flags=843 inet 192.168.3.10 netmask ffffff00 broadcast 192.168.3.255 facter-1.7.5/spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig0000644005276200011600000000302412276213016024013 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863 mtu 1500 ether 00:1b:63:ae:02:66 media: autoselect status: inactive supported media: autoselect 10baseT/UTP 10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT none fw0: flags=8863 mtu 4078 lladdr 00:1e:52:ff:fe:31:1a:80 media: autoselect status: inactive supported media: autoselect en1: flags=8863 mtu 1500 inet6 fe80::21e:52ff:fe70:d7b6%en1 prefixlen 64 scopeid 0x6 inet 192.168.0.4 netmask 0xffffff00 broadcast 192.168.0.255 ether 00:1e:52:70:d7:b6 media: autoselect status: active supported media: autoselect vmnet8: flags=8863 mtu 1500 inet 172.16.15.1 netmask 0xffffff00 broadcast 172.16.15.255 ether 00:50:56:c0:00:08 vmnet1: flags=8863 mtu 1500 inet 192.168.89.1 netmask 0xffffff00 broadcast 192.168.89.255 ether 00:50:56:c0:00:01 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_lanscan0000644005276200011600000000131712276213016025435 0ustar jenkinsjenkinsHardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI Path Address In# State NamePPA ID Type Support Mjr# 0/1/2/0 0x001319BD1C2D 0 UP lan0 snap0 1 ETHER Yes 119 0/2/1/0 0x0012819E48DE 1 UP lan1 snap1 2 ETHER Yes 119 0/2/1/1 0x0012819E48DF 2 UP lan2 snap2 3 ETHER Yes 119 0/4/2/0/6/0 0x001165EB7385 5 UP lan5 snap5 4 ETHER Yes 119 0/5/2/0/6/0 0x001165EB73E6 3 UP lan3 snap3 5 ETHER Yes 119 0/6/1/0 0x0012819E4A7E 4 UP lan4 snap4 6 ETHER Yes 119 0/6/1/1 0x0012819E4A7F 6 UP lan6 snap6 7 ETHER Yes 119 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan10000644005276200011600000000016412276213016024163 0ustar jenkinsjenkinslan1: flags=1843 inet 10.1.54.36 netmask ffffff00 broadcast 10.1.54.255 facter-1.7.5/spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface0000644005276200011600000000042712276213016026466 0ustar jenkinsjenkinsen1: flags=8863 mtu 1500 inet6 fe80::21c:b3ff:febe:81c9%en1 prefixlen 64 scopeid 0x6 inet 10.0.0.101 netmask 0xffffff00 broadcast 10.0.0.255 ether 00:1c:b3:be:81:c9 media: autoselect status: active supported media: autoselect facter-1.7.5/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig0000644005276200011600000000117212276213016024364 0ustar jenkinsjenkinsfxp0: flags=8843 mtu 1500 options=b inet x.x.58.26 netmask 0xfffffff8 broadcast x.x.58.31 inet x.x.58.27 netmask 0xffffffff broadcast x.x.58.27 inet x.x.58.28 netmask 0xffffffff broadcast x.x.58.28 inet x.x.58.29 netmask 0xffffffff broadcast x.x.58.29 inet x.x.58.30 netmask 0xffffffff broadcast x.x.58.30 ether 00:0e:0c:68:67:7c media: Ethernet autoselect (100baseTX ) status: active lo0: flags=8049 mtu 16384 inet 127.0.0.1 netmask 0xff000000 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4_10000644005276200011600000000017312276213016026737 0ustar jenkinsjenkinslan4:1: flags=1843 inet 192.168.1.197 netmask ffffff00 broadcast 192.168.1.255 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lo00000644005276200011600000000012612276213016024020 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_netstat_in0000644005276200011600000000073712276213016026173 0ustar jenkinsjenkinsName Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll lan4:1 1500 192.168.1.0 192.168.1.197 121 0 6 0 0 lan3* 1500 none none 0 0 0 0 0 lan1 1500 192.168.30.0 192.168.30.32 211188606 0 132070934 0 0 lo0 4136 127.0.0.0 127.0.0.1 513508160 0 513509185 0 0 lan4 1500 192.168.32.0 192.168.32.75 2640827721 0 2257447701 0 0 facter-1.7.5/spec/fixtures/unit/util/ip/linux_get_single_interface_lo0000644005276200011600000000062512276213016026026 0ustar jenkinsjenkinslo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1630 errors:0 dropped:0 overruns:0 frame:0 TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB) facter-1.7.5/spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig0000644005276200011600000000343712276213016024714 0ustar jenkinsjenkinsem0: flags=8843 metric 0 mtu 1500 options=209b ether 0:11:a:59:67:90 inet6 fe80::211:aff:fe59:6790%em0 prefixlen 64 scopeid 0x1 nd6 options=3 media: Ethernet autoselect (1000baseT ) status: active em1: flags=8843 metric 0 mtu 1500 options=209b ether 0:11:a:59:67:91 inet6 fe80::211:aff:fe59:6791%em1 prefixlen 64 scopeid 0x2 inet 192.168.10.10 netmask 0xffffff00 broadcast 192.168.10.255 nd6 options=3 media: Ethernet autoselect (100baseTX ) status: active bge0: flags=8802 metric 0 mtu 1500 options=8009b ether 0:14:c2:3f:ea:e4 media: Ethernet autoselect (none) status: no carrier bge1: flags=8802 metric 0 mtu 1500 options=8009b ether 0:14:c2:3f:ea:e3 media: Ethernet autoselect (none) status: no carrier lo0: flags=8049 metric 0 mtu 16384 options=3 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 inet 127.0.0.1 netmask 0xff000000 nd6 options=3 vlan0: flags=8843 metric 0 mtu 1500 options=3 ether 0:11:a:59:67:90 inet6 fe80::211:aff:fe59:6790%vlan0 prefixlen 64 scopeid 0x6 inet 192.168.192.2 netmask 0xffffff00 broadcast 192.168.192.255 nd6 options=3 media: Ethernet autoselect (1000baseT ) status: active vlan: 192 parent interface: em0 facter-1.7.5/spec/fixtures/unit/util/ip/windows_netsh_single_interface0000644005276200011600000000057212276213016026232 0ustar jenkinsjenkinsConfiguration for interface "Local Area Connection" DHCP enabled: Yes IP Address: 172.16.138.216 Subnet Prefix: 172.16.138.0/24 (mask 255.255.255.0) Default Gateway: 172.16.138.2 Gateway Metric: 0 InterfaceMetric: 10 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_asterisk_netstat_in0000644005276200011600000000047312276213016025544 0ustar jenkinsjenkinsName Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll lan1* 1500 10.10.0.0 10.10.0.5 786 0 240 0 0 lan0 1500 192.168.3.0 192.168.3.9 1823744990 0 23598735 0 0 lo0 4136 127.0.0.0 127.0.0.1 7048047 0 7048047 0 0 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_netstat_in0000644005276200011600000000047712276213016023643 0ustar jenkinsjenkinsName Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll lan1 1500 10.1.54.0 10.1.54.36 117489535 0 1681709 0 79 lan0 1500 192.168.30.0 192.168.30.152 964843646 0 1668475345 0 0 lo0 4136 127.0.0.0 127.0.0.1 4658855 0 4658855 0 0 facter-1.7.5/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface0000644005276200011600000000164712276213016030231 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:0c:29:52:15:e9 inet addr:172.16.15.133 Bcast:172.16.15.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe52:15e9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:173 errors:173 dropped:0 overruns:0 frame:0 TX packets:208 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:40970 (40.0 KB) TX bytes:24760 (24.1 KB) Interrupt:16 Base address:0x2024 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1630 errors:0 dropped:0 overruns:0 frame:0 TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB) facter-1.7.5/spec/fixtures/unit/util/ip/linux_2_6_35_proc_net_bonding_bond00000644005276200011600000000066312276213016026546 0ustar jenkinsjenkinsEthernet Channel Bonding Driver: v3.5.0 (November 4, 2008) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eth0 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 200 Down Delay (ms): 200 Slave Interface: eth1 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:11:22:33:44:56 Slave Interface: eth0 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:11:22:33:44:55 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1131_asterisk_lanscan0000644005276200011600000000062312276213016025010 0ustar jenkinsjenkinsHardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI Path Address In# State NamePPA ID Type Support Mjr# 0/0/0/0 0x00305D0626B2 0 UP lan0 snap0 1 ETHER Yes 119 0/4/2/0/6/0 0x0010797BBE46 1 UP lan1 snap1 2 ETHER Yes 119 0/4/2/0/7/0 0x0010797BBE47 2 DOWN lan2 snap2 3 ETHER Yes 119 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1111_lanscan0000644005276200011600000000060112276213016023075 0ustar jenkinsjenkinsHardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI Path Address In# State NamePPA ID Type Support Mjr# 0/0/0/0 0x00307F0C79DC 0 UP lan0 snap0 1 ETHER Yes 119 0/10/0/0/6/0 0x0010797B5CDE 1 UP lan1 snap1 2 ETHER Yes 119 0/10/0/0/7/0 0x0010797B5CDF 2 UP lan2 snap2 3 ETHER Yes 119 facter-1.7.5/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lo00000644005276200011600000000012612276213016024016 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-1.7.5/spec/fixtures/unit/util/ip/windows_netsh_all_interfaces0000644005276200011600000000124112276213016025676 0ustar jenkinsjenkinsIdx Met MTU State Name --- ---------- ---------- ------------ --------------------------- 1 50 4294967295 connected Loopback Pseudo-Interface 1 9 10 1500 connected Local Area Connection Idx Met MTU State Name --- ---------- ---------- ------------ --------------------------- 1 50 4294967295 connected Loopback Pseudo-Interface 1 9 10 1500 connected Local Area Connection 11 50 1280 disconnected isatap.localdomain 12 50 1280 connected Teredo Tunneling Pseudo-Interface facter-1.7.5/spec/fixtures/unit/util/manufacturer/0000755005276200011600000000000012276213023022111 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag0000644005276200011600000000314012276213016027525 0ustar jenkinsjenkinsSystem Configuration: Sun Microsystems sun4u Sun Fire V120 (UltraSPARC-IIe 648MHz) System clock frequency: 100 MHz Memory size: 2048 Megabytes ========================= CPUs ========================= Run Ecache CPU CPU Brd CPU Module MHz MB Impl. Mask --- --- ------- ----- ------ ------ ---- 0 0 0 648 0.5 13 3.3 ========================= IO Cards ========================= Bus# Freq Brd Type MHz Slot Name Model --- ---- ---- ---- -------------------------------- ---------------------- 0 PCI-1 33 12 ebus 0 PCI-1 33 3 pmu-pci10b9,7101 0 PCI-1 33 3 lomp 0 PCI-1 33 7 isa 0 PCI-1 33 12 network-pci108e,1101 SUNW,pci-eri 0 PCI-1 33 12 usb-pci108e,1103.1 0 PCI-1 33 13 ide-pci10b9,5229 0 PCI-1 33 5 network-pci108e,1101 SUNW,pci-eri 0 PCI-1 33 5 usb-pci108e,1103.1 0 PCI-2 33 8 scsi-glm Symbios,53C896 0 PCI-2 33 8 scsi-glm Symbios,53C896 0 PCI-2 33 5 network-pci108e,2bad SUNW,pci-gem No failures found in System =========================== facter-1.7.5/spec/fixtures/unit/util/manufacturer/intel_linux_dmidecode0000644005276200011600000003467512276213016026404 0ustar jenkinsjenkins# dmidecode 2.11 SMBIOS 2.7 present. 52 structures occupying 2192 bytes. Table at 0x000EB270. Handle 0x0000, DMI type 0, 24 bytes BIOS Information Vendor: Intel Corp. Version: AGH6110H.86A.0039.2012.0410.1054 Release Date: 04/10/2012 Address: 0xF0000 Runtime Size: 64 kB ROM Size: 1024 kB Characteristics: PCI is supported BIOS is upgradeable BIOS shadowing is allowed Boot from CD is supported Selectable boot is supported BIOS ROM is socketed EDD is supported 5.25"/1.2 MB floppy services are supported (int 13h) 3.5"/720 kB floppy services are supported (int 13h) 3.5"/2.88 MB floppy services are supported (int 13h) Print screen service is supported (int 5h) 8042 keyboard services are supported (int 9h) Serial services are supported (int 14h) Printer services are supported (int 17h) ACPI is supported USB legacy is supported BIOS boot specification is supported Targeted content distribution is supported UEFI is supported Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Product Name: Version: Serial Number: UUID: 60A98BB3-95B6-E111-AF74-4C72B9247D28 Wake-up Type: Power Switch SKU Number: Not Specified Family: Not Specified Handle 0x0002, DMI type 2, 15 bytes Base Board Information Manufacturer: Intel Corporation Product Name: DH61AG Version: AAG23736-503 Serial Number: BTAG2240143N Asset Tag: To be filled by O.E.M. Features: Board is a hosting board Board is replaceable Location In Chassis: To be filled by O.E.M. Chassis Handle: 0x0003 Type: Motherboard Contained Object Handles: 0 Handle 0x0003, DMI type 3, 22 bytes Chassis Information Manufacturer: Type: Desktop Lock: Not Present Version: Serial Number: Asset Tag: Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: None OEM Information: 0x00000000 Height: Unspecified Number Of Power Cords: 1 Contained Elements: 0 SKU Number: To be filled by O.E.M. Handle 0x0004, DMI type 4, 42 bytes Processor Information Socket Designation: LGA1155 CPU 1 Type: Central Processor Family: Core i3 Manufacturer: Intel(R) Corp. ID: A7 06 02 00 FF FB EB BF Signature: Type 0, Family 6, Model 42, Stepping 7 Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) DE (Debugging extension) PSE (Page size extension) TSC (Time stamp counter) MSR (Model specific registers) PAE (Physical address extension) MCE (Machine check exception) CX8 (CMPXCHG8 instruction supported) APIC (On-chip APIC hardware supported) SEP (Fast system call) MTRR (Memory type range registers) PGE (Page global enable) MCA (Machine check architecture) CMOV (Conditional move instruction supported) PAT (Page attribute table) PSE-36 (36-bit page size extension) CLFSH (CLFLUSH instruction supported) DS (Debug store) ACPI (ACPI supported) MMX (MMX technology supported) FXSR (FXSAVE and FXSTOR instructions supported) SSE (Streaming SIMD extensions) SSE2 (Streaming SIMD extensions 2) SS (Self-snoop) HTT (Multi-threading) TM (Thermal monitor supported) PBE (Pending break enabled) Version: Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz Voltage: 1.7 V External Clock: 25 MHz Max Speed: 4000 MHz Current Speed: 3400 MHz Status: Populated, Enabled Upgrade: Socket BGA1155 L1 Cache Handle: 0x0005 L2 Cache Handle: 0x0006 L3 Cache Handle: 0x0007 Serial Number: To Be Filled By O.E.M. Asset Tag: To Be Filled By O.E.M. Part Number: To Be Filled By O.E.M. Core Count: 2 Core Enabled: 1 Thread Count: 2 Characteristics: 64-bit capable Handle 0x0005, DMI type 7, 19 bytes Cache Information Socket Designation: L1-Cache Configuration: Enabled, Not Socketed, Level 1 Operational Mode: Write Back Location: Internal Installed Size: 32 kB Maximum Size: 32 kB Supported SRAM Types: Other Installed SRAM Type: Other Speed: Unknown Error Correction Type: None System Type: Unified Associativity: 8-way Set-associative Handle 0x0006, DMI type 7, 19 bytes Cache Information Socket Designation: L2-Cache Configuration: Enabled, Not Socketed, Level 2 Operational Mode: Varies With Memory Address Location: Internal Installed Size: 512 kB Maximum Size: 512 kB Supported SRAM Types: Other Installed SRAM Type: Other Speed: Unknown Error Correction Type: None System Type: Unified Associativity: 8-way Set-associative Handle 0x0007, DMI type 7, 19 bytes Cache Information Socket Designation: L3-Cache Configuration: Enabled, Not Socketed, Level 3 Operational Mode: Unknown Location: Internal Installed Size: 3072 kB Maximum Size: 3072 kB Supported SRAM Types: Other Installed SRAM Type: Other Speed: Unknown Error Correction Type: None System Type: Unified Associativity: Other Handle 0x0008, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J1A1 Internal Connector Type: None External Reference Designator: PS2Mouse External Connector Type: PS/2 Port Type: Mouse Port Handle 0x0009, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J1A1 Internal Connector Type: None External Reference Designator: Keyboard External Connector Type: PS/2 Port Type: Keyboard Port Handle 0x000A, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J2A1 Internal Connector Type: None External Reference Designator: TV Out External Connector Type: Mini Centronics Type-14 Port Type: Other Handle 0x000B, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J2A2A Internal Connector Type: None External Reference Designator: COM A External Connector Type: DB-9 male Port Type: Serial Port 16550A Compatible Handle 0x000C, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J2A2B Internal Connector Type: None External Reference Designator: Video External Connector Type: DB-15 female Port Type: Video Port Handle 0x000D, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J3A1 Internal Connector Type: None External Reference Designator: USB1 External Connector Type: Access Bus (USB) Port Type: USB Handle 0x000E, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J3A1 Internal Connector Type: None External Reference Designator: USB2 External Connector Type: Access Bus (USB) Port Type: USB Handle 0x000F, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J3A1 Internal Connector Type: None External Reference Designator: USB3 External Connector Type: Access Bus (USB) Port Type: USB Handle 0x0010, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9A1 - TPM HDR Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0011, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9C1 - PCIE DOCKING CONN Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0012, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J2B3 - CPU FAN Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0013, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J6C2 - EXT HDMI Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0014, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J3C1 - GMCH FAN Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0015, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J1D1 - ITP Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0016, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9E2 - MDC INTPSR Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0017, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9E4 - MDC INTPSR Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0018, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9E3 - LPC HOT DOCKING Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0019, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9E1 - SCAN MATRIX Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x001A, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9G1 - LPC SIDE BAND Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x001B, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J8F1 - UNIFIED Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x001C, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J6F1 - LVDS Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x001D, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J2F1 - LAI FAN Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x001E, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J2G1 - GFX VID Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x001F, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J1G6 - AC JACK Internal Connector Type: Other External Reference Designator: Not Specified External Connector Type: None Port Type: Other Handle 0x0020, DMI type 9, 17 bytes System Slot Information Designation: PCIe X4 SLOT1 Type: x4 PCI Express Current Usage: Available Length: Long ID: 0 Characteristics: 3.3 V is provided Opening is shared PME signal is supported Bus Address: 0000:00:01.0 Handle 0x0021, DMI type 10, 6 bytes On Board Device Information Type: Video Status: Enabled Description: Intel(R) HD Graphics Device Handle 0x0022, DMI type 10, 6 bytes On Board Device Information Type: Ethernet Status: Enabled Description: Intel(R) 82579V Gigabit Network Device Handle 0x0023, DMI type 10, 6 bytes On Board Device Information Type: Sound Status: Enabled Description: Intel(R) High Definition Audio Device Handle 0x0024, DMI type 11, 5 bytes OEM Strings String 1: To Be Filled By O.E.M. Handle 0x0025, DMI type 12, 5 bytes System Configuration Options Option 1: To Be Filled By O.E.M. Handle 0x0026, DMI type 16, 15 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: None Maximum Capacity: 16 GB Error Information Handle: No Error Number Of Devices: 2 Handle 0x0027, DMI type 18, 23 bytes 32-bit Memory Error Information Type: OK Granularity: Unknown Operation: Unknown Vendor Syndrome: Unknown Memory Array Address: Unknown Device Address: Unknown Resolution: Unknown Handle 0x0028, DMI type 19, 15 bytes Memory Array Mapped Address Starting Address: 0x00000000000 Ending Address: 0x003FFFFFFFF Range Size: 16 GB Physical Array Handle: 0x0026 Partition Width: 1 Handle 0x0029, DMI type 17, 28 bytes Memory Device Array Handle: 0x0026 Error Information Handle: No Error Total Width: 64 bits Data Width: 64 bits Size: 8192 MB Form Factor: DIMM Set: None Locator: SODIMM1 Bank Locator: Channel A DIMM 0 Type: DDR3 Type Detail: Synchronous Speed: 1333 MHz Manufacturer: Kingston Serial Number: 363D6E24 Asset Tag: A1_AssetTagNum0 Part Number: 9905428-093.A00LF Rank: 2 Handle 0x002A, DMI type 18, 23 bytes 32-bit Memory Error Information Type: OK Granularity: Unknown Operation: Unknown Vendor Syndrome: Unknown Memory Array Address: Unknown Device Address: Unknown Resolution: Unknown Handle 0x002B, DMI type 20, 19 bytes Memory Device Mapped Address Starting Address: 0x00000000000 Ending Address: 0x001FFFFFFFF Range Size: 8 GB Physical Device Handle: 0x0029 Memory Array Mapped Address Handle: 0x0028 Partition Row Position: 1 Handle 0x002C, DMI type 17, 28 bytes Memory Device Array Handle: 0x0026 Error Information Handle: No Error Total Width: 64 bits Data Width: 64 bits Size: 8192 MB Form Factor: DIMM Set: None Locator: SODIMM2 Bank Locator: Channel B DIMM 0 Type: DDR3 Type Detail: Synchronous Speed: 1333 MHz Manufacturer: Kingston Serial Number: 363D2A28 Asset Tag: A1_AssetTagNum1 Part Number: 9905428-093.A00LF Rank: 2 Handle 0x002D, DMI type 18, 23 bytes 32-bit Memory Error Information Type: OK Granularity: Unknown Operation: Unknown Vendor Syndrome: Unknown Memory Array Address: Unknown Device Address: Unknown Resolution: Unknown Handle 0x002E, DMI type 20, 19 bytes Memory Device Mapped Address Starting Address: 0x00200000000 Ending Address: 0x003FFFFFFFF Range Size: 8 GB Physical Device Handle: 0x002C Memory Array Mapped Address Handle: 0x0028 Partition Row Position: 1 Handle 0x002F, DMI type 32, 20 bytes System Boot Information Status: No errors detected Handle 0x0030, DMI type 41, 11 bytes Onboard Device Reference Designation: Intel(R) HD Graphics Device Type: Video Status: Enabled Type Instance: 1 Bus Address: 0000:00:02.0 Handle 0x0031, DMI type 41, 11 bytes Onboard Device Reference Designation: Intel(R) 82579V Gigabit Network Device Type: Ethernet Status: Enabled Type Instance: 1 Bus Address: 0000:00:19.0 Handle 0x0032, DMI type 41, 11 bytes Onboard Device Reference Designation: Intel(R) High Definition Audio Device Type: Sound Status: Enabled Type Instance: 1 Bus Address: 0000:00:1b.0 Handle 0x0041, DMI type 127, 4 bytes End Of Table facter-1.7.5/spec/fixtures/unit/util/manufacturer/opensolaris_smbios0000644005276200011600000000157612276213016025761 0ustar jenkinsjenkinsID SIZE TYPE 0 54 SMB_TYPE_BIOS (BIOS information) Vendor: innotek GmbH Version String: VirtualBox Release Date: 12/01/2006 Address Segment: 0xe000 ROM Size: 131072 bytes Image Size: 131072 bytes Characteristics: 0x48018090 SMB_BIOSFL_ISA (ISA is supported) SMB_BIOSFL_PCI (PCI is supported) SMB_BIOSFL_CDBOOT (Boot from CD is supported) SMB_BIOSFL_SELBOOT (Selectable Boot supported) SMB_BIOSFL_I9_KBD (int 0x9 8042 keyboard svcs) SMB_BIOSFL_I10_CGA (int 0x10 CGA svcs) Characteristics Extension Byte 1: 0x1 SMB_BIOSXB1_ACPI (ACPI is supported) Characteristics Extension Byte 2: 0x0 ID SIZE TYPE 1 72 SMB_TYPE_SYSTEM (system information) Manufacturer: innotek GmbH Product: VirtualBox Version: 1.2 Serial Number: 0 UUID: cf4bff06-0b33-4891-bda0-5ec17bea5511 Wake-Up Event: 0x6 (power switch) SKU Number: Family: Virtual Machine facter-1.7.5/spec/fixtures/unit/util/manufacturer/freebsd_dmidecode0000644005276200011600000000163112276213016025446 0ustar jenkinsjenkins# dmidecode 2.10 SMBIOS 2.5 present. 5 structures occupying 352 bytes. Table at 0x000E1000. Handle 0x0000, DMI type 0, 20 bytes BIOS Information Vendor: innotek GmbH Version: VirtualBox Release Date: 12/01/2006 Address: 0xE0000 Runtime Size: 128 kB ROM Size: 128 kB Characteristics: ISA is supported PCI is supported Boot from CD is supported Selectable boot is supported 8042 keyboard services are supported (int 9h) CGA/mono video services are supported (int 10h) ACPI is supported Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: innotek GmbH Product Name: VirtualBox Version: 1.2 Serial Number: 0 UUID: 3BD58031-AE9E-4F06-8A57-941942861939 Wake-up Type: Power Switch SKU Number: Not Specified Family: Virtual Machine Handle 0x0003, DMI type 126, 13 bytes Inactive Handle 0x0002, DMI type 126, 7 bytes Inactive Handle 0xFEFF, DMI type 127, 147 bytes End Of Table facter-1.7.5/spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag0000644005276200011600000001472612276213016026072 0ustar jenkinsjenkinsSystem Configuration: Sun Microsystems sun4v SPARC Enterprise T5220 Memory size: 32640 Megabytes ================================ Virtual CPUs ================================ CPU ID Frequency Implementation Status ------ --------- ---------------------- ------- 0 1165 MHz SUNW,UltraSPARC-T2 on-line 1 1165 MHz SUNW,UltraSPARC-T2 on-line 2 1165 MHz SUNW,UltraSPARC-T2 on-line 3 1165 MHz SUNW,UltraSPARC-T2 on-line 4 1165 MHz SUNW,UltraSPARC-T2 on-line 5 1165 MHz SUNW,UltraSPARC-T2 on-line 6 1165 MHz SUNW,UltraSPARC-T2 on-line 7 1165 MHz SUNW,UltraSPARC-T2 on-line 8 1165 MHz SUNW,UltraSPARC-T2 on-line 9 1165 MHz SUNW,UltraSPARC-T2 on-line 10 1165 MHz SUNW,UltraSPARC-T2 on-line 11 1165 MHz SUNW,UltraSPARC-T2 on-line 12 1165 MHz SUNW,UltraSPARC-T2 on-line 13 1165 MHz SUNW,UltraSPARC-T2 on-line 14 1165 MHz SUNW,UltraSPARC-T2 on-line 15 1165 MHz SUNW,UltraSPARC-T2 on-line 16 1165 MHz SUNW,UltraSPARC-T2 on-line 17 1165 MHz SUNW,UltraSPARC-T2 on-line 18 1165 MHz SUNW,UltraSPARC-T2 on-line 19 1165 MHz SUNW,UltraSPARC-T2 on-line 20 1165 MHz SUNW,UltraSPARC-T2 on-line 21 1165 MHz SUNW,UltraSPARC-T2 on-line 22 1165 MHz SUNW,UltraSPARC-T2 on-line 23 1165 MHz SUNW,UltraSPARC-T2 on-line 24 1165 MHz SUNW,UltraSPARC-T2 on-line 25 1165 MHz SUNW,UltraSPARC-T2 on-line 26 1165 MHz SUNW,UltraSPARC-T2 on-line 27 1165 MHz SUNW,UltraSPARC-T2 on-line 28 1165 MHz SUNW,UltraSPARC-T2 on-line 29 1165 MHz SUNW,UltraSPARC-T2 on-line 30 1165 MHz SUNW,UltraSPARC-T2 on-line 31 1165 MHz SUNW,UltraSPARC-T2 on-line 32 1165 MHz SUNW,UltraSPARC-T2 on-line 33 1165 MHz SUNW,UltraSPARC-T2 on-line 34 1165 MHz SUNW,UltraSPARC-T2 on-line 35 1165 MHz SUNW,UltraSPARC-T2 on-line 36 1165 MHz SUNW,UltraSPARC-T2 on-line 37 1165 MHz SUNW,UltraSPARC-T2 on-line 38 1165 MHz SUNW,UltraSPARC-T2 on-line 39 1165 MHz SUNW,UltraSPARC-T2 on-line 40 1165 MHz SUNW,UltraSPARC-T2 on-line 41 1165 MHz SUNW,UltraSPARC-T2 on-line 42 1165 MHz SUNW,UltraSPARC-T2 on-line 43 1165 MHz SUNW,UltraSPARC-T2 on-line 44 1165 MHz SUNW,UltraSPARC-T2 on-line 45 1165 MHz SUNW,UltraSPARC-T2 on-line 46 1165 MHz SUNW,UltraSPARC-T2 on-line 47 1165 MHz SUNW,UltraSPARC-T2 on-line 48 1165 MHz SUNW,UltraSPARC-T2 on-line 49 1165 MHz SUNW,UltraSPARC-T2 on-line 50 1165 MHz SUNW,UltraSPARC-T2 on-line 51 1165 MHz SUNW,UltraSPARC-T2 on-line 52 1165 MHz SUNW,UltraSPARC-T2 on-line 53 1165 MHz SUNW,UltraSPARC-T2 on-line 54 1165 MHz SUNW,UltraSPARC-T2 on-line 55 1165 MHz SUNW,UltraSPARC-T2 on-line 56 1165 MHz SUNW,UltraSPARC-T2 on-line 57 1165 MHz SUNW,UltraSPARC-T2 on-line 58 1165 MHz SUNW,UltraSPARC-T2 on-line 59 1165 MHz SUNW,UltraSPARC-T2 on-line 60 1165 MHz SUNW,UltraSPARC-T2 on-line 61 1165 MHz SUNW,UltraSPARC-T2 on-line 62 1165 MHz SUNW,UltraSPARC-T2 on-line 63 1165 MHz SUNW,UltraSPARC-T2 on-line ======================= Physical Memory Configuration ======================== Segment Table: -------------------------------------------------------------- Base Segment Interleave Bank Contains Address Size Factor Size Modules -------------------------------------------------------------- 0x0 32 GB 8 4 GB MB/CMP0/BR0/CH0/D0 MB/CMP0/BR0/CH1/D0 4 GB MB/CMP0/BR0/CH0/D1 MB/CMP0/BR0/CH1/D1 4 GB MB/CMP0/BR1/CH0/D0 MB/CMP0/BR1/CH1/D0 4 GB MB/CMP0/BR1/CH0/D1 MB/CMP0/BR1/CH1/D1 4 GB MB/CMP0/BR2/CH0/D0 MB/CMP0/BR2/CH1/D0 4 GB MB/CMP0/BR2/CH0/D1 MB/CMP0/BR2/CH1/D1 4 GB MB/CMP0/BR3/CH0/D0 MB/CMP0/BR3/CH1/D0 4 GB MB/CMP0/BR3/CH0/D1 MB/CMP0/BR3/CH1/D1 ================================ IO Devices ================================ Slot + Bus Name + Model Status Type Path ---------------------------------------------------------------------------- MB/NET0 PCIE network-pciex8086,105e /pci@0/pci@0/pci@1/pci@0/pci@2/network@0 MB/NET1 PCIE network-pciex8086,105e /pci@0/pci@0/pci@1/pci@0/pci@2/network@0,1 MB/NET2 PCIE network-pciex8086,105e /pci@0/pci@0/pci@1/pci@0/pci@3/network@0 MB/NET3 PCIE network-pciex8086,105e /pci@0/pci@0/pci@1/pci@0/pci@3/network@0,1 MB/SASHBA PCIE scsi-pciex1000,58 LSI,1068E /pci@0/pci@0/pci@2/scsi@0 MB PCIX usb-pciclass,0c0310 /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0 MB PCIX usb-pciclass,0c0310 /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0,1 MB PCIX usb-pciclass,0c0320 /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0,2 ============================ Environmental Status ============================ Fan sensors: All fan sensors are OK. Temperature sensors: All temperature sensors are OK. Current sensors: All current sensors are OK. Voltage sensors: All voltage sensors are OK. Voltage indicators: All voltage indicators are OK. ============================ FRU Status ============================ All FRUs are enabled. facter-1.7.5/spec/fixtures/unit/util/manufacturer/linux_dmidecode_with_spaces0000644005276200011600000000451112276213016027564 0ustar jenkinsjenkins# dmidecode 2.2 SMBIOS 2.3 present. 32 structures occupying 994 bytes. Table at 0x000F0800. Handle 0x0000 DMI type 0, 20 bytes. BIOS Information Vendor: Award Software International, Inc. Version: 6.00 PG Release Date: 01/03/2003 Address: 0xE0000 Runtime Size: 128 kB ROM Size: 256 kB Characteristics: ISA is supported PCI is supported PNP is supported APM is supported BIOS is upgradeable BIOS shadowing is allowed ESCD support is available Boot from CD is supported Selectable boot is supported BIOS ROM is socketed EDD is supported 5.25"/360 KB floppy services are supported (int 13h) 5.25"/1.2 MB floppy services are supported (int 13h) 3.5"/720 KB floppy services are supported (int 13h) 3.5"/2.88 MB floppy services are supported (int 13h) Print screen service is supported (int 5h) 8042 keyboard services are supported (int 9h) Serial services are supported (int 14h) Printer services are supported (int 17h) CGA/mono video services are supported (int 10h) ACPI is supported USB legacy is supported AGP is supported LS-120 boot is supported ATAPI Zip drive boot is supported Handle 0x0001 DMI type 1, 25 bytes. System Information Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD Product Name: MS-6754 Version: Serial Number: UUID: Not Present Wake-up Type: Power Switch Handle 0x0002 DMI type 2, 8 bytes. Base Board Information Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD Product Name: MS-6754 Version: Serial Number: Handle 0x001F DMI type 127, 4 bytes. End Of Table facter-1.7.5/spec/fixtures/unit/interfaces/0000755005276200011600000000000012276213023020563 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt0000644005276200011600000000204012276213016025640 0ustar jenkinsjenkinsem1: flags=4163 mtu 1500 inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255 inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0 inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20 ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet) RX packets 27222144 bytes 31247414760 (29.1 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10259038 bytes 7784519352 (7.2 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xd2600000-d2620000 lo: flags=73 mtu 16436 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 257371 bytes 37104110 (35.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 257371 bytes 37104110 (35.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 facter-1.7.5/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.em10000644005276200011600000000120512276213016026323 0ustar jenkinsjenkinsem1: flags=4163 mtu 1500 inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255 inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0 inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20 ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet) RX packets 27222144 bytes 31247414760 (29.1 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10259038 bytes 7784519352 (7.2 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xd2600000-d2620000 facter-1.7.5/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.lo0000644005276200011600000000063212276213016026256 0ustar jenkinsjenkinslo: flags=73 mtu 16436 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 257371 bytes 37104110 (35.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 257371 bytes 37104110 (35.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 facter-1.7.5/spec/fixtures/unit/zfs_version/0000755005276200011600000000000012276213023021007 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/zfs_version/solaris_100000644005276200011600000000054612276213017022716 0ustar jenkinsjenkinsThe following filesystem versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS filesystem version 2 Enhanced directory entries 3 Case insensitive and SMB credentials support For more information on a particular version, including supported releases, see the ZFS Administration Guide. facter-1.7.5/spec/fixtures/unit/zfs_version/freebsd_9.00000644005276200011600000000066112276213017022740 0ustar jenkinsjenkinsThe following filesystem versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS filesystem version 2 Enhanced directory entries 3 Case insensitive and File system unique identifier (FUID) 4 userquota, groupquota properties 5 System attributes For more information on a particular version, including supported releases, see the ZFS Administration Guide. facter-1.7.5/spec/fixtures/unit/zfs_version/solaris_110000644005276200011600000000064312276213017022715 0ustar jenkinsjenkinsThe following filesystem versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS filesystem version 2 Enhanced directory entries 3 Case insensitive and SMB credentials support 4 userquota, groupquota properties 5 System attributes For more information on a particular version, including supported releases, see the ZFS Administration Guide. facter-1.7.5/spec/fixtures/unit/zfs_version/freebsd_8.20000644005276200011600000000073012276213017022736 0ustar jenkinsjenkinsThe following filesystem versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS filesystem version 2 Enhanced directory entries 3 Case insensitive and File system unique identifer (FUID) 4 userquota, groupquota properties For more information on a particular version, including supported releases, see: http://www.opensolaris.org/os/community/zfs/version/zpl/N Where 'N' is the version number. facter-1.7.5/spec/fixtures/unit/zfs_version/linux-fuse_0.6.90000644005276200011600000000073112276213017023567 0ustar jenkinsjenkinsThe following filesystem versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS filesystem version 2 Enhanced directory entries 3 Case insensitive and File system unique identifier (FUID) 4 userquota, groupquota properties For more information on a particular version, including supported releases, see: http://www.opensolaris.org/os/community/zfs/version/zpl/N Where 'N' is the version number. facter-1.7.5/spec/fixtures/unit/ipaddress/0000755005276200011600000000000012276213023020416 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt0000644005276200011600000000204012276213016025473 0ustar jenkinsjenkinsem1: flags=4163 mtu 1500 inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255 inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0 inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20 ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet) RX packets 27222144 bytes 31247414760 (29.1 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10259038 bytes 7784519352 (7.2 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xd2600000-d2620000 lo: flags=73 mtu 16436 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 257371 bytes 37104110 (35.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 257371 bytes 37104110 (35.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 facter-1.7.5/spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt0000644005276200011600000000217212276213016027310 0ustar jenkinsjenkinslo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:9031461 errors:0 dropped:0 overruns:0 frame:0 TX packets:9031461 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3205490447 (2.9 GiB) TX bytes:3205490447 (2.9 GiB) venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 RX packets:38161277 errors:0 dropped:0 overruns:0 frame:0 TX packets:24601924 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3847964603 (3.5 GiB) TX bytes:5770630041 (5.3 GiB) venet0:1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:10.0.222.20 P-t-P:10.0.222.20 Bcast:10.0.222.20 Mask:255.255.255.255 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 facter-1.7.5/spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt0000644005276200011600000000146612276213016025024 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 42:01:0a:57:50:6e inet addr:10.87.80.110 Bcast:10.87.80.110 Mask:255.255.255.255 UP BROADCAST RUNNING MULTICAST MTU:1460 Metric:1 RX packets:1609444 errors:0 dropped:0 overruns:0 frame:0 TX packets:1479569 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:673812693 (673.8 MB) TX bytes:221186872 (221.1 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:5435415 errors:0 dropped:0 overruns:0 frame:0 TX packets:5435415 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:734540224 (734.5 MB) TX bytes:734540224 (734.5 MB) facter-1.7.5/spec/fixtures/unit/ipaddress/ifconfig_non_english_locale.txt0000644005276200011600000000163712276213016026656 0ustar jenkinsjenkinslo Link encap:Boucle locale inet adr:127.0.0.1 Masque:255.0.0.0 adr inet6: ::1/128 Scope:Hote UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:1001 errors:0 dropped:0 overruns:0 frame:0 TX packets:1001 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 lg file transmission:0 RX bytes:52562 (51.3 KiB) TX bytes:52562 (51.3 KiB) wlan0 Link encap:Ethernet HWaddr ac:81:12:2d:86:25 inet adr:192.168.1.83 Bcast:192.168.1.255 Masque:255.255.255.0 adr inet6: fe80::ae81:12ff:fe2d:8625/64 Scope:Lien UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:493220 errors:0 dropped:0 overruns:0 frame:0 TX packets:390375 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 lg file transmission:1000 RX bytes:569234568 (542.8 MiB) TX bytes:69778980 (66.5 MiB) facter-1.7.5/spec/fixtures/unit/virtual/0000755005276200011600000000000012276213023020126 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt0000644005276200011600000000005212276213017025271 0ustar jenkinsjenkinsGoogleGooglefacter-1.7.5/spec/fixtures/unit/zpool_version/0000755005276200011600000000000012276213023021350 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/zpool_version/solaris_100000644005276200011600000000165112276213017023255 0ustar jenkinsjenkinsThis system is currently running ZFS pool version 22. The following versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS version 2 Ditto blocks (replicated metadata) 3 Hot spares and double parity RAID-Z 4 zpool history 5 Compression using the gzip algorithm 6 bootfs pool property 7 Separate intent log devices 8 Delegated administration 9 refquota and refreservation properties 10 Cache devices 11 Improved scrub performance 12 Snapshot properties 13 snapused property 14 passthrough-x aclinherit 15 user/group space accounting 16 stmf property support 17 Triple-parity RAID-Z 18 Snapshot user holds 19 Log device removal 20 Compression using zle (zero-length encoding) 21 Reserved 22 Received properties For more information on a particular version, including supported releases, see the ZFS Administration Guide. facter-1.7.5/spec/fixtures/unit/zpool_version/freebsd_9.00000644005276200011600000000214612276213017023301 0ustar jenkinsjenkinsThis system is currently running ZFS pool version 28. The following versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS version 2 Ditto blocks (replicated metadata) 3 Hot spares and double parity RAID-Z 4 zpool history 5 Compression using the gzip algorithm 6 bootfs pool property 7 Separate intent log devices 8 Delegated administration 9 refquota and refreservation properties 10 Cache devices 11 Improved scrub performance 12 Snapshot properties 13 snapused property 14 passthrough-x aclinherit 15 user/group space accounting 16 stmf property support 17 Triple-parity RAID-Z 18 Snapshot user holds 19 Log device removal 20 Compression using zle (zero-length encoding) 21 Deduplication 22 Received properties 23 Slim ZIL 24 System attributes 25 Improved scrub stats 26 Improved snapshot deletion performance 27 Improved snapshot creation performance 28 Multiple vdev replacements For more information on a particular version, including supported releases, see the ZFS Administration Guide. facter-1.7.5/spec/fixtures/unit/zpool_version/solaris_110000644005276200011600000000240112276213017023250 0ustar jenkinsjenkinszpool upgrade -v This system is currently running ZFS pool version 33. The following versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS version 2 Ditto blocks (replicated metadata) 3 Hot spares and double parity RAID-Z 4 zpool history 5 Compression using the gzip algorithm 6 bootfs pool property 7 Separate intent log devices 8 Delegated administration 9 refquota and refreservation properties 10 Cache devices 11 Improved scrub performance 12 Snapshot properties 13 snapused property 14 passthrough-x aclinherit 15 user/group space accounting 16 stmf property support 17 Triple-parity RAID-Z 18 Snapshot user holds 19 Log device removal 20 Compression using zle (zero-length encoding) 21 Deduplication 22 Received properties 23 Slim ZIL 24 System attributes 25 Improved scrub stats 26 Improved snapshot deletion performance 27 Improved snapshot creation performance 28 Multiple vdev replacements 29 RAID-Z/mirror hybrid allocator 30 Encryption 31 Improved 'zfs list' performance 32 One MB blocksize 33 Improved share support For more information on a particular version, including supported releases, see the ZFS Administration Guide. facter-1.7.5/spec/fixtures/unit/zpool_version/freebsd_8.20000644005276200011600000000144512276213017023303 0ustar jenkinsjenkinsThis system is currently running ZFS pool version 15. The following versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS version 2 Ditto blocks (replicated metadata) 3 Hot spares and double parity RAID-Z 4 zpool history 5 Compression using the gzip algorithm 6 bootfs pool property 7 Separate intent log devices 8 Delegated administration 9 refquota and refreservation properties 10 Cache devices 11 Improved scrub performance 12 Snapshot properties 13 snapused property 14 passthrough-x aclinherit 15 user/group space accounting For more information on a particular version, including supported releases, see: http://www.opensolaris.org/os/community/zfs/version/N Where 'N' is the version number. facter-1.7.5/spec/fixtures/unit/zpool_version/linux-fuse_0.6.90000644005276200011600000000177012276213017024134 0ustar jenkinsjenkinsThis system is currently running ZFS pool version 23. The following versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS version 2 Ditto blocks (replicated metadata) 3 Hot spares and double parity RAID-Z 4 zpool history 5 Compression using the gzip algorithm 6 bootfs pool property 7 Separate intent log devices 8 Delegated administration 9 refquota and refreservation properties 10 Cache devices 11 Improved scrub performance 12 Snapshot properties 13 snapused property 14 passthrough-x aclinherit 15 user/group space accounting 16 stmf property support 17 Triple-parity RAID-Z 18 Snapshot user holds 19 Log device removal 20 Compression using zle (zero-length encoding) 21 Deduplication 22 Received properties 23 Slim ZIL For more information on a particular version, including supported releases, see: http://www.opensolaris.org/os/community/zfs/version/N Where 'N' is the version number. facter-1.7.5/spec/fixtures/unit/netmask/0000755005276200011600000000000012276213023020102 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt0000644005276200011600000000204012276213016025157 0ustar jenkinsjenkinsem1: flags=4163 mtu 1500 inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255 inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0 inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20 ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet) RX packets 27222144 bytes 31247414760 (29.1 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10259038 bytes 7784519352 (7.2 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xd2600000-d2620000 lo: flags=73 mtu 16436 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 257371 bytes 37104110 (35.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 257371 bytes 37104110 (35.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 facter-1.7.5/spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt0000644005276200011600000000146612276213016024510 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 42:01:0a:57:50:6e inet addr:10.87.80.110 Bcast:10.87.80.110 Mask:255.255.255.255 UP BROADCAST RUNNING MULTICAST MTU:1460 Metric:1 RX packets:1609444 errors:0 dropped:0 overruns:0 frame:0 TX packets:1479569 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:673812693 (673.8 MB) TX bytes:221186872 (221.1 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:5435415 errors:0 dropped:0 overruns:0 frame:0 TX packets:5435415 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:734540224 (734.5 MB) TX bytes:734540224 (734.5 MB) facter-1.7.5/spec/fixtures/unit/selinux/0000755005276200011600000000000012276213023020127 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/selinux/selinux_sestatus0000644005276200011600000000030312276213016023472 0ustar jenkinsjenkinsSELinux status: enabled SELinuxfs mount: /selinux Current Mode: permissive Mode from config file: permissive Policy version: 16 Policy from config file: targeted facter-1.7.5/spec/fixtures/unit/filesystems/0000755005276200011600000000000012276213023021007 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/unit/filesystems/linux0000644005276200011600000000065312276213016022077 0ustar jenkinsjenkinsnodev sysfs nodev rootfs nodev bdev nodev proc nodev cgroup nodev cpuset nodev debugfs nodev securityfs nodev sockfs nodev pipefs nodev anon_inodefs nodev tmpfs nodev inotifyfs nodev devpts ext3 ext2 ext4 nodev ramfs nodev hugetlbfs nodev ecryptfs nodev fuse fuseblk nodev fusectl nodev mqueue xfs nodev binfmt_misc vfat iso9660 facter-1.7.5/spec/fixtures/ifconfig/0000755005276200011600000000000012276213023017245 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/ifconfig/darwin_10_6_40000644005276200011600000000227512276213016021434 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863 mtu 1500 ether 58:b0:35:fa:08:b1 media: autoselect status: inactive en1: flags=8863 mtu 1500 ether 58:b0:35:7f:25:b3 inet6 fe80::5ab0:35ff:fe7f:25b3%en1 prefixlen 64 scopeid 0x5 inet 192.168.100.230 netmask 0xffffff00 broadcast 192.168.100.255 media: status: active fw0: flags=8863 mtu 4078 lladdr c4:2c:03:ff:fe:fc:c8:aa media: autoselect status: inactive vboxnet0: flags=8842 mtu 1500 ether 0a:00:27:00:00:00 vmnet1: flags=8863 mtu 1500 ether 00:50:56:c0:00:01 inet 172.16.135.1 netmask 0xffffff00 broadcast 172.16.135.255 vmnet8: flags=8863 mtu 1500 ether 00:50:56:c0:00:08 inet 172.16.38.1 netmask 0xffffff00 broadcast 172.16.38.255 facter-1.7.5/spec/fixtures/ifconfig/ifconfig_net_tools_1.60.txt0000644005276200011600000000204012276213016024322 0ustar jenkinsjenkinsem1: flags=4163 mtu 1500 inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255 inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0 inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20 ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet) RX packets 27222144 bytes 31247414760 (29.1 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10259038 bytes 7784519352 (7.2 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xd2600000-d2620000 lo: flags=73 mtu 16436 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 257371 bytes 37104110 (35.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 257371 bytes 37104110 (35.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 facter-1.7.5/spec/fixtures/ifconfig/centos_5_50000644005276200011600000000157112276213016021141 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 16:8D:2A:15:17:91 inet addr:100.100.100.92 Bcast:100.100.100.255 Mask:255.255.255.0 inet6 addr: fe80::148d:2aff:fe15:1791/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1914742 errors:0 dropped:0 overruns:0 frame:0 TX packets:3933 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:178728699 (170.4 MiB) TX bytes:389936 (380.7 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) facter-1.7.5/spec/fixtures/ifconfig/fedora_10_eth00000644005276200011600000000104012276213016021645 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:17:F2:06:E4:26 inet addr:100.100.108.9 Bcast:100.100.108.255 Mask:255.255.255.0 inet6 addr: fe80::217:f2ff:fe06:e426/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:47711864 errors:0 dropped:0 overruns:0 frame:0 TX packets:45447195 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:17037147877 (15.8 GiB) TX bytes:9198873602 (8.5 GiB) Memory:92c20000-92c40000 facter-1.7.5/spec/fixtures/ifconfig/darwin_9_8_00000644005276200011600000000401212276213016021351 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863 mtu 1500 inet6 fe80::217:f2ff:fe06:e42e%en0 prefixlen 64 scopeid 0x4 inet 100.100.107.4 netmask 0xffffff00 broadcast 100.100.107.255 ether 00:17:f2:06:e4:2e media: autoselect (1000baseT ) status: active supported media: autoselect 10baseT/UTP 10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT en1: flags=8863 mtu 1500 ether 00:17:f2:06:e4:2f media: autoselect status: inactive supported media: autoselect 10baseT/UTP 10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT fw0: flags=8863 mtu 2030 lladdr 00:16:cb:ff:fe:76:66:f2 media: autoselect status: inactive supported media: autoselect vmnet8: flags=8863 mtu 1500 inet 192.168.210.1 netmask 0xffffff00 broadcast 192.168.210.255 ether 00:50:56:c0:00:08 vmnet1: flags=8863 mtu 1500 inet 192.168.61.1 netmask 0xffffff00 broadcast 192.168.61.255 ether 00:50:56:c0:00:01 facter-1.7.5/spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces0000644005276200011600000000177612276213016030336 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863 mtu 1500 ether 00:23:32:d5:ee:34 inet6 fe80::223:32ff:fed5:ee34%en0 prefixlen 64 scopeid 0x4 inet6 2610:10:20:209:223:32ff:fed5:ee34 prefixlen 64 autoconf inet 131.252.209.140 netmask 0xffffff00 broadcast 131.252.209.255 media: autoselect (100baseTX ) status: active en1: flags=8863 mtu 1500 ether 00:11:33:22:55:44 inet6 fe80::211:33ff:fe22:5544%en1 prefixlen 64 scopeid 0x5 inet 131.252.246.129 netmask 0xfffffe00 broadcast 131.252.247.255 media: autoselect status: active fw0: flags=8863 mtu 4078 lladdr 00:23:32:ff:fe:d5:ee:34 media: autoselect status: inactive facter-1.7.5/spec/fixtures/ifconfig/fedora_8_eth00000644005276200011600000000102512276213016021577 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:18:F3:F6:33:E5 inet addr:64.71.191.242 Bcast:64.71.191.247 Mask:255.255.255.248 inet6 addr: fe80::218:f3ff:fef6:33e5/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:834423032 errors:0 dropped:0 overruns:0 frame:0 TX packets:1241890434 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3777811119 (3.5 GiB) TX bytes:2061606027 (1.9 GiB) Interrupt:21 facter-1.7.5/spec/fixtures/ifconfig/ubuntu_7_040000644005276200011600000000356412276213016021255 0ustar jenkinsjenkinsath0 Link encap:Ethernet HWaddr 00:17:F2:49:E0:E6 inet6 addr: fe80::217:f2ff:fe49:e0e6/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) ath0:avah Link encap:Ethernet HWaddr 00:17:F2:49:E0:E6 inet addr:169.254.10.213 Bcast:169.254.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 eth0 Link encap:Ethernet HWaddr 00:16:CB:A6:D4:3A inet addr:100.100.106.200 Bcast:100.100.106.255 Mask:255.255.255.0 inet6 addr: fe80::216:cbff:fea6:d43a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1070 errors:0 dropped:0 overruns:0 frame:0 TX packets:236 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:69905 (68.2 KiB) TX bytes:28435 (27.7 KiB) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:33 errors:0 dropped:0 overruns:0 frame:0 TX packets:33 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3067 (2.9 KiB) TX bytes:3067 (2.9 KiB) wifi0 Link encap:UNSPEC HWaddr 00-17-F2-49-E0-E6-00-00-00-00-00-00-00-00-00-00 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2655 errors:0 dropped:0 overruns:0 frame:24795 TX packets:193 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:199 RX bytes:754290 (736.6 KiB) TX bytes:8878 (8.6 KiB) Interrupt:16 facter-1.7.5/spec/fixtures/ifconfig/linux_ifconfig_no_addr0000644005276200011600000000204012276213016023657 0ustar jenkinsjenkinsem1: flags=4163 mtu 1500 inet 131.252.209.153 netmask 255.255.255.0 broadcast 192.168.76.255 inet6 2610:10:20:209:212:3fff:febe:2201 prefixlen 128 scopeid 0x0 inet6 fe80::221:ccff:fe4b:297d prefixlen 64 scopeid 0x20 ether 00:21:cc:4b:29:7d txqueuelen 1000 (Ethernet) RX packets 27222144 bytes 31247414760 (29.1 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10259038 bytes 7784519352 (7.2 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xd2600000-d2620000 lo: flags=73 mtu 16436 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 257371 bytes 37104110 (35.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 257371 bytes 37104110 (35.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 facter-1.7.5/spec/fixtures/ifconfig/darwin_10_3_00000644005276200011600000000235712276213016021426 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863 mtu 1500 ether 00:17:f2:06:e3:c2 inet6 fe80::217:f2ff:fe06:e3c2%en0 prefixlen 64 scopeid 0x4 inet 100.100.104.12 netmask 0xffffff00 broadcast 100.100.104.255 media: autoselect (1000baseT ) status: active en1: flags=8863 mtu 1500 ether 00:17:f2:06:e3:c3 media: autoselect status: inactive fw0: flags=8863 mtu 2030 lladdr 00:16:cb:ff:fe:76:6e:be media: autoselect status: inactive vmnet8: flags=8863 mtu 1500 ether 00:50:56:c0:00:08 inet 172.16.95.1 netmask 0xffffff00 broadcast 172.16.95.255 vmnet1: flags=8863 mtu 1500 ether 00:50:56:c0:00:01 inet 172.16.201.1 netmask 0xffffff00 broadcast 172.16.201.255 facter-1.7.5/spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt0000644005276200011600000000146612276213016023653 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 42:01:0a:57:50:6e inet addr:10.87.80.110 Bcast:10.87.80.110 Mask:255.255.255.255 UP BROADCAST RUNNING MULTICAST MTU:1460 Metric:1 RX packets:1609444 errors:0 dropped:0 overruns:0 frame:0 TX packets:1479569 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:673812693 (673.8 MB) TX bytes:221186872 (221.1 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:5435415 errors:0 dropped:0 overruns:0 frame:0 TX packets:5435415 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:734540224 (734.5 MB) TX bytes:734540224 (734.5 MB) facter-1.7.5/spec/fixtures/ifconfig/darwin_10_3_0_en00000644005276200011600000000050112276213016022155 0ustar jenkinsjenkinsen0: flags=8863 mtu 1500 ether 00:17:f2:06:e3:c2 inet6 fe80::217:f2ff:fe06:e3c2%en0 prefixlen 64 scopeid 0x4 inet 100.100.104.12 netmask 0xffffff00 broadcast 100.100.104.255 media: autoselect (1000baseT ) status: active facter-1.7.5/spec/fixtures/ifconfig/open_solaris_100000644005276200011600000000123412276213016022167 0ustar jenkinsjenkinslo0: flags=2001000849 mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 hme0: flags=1000843 mtu 1500 index 2 inet 192.168.2.83 netmask ffffff00 broadcast 192.168.2.255 ether 8:0:20:d1:6d:79 lo0: flags=2002000849 mtu 8252 index 1 inet6 ::1/128 hme0: flags=2000841 mtu 1500 index 2 inet6 fe80::a00:20ff:fed1:6d79/10 ether 8:0:20:d1:6d:79 hme0:1: flags=2080841 mtu 1500 index 2 inet6 2404:130:0:1000:a00:20ff:fed1:6d79/64 facter-1.7.5/spec/fixtures/ifconfig/fedora_13_eth00000644005276200011600000000103512276213016021654 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:17:F2:0D:9B:A8 inet addr:100.100.108.27 Bcast:100.100.108.255 Mask:255.255.255.0 inet6 addr: fe80::217:f2ff:fe0d:9ba8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1813275 errors:0 dropped:0 overruns:0 frame:0 TX packets:1539208 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1729726282 (1.6 GiB) TX bytes:1606599653 (1.4 GiB) Memory:f2c20000-f2c40000 facter-1.7.5/spec/fixtures/ifconfig/centos_5_5_eth00000644005276200011600000000076612276213016022066 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 16:8D:2A:15:17:91 inet addr:100.100.100.92 Bcast:100.100.100.255 Mask:255.255.255.0 inet6 addr: fe80::148d:2aff:fe15:1791/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1914871 errors:0 dropped:0 overruns:0 frame:0 TX packets:3960 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:178738891 (170.4 MiB) TX bytes:393862 (384.6 KiB) facter-1.7.5/spec/fixtures/ifconfig/fedora_130000644005276200011600000000166212276213016020742 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:17:F2:0D:9B:A8 inet addr:100.100.108.27 Bcast:100.100.108.255 Mask:255.255.255.0 inet6 addr: fe80::217:f2ff:fe0d:9ba8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1813272 errors:0 dropped:0 overruns:0 frame:0 TX packets:1539207 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1729725903 (1.6 GiB) TX bytes:1606599540 (1.4 GiB) Memory:f2c20000-f2c40000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:482 errors:0 dropped:0 overruns:0 frame:0 TX packets:482 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:48488 (47.3 KiB) TX bytes:48488 (47.3 KiB) facter-1.7.5/spec/fixtures/ifconfig/fedora_80000644005276200011600000000346012276213016020664 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:18:F3:F6:33:E5 inet addr:64.71.191.242 Bcast:64.71.191.247 Mask:255.255.255.248 inet6 addr: fe80::218:f3ff:fef6:33e5/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:834422948 errors:0 dropped:0 overruns:0 frame:0 TX packets:1241890353 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3777804409 (3.5 GiB) TX bytes:2061587234 (1.9 GiB) Interrupt:21 eth0:0 Link encap:Ethernet HWaddr 00:18:F3:F6:33:E5 inet addr:64.71.191.243 Bcast:64.71.191.247 Mask:255.255.255.248 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:21 eth0:1 Link encap:Ethernet HWaddr 00:18:F3:F6:33:E5 inet addr:64.71.191.244 Bcast:64.71.191.247 Mask:255.255.255.248 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:21 eth0:2 Link encap:Ethernet HWaddr 00:18:F3:F6:33:E5 inet addr:64.71.191.245 Bcast:64.71.191.247 Mask:255.255.255.248 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:21 eth0:3 Link encap:Ethernet HWaddr 00:18:F3:F6:33:E5 inet addr:64.71.191.246 Bcast:64.71.191.247 Mask:255.255.255.248 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:21 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:59385736 errors:0 dropped:0 overruns:0 frame:0 TX packets:59385736 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3519026710 (3.2 GiB) TX bytes:3519026710 (3.2 GiB) facter-1.7.5/spec/fixtures/ifconfig/fedora_100000644005276200011600000000355112276213016020736 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:17:F2:06:E4:26 inet addr:100.100.108.9 Bcast:100.100.108.255 Mask:255.255.255.0 inet6 addr: fe80::217:f2ff:fe06:e426/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:47711100 errors:0 dropped:0 overruns:0 frame:0 TX packets:45446436 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:17037006736 (15.8 GiB) TX bytes:9198820680 (8.5 GiB) Memory:92c20000-92c40000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:366974 errors:0 dropped:0 overruns:0 frame:0 TX packets:366974 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:33867944 (32.2 MiB) TX bytes:33867944 (32.2 MiB) vmnet1 Link encap:Ethernet HWaddr 00:50:56:C0:00:01 inet addr:172.16.131.1 Bcast:172.16.131.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:20 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) vmnet8 Link encap:Ethernet HWaddr 00:50:56:C0:00:08 inet addr:192.168.183.1 Bcast:192.168.183.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fec0:8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:20 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) facter-1.7.5/spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces0000644005276200011600000000151512276213016027611 0ustar jenkinsjenkinsbge0: flags=8843 metric 0 mtu 1500 options=9b ether 00:0b:db:93:09:67 inet 131.252.208.203 netmask 0xffffff00 broadcast 131.252.208.255 inet6 fe80::20b:dbff:fe93:967%bge0 prefixlen 64 scopeid 0x1 inet6 2610:10:20:208:20b:dbff:fe93:967 prefixlen 64 autoconf media: Ethernet autoselect (1000baseT ) status: active bge1: flags=8802 metric 0 mtu 1500 options=9b ether 00:0b:db:93:09:68 media: Ethernet autoselect (none) status: no carrier lo0: flags=8049 metric 0 mtu 16384 options=3 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 facter-1.7.5/spec/fixtures/ifconfig/freebsd_6_00000644005276200011600000000117212276213016021251 0ustar jenkinsjenkinsfxp0: flags=8843 mtu 1500 options=b inet x.x.58.26 netmask 0xfffffff8 broadcast x.x.58.31 inet x.x.58.27 netmask 0xffffffff broadcast x.x.58.27 inet x.x.58.28 netmask 0xffffffff broadcast x.x.58.28 inet x.x.58.29 netmask 0xffffffff broadcast x.x.58.29 inet x.x.58.30 netmask 0xffffffff broadcast x.x.58.30 ether 00:0e:0c:68:67:7c media: Ethernet autoselect (100baseTX ) status: active lo0: flags=8049 mtu 16384 inet 127.0.0.1 netmask 0xff000000 facter-1.7.5/spec/fixtures/ifconfig/darwin_10_6_6_dualstack_en10000644005276200011600000000045012276213016024225 0ustar jenkinsjenkinsen1: flags=8863 mtu 1500 ether 00:25:00:48:19:ef inet6 fe80::225:ff:fe48:19ef%en1 prefixlen 64 scopeid 0x5 inet 192.168.1.207 netmask 0xffffff00 broadcast 192.168.1.255 inet6 2000:44b4:32:400::1 prefixlen 64 media: autoselect status: active facter-1.7.5/spec/fixtures/ifconfig/linux_ifconfig_no_mac0000644005276200011600000000053212276213016023511 0ustar jenkinsjenkinslo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) facter-1.7.5/spec/fixtures/ifconfig/darwin_10_6_6_dualstack0000644005276200011600000000045212276213016023464 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 en0: flags=8863 mtu 1500 ether 00:25:4b:ca:56:72 media: autoselect status: inactive facter-1.7.5/spec/fixtures/ifconfig/linux_ifconfig_venet0000644005276200011600000000254212276213016023401 0ustar jenkinsjenkinslo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:334 errors:0 dropped:0 overruns:0 frame:0 TX packets:334 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:16700 (16.7 KB) TX bytes:16700 (16.7 KB) venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 RX packets:7622207 errors:0 dropped:0 overruns:0 frame:0 TX packets:8183436 errors:0 dropped:1 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2102750761 (2.1 GB) TX bytes:2795213667 (2.7 GB) venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:XXX.XXX.XXX.XX1 P-t-P:XXX.XXX.XXX.XX1 Bcast:0.0.0.0 Mask:255.255.255.255 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 venet0:1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:XXX.XXX.XXX.XX2 P-t-P:XXX.XXX.XXX.XX2 Bcast:0.0.0.0 Mask:255.255.255.255 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 facter-1.7.5/spec/fixtures/ifconfig/ubuntu_7_04_eth00000644005276200011600000000100312276213016022157 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:16:CB:A6:D4:3A inet addr:100.100.106.200 Bcast:100.100.106.255 Mask:255.255.255.0 inet6 addr: fe80::216:cbff:fea6:d43a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1131 errors:0 dropped:0 overruns:0 frame:0 TX packets:280 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:73859 (72.1 KiB) TX bytes:35243 (34.4 KiB) Interrupt:17 facter-1.7.5/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces0000644005276200011600000000176412276213016030206 0ustar jenkinsjenkinseth0 Link encap:Ethernet HWaddr 00:12:3f:be:22:01 inet addr:131.252.209.153 Bcast:131.252.209.255 Mask:255.255.255.0 inet6 addr: 2610:10:20:209:212:3fff:febe:2201/64 Scope:Global inet6 addr: fe80::212:3fff:febe:2201/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:20793317 errors:0 dropped:0 overruns:0 frame:0 TX packets:19583281 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1723593481 (1.7 GB) TX bytes:283377282 (283.3 MB) Interrupt:16 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:31809 errors:0 dropped:0 overruns:0 frame:0 TX packets:31809 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2075836 (2.0 MB) TX bytes:2075836 (2.0 MB) facter-1.7.5/spec/fixtures/ifconfig/sunos_ifconfig_all_with_multiple_interfaces0000644005276200011600000000113612276213016030207 0ustar jenkinsjenkinslo0: flags=2001000849 mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 bge0: flags=1000843 mtu 1500 index 2 inet 131.252.209.59 netmask ffffff00 broadcast 131.252.209.255 lo0: flags=2002000849 mtu 8252 index 1 inet6 ::1/128 bge0: flags=2000841 mtu 1500 index 2 inet6 fe80::203:baff:fe27:a7c/10 bge0:1: flags=2080841 mtu 1500 index 2 inet6 2610:10:20:209:203:baff:fe27:a7c/64 facter-1.7.5/spec/fixtures/ifconfig/open_solaris_b1320000644005276200011600000000214312276213016022416 0ustar jenkinsjenkinslo0: flags=2001000849 mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 bge0: flags=1100943 mtu 1500 index 2 inet 202.78.241.97 netmask fffffff8 broadcast 202.78.241.103 ether 0:1e:c9:43:55:f9 int0: flags=1100843 mtu 9000 index 3 inet 172.31.255.254 netmask ffffff00 broadcast 172.31.255.255 ether 2:8:20:89:75:75 lo0: flags=2002000849 mtu 8252 index 1 inet6 ::1/128 bge0: flags=2100941 mtu 1500 index 2 inet6 fe80::ff:0/10 ether 0:1e:c9:43:55:f9 bge0:1: flags=2180941 mtu 1500 index 2 inet6 2404:130:40:10::ff:0/64 int0: flags=2100841 mtu 9000 index 3 inet6 fe80::ff:0/10 ether 2:8:20:89:75:75 int0:1: flags=2180841 mtu 9000 index 3 inet6 2404:130:40:18::ff:0/64 facter-1.7.5/spec/fixtures/ifconfig/darwin_9_8_0_en00000644005276200011600000000126712276213016022124 0ustar jenkinsjenkinsen0: flags=8863 mtu 1500 inet6 fe80::217:f2ff:fe06:e42e%en0 prefixlen 64 scopeid 0x4 inet 100.100.107.4 netmask 0xffffff00 broadcast 100.100.107.255 ether 00:17:f2:06:e4:2e media: autoselect (1000baseT ) status: active supported media: autoselect 10baseT/UTP 10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT facter-1.7.5/spec/fixtures/ifconfig/darwin_10_6_4_en10000644005276200011600000000041512276213016022171 0ustar jenkinsjenkinsen1: flags=8863 mtu 1500 ether 58:b0:35:7f:25:b3 inet6 fe80::5ab0:35ff:fe7f:25b3%en1 prefixlen 64 scopeid 0x5 inet 192.168.100.230 netmask 0xffffff00 broadcast 192.168.100.255 media: status: active facter-1.7.5/spec/fixtures/processorcount/0000755005276200011600000000000012276213023020551 5ustar jenkinsjenkinsfacter-1.7.5/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info0000644005276200011600000002316612276213016025760 0ustar jenkinsjenkinsmodule: cpu_info instance: 0 name: cpu_info0 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 0 chip_id 0 clock_MHz 2300 clog_id 0 core_id 0 cpu_type i386 crtime 150.118972763 current_clock_Hz 2300000000 current_cstate 0 family 16 fpu_type i387 compatible implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 2 pkg_core_id 0 snaptime 1964970.24919915 state on-line state_begin 1315115687 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD module: cpu_info instance: 1 name: cpu_info1 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 1 chip_id 0 clock_MHz 2300 clog_id 1 core_id 1 cpu_type i386 crtime 153.090853556 current_clock_Hz 1200000000 current_cstate 1 family 16 fpu_type i387 compatible implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 3 pkg_core_id 1 snaptime 1964970.24965225 state on-line state_begin 1315115690 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD module: cpu_info instance: 2 name: cpu_info2 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 2 chip_id 0 clock_MHz 2300 clog_id 2 core_id 2 cpu_type i386 crtime 153.160162766 current_clock_Hz 1200000000 current_cstate 1 family 16 fpu_type i387 compatible implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 4 pkg_core_id 2 snaptime 1964970.24997443 state on-line state_begin 1315115690 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD module: cpu_info instance: 3 name: cpu_info3 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 3 chip_id 0 clock_MHz 2300 clog_id 3 core_id 3 cpu_type i386 crtime 153.190177596 current_clock_Hz 1200000000 current_cstate 1 family 16 fpu_type i387 compatible implementation x86 (chipid 0x0 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 5 pkg_core_id 3 snaptime 1964970.2502919 state on-line state_begin 1315115690 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD module: cpu_info instance: 4 name: cpu_info4 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 4 chip_id 1 clock_MHz 2300 clog_id 0 core_id 4 cpu_type i386 crtime 153.2201642 current_clock_Hz 1200000000 current_cstate 1 family 16 fpu_type i387 compatible implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 7 pkg_core_id 0 snaptime 1964970.2505907 state on-line state_begin 1315115690 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD module: cpu_info instance: 5 name: cpu_info5 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 5 chip_id 1 clock_MHz 2300 clog_id 1 core_id 5 cpu_type i386 crtime 153.250190916 current_clock_Hz 1200000000 current_cstate 1 family 16 fpu_type i387 compatible implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 8 pkg_core_id 1 snaptime 1964970.25087316 state on-line state_begin 1315115690 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD module: cpu_info instance: 6 name: cpu_info6 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 6 chip_id 1 clock_MHz 2300 clog_id 2 core_id 6 cpu_type i386 crtime 153.280185962 current_clock_Hz 1200000000 current_cstate 1 family 16 fpu_type i387 compatible implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 9 pkg_core_id 2 snaptime 1964970.25117252 state on-line state_begin 1315115690 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD module: cpu_info instance: 7 name: cpu_info7 class: misc brand Quad-Core AMD Opteron(tm) Processor 2356 cache_id 7 chip_id 1 clock_MHz 2300 clog_id 3 core_id 7 cpu_type i386 crtime 153.310206904 current_clock_Hz 2300000000 current_cstate 1 family 16 fpu_type i387 compatible implementation x86 (chipid 0x1 AuthenticAMD family 16 model 2 step 3 clock 2300 MHz) model 2 ncore_per_chip 4 ncpu_per_chip 4 pg_id 10 pkg_core_id 3 snaptime 1964970.25143389 state on-line state_begin 1315115690 stepping 3 supported_frequencies_Hz 1200000000:1400000000:1700000000:2000000000:2300000000 supported_max_cstates 0 vendor_id AuthenticAMD facter-1.7.5/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info0000644005276200011600000014643412276213016026136 0ustar jenkinsjenkinsmodule: cpu_info instance: 0 name: cpu_info0 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312660.5754132 current_clock_Hz 1165379264 device_ID 0 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 1 snaptime 23630289.0909192 state on-line state_begin 1315099346 supported_frequencies_Hz 1165379264 module: cpu_info instance: 1 name: cpu_info1 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2806834 current_clock_Hz 1165379264 device_ID 1 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 1 snaptime 23630289.0927599 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 2 name: cpu_info2 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2828084 current_clock_Hz 1165379264 device_ID 2 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 1 snaptime 23630289.0943224 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 3 name: cpu_info3 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.284967 current_clock_Hz 1165379264 device_ID 3 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 1 snaptime 23630289.0959092 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 4 name: cpu_info4 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2869702 current_clock_Hz 1165379264 device_ID 4 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 4 snaptime 23630289.0974779 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 5 name: cpu_info5 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2890495 current_clock_Hz 1165379264 device_ID 5 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 4 snaptime 23630289.0990405 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 6 name: cpu_info6 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2911274 current_clock_Hz 1165379264 device_ID 6 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 4 snaptime 23630289.1006005 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 7 name: cpu_info7 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 516 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2932203 current_clock_Hz 1165379264 device_ID 7 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 4 snaptime 23630289.1021675 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 8 name: cpu_info8 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2953277 current_clock_Hz 1165379264 device_ID 8 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 5 snaptime 23630289.1037276 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 9 name: cpu_info9 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2973458 current_clock_Hz 1165379264 device_ID 9 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 5 snaptime 23630289.1053163 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 10 name: cpu_info10 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.2993978 current_clock_Hz 1165379264 device_ID 10 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 5 snaptime 23630289.1068773 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 11 name: cpu_info11 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3015554 current_clock_Hz 1165379264 device_ID 11 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 5 snaptime 23630289.1085511 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 12 name: cpu_info12 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3035692 current_clock_Hz 1165379264 device_ID 12 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 7 snaptime 23630289.1101482 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 13 name: cpu_info13 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3058002 current_clock_Hz 1165379264 device_ID 13 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 7 snaptime 23630289.1117123 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 14 name: cpu_info14 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3078818 current_clock_Hz 1165379264 device_ID 14 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 7 snaptime 23630289.1132754 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 15 name: cpu_info15 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 524 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3099415 current_clock_Hz 1165379264 device_ID 15 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 7 snaptime 23630289.1148379 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 16 name: cpu_info16 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3121222 current_clock_Hz 1165379264 device_ID 16 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 8 snaptime 23630289.1164032 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 17 name: cpu_info17 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3144076 current_clock_Hz 1165379264 device_ID 17 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 8 snaptime 23630289.1179674 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 18 name: cpu_info18 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3164902 current_clock_Hz 1165379264 device_ID 18 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 8 snaptime 23630289.119694 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 19 name: cpu_info19 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3186612 current_clock_Hz 1165379264 device_ID 19 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 8 snaptime 23630289.1212498 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 20 name: cpu_info20 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3208774 current_clock_Hz 1165379264 device_ID 20 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 10 snaptime 23630289.1228643 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 21 name: cpu_info21 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3230514 current_clock_Hz 1165379264 device_ID 21 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 10 snaptime 23630289.1244296 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 22 name: cpu_info22 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3252122 current_clock_Hz 1165379264 device_ID 22 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 10 snaptime 23630289.1260106 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 23 name: cpu_info23 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 531 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3275665 current_clock_Hz 1165379264 device_ID 23 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 10 snaptime 23630289.1276002 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 24 name: cpu_info24 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3297949 current_clock_Hz 1165379264 device_ID 24 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 11 snaptime 23630289.1291771 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 25 name: cpu_info25 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3320294 current_clock_Hz 1165379264 device_ID 25 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 11 snaptime 23630289.1307659 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 26 name: cpu_info26 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3342617 current_clock_Hz 1165379264 device_ID 26 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 11 snaptime 23630289.132355 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 27 name: cpu_info27 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3364207 current_clock_Hz 1165379264 device_ID 27 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 11 snaptime 23630289.1339703 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 28 name: cpu_info28 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3387068 current_clock_Hz 1165379264 device_ID 28 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 13 snaptime 23630289.1355427 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 29 name: cpu_info29 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3410924 current_clock_Hz 1165379264 device_ID 29 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 13 snaptime 23630289.1371043 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 30 name: cpu_info30 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.343326 current_clock_Hz 1165379264 device_ID 30 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 13 snaptime 23630289.1387291 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 31 name: cpu_info31 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 538 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3455326 current_clock_Hz 1165379264 device_ID 31 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 13 snaptime 23630289.1403642 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 32 name: cpu_info32 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3477709 current_clock_Hz 1165379264 device_ID 32 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 14 snaptime 23630289.141927 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 33 name: cpu_info33 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3502553 current_clock_Hz 1165379264 device_ID 33 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 14 snaptime 23630289.1435087 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 34 name: cpu_info34 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3525534 current_clock_Hz 1165379264 device_ID 34 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 14 snaptime 23630289.1451002 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 35 name: cpu_info35 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3548208 current_clock_Hz 1165379264 device_ID 35 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 14 snaptime 23630289.1466879 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 36 name: cpu_info36 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3571762 current_clock_Hz 1165379264 device_ID 36 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 16 snaptime 23630289.1482783 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 37 name: cpu_info37 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3594942 current_clock_Hz 1165379264 device_ID 37 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 16 snaptime 23630289.1498468 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 38 name: cpu_info38 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3619156 current_clock_Hz 1165379264 device_ID 38 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 16 snaptime 23630289.1514097 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 39 name: cpu_info39 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 545 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3641867 current_clock_Hz 1165379264 device_ID 39 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 16 snaptime 23630289.1529782 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 40 name: cpu_info40 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3664573 current_clock_Hz 1165379264 device_ID 40 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 17 snaptime 23630289.1546012 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 41 name: cpu_info41 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3689115 current_clock_Hz 1165379264 device_ID 41 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 17 snaptime 23630289.1561584 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 42 name: cpu_info42 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3713041 current_clock_Hz 1165379264 device_ID 42 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 17 snaptime 23630289.1577271 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 43 name: cpu_info43 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.373675 current_clock_Hz 1165379264 device_ID 43 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 17 snaptime 23630289.1592959 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 44 name: cpu_info44 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3760962 current_clock_Hz 1165379264 device_ID 44 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 19 snaptime 23630289.1608683 state on-line state_begin 1315099348 supported_frequencies_Hz 1165379264 module: cpu_info instance: 45 name: cpu_info45 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3784792 current_clock_Hz 1165379264 device_ID 45 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 19 snaptime 23630289.1624495 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 46 name: cpu_info46 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3809418 current_clock_Hz 1165379264 device_ID 46 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 19 snaptime 23630289.1640098 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 47 name: cpu_info47 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 552 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3833624 current_clock_Hz 1165379264 device_ID 47 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 19 snaptime 23630289.1655756 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 48 name: cpu_info48 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3857846 current_clock_Hz 1165379264 device_ID 48 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 20 snaptime 23630289.1671529 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 49 name: cpu_info49 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3883379 current_clock_Hz 1165379264 device_ID 49 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 20 snaptime 23630289.1687334 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 50 name: cpu_info50 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3908908 current_clock_Hz 1165379264 device_ID 50 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 20 snaptime 23630289.1703504 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 51 name: cpu_info51 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3933023 current_clock_Hz 1165379264 device_ID 51 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 20 snaptime 23630289.1719139 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 52 name: cpu_info52 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3957577 current_clock_Hz 1165379264 device_ID 52 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 22 snaptime 23630289.1734706 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 53 name: cpu_info53 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.3982132 current_clock_Hz 1165379264 device_ID 53 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 22 snaptime 23630289.1750473 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 54 name: cpu_info54 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4008234 current_clock_Hz 1165379264 device_ID 54 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 22 snaptime 23630289.1767452 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 55 name: cpu_info55 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 559 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4032588 current_clock_Hz 1165379264 device_ID 55 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 22 snaptime 23630289.1783072 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 56 name: cpu_info56 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4057018 current_clock_Hz 1165379264 device_ID 56 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 23 snaptime 23630289.1798837 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 57 name: cpu_info57 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4083202 current_clock_Hz 1165379264 device_ID 57 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 23 snaptime 23630289.1814739 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 58 name: cpu_info58 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4108088 current_clock_Hz 1165379264 device_ID 58 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 23 snaptime 23630289.1830437 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 59 name: cpu_info59 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4133075 current_clock_Hz 1165379264 device_ID 59 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 23 snaptime 23630289.1846328 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 60 name: cpu_info60 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4157926 current_clock_Hz 1165379264 device_ID 60 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 25 snaptime 23630289.1862341 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 61 name: cpu_info61 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4217917 current_clock_Hz 1165379264 device_ID 61 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 25 snaptime 23630289.1878047 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 62 name: cpu_info62 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4243642 current_clock_Hz 1165379264 device_ID 62 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 25 snaptime 23630289.1894041 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 module: cpu_info instance: 63 name: cpu_info63 class: misc brand UltraSPARC-T2 chip_id 0 clock_MHz 1165 core_id 566 cpu_fru hc:///component= cpu_type sparcv9 crtime 23312663.4268942 current_clock_Hz 1165379264 device_ID 63 fpu_type sparcv9 implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) pg_id 25 snaptime 23630289.1910039 state on-line state_begin 1315099349 supported_frequencies_Hz 1165379264 facter-1.7.5/spec/fixtures/processorcount/solaris-psrinfo0000644005276200011600000000204012276213016023624 0ustar jenkinsjenkins0 on-line since 10/01/2012 21:05:55 1 on-line since 10/01/2012 21:06:00 2 on-line since 10/01/2012 21:06:00 3 on-line since 10/01/2012 21:06:00 4 on-line since 10/01/2012 21:06:00 5 on-line since 10/01/2012 21:06:00 6 on-line since 10/01/2012 21:06:00 7 on-line since 10/01/2012 21:06:00 8 on-line since 10/01/2012 21:06:00 9 on-line since 10/01/2012 21:06:00 10 on-line since 10/01/2012 21:06:00 11 on-line since 10/01/2012 21:06:00 12 on-line since 10/01/2012 21:06:01 13 on-line since 10/01/2012 21:06:01 14 on-line since 10/01/2012 21:06:01 15 on-line since 10/01/2012 21:06:01 16 on-line since 10/01/2012 21:06:01 17 on-line since 10/01/2012 21:06:01 18 on-line since 10/01/2012 21:06:01 19 on-line since 10/01/2012 21:06:01 20 on-line since 10/01/2012 21:06:01 21 on-line since 10/01/2012 21:06:01 22 on-line since 10/01/2012 21:06:01 23 on-line since 10/01/2012 21:06:01 facter-1.7.5/spec/watchr.rb0000755005276200011600000000533612276213017015442 0ustar jenkinsjenkinsENV["WATCHR"] = "1" ENV['AUTOTEST'] = 'true' def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc putc c line << c if c == ?\n results << if RUBY_VERSION >= "1.9" then line.join else line.pack "c*" end line.clear end end end ensure $stdout.sync = old_sync end results.join end def clear #system("clear") end def growl(message, status) # Strip the color codes message.gsub!(/\[\d+m/, '') growlnotify = `which growlnotify`.chomp return if growlnotify.empty? title = "Watchr Test Results" image = status == :pass ? "autotest/images/pass.png" : "autotest/images/fail.png" options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'" system %(#{growlnotify} #{options} &) end def file2specs(file) %w{spec/unit spec/integration}.collect { |d| file.sub('lib/facter', d).sub('.rb', '_spec.rb') }.find_all { |f| FileTest.exist?(f) } end def run_spec(command) clear result = run_comp(command).split("\n").last status = result.include?('0 failures') ? :pass : :fail growl result, status end def run_spec_files(files) files = Array(files) return if files.empty? opts = File.readlines('.rspec').collect { |l| l.chomp }.join(" ") begin run_spec("rspec --tty #{opts} #{files.join(' ')}") rescue => detail puts detail.backtrace warn "Failed to run #{files.join(', ')}: #{detail}" end end def run_suite files = files("unit") + files("integration") opts = File.readlines('.rspec').collect { |l| l.chomp }.join(" ") run_spec("rspec --tty #{opts} #{files.join(' ')}") end def files(dir) require 'find' result = [] Find.find(File.join("spec", dir)) do |path| result << path if path =~ /\.rb/ end result end watch('spec/spec_helper.rb') { run_suite } watch(%r{^spec/(unit|integration)/.*\.rb$}) { |md| run_spec_files(md[0]) } watch(%r{^lib/facter/(.*)\.rb$}) { |md| run_spec_files(file2specs(md[0])) } watch(%r{^spec/lib/spec.*}) { |md| run_suite } watch(%r{^spec/lib/monkey_patches/.*}) { |md| run_suite } # Ctrl-\ Signal.trap 'QUIT' do puts " --- Running all tests ---\n\n" run_suite end @interrupted = false # Ctrl-C Signal.trap 'INT' do if @interrupted @wants_to_quit = true abort("\n") else puts "Interrupt a second time to quit; wait for rerun of tests" @interrupted = true Kernel.sleep 1.5 # raise Interrupt, nil # let the run loop catch it begin run_suite rescue => detail puts detail.backtrace puts "Could not run suite: #{detail}" end end end facter-1.7.5/spec/shared_formats/0000755005276200011600000000000012276213023016611 5ustar jenkinsjenkinsfacter-1.7.5/spec/shared_formats/parses.rb0000644005276200011600000000015012276213017020432 0ustar jenkinsjenkinsRSpec.configure do |config| config.alias_it_should_behave_like_to :example_behavior_for, "parses" end facter-1.7.5/spec/puppetlabs_spec_helper.rb0000644005276200011600000000172612276213017020676 0ustar jenkinsjenkins# Define the main module namespace for use by the helper modules module PuppetlabsSpec # FIXTURE_DIR represents the standard locations of all fixture data. Normally # this represents /spec/fixtures. This will be used by the fixtures # library to find relative fixture data. FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), \ "fixtures") unless defined?(FIXTURE_DIR) end # Require all necessary helper libraries so they can be used later require 'puppetlabs_spec/files' require 'puppetlabs_spec/fixtures' require 'puppetlabs_spec/matchers' require 'puppetlabs_spec/verbose' RSpec.configure do |config| # Include PuppetlabsSpec helpers so they can be called at convenience config.extend PuppetlabsSpec::Files config.extend PuppetlabsSpec::Fixtures config.include PuppetlabsSpec::Fixtures # This will cleanup any files that were created with tmpdir or tmpfile config.after :each do PuppetlabsSpec::Files.cleanup end end facter-1.7.5/spec/spec_helper.rb0000644005276200011600000000450712276213017016437 0ustar jenkinsjenkinsrequire 'rubygems' require 'mocha' require 'rspec' require 'facter' require 'fileutils' require 'puppetlabs_spec_helper' require 'pathname' # load shared_context within this project's spec directory dir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift File.join(dir, 'lib') Pathname.glob("#{dir}/shared_contexts/*.rb") do |file| require file.relative_path_from(Pathname.new(dir)) end module LogSpecOrder # Log the spec order to a file, but only if the LOG_SPEC_ORDER environment # variable is set. This could be enabled on Jenkins runs, as it can # be used with Nick L.'s bisect script to help identify and debug # order-dependent spec failures. # # jpartlow 2013-07-05: this was in puppet and I pulled it into facter because # I was seeing similar ordering issues in the specs...and needed to bisect them :/ def self.log_spec_order if ENV['LOG_SPEC_ORDER'] File.open("./spec_order.txt", "w") do |logfile| RSpec.configuration.files_to_run.each { |f| logfile.puts f } end end end end # Executing here rather than after :suite, so that we can get the order output # even when the issue breaks rspec when specs are first loaded. LogSpecOrder.log_spec_order RSpec.configure do |config| config.mock_with :mocha if Facter::Util::Config.is_windows? require 'win32console' config.output_stream = $stdout config.error_stream = $stderr config.formatters.each { |f| f.instance_variable_set(:@output, $stdout) } end config.before :each do # Ensure that we don't accidentally cache facts and environment # between test cases. Facter::Util::Loader.any_instance.stubs(:load_all) Facter.clear Facter.clear_messages # Store any environment variables away to be restored later @old_env = {} ENV.each_key {|k| @old_env[k] = ENV[k]} end config.after :each do # Restore environment variables after execution of each test @old_env.each_pair {|k, v| ENV[k] = v} to_remove = ENV.keys.reject {|key| @old_env.include? key } to_remove.each {|key| ENV.delete key } end end module FacterSpec module ConfigHelper def given_a_configuration_of(config) Facter::Util::Config.stubs(:is_windows?).returns(config[:is_windows]) Facter::Util::Config.stubs(:external_facts_dir).returns(config[:external_facts_dir] || "data_dir") end end end facter-1.7.5/spec/unit/0000755005276200011600000000000012276213024014570 5ustar jenkinsjenkinsfacter-1.7.5/spec/unit/kernel_spec.rb0000644005276200011600000000120112276213017017403 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "Kernel fact" do include FacterSpec::ConfigHelper describe "on Windows" do it "should return the kernel as 'windows'" do given_a_configuration_of(:is_windows => true, :data_dir => "data_dir") Facter.fact(:kernel).value.should == "windows" end end describe "on everything else" do it "should return the kernel using 'uname -s'" do given_a_configuration_of(:is_windows => false) Facter::Util::Resolution.stubs(:exec).with('uname -s').returns("test_kernel") Facter.fact(:kernel).value.should == 'test_kernel' end end end facter-1.7.5/spec/unit/lsbrelease_spec.rb0000755005276200011600000000133012276213017020252 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbrelease fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do before :each do Facter.fact(:kernel).stubs(:value).returns kernel end it "should return the release through lsb_release -v -s 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns 'n/a' Facter.fact(:lsbrelease).value.should == 'n/a' end it "should return nil if lsb_release is not installed" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns nil Facter.fact(:lsbrelease).value.should be_nil end end end end facter-1.7.5/spec/unit/operatingsystem_spec.rb0000755005276200011600000001215312276213017021373 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Operating System fact" do before :each do FileTest.stubs(:exists?).returns false end it "should default to the kernel name" do Facter.fact(:kernel).stubs(:value).returns("Nutmeg") Facter.fact(:operatingsystem).value.should == "Nutmeg" end it "should be ESXi for VMkernel" do Facter.fact(:kernel).stubs(:value).returns("VMkernel") Facter.fact(:operatingsystem).value.should == "ESXi" end describe "on Solaris variants" do before :each do Facter.fact(:kernel).stubs(:value).returns("SunOS") end it "should be Nexenta if /etc/debian_version is present" do FileTest.expects(:exists?).with("/etc/debian_version").returns true Facter.fact(:operatingsystem).value.should == "Nexenta" end it "should be Solaris if /etc/debian_version is missing and uname -v failed to match" do FileTest.expects(:exists?).with("/etc/debian_version").returns false Facter.fact(:operatingsystem).value.should == "Solaris" end { "SmartOS" => "joyent_20120629T002039Z", "OmniOS" => "omnios-dda4bb3", "OpenIndiana" => "oi_151a", }.each_pair do |distribution, string| it "should be #{distribution} if uname -v is '#{string}'" do Facter::Util::Resolution.stubs(:exec).with('uname -v').returns(string) Facter.fact(:operatingsystem).value.should == distribution end end end describe "on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") # Always stub lsbdistid by default, so tests work on Ubuntu Facter.stubs(:value).with(:lsbdistid).returns(nil) end { "Debian" => "/etc/debian_version", "Gentoo" => "/etc/gentoo-release", "Fedora" => "/etc/fedora-release", "Mandriva" => "/etc/mandriva-release", "Mandrake" => "/etc/mandrake-release", "MeeGo" => "/etc/meego-release", "Archlinux" => "/etc/arch-release", "OracleLinux" => "/etc/oracle-release", "OpenWrt" => "/etc/openwrt_release", "Alpine" => "/etc/alpine-release", "VMWareESX" => "/etc/vmware-release", "Bluewhite64" => "/etc/bluewhite64-version", "Slamd64" => "/etc/slamd64-version", "Slackware" => "/etc/slackware-version", "Amazon" => "/etc/system-release", }.each_pair do |distribution, releasefile| it "should be #{distribution} if #{releasefile} exists" do FileTest.expects(:exists?).with(releasefile).returns true Facter.fact(:operatingsystem).value.should == distribution end end describe "depending on LSB release information" do before :each do Facter.collection.internal_loader.load(:lsb) end it "on Ubuntu should use the lsbdistid fact" do FileUtils.stubs(:exists?).with("/etc/debian_version").returns true Facter.stubs(:value).with(:lsbdistid).returns("Ubuntu") Facter.fact(:operatingsystem).value.should == "Ubuntu" end end # Check distributions that rely on the contents of /etc/redhat-release { "RedHat" => "Red Hat Enterprise Linux Server release 6.0 (Santiago)", "CentOS" => "CentOS release 5.6 (Final)", "Scientific" => "Scientific Linux release 6.0 (Carbon)", "SLC" => "Scientific Linux CERN SLC release 5.7 (Boron)", "Ascendos" => "Ascendos release 6.0 (Nameless)", "CloudLinux" => "CloudLinux Server release 5.5", "XenServer" => "XenServer release 5.6.0-31188p (xenenterprise)", }.each_pair do |operatingsystem, string| it "should be #{operatingsystem} based on /etc/redhat-release contents #{string}" do FileTest.expects(:exists?).with("/etc/redhat-release").returns true File.expects(:read).with("/etc/redhat-release").returns string Facter.fact(:operatingsystem).value.should == operatingsystem end end describe "Oracle variant" do it "should be OVS if /etc/ovs-release exists" do Facter.stubs(:value).with(:lsbdistid) FileTest.expects(:exists?).with("/etc/enterprise-release").returns true FileTest.expects(:exists?).with("/etc/ovs-release").returns true Facter.fact(:operatingsystem).value.should == "OVS" end it "should be OEL if /etc/ovs-release doesn't exist" do FileTest.expects(:exists?).with("/etc/enterprise-release").returns true FileTest.expects(:exists?).with("/etc/ovs-release").returns false Facter.fact(:operatingsystem).value.should == "OEL" end end it "should identify VMWare ESX" do Facter.stubs(:value).with(:lsbdistid).returns(nil) FileTest.expects(:exists?).with("/etc/vmware-release").returns true Facter.fact(:operatingsystem).value.should == "VMWareESX" end it "should differentiate between Scientific Linux CERN and Scientific Linux" do FileTest.expects(:exists?).with("/etc/redhat-release").returns true File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)") Facter.fact(:operatingsystem).value.should == "SLC" end end end facter-1.7.5/spec/unit/zonename_spec.rb0000644005276200011600000000050312276213017017743 0ustar jenkinsjenkins#!/usr/bin/env rspec require 'spec_helper' require 'facter' describe "zonename fact" do it "should return global zone" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter::Util::Resolution.stubs(:exec).with("zonename").returns('global') Facter.fact(:zonename).value.should == "global" end end facter-1.7.5/spec/unit/architecture_spec.rb0000755005276200011600000000355712276213017020630 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/architecture' describe "Architecture fact" do it "should default to the hardware model" do Facter.fact(:hardwaremodel).stubs(:value).returns("NonSpecialCasedHW") Facter.fact(:architecture).value.should == "NonSpecialCasedHW" end os_archs = Hash.new os_archs = { ["Debian","x86_64"] => "amd64", ["Gentoo","x86_64"] => "amd64", ["GNU/kFreeBSD","x86_64"] => "amd64", ["Ubuntu","x86_64"] => "amd64", ["Gentoo","i386"] => "x86", ["Gentoo","i486"] => "x86", ["Gentoo","i586"] => "x86", ["Gentoo","i686"] => "x86", ["Gentoo","pentium"] => "x86", ["windows","i386"] => "x86", ["windows","i686"] => "x86", ["windows","x64"] => "x64", } generic_archs = Hash.new generic_archs = { "i386" => "i386", "i486" => "i386", "i586" => "i386", "i686" => "i386", "pentium" => "i386", } os_archs.each do |pair, result| it "should be #{result} if os is #{pair[0]} and hardwaremodel is #{pair[1]}" do Facter.fact(:operatingsystem).stubs(:value).returns(pair[0]) Facter.fact(:hardwaremodel).stubs(:value).returns(pair[1]) Facter.fact(:architecture).value.should == result end end generic_archs.each do |hw, result| it "should be #{result} if hardwaremodel is #{hw}" do Facter.fact(:hardwaremodel).stubs(:value).returns(hw) Facter.fact(:operatingsystem).stubs(:value).returns("NonSpecialCasedOS") Facter.fact(:architecture).value.should == result end end it "(#16081) should be PowerPC_POWER7 if os is AIX" do Facter.fact(:kernel).stubs(:value).returns("AIX") Facter::Util::Architecture.stubs(:lsattr).returns("type PowerPC_POWER7 Processor type False") Facter.fact(:hardwaremodel).stubs(:value).returns("IBM,8233-E8B") Facter.fact(:architecture).value.should == "PowerPC_POWER7" end end facter-1.7.5/spec/unit/hardwaremodel_spec.rb0000644005276200011600000000343112276213017020750 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' describe "Hardwaremodel fact" do it "should match uname -m by default" do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter::Util::Resolution.stubs(:exec).with("uname -m").returns("Inky") Facter.fact(:hardwaremodel).value.should == "Inky" end describe "on Windows" do require 'facter/util/wmi' before :each do Facter.fact(:kernel).stubs(:value).returns("windows") end it "should detect i486" do cpu = mock('cpu', :Architecture => 0) cpu.expects(:Level).returns(4).twice Facter::Util::WMI.expects(:execquery).returns([cpu]) Facter.fact(:hardwaremodel).value.should == "i486" end it "should detect i686" do cpu = mock('cpu', :Architecture => 0, :Level => 6) Facter::Util::WMI.expects(:execquery).returns([cpu]) Facter.fact(:hardwaremodel).value.should == "i686" end it "should detect x64" do cpu = mock('cpu', :Architecture => 9, :AddressWidth => 64, :Level => 6) Facter::Util::WMI.expects(:execquery).returns([cpu]) Facter.fact(:hardwaremodel).value.should == "x64" end it "(#16948) reports i686 when a 32 bit OS is running on a 64 bit CPU" do cpu = mock('cpu', :Architecture => 9, :AddressWidth => 32, :Level => 6) Facter::Util::WMI.expects(:execquery).returns([cpu]) Facter.fact(:hardwaremodel).value.should == "i686" end it "(#20989) should report i686 when a 32 bit OS is running on a 64 bit CPU and when level is greater than 6 (and not something like i1586)" do cpu = mock('cpu', :Architecture => 9, :AddressWidth => 32, :Level => 15) Facter::Util::WMI.expects(:execquery).returns([cpu]) Facter.fact(:hardwaremodel).value.should == "i686" end end end facter-1.7.5/spec/unit/kernelversion_spec.rb0000644005276200011600000000140512276213017021017 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "Kernel version fact" do describe "on Solaris/Sun OS" do before do Facter.fact(:kernel).stubs(:value).returns('sunos') Facter::Util::Resolution.stubs(:exec).with('uname -v').returns("1.234.5") end it "should return the kernel version using 'uname -v'" do Facter.fact(:kernelversion).value.should == "1.234.5" end end describe "on everything else" do before do Facter.fact(:kernel).stubs(:value).returns('linux') Facter.fact(:kernelrelease).stubs(:value).returns('1.23.4-56') end it "should return the kernel version using kernel release" do Facter.fact(:kernelversion).value.should == "1.23.4" end end end facter-1.7.5/spec/unit/ec2_spec.rb0000755005276200011600000001357112276213017016614 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/ec2' describe "ec2 facts" do # This is the standard prefix for making an API call in EC2 (or fake) # environments. let(:api_prefix) { "http://169.254.169.254" } describe "when running on ec2" do before :each do # This is an ec2 instance, not a eucalyptus instance Facter::Util::EC2.stubs(:has_euca_mac?).returns(false) Facter::Util::EC2.stubs(:has_openstack_mac?).returns(false) Facter::Util::EC2.stubs(:has_ec2_arp?).returns(true) # Assume we can connect Facter::Util::EC2.stubs(:can_connect?).returns(true) end it "should create flat meta-data facts" do Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/"). at_least_once.returns(StringIO.new("foo")) Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/foo"). at_least_once.returns(StringIO.new("bar")) Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_foo).value.should == "bar" end it "should create flat meta-data facts with comma seperation" do Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/"). at_least_once.returns(StringIO.new("foo")) Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/foo"). at_least_once.returns(StringIO.new("bar\nbaz")) Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_foo).value.should == "bar,baz" end it "should create structured meta-data facts" do Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/"). at_least_once.returns(StringIO.new("foo/")) Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/foo/"). at_least_once.returns(StringIO.new("bar")) Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/foo/bar"). at_least_once.returns(StringIO.new("baz")) Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_foo_bar).value.should == "baz" end it "should create ec2_user_data fact" do # No meta-data Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/"). at_least_once.returns(StringIO.new("")) Facter::Util::EC2.stubs(:read_uri). with("#{api_prefix}/latest/user-data/"). returns("test") Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_userdata).value.should == ["test"] end end describe "when running on eucalyptus" do before :each do # Return false for ec2, true for eucalyptus Facter::Util::EC2.stubs(:has_euca_mac?).returns(true) Facter::Util::EC2.stubs(:has_openstack_mac?).returns(false) Facter::Util::EC2.stubs(:has_ec2_arp?).returns(false) # Assume we can connect Facter::Util::EC2.stubs(:can_connect?).returns(true) end it "should create ec2_user_data fact" do # No meta-data Object.any_instance.expects(:open).\ with("#{api_prefix}/2008-02-01/meta-data/").\ at_least_once.returns(StringIO.new("")) Facter::Util::EC2.stubs(:read_uri). with("#{api_prefix}/latest/user-data/"). returns("test") # Force a fact load Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_userdata).value.should == ["test"] end end describe "when running on openstack" do before :each do # Return false for ec2, true for eucalyptus Facter::Util::EC2.stubs(:has_openstack_mac?).returns(true) Facter::Util::EC2.stubs(:has_euca_mac?).returns(false) Facter::Util::EC2.stubs(:has_ec2_arp?).returns(false) # Assume we can connect Facter::Util::EC2.stubs(:can_connect?).returns(true) end it "should create ec2_user_data fact" do # No meta-data Object.any_instance.expects(:open).\ with("#{api_prefix}/2008-02-01/meta-data/").\ at_least_once.returns(StringIO.new("")) Facter::Util::EC2.stubs(:read_uri). with("#{api_prefix}/latest/user-data/"). returns("test") # Force a fact load Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_userdata).value.should == ["test"] end it "should return nil if open fails" do Facter.stubs(:warn) # do not pollute test output Facter.expects(:warn).with('Could not retrieve ec2 metadata: host unreachable') Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/"). at_least_once.raises(RuntimeError, 'host unreachable') Facter::Util::EC2.stubs(:read_uri). with("#{api_prefix}/latest/user-data/"). raises(RuntimeError, 'host unreachable') # Force a fact load Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_userdata).value.should be_nil end end describe "when api connect test fails" do before :each do Facter.stubs(:warnonce) end it "should not populate ec2_userdata" do # Emulate ec2 for now as it matters little to this test Facter::Util::EC2.stubs(:has_euca_mac?).returns(true) Facter::Util::EC2.stubs(:has_ec2_arp?).never Facter::Util::EC2.expects(:can_connect?).at_least_once.returns(false) # The API should never be called at this point Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/meta-data/").never Object.any_instance.expects(:open). with("#{api_prefix}/2008-02-01/user-data/").never # Force a fact load Facter.collection.internal_loader.load(:ec2) Facter.fact(:ec2_userdata).should == nil end it "should rescue the exception" do Facter::Util::EC2.expects(:open).with("#{api_prefix}:80/").raises(Timeout::Error) Facter::Util::EC2.should_not be_can_connect end end end facter-1.7.5/spec/unit/lsbdistid_spec.rb0000755005276200011600000000134212276213017020115 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistid fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do before :each do Facter.fact(:kernel).stubs(:value).returns kernel end it "should return the id through lsb_release -i -s 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns 'Gentoo' Facter.fact(:lsbdistid).value.should == 'Gentoo' end it "should return nil if lsb_release is not installed 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns nil Facter.fact(:lsbdistid).value.should be_nil end end end end facter-1.7.5/spec/unit/ps_spec.rb0000755005276200011600000000175312276213017016564 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "ps facts" do it "should return busybox style ps www on OpenWrt" do Facter.fact(:operatingsystem).stubs(:value).returns 'OpenWrt' Facter.fact(:ps).value.should == 'ps www' end [ 'FreeBSD', 'NetBSD', 'OpenBSD', 'Darwin', 'DragonFly' ].each do |os| it "should return unix style ps on operatingsystem #{os}" do Facter.fact(:operatingsystem).stubs(:value).returns os Facter.fact(:ps).value.should == 'ps auxwww' end end # Other Linux Distros should return a ps -ef [ 'RedHat', 'Debian', ].each do |os| it "should return gnu/linux style ps -ef on operatingsystem #{os}" do Facter.fact(:operatingsystem).stubs(:value).returns os Facter.fact(:ps).value.should == 'ps -ef' end end it "should return tasklist.exe on Windows" do Facter.fact(:operatingsystem).stubs(:value).returns 'windows' Facter.fact(:ps).value.should == 'tasklist.exe' end end facter-1.7.5/spec/unit/util/0000755005276200011600000000000012276213024015545 5ustar jenkinsjenkinsfacter-1.7.5/spec/unit/util/loader_spec.rb0000755005276200011600000002471412276213017020367 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/loader' # loader subclass for making assertions about file/directory ordering class TestLoader < Facter::Util::Loader def loaded_files @loaded_files ||= [] end def load_file(file) loaded_files << file super end end describe Facter::Util::Loader do before :each do Facter::Util::Loader.any_instance.unstub(:load_all) end it "should have a method for loading individual facts by name" do Facter::Util::Loader.new.should respond_to(:load) end it "should have a method for loading all facts" do Facter::Util::Loader.new.should respond_to(:load_all) end it "should have a method for returning directories containing facts" do Facter::Util::Loader.new.should respond_to(:search_path) end describe "#valid_seach_path?" do before :each do @loader = Facter::Util::Loader.new @settings = mock 'settings' @settings.stubs(:value).returns "/eh" end it "should cache the result of a previous check" do Pathname.any_instance.expects(:absolute?).returns(true).once # we explicitly want two calls here to check that we get # the second from the cache @loader.should be_valid_search_path "/foo" @loader.should be_valid_search_path "/foo" end # Used to have test for " " as a directory since that should # be a relative directory, but on Windows in both 1.8.7 and # 1.9.3 it is an absolute directory (WTF Windows). Considering # we didn't have a valid use case for a " " directory, the # test was removed. [ '.', '..', '...', '.foo', '../foo', 'foo', 'foo/bar', 'foo/../bar', ' /', ' \/', ].each do |dir| it "should be false for relative path #{dir}" do @loader.should_not be_valid_search_path dir end end [ '/.', '/..', '/...', '/.foo', '/../foo', '/foo', '/foo/bar', '/foo/../bar', '/ ', '/ /..', ].each do |dir| it "should be true for absolute path #{dir}" do @loader.should be_valid_search_path dir end end end describe "when determining the search path" do before do @loader = Facter::Util::Loader.new @settings = mock 'settings' @settings.stubs(:value).returns "/eh" end it "should include the facter subdirectory of all paths in ruby LOAD_PATH" do dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") } @loader.stubs(:valid_search_path?).returns(true) paths = @loader.search_path dirs.each do |dir| paths.should be_include(dir) end end it "should warn the user when an invalid search path has been excluded" do dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") } @loader.stubs(:valid_search_path?).returns(false) dirs.each do |dir| Facter.expects(:debugonce).with("Relative directory #{dir} removed from search path.").once end paths = @loader.search_path end it "should exclude invalid search paths" do dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") } @loader.stubs(:valid_search_path?).returns(false) paths = @loader.search_path dirs.each do |dir| paths.should_not be_include(dir) end end it "should include all search paths registered with Facter" do Facter.expects(:search_path).returns %w{/one /two} paths = @loader.search_path paths.should be_include("/one") paths.should be_include("/two") end describe "and the FACTERLIB environment variable is set" do it "should include all paths in FACTERLIB" do Facter::Util::Resolution.with_env "FACTERLIB" => "/one/path#{File::PATH_SEPARATOR}/two/path" do paths = @loader.search_path %w{/one/path /two/path}.each do |dir| paths.should be_include(dir) end end end end end describe "when loading facts" do before do @loader = Facter::Util::Loader.new @loader.stubs(:search_path).returns [] end it "should load values from the matching environment variable if one is present" do Facter.expects(:add).with("testing") Facter::Util::Resolution.with_env "facter_testing" => "yayness" do @loader.load(:testing) end end it "should load any files in the search path with names matching the fact name" do @loader.expects(:search_path).returns %w{/one/dir /two/dir} FileTest.stubs(:exist?).returns false FileTest.expects(:exist?).with("/one/dir/testing.rb").returns true FileTest.expects(:exist?).with("/two/dir/testing.rb").returns true Kernel.expects(:load).with("/one/dir/testing.rb") Kernel.expects(:load).with("/two/dir/testing.rb") @loader.load(:testing) end it 'should load any ruby files in directories matching the fact name in the search path in sorted order regardless of the order returned by Dir.entries' do @loader = TestLoader.new @loader.stubs(:search_path).returns %w{/one/dir} FileTest.stubs(:exist?).returns false FileTest.stubs(:directory?).with("/one/dir/testing").returns true @loader.stubs(:search_path).returns %w{/one/dir} Dir.stubs(:entries).with("/one/dir/testing").returns %w{foo.rb bar.rb} %w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each do |f| File.stubs(:directory?).with(f).returns false Kernel.stubs(:load).with(f) end @loader.load(:testing) @loader.loaded_files.should == %w{/one/dir/testing/bar.rb /one/dir/testing/foo.rb} end it "should load any ruby files in directories matching the fact name in the search path" do @loader.expects(:search_path).returns %w{/one/dir} FileTest.stubs(:exist?).returns false FileTest.expects(:directory?).with("/one/dir/testing").returns true Dir.expects(:entries).with("/one/dir/testing").returns %w{two.rb} Kernel.expects(:load).with("/one/dir/testing/two.rb") @loader.load(:testing) end it "should not load files that don't end in '.rb'" do @loader.expects(:search_path).returns %w{/one/dir} FileTest.stubs(:exist?).returns false FileTest.expects(:directory?).with("/one/dir/testing").returns true Dir.expects(:entries).with("/one/dir/testing").returns %w{one} Kernel.expects(:load).never @loader.load(:testing) end end describe "when loading all facts" do before :each do @loader = Facter::Util::Loader.new @loader.stubs(:search_path).returns [] FileTest.stubs(:directory?).returns true end it "should skip directories that do not exist" do @loader.expects(:search_path).returns %w{/one/dir} FileTest.expects(:directory?).with("/one/dir").returns false Dir.expects(:entries).with("/one/dir").never @loader.load_all end it "should load all files in all search paths" do @loader.expects(:search_path).returns %w{/one/dir /two/dir} Dir.expects(:entries).with("/one/dir").returns %w{a.rb b.rb} Dir.expects(:entries).with("/two/dir").returns %w{c.rb d.rb} %w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each { |f| Kernel.expects(:load).with(f) } @loader.load_all end it "should load all files in all subdirectories in all search paths" do @loader.expects(:search_path).returns %w{/one/dir /two/dir} Dir.expects(:entries).with("/one/dir").returns %w{a} Dir.expects(:entries).with("/two/dir").returns %w{b} %w{/one/dir/a /two/dir/b}.each { |f| File.expects(:directory?).with(f).returns true } Dir.expects(:entries).with("/one/dir/a").returns %w{c.rb} Dir.expects(:entries).with("/two/dir/b").returns %w{d.rb} %w{/one/dir/a/c.rb /two/dir/b/d.rb}.each { |f| Kernel.expects(:load).with(f) } @loader.load_all end it 'should load all files in sorted order for any given directory regardless of the order returned by Dir.entries' do @loader = TestLoader.new @loader.stubs(:search_path).returns %w{/one/dir} Dir.stubs(:entries).with("/one/dir").returns %w{foo.rb bar.rb} %w{/one/dir}.each { |f| File.stubs(:directory?).with(f).returns true } %w{/one/dir/foo.rb /one/dir/bar.rb}.each do |f| File.stubs(:directory?).with(f).returns false Kernel.expects(:load).with(f) end @loader.load_all @loader.loaded_files.should == %w{/one/dir/bar.rb /one/dir/foo.rb} end it "should not load files in the util subdirectory" do @loader.expects(:search_path).returns %w{/one/dir} Dir.expects(:entries).with("/one/dir").returns %w{util} File.expects(:directory?).with("/one/dir/util").returns true Dir.expects(:entries).with("/one/dir/util").never @loader.load_all end it "should not load files in a lib subdirectory" do @loader.expects(:search_path).returns %w{/one/dir} Dir.expects(:entries).with("/one/dir").returns %w{lib} File.expects(:directory?).with("/one/dir/lib").returns true Dir.expects(:entries).with("/one/dir/lib").never @loader.load_all end it "should not load files in '.' or '..'" do @loader.expects(:search_path).returns %w{/one/dir} Dir.expects(:entries).with("/one/dir").returns %w{. ..} File.expects(:entries).with("/one/dir/.").never File.expects(:entries).with("/one/dir/..").never @loader.load_all end it "should not raise an exception when a file is unloadable" do @loader.expects(:search_path).returns %w{/one/dir} Dir.expects(:entries).with("/one/dir").returns %w{a.rb} Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError) Facter.expects(:warn) lambda { @loader.load_all }.should_not raise_error end it "should load all facts from the environment" do Facter::Util::Resolution.with_env "facter_one" => "yayness", "facter_two" => "boo" do @loader.load_all end Facter.value(:one).should == 'yayness' Facter.value(:two).should == 'boo' end it "should only load all facts one time" do @loader.expects(:load_env).once @loader.load_all @loader.load_all end end it "should load facts on the facter search path only once" do facterlibdir = File.expand_path(File.dirname(__FILE__) + '../../../fixtures/unit/util/loader') Facter::Util::Resolution.with_env 'FACTERLIB' => facterlibdir do Facter::Util::Loader.new.load_all Facter.value(:nosuchfact).should be_nil end end end facter-1.7.5/spec/unit/util/config_spec.rb0000644005276200011600000000454412276213017020362 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe Facter::Util::Config do include PuppetlabsSpec::Files describe "is_windows? function" do it "should detect windows if Ruby RbConfig::CONFIG['host_os'] returns a windows OS" do host_os = ["mswin","win32","dos","mingw","cygwin"] host_os.each do |h| RbConfig::CONFIG.stubs(:[]).with('host_os').returns(h) Facter::Util::Config.is_windows?.should be_true end end it "should not detect windows if Ruby RbConfig::CONFIG['host_os'] returns a non-windows OS" do host_os = ["darwin","linux"] host_os.each do |h| RbConfig::CONFIG.stubs(:[]).with('host_os').returns(h) Facter::Util::Config.is_windows?.should be_false end end end describe "is_mac? function" do it "should detect mac if Ruby RbConfig::CONFIG['host_os'] returns darwin" do host_os = ["darwin"] host_os.each do |h| RbConfig::CONFIG.stubs(:[]).with('host_os').returns(h) Facter::Util::Config.is_mac?.should be_true end end end describe "external_facts_dirs" do before :each do Facter::Util::Root.stubs(:root?).returns(true) end it "should return the default value for linux" do Facter::Util::Config.stubs(:is_windows?).returns(false) Facter::Util::Config.stubs(:windows_data_dir).returns(nil) Facter::Util::Config.external_facts_dirs.should == ["/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"] end it "should return the default value for windows 2008" do Facter::Util::Config.stubs(:is_windows?).returns(true) Facter::Util::Config.stubs(:windows_data_dir).returns("C:\\ProgramData") Facter::Util::Config.external_facts_dirs.should == [File.join("C:\\ProgramData", 'PuppetLabs', 'facter', 'facts.d')] end it "should return the default value for windows 2003R2" do Facter::Util::Config.stubs(:is_windows?).returns(true) Facter::Util::Config.stubs(:windows_data_dir).returns("C:\\Documents") Facter::Util::Config.external_facts_dirs.should == [File.join("C:\\Documents", 'PuppetLabs', 'facter', 'facts.d')] end it "returns the users home directory when not root" do Facter::Util::Root.stubs(:root?).returns(false) Facter::Util::Config.external_facts_dirs.should == [File.expand_path(File.join("~", ".facter", "facts.d"))] end end end facter-1.7.5/spec/unit/util/confine_spec.rb0000755005276200011600000001007212276213017020532 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/confine' require 'facter/util/values' include Facter::Util::Values describe Facter::Util::Confine do it "should require a fact name" do Facter::Util::Confine.new("yay", true).fact.should == "yay" end it "should accept a value specified individually" do Facter::Util::Confine.new("yay", "test").values.should == ["test"] end it "should accept multiple values specified at once" do Facter::Util::Confine.new("yay", "test", "other").values.should == ["test", "other"] end it "should fail if no fact name is provided" do lambda { Facter::Util::Confine.new(nil, :test) }.should raise_error(ArgumentError) end it "should fail if no values were provided" do lambda { Facter::Util::Confine.new("yay") }.should raise_error(ArgumentError) end it "should have a method for testing whether it matches" do Facter::Util::Confine.new("yay", :test).should respond_to(:true?) end describe "when evaluating" do def confined(fact_value, *confines) @fact.stubs(:value).returns fact_value Facter::Util::Confine.new("yay", *confines).true? end before do @fact = mock 'fact' Facter.stubs(:[]).returns @fact end it "should return false if the fact does not exist" do Facter.expects(:[]).with("yay").returns nil Facter::Util::Confine.new("yay", "test").true?.should be_false end it "should use the returned fact to get the value" do Facter.expects(:[]).with("yay").returns @fact @fact.expects(:value).returns nil Facter::Util::Confine.new("yay", "test").true? end it "should return false if the fact has no value" do confined(nil, "test").should be_false end it "should return true if any of the provided values matches the fact's value" do confined("two", "two").should be_true end it "should return true if any of the provided symbol values matches the fact's value" do confined(:xy, :xy).should be_true end it "should return true if any of the provided integer values matches the fact's value" do confined(1, 1).should be_true end it "should return true if any of the provided boolan values matches the fact's value" do confined(true, true).should be_true end it "should return true if any of the provided array values matches the fact's value" do confined([3,4], [3,4]).should be_true end it "should return true if any of the provided symbol values matches the fact's string value" do confined(:one, "one").should be_true end it "should return true if any of the provided string values matches case-insensitive the fact's value" do confined("four", "Four").should be_true end it "should return true if any of the provided symbol values matches case-insensitive the fact's string value" do confined(:four, "Four").should be_true end it "should return true if any of the provided symbol values matches the fact's string value" do confined("xy", :xy).should be_true end it "should return true if any of the provided regexp values matches the fact's string value" do confined("abc", /abc/).should be_true end it "should return true if any of the provided ranges matches the fact's value" do confined(6, (5..7)).should be_true end it "should return false if none of the provided values matches the fact's value" do confined("three", "two", "four").should be_false end it "should return false if none of the provided integer values matches the fact's value" do confined(2, 1, [3,4], (5..7)).should be_false end it "should return false if none of the provided boolan values matches the fact's value" do confined(false, true).should be_false end it "should return false if none of the provided array values matches the fact's value" do confined([1,2], [3,4]).should be_false end it "should return false if none of the provided ranges matches the fact's value" do confined(8, (5..7)).should be_false end end end facter-1.7.5/spec/unit/util/ec2_spec.rb0000755005276200011600000001375012276213017017570 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/ec2' describe Facter::Util::EC2 do # This is the standard prefix for making an API call in EC2 (or fake) # environments. let(:api_prefix) { "http://169.254.169.254" } describe "is_ec2_arp? method" do describe "on linux" do before :each do # Return fake kernel Facter.stubs(:value).with(:kernel).returns("linux") end it "should succeed if arp table contains fe:ff:ff:ff:ff:ff" do ec2arp = my_fixture_read("linux-arp-ec2.out") Facter::Util::Resolution.expects(:exec).with("arp -an").\ at_least_once.returns(ec2arp) Facter::Util::EC2.has_ec2_arp?.should == true end it "should succeed if arp table contains FE:FF:FF:FF:FF:FF" do ec2arp = my_fixture_read("centos-arp-ec2.out") Facter::Util::Resolution.expects(:exec).with("arp -an").\ at_least_once.returns(ec2arp) Facter::Util::EC2.has_ec2_arp?.should == true end it "should fail if arp table does not contain fe:ff:ff:ff:ff:ff" do ec2arp = my_fixture_read("linux-arp-not-ec2.out") Facter::Util::Resolution.expects(:exec).with("arp -an"). at_least_once.returns(ec2arp) Facter::Util::EC2.has_ec2_arp?.should == false end end describe "on windows" do before :each do # Return fake kernel Facter.stubs(:value).with(:kernel).returns("windows") end it "should succeed if arp table contains fe-ff-ff-ff-ff-ff" do ec2arp = my_fixture_read("windows-2008-arp-a.out") Facter::Util::Resolution.expects(:exec).with("arp -a").\ at_least_once.returns(ec2arp) Facter::Util::EC2.has_ec2_arp?.should == true end it "should fail if arp table does not contain fe-ff-ff-ff-ff-ff" do ec2arp = my_fixture_read("windows-2008-arp-a-not-ec2.out") Facter::Util::Resolution.expects(:exec).with("arp -a"). at_least_once.returns(ec2arp) Facter::Util::EC2.has_ec2_arp?.should == false end end describe "on solaris" do before :each do Facter.stubs(:value).with(:kernel).returns("SunOS") end it "should fail if arp table does not contain fe:ff:ff:ff:ff:ff" do ec2arp = my_fixture_read("solaris8_arp_a_not_ec2.out") Facter::Util::Resolution.expects(:exec).with("arp -a"). at_least_once.returns(ec2arp) Facter::Util::EC2.has_ec2_arp?.should == false end end end describe "is_euca_mac? method" do it "should return true when the mac is a eucalyptus one" do Facter.expects(:value).with(:macaddress).\ at_least_once.returns("d0:0d:1a:b0:a1:00") Facter::Util::EC2.has_euca_mac?.should == true end it "should return false when the mac is not a eucalyptus one" do Facter.expects(:value).with(:macaddress).\ at_least_once.returns("0c:1d:a0:bc:aa:02") Facter::Util::EC2.has_euca_mac?.should == false end end describe "is_openstack_mac? method" do it "should return true when the mac is an openstack one" do Facter.expects(:value).with(:macaddress).\ at_least_once.returns("02:16:3e:54:89:fd") Facter::Util::EC2.has_openstack_mac?.should == true end it "should return true when the mac is a newer openstack mac" do # https://github.com/openstack/nova/commit/b684d651f540fc512ced58acd5ae2ef4d55a885c#nova/utils.py Facter.expects(:value).with(:macaddress).\ at_least_once.returns("fa:16:3e:54:89:fd") Facter::Util::EC2.has_openstack_mac?.should == true end it "should return true when the mac is a newer openstack mac and returned in upper case" do # https://github.com/openstack/nova/commit/b684d651f540fc512ced58acd5ae2ef4d55a885c#nova/utils.py Facter.expects(:value).with(:macaddress).\ at_least_once.returns("FA:16:3E:54:89:FD") Facter::Util::EC2.has_openstack_mac?.should == true end it "should return false when the mac is not a openstack one" do Facter.expects(:value).with(:macaddress).\ at_least_once.returns("0c:1d:a0:bc:aa:02") Facter::Util::EC2.has_openstack_mac?.should == false end end describe "can_connect? method" do it "returns true if api responds" do # Return something upon connecting to the root Module.any_instance.expects(:open).with("#{api_prefix}:80/"). at_least_once.returns("2008-02-01\nlatest") Facter::Util::EC2.can_connect?.should be_true end describe "when connection times out" do it "should return false" do # Emulate a timeout when connecting by throwing an exception Module.any_instance.expects(:open).with("#{api_prefix}:80/"). at_least_once.raises(RuntimeError) Facter::Util::EC2.can_connect?.should be_false end end describe "when connection is refused" do it "should return false" do # Emulate a connection refused Module.any_instance.expects(:open).with("#{api_prefix}:80/"). at_least_once.raises(Errno::ECONNREFUSED) Facter::Util::EC2.can_connect?.should be_false end end end describe "Facter::Util::EC2.userdata" do let :not_found_error do OpenURI::HTTPError.new("404 Not Found", StringIO.new) end let :example_userdata do "owner=jeff@puppetlabs.com\ngroup=platform_team" end it 'returns nil when no userdata is present' do Facter::Util::EC2.stubs(:read_uri).raises(not_found_error) Facter::Util::EC2.userdata.should be_nil end it "returns the string containing the body" do Facter::Util::EC2.stubs(:read_uri).returns(example_userdata) Facter::Util::EC2.userdata.should == example_userdata end it "uses the specified API version" do expected_uri = "http://169.254.169.254/2008-02-01/user-data/" Facter::Util::EC2.expects(:read_uri).with(expected_uri).returns(example_userdata) Facter::Util::EC2.userdata('2008-02-01').should == example_userdata end end end facter-1.7.5/spec/unit/util/monkey_patches_spec.rb0000644005276200011600000000176612276213017022131 0ustar jenkinsjenkinsrequire 'spec_helper' require 'tempfile' describe 'Monkey Patches' do let(:subject) { "a b c d e f\ng h i j" } context 'String' do it "should respond to lines" do subject.lines.to_a.should == ["a b c d e f\n", "g h i j"] end it "should accept a block" do our_lines = [] subject.lines do |line| our_lines << line end our_lines.should == ["a b c d e f\n", "g h i j"] end end context 'IO' do it "should respond to lines" do our_lines = nil Tempfile.open("lines") do | file | file.write(subject) file.flush file.rewind our_lines = file.lines.to_a end our_lines.should == ["a b c d e f\n", "g h i j"] end it "should accept a block" do our_lines = [] file = Tempfile.new("lines") file.write(subject) file.flush file.rewind file.lines.each do |line| our_lines << line end file.unlink our_lines.should == ["a b c d e f\n", "g h i j"] end end end facter-1.7.5/spec/unit/util/fact_spec.rb0000755005276200011600000001050512276213017020027 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/fact' describe Facter::Util::Fact do it "should require a name" do lambda { Facter::Util::Fact.new }.should raise_error(ArgumentError) end it "should always downcase the name and convert it to a symbol" do Facter::Util::Fact.new("YayNess").name.should == :yayness end it "should default to its name converted to a string as its ldapname" do Facter::Util::Fact.new("YayNess").ldapname.should == "yayness" end it "should allow specifying the ldap name at initialization" do Facter::Util::Fact.new("YayNess", :ldapname => "fooness").ldapname.should == "fooness" end it "should fail if an unknown option is provided" do lambda { Facter::Util::Fact.new('yay', :foo => :bar) }.should raise_error(ArgumentError) end it "should have a method for adding resolution mechanisms" do Facter::Util::Fact.new("yay").should respond_to(:add) end describe "when adding resolution mechanisms" do before do @fact = Facter::Util::Fact.new("yay") @resolution = Facter::Util::Resolution.new("yay") end it "should be to create a new resolution instance with a block" do Facter::Util::Resolution.expects(:new).returns @resolution @fact.add { } end it "should instance_eval the passed block on the new resolution" do @fact.add { setcode { "foo" } } @fact.value.should == "foo" end it "should re-sort the resolutions by weight, so the most restricted resolutions are first" do @fact.add { self.value = "1"; self.weight = 1 } @fact.add { self.value = "2"; self.weight = 2 } @fact.add { self.value = "0"; self.weight = 0 } @fact.value.should == "2" end end it "should be able to return a value" do Facter::Util::Fact.new("yay").should respond_to(:value) end describe "when returning a value" do before do @fact = Facter::Util::Fact.new("yay") end it "should return nil if there are no resolutions" do Facter::Util::Fact.new("yay").value.should be_nil end it "should return the first value returned by a resolution" do r1 = stub 'r1', :weight => 2, :value => nil, :suitable? => true r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true r3 = stub 'r3', :weight => 0, :value => "foo", :suitable? => true Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3) @fact.add { } @fact.add { } @fact.add { } @fact.value.should == "yay" end it "should short-cut returning the value once one is found" do r1 = stub 'r1', :weight => 2, :value => "foo", :suitable? => true r2 = stub 'r2', :weight => 1, :suitable? => true # would fail if 'value' were asked for Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2) @fact.add { } @fact.add { } @fact.value end it "should skip unsuitable resolutions" do r1 = stub 'r1', :weight => 2, :suitable? => false # would fail if 'value' were asked for' r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2) @fact.add { } @fact.add { } @fact.value.should == "yay" end it "should return nil if the value is the empty string" do r1 = stub 'r1', :suitable? => true, :value => "" Facter::Util::Resolution.expects(:new).returns r1 @fact.add { } @fact.value.should be_nil end end describe '#flush' do subject do Facter::Util::Fact.new(:foo) end context 'basic facts using setcode' do it "flushes the cached value when invoked" do system = mock('some_system_call') system.expects(:data).twice.returns(100,200) subject.add { setcode { system.data } } 5.times { subject.value.should == 100 } subject.flush subject.value.should == 200 end end context 'facts using setcode and on_flush' do it 'invokes the block passed to on_flush' do model = { :data => "Hello World" } subject.add do on_flush { model[:data] = "FLUSHED!" } setcode { model[:data] } end subject.value.should == "Hello World" subject.flush subject.value.should == "FLUSHED!" end end end end facter-1.7.5/spec/unit/util/ip_spec.rb0000755005276200011600000005250212276213017017525 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/ip' describe Facter::Util::IP do include FacterSpec::ConfigHelper before :each do given_a_configuration_of(:is_windows => false) end [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux", :"gnu/kfreebsd", :windows].each do |platform| it "should be supported on #{platform}" do given_a_configuration_of(:is_windows => platform == :windows) Facter::Util::IP.supported_platforms.should be_include(platform) end end it "should return a list of interfaces" do Facter::Util::IP.should respond_to(:get_interfaces) end it "should return an empty list of interfaces on an unknown kernel" do Facter.stubs(:value).returns("UnknownKernel") Facter::Util::IP.get_interfaces().should == [] end it "should return a list with a single interface and the loopback interface on Linux with a single interface" do linux_ifconfig = my_fixture_read("linux_ifconfig_all_with_single_interface") Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig) Facter::Util::IP.get_interfaces().should == ["eth0", "lo"] end it "should return a list two interfaces on Darwin with two interfaces" do darwin_ifconfig = my_fixture_read("darwin_ifconfig_all_with_multiple_interfaces") Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig) Facter::Util::IP.get_interfaces().should == ["lo0", "en0"] end it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do solaris_ifconfig = my_fixture_read("solaris_ifconfig_all_with_multiple_interfaces") Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig) Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"] end it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig") Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig) Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", "bge1", "lo0", "vlan0"] end it "should return a list of only connected interfaces on Windows" do Facter.fact(:kernel).stubs(:value).returns("windows") Facter::Util::IP::Windows.expects(:interfaces).returns(["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"]) Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"] end it "should return a value for a specific interface" do Facter::Util::IP.should respond_to(:get_interface_value) end it "should not return interface information for unsupported platforms" do Facter.stubs(:value).with(:kernel).returns("bleah") Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == [] end it "should return ipaddress information for Solaris" do solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") Facter::Util::IP.get_interface_value("e1000g0", "ipaddress").should == "172.16.15.138" end it "should return netmask information for Solaris" do solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0" end it "should return calculated network information for Solaris" do solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") Facter::Util::IP.get_network_value("e1000g0").should == "172.16.15.0" end it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig) Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") Facter::Util::IP.get_interface_value("em0", "macaddress").should == "0:11:a:59:67:90" end it "should return interface information for FreeBSD supported via an alias" do ifconfig_interface = my_fixture_read("6.0-STABLE_FreeBSD_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("FreeBSD") Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c" end it "should return macaddress information for OS X" do ifconfig_interface = my_fixture_read("Mac_OS_X_10.5.5_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Darwin") Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66" end it "should return all interfaces correctly on OS X" do ifconfig_interface = my_fixture_read("Mac_OS_X_10.5.5_ifconfig") Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Darwin") Facter::Util::IP.get_interfaces().should == ["lo0", "gif0", "stf0", "en0", "fw0", "en1", "vmnet8", "vmnet1"] end it "should return a human readable netmask on Solaris" do solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0" end it "should return a human readable netmask on Darwin" do darwin_ifconfig_interface = my_fixture_read("darwin_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Darwin") Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0" end it "should return a human readable netmask on GNU/kFreeBSD" do kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig") Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig) Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") Facter::Util::IP.get_interface_value("em1", "netmask").should == "255.255.255.0" end it "should return correct macaddress information for infiniband on Linux" do correct_ifconfig_interface = my_fixture_read("linux_get_single_interface_ib0") Facter::Util::IP.expects(:get_single_interface_output).with("ib0").returns(correct_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Linux") Facter::Util::IP.get_interface_value("ib0", "macaddress").should == "80:00:00:4a:fe:80:00:00:00:00:00:00:00:02:c9:03:00:43:27:21" end it "should replace the incorrect macaddress with the correct macaddress in ifconfig for infiniband on Linux" do ifconfig_interface = my_fixture_read("linux_ifconfig_ib0") correct_ifconfig_interface = my_fixture_read("linux_get_single_interface_ib0") Facter::Util::IP.expects(:get_infiniband_macaddress).with("ib0").returns("80:00:00:4a:fe:80:00:00:00:00:00:00:00:02:c9:03:00:43:27:21") Facter::Util::IP.expects(:ifconfig_interface).with("ib0").returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Linux") Facter::Util::IP.get_single_interface_output("ib0").should == correct_ifconfig_interface end it "should return fake macaddress information for infiniband on Linux when neither sysfs or /sbin/ip are available" do ifconfig_interface = my_fixture_read("linux_ifconfig_ib0") File.expects(:exists?).with("/sys/class/net/ib0/address").returns(false) File.expects(:exists?).with("/sbin/ip").returns(false) Facter::Util::IP.expects(:ifconfig_interface).with("ib0").returns(ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Linux") Facter::Util::IP.get_interface_value("ib0", "macaddress").should == "FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF" end it "should not get bonding master on interface aliases" do Facter.stubs(:value).with(:kernel).returns("Linux") Facter::Util::IP.get_bonding_master("eth0:1").should be_nil end [:freebsd, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux"].each do |platform| it "should require conversion from hex on #{platform}" do Facter::Util::IP.convert_from_hex?(platform).should == true end end [:windows].each do |platform| it "should not require conversion from hex on #{platform}" do Facter::Util::IP.convert_from_hex?(platform).should be_false end end it "should return an arp address on Linux" do Facter.stubs(:value).with(:kernel).returns("Linux") Facter::Util::IP.expects(:get_arp_value).with("eth0").returns("00:00:0c:9f:f0:04") Facter::Util::IP.get_arp_value("eth0").should == "00:00:0c:9f:f0:04" end it "should return mtu information on Linux" do linux_ifconfig = my_fixture_read("linux_ifconfig_all_with_single_interface") Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig) Facter::Util::IP.stubs(:get_single_interface_output).with("eth0"). returns(my_fixture_read("linux_get_single_interface_eth0")) Facter::Util::IP.stubs(:get_single_interface_output).with("lo"). returns(my_fixture_read("linux_get_single_interface_lo")) Facter.stubs(:value).with(:kernel).returns("Linux") Facter::Util::IP.get_interface_value("eth0", "mtu").should == "1500" Facter::Util::IP.get_interface_value("lo", "mtu").should == "16436" end it "should return mtu information on Darwin" do darwin_ifconfig_interface = my_fixture_read("darwin_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("Darwin") Facter::Util::IP.get_interface_value("en1", "mtu").should == "1500" end it "should return mtu information for Solaris" do solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface") Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) Facter.stubs(:value).with(:kernel).returns("SunOS") Facter::Util::IP.get_interface_value("e1000g0", "mtu").should == "1500" end # (#17487) - tests for HP-UX. # some fake data for testing robustness of regexps. def self.fake_netstat_in_examples examples = [] examples << ["Header row\na line with none in it\na line without\nanother line without\n", "a line without\nanother line without\n"] examples << ["Header row\na line without\na line with none in it\nanother line with none\nanother line without\n", "a line without\nanother line without\n"] examples << ["Header row\na line with * asterisks *\na line with none in it\nanother line without\n", "a line with asterisks \nanother line without\n"] examples << ["a line with none none none in it\na line with none in it\na line without\nanother line without\n", "another line without\n"] examples end fake_netstat_in_examples.each_with_index do |example, i| input, expected_output = example it "should pass regexp test on fake netstat input example #{i}" do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.stubs(:hpux_netstat_in).returns(input) Facter::Util::IP.get_all_interface_output().should == expected_output end end # and some real data for exhaustive tests. def self.hpux_examples examples = [] examples << ["HP-UX 11.11", ["lan1", "lan0", "lo0" ], ["1500", "1500", "4136" ], ["10.1.1.6", "192.168.3.10", "127.0.0.1"], ["255.255.255.0", "255.255.255.0", "255.0.0.0"], ["00:10:79:7B:5C:DE", "00:30:7F:0C:79:DC", nil ], [my_fixture_read("hpux_1111_ifconfig_lan1"), my_fixture_read("hpux_1111_ifconfig_lan0"), my_fixture_read("hpux_1111_ifconfig_lo0")], my_fixture_read("hpux_1111_netstat_in"), my_fixture_read("hpux_1111_lanscan")] examples << ["HP-UX 11.31", ["lan1", "lan0", "lo0" ], ["1500", "1500", "4136" ], ["10.1.54.36", "192.168.30.152", "127.0.0.1"], ["255.255.255.0", "255.255.255.0", "255.0.0.0"], ["00:17:FD:2D:2A:57", "00:12:31:7D:62:09", nil ], [my_fixture_read("hpux_1131_ifconfig_lan1"), my_fixture_read("hpux_1131_ifconfig_lan0"), my_fixture_read("hpux_1131_ifconfig_lo0")], my_fixture_read("hpux_1131_netstat_in"), my_fixture_read("hpux_1131_lanscan")] examples << ["HP-UX 11.31 with an asterisk after a NIC that has an address", ["lan1", "lan0", "lo0" ], ["1500", "1500", "4136" ], ["10.10.0.5", "192.168.3.9", "127.0.0.1"], ["255.255.255.0", "255.255.255.0", "255.0.0.0"], ["00:10:79:7B:BE:46", "00:30:5D:06:26:B2", nil ], [my_fixture_read("hpux_1131_asterisk_ifconfig_lan1"), my_fixture_read("hpux_1131_asterisk_ifconfig_lan0"), my_fixture_read("hpux_1131_asterisk_ifconfig_lo0")], my_fixture_read("hpux_1131_asterisk_netstat_in"), my_fixture_read("hpux_1131_asterisk_lanscan")] examples << ["HP-UX 11.31 with NIC bonding and one virtual NIC", ["lan4:1", "lan1", "lo0", "lan4" ], ["1500", "1500", "4136", "1500" ], ["192.168.1.197", "192.168.30.32", "127.0.0.1", "192.168.32.75" ], ["255.255.255.0", "255.255.255.0", "255.0.0.0", "255.255.255.0" ], [nil, "00:12:81:9E:48:DE", nil, "00:12:81:9E:4A:7E"], [my_fixture_read("hpux_1131_nic_bonding_ifconfig_lan4_1"), my_fixture_read("hpux_1131_nic_bonding_ifconfig_lan1"), my_fixture_read("hpux_1131_nic_bonding_ifconfig_lo0"), my_fixture_read("hpux_1131_nic_bonding_ifconfig_lan4")], my_fixture_read("hpux_1131_nic_bonding_netstat_in"), my_fixture_read("hpux_1131_nic_bonding_lanscan")] examples end hpux_examples.each do |example| description, array_of_expected_ifs, array_of_expected_mtus, array_of_expected_ips, array_of_expected_netmasks, array_of_expected_macs, array_of_ifconfig_fixtures, netstat_in_fixture, lanscan_fixture = example it "should return a list three interfaces on #{description}" do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.stubs(:hpux_netstat_in).returns(netstat_in_fixture) Facter::Util::IP.get_interfaces().should == array_of_expected_ifs end array_of_expected_ifs.each_with_index do |nic, i| ifconfig_fixture = array_of_ifconfig_fixtures[i] expected_mtu = array_of_expected_mtus[i] expected_ip = array_of_expected_ips[i] expected_netmask = array_of_expected_netmasks[i] expected_mac = array_of_expected_macs[i] # (#17808) These tests fail because MTU facts haven't been implemented for HP-UX. #it "should return MTU #{expected_mtu} on #{nic} for #{description} example" do # Facter.stubs(:value).with(:kernel).returns("HP-UX") # Facter::Util::IP.stubs(:hpux_netstat_in).returns(netstat_in_fixture) # Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture) # Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture) # Facter::Util::IP.get_interface_value(nic, "mtu").should == expected_mtu #end it "should return IP #{expected_ip} on #{nic} for #{description} example" do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture) Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture) Facter::Util::IP.get_interface_value(nic, "ipaddress").should == expected_ip end it "should return netmask #{expected_netmask} on #{nic} for #{description} example" do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture) Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture) Facter::Util::IP.get_interface_value(nic, "netmask").should == expected_netmask end it "should return MAC address #{expected_mac} on #{nic} for #{description} example" do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.stubs(:hpux_lanscan).returns(lanscan_fixture) Facter::Util::IP.stubs(:hpux_ifconfig_interface).with(nic).returns(ifconfig_fixture) Facter::Util::IP.get_interface_value(nic, "macaddress").should == expected_mac end end end describe "on Windows" do require 'facter/util/ip/windows' before :each do Facter.stubs(:value).with(:kernel).returns("windows") end it "should return ipaddress information" do Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "ipaddress").returns('172.16.138.216') Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress").should == "172.16.138.216" end it "should return network information" do Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "ipaddress").returns('172.16.138.216') Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "netmask").returns('255.255.255.0') Facter::Util::IP.get_network_value("Local Area Connection").should == "172.16.138.0" end it "should return ipaddress6 information" do Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "ipaddress6").returns("2001:0:4137:9e76:2087:77a:53ef:7527") Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress6").should == "2001:0:4137:9e76:2087:77a:53ef:7527" end end describe "exec_ifconfig" do it "uses get_ifconfig" do Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig").once Facter::Util::IP.exec_ifconfig end it "support additional arguments" do Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") Facter::Util::Resolution.stubs(:exec).with("/sbin/ifconfig -a") Facter::Util::IP.exec_ifconfig(["-a"]) end it "joins multiple arguments correctly" do Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") Facter::Util::Resolution.stubs(:exec).with("/sbin/ifconfig -a -e -i -j") Facter::Util::IP.exec_ifconfig(["-a","-e","-i","-j"]) end end describe "get_ifconfig" do it "assigns /sbin/ifconfig if it is executable" do File.stubs(:executable?).returns(false) File.stubs(:executable?).with("/sbin/ifconfig").returns(true) Facter::Util::IP.get_ifconfig.should eq("/sbin/ifconfig") end it "assigns /usr/sbin/ifconfig if it is executable" do File.stubs(:executable?).returns(false) File.stubs(:executable?).with("/usr/sbin/ifconfig").returns(true) Facter::Util::IP.get_ifconfig.should eq("/usr/sbin/ifconfig") end it "assigns /bin/ifconfig if it is executable" do File.stubs(:executable?).returns(false) File.stubs(:executable?).with("/bin/ifconfig").returns(true) Facter::Util::IP.get_ifconfig.should eq("/bin/ifconfig") end end context "with bonded ethernet interfaces on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end describe "Facter::Util::Ip.get_interface_value" do before :each do Facter::Util::IP.stubs(:read_proc_net_bonding). with("/proc/net/bonding/bond0"). returns(my_fixture_read("linux_2_6_35_proc_net_bonding_bond0")) Facter::Util::IP.stubs(:get_bonding_master).returns("bond0") end it 'provides the real device macaddress for eth0' do Facter::Util::IP.get_interface_value("eth0", "macaddress").should == "00:11:22:33:44:55" end it 'provides the real device macaddress for eth1' do Facter::Util::IP.get_interface_value("eth1", "macaddress").should == "00:11:22:33:44:56" end end end end facter-1.7.5/spec/unit/util/parser_spec.rb0000755005276200011600000001407512276213017020414 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter/util/parser' require 'tempfile' require 'tmpdir.rb' describe Facter::Util::Parser do include PuppetlabsSpec::Files describe "extension_matches? function" do it "should match extensions when subclass uses match_extension" do Facter::Util::Parser.extension_matches?("myfile.foobar", "foobar").should == true end it "should match extensions when subclass uses match_extension with an array" do Facter::Util::Parser.extension_matches?("myfile.ext1", ["ext1","ext2","ext3"]).should == true Facter::Util::Parser.extension_matches?("myfile.ext2", ["ext1","ext2","ext3"]).should == true Facter::Util::Parser.extension_matches?("myfile.ext3", ["ext1","ext2","ext3"]).should == true end it "should match extension ignoring case on file" do Facter::Util::Parser.extension_matches?("myfile.EXT1", "ext1").should == true Facter::Util::Parser.extension_matches?("myfile.ExT1", "ext1").should == true Facter::Util::Parser.extension_matches?("myfile.exT1", "ext1").should == true end it "should match extension ignoring case for match_extension" do Facter::Util::Parser.extension_matches?("myfile.EXT1", "EXT1").should == true Facter::Util::Parser.extension_matches?("myfile.ExT1", "EXT1").should == true Facter::Util::Parser.extension_matches?("myfile.exT1", "EXT1").should == true end end let(:data) do {"one" => "two", "three" => "four"} end describe "yaml" do let(:data_in_yaml) { YAML.dump(data) } let(:data_file) { "/tmp/foo.yaml" } it "should return a hash of whatever is stored on disk" do File.stubs(:read).with(data_file).returns(data_in_yaml) described_class.parser_for(data_file).results.should == data end it "should handle exceptions and warn" do # YAML data with an error File.stubs(:read).with(data_file).returns(data_in_yaml + "}") Facter.expects(:warn).at_least_once lambda { Facter::Util::Parser.parser_for(data_file).results }.should_not raise_error end end describe "json" do let(:data_in_json) { JSON.dump(data) } let(:data_file) { "/tmp/foo.json" } it "should return a hash of whatever is stored on disk" do pending("this test requires the json library") unless Facter.json? File.stubs(:read).with(data_file).returns(data_in_json) Facter::Util::Parser.parser_for(data_file).results.should == data end end describe "txt" do let(:data_file) { "/tmp/foo.txt" } shared_examples_for "txt parser" do it "should return a hash of whatever is stored on disk" do File.stubs(:read).with(data_file).returns(data_in_txt) Facter::Util::Parser.parser_for(data_file).results.should == data end end context "well formed data" do let(:data_in_txt) { "one=two\nthree=four\n" } it_behaves_like "txt parser" end context "extra equal sign" do let(:data_in_txt) { "one=two\nthree=four=five\n" } let(:data) do {"one" => "two", "three" => "four=five"} end it_behaves_like "txt parser" end context "extra data" do let(:data_in_txt) { "one=two\nfive\nthree=four\n" } it_behaves_like "txt parser" end end describe "scripts" do let(:ext) { Facter::Util::Config.is_windows? ? '.bat' : '.sh' } let(:cmd) { "/tmp/foo#{ext}" } let(:data_in_txt) { "one=two\nthree=four\n" } def expects_script_to_return(path, content, result) Facter::Util::Resolution.stubs(:exec).with(path).returns(content) File.stubs(:executable?).with(path).returns(true) File.stubs(:file?).with(path).returns(true) Facter::Util::Parser.parser_for(path).results.should == result end def expects_parser_to_return_nil_for_directory(path) File.stubs(:file?).with(path).returns(false) Facter::Util::Parser.parser_for(path).results.should be_nil end it "returns a hash of whatever is returned by the executable" do expects_script_to_return(cmd, data_in_txt, data) end it "should not parse a directory" do expects_parser_to_return_nil_for_directory(cmd) end it "returns an empty hash when the script returns nil" do expects_script_to_return(cmd, nil, {}) end it "quotes scripts with spaces" do path = "/h a s s p a c e s#{ext}" Facter::Util::Resolution.expects(:exec).with("\"#{path}\"").returns(data_in_txt) expects_script_to_return(path, data_in_txt, data) end context "exe, bat, cmd, and com files" do let :cmds do ["/tmp/foo.bat", "/tmp/foo.cmd", "/tmp/foo.exe", "/tmp/foo.com"] end before :each do cmds.each {|cmd| File.stubs(:executable?).with(cmd).returns(true) File.stubs(:file?).with(cmd).returns(true) } end it "should return nothing parser if not on windows" do Facter::Util::Config.stubs(:is_windows?).returns(false) cmds.each {|cmd| Facter::Util::Parser.parser_for(cmd).should be_an_instance_of(Facter::Util::Parser::NothingParser) } end it "should return script parser if on windows" do Facter::Util::Config.stubs(:is_windows?).returns(true) cmds.each {|cmd| Facter::Util::Parser.parser_for(cmd).should be_an_instance_of(Facter::Util::Parser::ScriptParser) } end end describe "powershell parser" do let(:ps1) { "/tmp/foo.ps1" } def expects_to_parse_powershell(cmd, content, result) Facter::Util::Config.stubs(:is_windows?).returns(true) Facter::Util::Resolution.stubs(:exec).returns(content) File.stubs(:file?).with(ps1).returns(true) Facter::Util::Parser.parser_for(cmd).results.should == result end it "should not parse a directory" do expects_parser_to_return_nil_for_directory(ps1) end it "should parse output from powershell" do expects_to_parse_powershell(ps1, data_in_txt, data) end end end describe "nothing parser" do it "uses the nothing parser when there is no other parser" do Facter::Util::Parser.parser_for("this.is.not.valid").results.should be_nil end end end facter-1.7.5/spec/unit/util/directory_loader_spec.rb0000644005276200011600000000537112276213017022446 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter/util/directory_loader' describe Facter::Util::DirectoryLoader do include PuppetlabsSpec::Files include FacterSpec::ConfigHelper subject { Facter::Util::DirectoryLoader.new(tmpdir('directory_loader')) } let(:collection) { Facter::Util::Collection.new(mock("internal loader"), subject) } it "should make the directory available" do subject.directory.should be_instance_of(String) end it "can be created with a given directory" do Facter::Util::DirectoryLoader.loader_for("ext").directory.should == "ext" end it "raises an error when the directory does not exist" do missing_dir = "missing" File.stubs(:directory?).with(missing_dir).returns(false) expect { Facter::Util::DirectoryLoader.loader_for(missing_dir) }.to raise_error Facter::Util::DirectoryLoader::NoSuchDirectoryError end it "should do nothing bad when dir doesn't exist" do fakepath = "/foobar/path" my_loader = Facter::Util::DirectoryLoader.new(fakepath) FileTest.exists?(my_loader.directory).should be_false expect { my_loader.load(collection) }.to_not raise_error end describe "when loading facts from disk" do it "should be able to load files from disk and set facts" do data = {"f1" => "one", "f2" => "two"} write_to_file("data.yaml", YAML.dump(data)) subject.load(collection) collection.value("f1").should == "one" collection.value("f2").should == "two" end it "should ignore files that begin with '.'" do not_to_be_used_collection = mock("collection should not be used") not_to_be_used_collection.expects(:add).never data = {"f1" => "one", "f2" => "two"} write_to_file(".data.yaml", YAML.dump(data)) subject.load(not_to_be_used_collection) end %w{bak orig}.each do |ext| it "should ignore files with an extension of '#{ext}'" do write_to_file("data" + ".#{ext}", "foo=bar") subject.load(collection) end end it "should warn when trying to parse unknown file types" do write_to_file("file.unknownfiletype", "stuff=bar") Facter.expects(:warn).with(regexp_matches(/file.unknownfiletype/)) subject.load(collection) end it "external facts should almost always precedence over all other facts" do Facter.add("f1", :value => "lower_weight_fact") { has_weight(Facter::Util::DirectoryLoader::EXTERNAL_FACT_WEIGHT - 1) } data = {"f1" => "external_fact"} write_to_file("data.yaml", YAML.dump(data)) subject.load(collection) collection.value("f1").should == "external_fact" end end def write_to_file(file_name, to_write) file = File.join(subject.directory, file_name) File.open(file, "w") { |f| f.print to_write} end end facter-1.7.5/spec/unit/util/ip/0000755005276200011600000000000012276213023016154 5ustar jenkinsjenkinsfacter-1.7.5/spec/unit/util/ip/windows_spec.rb0000644005276200011600000000517512276213017021220 0ustar jenkinsjenkins# encoding: UTF-8 require 'spec_helper' require 'facter/util/ip/windows' describe Facter::Util::IP::Windows do before :each do Facter.fact(:kernel).stubs(:value).returns('windows') end describe ".to_s" do let(:to_s) { described_class.to_s } it { to_s.should eq 'windows' } end describe ".convert_netmask_from_hex?" do let :convert_netmask_from_hex? do described_class.convert_netmask_from_hex? end it { convert_netmask_from_hex?.should be false } end describe ".bonding_master" do let(:bonding_master) { described_class.bonding_master('eth0') } pending("porting to Windows") do it { bonding_master.should be_nil } end end describe ".interfaces" do let(:name) { 'Local Area Connection' } let(:index) { 7 } let(:nic_config) { mock('nic_config', :Index => index) } let(:nic) { stub('nic', :NetConnectionId => name ) } let(:nic_empty_NetConnectionId) { stub('nic', :NetConnectionId => '' ) } let(:nic_nil_NetConnectionId) { stub('nic', :NetConnectionId => nil ) } let(:wmi_query) {"SELECT * FROM Win32_NetworkAdapter WHERE Index = #{index} AND NetEnabled = TRUE"} it "should return an array of only connected interfaces" do Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY). returns([nic_config]) Facter::Util::WMI.expects(:execquery).with(wmi_query). returns([nic]) described_class.interfaces.should == [name] end it "should not return an interface with an empty NetConnectionId" do Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY). returns([nic_config]) Facter::Util::WMI.expects(:execquery).with(wmi_query). returns([nic_empty_NetConnectionId]) described_class.interfaces.should == [] end it "should not return an interface with a nil NetConnectionId" do Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY). returns([nic_config]) Facter::Util::WMI.expects(:execquery).with(wmi_query). returns([nic_nil_NetConnectionId]) described_class.interfaces.should == [] end context "when the adapter configuration is enabled but the underlying adapter is not enabled" do it "should not return an interface" do Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY). returns([nic_config]) Facter::Util::WMI.expects(:execquery).with(wmi_query). returns([]) described_class.interfaces.should == [] end end end end facter-1.7.5/spec/unit/util/solaris_zones_spec.rb0000644005276200011600000000750412276213017022006 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/util/solaris_zones' describe Facter::Util::SolarisZones do let :zone_list do zone_list = <<-EOF 0:global:running:/::native:shared -:local:configured:/::native:shared -:zoneA:stopped:/::native:shared EOF end let :zone_list2 do zone_list = <<-EOF 0:global:running:/::native:shared -:local:configured:/::native:shared -:zoneB:stopped:/::native:shared -:zoneC:stopped:/::native:shared EOF end subject do described_class.new(:zoneadm_output => zone_list) end describe '.add_facts' do before :each do zones = described_class.new(:zoneadm_output => zone_list) zones.send(:parse!) zones.stubs(:refresh) described_class.stubs(:new).returns(zones) end it 'defines the zones fact' do described_class.add_facts Facter.fact(:zones).value.should == 3 end it 'defines a fact for each attribute of a zone' do described_class.add_facts [:id, :name, :status, :path, :uuid, :brand, :iptype].each do |attr| Facter.fact("zone_local_#{attr}".intern). should be_a_kind_of Facter::Util::Fact end end end describe '#refresh' do it 'executes the zoneadm_cmd' do Facter::Util::Resolution.expects(:exec).with(subject.zoneadm_cmd).returns(zone_list) subject.refresh end end describe 'multiple facts sharing a single model' do context 'when zones is resolved for the first time' do it 'counts the number of zones' do given_initial_zone_facts Facter.fact(:zones).value.should == 3 end it 'defines facts for zoneA' do given_initial_zone_facts Facter.fact(:zone_zoneA_id).value.should == '-' end it 'does not define facts for zoneB' do given_initial_zone_facts Facter.fact(:zone_zoneB_id).should be_nil end it 'uses a single read of the system information for all of the dynamically generated zone facts' do given_initial_zone_facts # <= single read happens here Facter::Util::Resolution.expects(:exec).never Facter.fact(:zone_zoneA_id).value Facter.fact(:zone_local_id).value end end context 'when all facts have been flushed after zones was resolved once' do it 'updates the number of zones' do given_initial_zone_facts when_facts_have_been_resolved_then_flushed Facter.fact(:zones).value.should == 4 end it 'stops resolving a value for a zone that no longer exists' do given_initial_zone_facts when_facts_have_been_resolved_then_flushed Facter.fact(:zone_zoneA_id).value.should be_nil Facter.fact(:zone_zoneA_status).value.should be_nil Facter.fact(:zone_zoneA_path).value.should be_nil end it 'defines facts for new zones' do given_initial_zone_facts when_facts_have_been_resolved_then_flushed Facter.fact(:zone_zoneB_id).should be_nil Facter.fact(:zones).value Facter.fact(:zone_zoneB_id).value.should be_a_kind_of String end it 'uses a single read of the system information for all of the dynamically generated zone facts' do given_initial_zone_facts when_facts_have_been_resolved_then_flushed Facter::Util::Resolution.expects(:exec).once.returns(zone_list2) Facter.fact(:zones).value Facter.fact(:zone_zoneA_id).value Facter.fact(:zone_local_id).value end end end def given_initial_zone_facts Facter::Util::Resolution.stubs(:exec). with(subject.zoneadm_cmd). returns(zone_list) described_class.add_facts end def when_facts_have_been_resolved_then_flushed Facter.fact(:zones).value Facter.fact(:zone_zoneA_id).value Facter.fact(:zone_local_id).value Facter::Util::Resolution.stubs(:exec).returns(zone_list2) Facter.flush end end facter-1.7.5/spec/unit/util/manufacturer_spec.rb0000755005276200011600000001514012276213017021606 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/manufacturer' describe Facter::Manufacturer do before :each do Facter.clear end it "should return the system DMI table" do Facter::Manufacturer.should respond_to(:get_dmi_table) end it "should return nil on non-supported operating systems" do Facter.stubs(:value).with(:kernel).returns("SomeThing") Facter::Manufacturer.get_dmi_table().should be_nil end it "should parse prtdiag output on a sunfire v120" do Facter::Util::Resolution.stubs(:exec).returns(my_fixture_read("solaris_sunfire_v120_prtdiag")) Facter::Manufacturer.prtdiag_sparc_find_system_info() Facter.value(:manufacturer).should == "Sun Microsystems" Facter.value(:productname).should == "Sun Fire V120 (UltraSPARC-IIe 648MHz)" end it "should parse prtdiag output on a t5220" do Facter::Util::Resolution.stubs(:exec).returns(my_fixture_read("solaris_t5220_prtdiag")) Facter::Manufacturer.prtdiag_sparc_find_system_info() Facter.value(:manufacturer).should == "Sun Microsystems" Facter.value(:productname).should == "SPARC Enterprise T5220" end it "should not set manufacturer if prtdiag output is nil" do # Stub kernel so we don't have windows fall through to its own mechanism Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter.fact(:hardwareisa).stubs(:value).returns("sparc") Facter::Util::Resolution.stubs(:exec).with(regexp_matches(/prtdiag/)).returns(nil) Facter::Manufacturer.prtdiag_sparc_find_system_info() Facter.value(:manufacturer).should_not == "Sun Microsystems" end it "should strip white space on dmi output with spaces" do dmidecode_output = my_fixture_read("linux_dmidecode_with_spaces") Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) Facter.fact(:kernel).stubs(:value).returns("Linux") query = { '[Ss]ystem [Ii]nformation' => [ { 'Product(?: Name)?:' => 'productname' } ] } Facter::Manufacturer.dmi_find_system_info(query) Facter.value(:productname).should == "MS-6754" end it "should handle output from smbios when run under sunos" do smbios_output = my_fixture_read("opensolaris_smbios") Facter::Manufacturer.expects(:get_dmi_table).returns(smbios_output) Facter.fact(:kernel).stubs(:value).returns("SunOS") query = { 'BIOS information' => [ { 'Release Date:' => 'reldate' } ] } Facter::Manufacturer.dmi_find_system_info(query) Facter.value(:reldate).should == "12/01/2006" end it "should not split on dmi keys containing the string Handle" do dmidecode_output = <<-eos Handle 0x1000, DMI type 16, 15 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: None Maximum Capacity: 4 GB Error Information Handle: Not Provided Number Of Devices: 123 Handle 0x001F DMI type 127, 4 bytes. End Of Table eos Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) Facter.fact(:kernel).stubs(:value).returns("Linux") query = { 'Physical Memory Array' => [ { 'Number Of Devices:' => 'ramslots'}]} Facter::Manufacturer.dmi_find_system_info(query) Facter.value(:ramslots).should == "123" end it "should match the key in the defined section and not the first one found" do dmidecode_output = <<-eos Handle 0x000C, DMI type 7, 19 bytes Cache Information Socket Designation: Internal L2 Cache Configuration: Enabled, Socketed, Level 2 Operational Mode: Write Back Location: Internal Installed Size: 4096 KB Maximum Size: 4096 KB Supported SRAM Types: Burst Installed SRAM Type: Burst Speed: Unknown Error Correction Type: Single-bit ECC System Type: Unified Associativity: 8-way Set-associative Handle 0x1000, DMI type 16, 15 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: None Maximum Capacity: 4 GB Error Information Handle: Not Provided Number Of Devices: 2 Handle 0x001F DMI type 127, 4 bytes. End Of Table eos Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) Facter.fact(:kernel).stubs(:value).returns("Linux") query = { 'Physical Memory Array' => [ { 'Location:' => 'ramlocation'}]} Facter::Manufacturer.dmi_find_system_info(query) Facter.value(:ramlocation).should == "System Board Or Motherboard" end it "should return an appropriate uuid on linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") dmidecode = my_fixture_read("intel_linux_dmidecode") Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode) query = { '[Ss]ystem [Ii]nformation' => [ { 'UUID:' => 'uuid' } ] } Facter::Manufacturer.dmi_find_system_info(query) Facter.value(:uuid).should == "60A98BB3-95B6-E111-AF74-4C72B9247D28" end def find_product_name(os) output_file = case os when "FreeBSD" then my_fixture("freebsd_dmidecode") when "SunOS" then my_fixture("opensolaris_smbios") end output = File.new(output_file).read() query = { '[Ss]ystem [Ii]nformation' => [ { 'Product(?: Name)?:' => "product_name_#{os}" } ] } Facter.fact(:kernel).stubs(:value).returns(os) Facter::Manufacturer.expects(:get_dmi_table).returns(output) Facter::Manufacturer.dmi_find_system_info(query) return Facter.value("product_name_#{os}") end it "should return the same result with smbios than with dmidecode" do find_product_name("FreeBSD").should_not == nil find_product_name("FreeBSD").should == find_product_name("SunOS") end it "should find information on Windows" do Facter.fact(:kernel).stubs(:value).returns("windows") require 'facter/util/wmi' bios = stubs 'bios' bios.stubs(:Manufacturer).returns("Phoenix Technologies LTD") bios.stubs(:Serialnumber).returns("56 4d 40 2b 4d 81 94 d6-e6 c5 56 a4 56 0c 9e 9f") product = stubs 'product' product.stubs(:Name).returns("VMware Virtual Platform") wmi = stubs 'wmi' wmi.stubs(:ExecQuery).with("select * from Win32_Bios").returns([bios]) wmi.stubs(:ExecQuery).with("select * from Win32_Bios").returns([bios]) wmi.stubs(:ExecQuery).with("select * from Win32_ComputerSystemProduct").returns([product]) Facter::Util::WMI.stubs(:connect).returns(wmi) Facter.value(:manufacturer).should == "Phoenix Technologies LTD" Facter.value(:serialnumber).should == "56 4d 40 2b 4d 81 94 d6-e6 c5 56 a4 56 0c 9e 9f" Facter.value(:productname).should == "VMware Virtual Platform" end end facter-1.7.5/spec/unit/util/collection_spec.rb0000755005276200011600000001577012276213017021256 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/collection' require 'facter/util/nothing_loader' describe Facter::Util::Collection do let(:external_loader) { Facter::Util::NothingLoader.new } let(:internal_loader) do load = Facter::Util::Loader.new load.stubs(:load).returns nil load.stubs(:load_all).returns nil load end let(:collection) { Facter::Util::Collection.new(internal_loader, external_loader) } it "should delegate its load_all method to its loader" do internal_loader.expects(:load_all) collection.load_all end describe "when adding facts" do it "should create a new fact if no fact with the same name already exists" do collection.add(:myname) collection.fact(:myname).name.should == :myname end it "should accept options" do collection.add(:myname, :ldapname => "whatever") { } end it "should set any appropriate options on the fact instances" do # Use a real fact instance, because we're using respond_to? fact = Facter::Util::Fact.new(:myname) collection.add(:myname, :ldapname => "testing") collection.fact(:myname).ldapname.should == "testing" end it "should set appropriate options on the resolution instance" do fact = Facter::Util::Fact.new(:myname) Facter::Util::Fact.expects(:new).with(:myname).returns fact resolve = Facter::Util::Resolution.new(:myname) {} fact.expects(:add).returns resolve collection.add(:myname, :timeout => "myval") {} end it "should not pass fact-specific options to resolutions" do fact = Facter::Util::Fact.new(:myname) Facter::Util::Fact.expects(:new).with(:myname).returns fact resolve = Facter::Util::Resolution.new(:myname) {} fact.expects(:add).returns resolve fact.expects(:ldapname=).with("foo") resolve.expects(:timeout=).with("myval") collection.add(:myname, :timeout => "myval", :ldapname => "foo") {} end it "should fail if invalid options are provided" do lambda { collection.add(:myname, :foo => :bar) }.should raise_error(ArgumentError) end describe "and a block is provided" do it "should use the block to add a resolution to the fact" do fact = mock 'fact' Facter::Util::Fact.expects(:new).returns fact fact.expects(:add) collection.add(:myname) {} end it "should discard resolutions that throw an exception when added" do lambda { collection.add('yay') do raise setcode { 'yay' } end }.should_not raise_error collection.value('yay').should be_nil end end end describe "when retrieving facts" do before do @fact = collection.add("YayNess") end it "should return the fact instance specified by the name" do collection.fact("YayNess").should equal(@fact) end it "should be case-insensitive" do collection.fact("yayness").should equal(@fact) end it "should treat strings and symbols equivalently" do collection.fact(:yayness).should equal(@fact) end it "should use its loader to try to load the fact if no fact can be found" do collection.internal_loader.expects(:load).with(:testing) collection.fact("testing") end it "should return nil if it cannot find or load the fact" do collection.internal_loader.expects(:load).with(:testing) collection.fact("testing").should be_nil end end describe "when returning a fact's value" do before do @fact = collection.add("YayNess", :value => "result") end it "should return the result of calling :value on the fact" do collection.value("YayNess").should == "result" end it "should be case-insensitive" do collection.value("yayness").should == "result" end it "should treat strings and symbols equivalently" do collection.value(:yayness).should == "result" end end it "should return the fact's value when the array index method is used" do collection.add("myfact", :value => "foo") collection["myfact"].should == "foo" end it "should have a method for flushing all facts" do fact = collection.add("YayNess") fact.expects(:flush) collection.flush end it "should have a method that returns all fact names" do collection.add(:one) collection.add(:two) collection.list.sort { |a,b| a.to_s <=> b.to_s }.should == [:one, :two] end describe "when returning a hash of values" do it "should return a hash of fact names and values with the fact names as strings" do collection.add(:one, :value => "me") collection.to_hash.should == {"one" => "me"} end it "should not include facts that did not return a value" do collection.add(:two, :value => nil) collection.to_hash.should_not be_include(:two) end end describe "when iterating over facts" do before do collection.add(:one, :value => "ONE") collection.add(:two, :value => "TWO") end it "should yield each fact name and the fact value" do facts = {} collection.each do |fact, value| facts[fact] = value end facts.should == {"one" => "ONE", "two" => "TWO"} end it "should convert the fact name to a string" do facts = {} collection.each do |fact, value| fact.should be_instance_of(String) end end it "should only yield facts that have values" do collection.add(:nil_fact, :value => nil) facts = {} collection.each do |fact, value| facts[fact] = value end facts.should_not be_include("nil_fact") end end describe "when no facts are loaded" do it "should warn when no facts were loaded" do Facter.expects(:warnonce).with("No facts loaded from #{internal_loader.search_path.join(File::PATH_SEPARATOR)}").once collection.fact("one") end end describe "external facts" do let(:external_loader) { SingleFactLoader.new(:test_fact, "fact value") } let(:collection) { Facter::Util::Collection.new(internal_loader, external_loader) } it "loads when a specific fact is requested" do collection.fact(:test_fact).value.should == "fact value" end it "loads when facts are listed" do collection.list.should == [:test_fact] end it "loads when all facts are iterated over" do facts = [] collection.each { |fact_name, fact_value| facts << [fact_name, fact_value] } facts.should == [["test_fact", "fact value"]] end it "are loaded only once" do external_loader.expects(:load).with(collection) collection.load_all collection.load_all end it "are reloaded after flushing" do external_loader.expects(:load).with(collection).twice collection.load_all collection.flush collection.load_all end end class SingleFactLoader def initialize(name, value) @name = name @value = value end def load(collection) collection.add(@name, :value => @value) end end end facter-1.7.5/spec/unit/util/wmi_spec.rb0000755005276200011600000000106612276213017017710 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/wmi' describe Facter::Util::WMI do let(:connection) { stub 'connection' } it "should default to localhost" do Facter::Util::WMI.wmi_resource_uri.should == "winmgmts:{impersonationLevel=impersonate}!//./root/cimv2" end it "should execute the query on the connection" do Facter::Util::WMI.stubs(:connect).returns(connection) connection.stubs(:execquery).with("select * from Win32_OperatingSystem") Facter::Util::WMI.execquery("select * from Win32_OperatingSystem") end end facter-1.7.5/spec/unit/util/uptime_spec.rb0000755005276200011600000002032312276213017020414 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/uptime' describe Facter::Util::Uptime do describe ".get_uptime_seconds_unix", :unless => Facter::Util::Config.is_windows? do describe "when /proc/uptime is available" do before do uptime_file = my_fixture("ubuntu_proc_uptime") Facter::Util::Uptime.stubs(:uptime_file).returns("\"#{uptime_file}\"") end it "should return the uptime in seconds as an integer" do Facter::Util::Uptime.get_uptime_seconds_unix.should == 5097686 end end describe "when /proc/uptime is not available" do before :each do @nonexistent_file = '/non/existent/file' File.exists?(@nonexistent_file).should == false Facter::Util::Uptime.stubs(:uptime_file).returns(@nonexistent_file) end it "should use 'sysctl -n kern.boottime' on OpenBSD" do sysctl_output_file = my_fixture('sysctl_kern_boottime_openbsd') # Dec 09 21:11:46 +0000 2011 Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"") Time.stubs(:now).returns Time.parse("Dec 09 22:11:46 +0000 2011") # one hour later Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 end it "should use 'sysctl -n kern.boottime' on Darwin, etc." do sysctl_output_file = my_fixture('sysctl_kern_boottime_darwin') # Oct 30 21:52:27 +0000 2011 Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"") Time.stubs(:now).returns Time.parse("Oct 30 22:52:27 +0000 2011") # one hour later Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 end describe "nor is 'sysctl kern.boottime'" do before :each do Facter::Util::Uptime.stubs(:uptime_proc_uptime).returns(false) Facter::Util::Uptime.stubs(:uptime_sysctl).returns(false) Facter.fact(:kernel).stubs(:value).returns('SunOS') end describe "should use 'uptime' command" do # Note about uptime variations. # Solaris (I have examined 5.6, 5.7, 5.8, 5.9, 5.10 & 5.11) and HP-UX (11.00, 11.11, 11.23, 11.31) have time # right justified at at 8 characters, and two spaces before 'up'. # Solaris differs from all other Unices (and Linux) in that the plural/singular case of minutes/hours/days are # written min(s)/hr(s)/day(s) instead of min/mins/hr/hrs etc., e.g. 1 min(s), 2 min(s) as opposed to # 1 min, 2 mins, etc. # AIX (4.3.3, 5.2, 5.3, 6.1) differs from other SysV Unices in that times are padded with a leading 0 in the # hour column where necessary, and have AM/PM in uppercase, and there are three spaces before 'up'. # Tru64 (4.0, 5.1) differs from other SysV Unices in that times are in 24 hour format, and there are no # leading spaces. # Linux (RHEL, uptime version 2.0.7) differs from the SysV Unices in that only minutes before the first hour # are written as 1 min, 2 min, 3 min etc. and after that full hours are rendered 1:00 or 21:00. Time of # day was written 5:37pm and right-justified at 8 characters, with 2 spaces before 'up'. A figure in # whole days was written as 3 days, 0 min. # By version 2.0.17 the time of day was rewritten in 24hr time with seconds, right-justified at 9 characters. # By version 3.2.7 one of the spaces before 'up' had been removed. test_cases = [ [' 4:42pm up 1 min(s), 0 users, load average: 0.95, 0.25, 0.09', 1*60], ['13:16 up 58 mins, 2 users, load average: 0.00, 0.02, 0.05', 58*60], ['13:18 up 1 hr, 1 user, load average: 0.58, 0.23, 0.14', 1*60*60 ], [' 10:14pm up 3 hr(s), 0 users, load average: 0.00, 0.00, 0.00', 3*60*60 ], ['14:18 up 2 hrs, 0 users, load average: 0.33, 0.27, 0.29', 2*60*60 ], [' 9:01pm up 1:47, 0 users, load average: 0.00, 0.00, 0.00', 1*60*60 + 47*60], ['13:19 up 1:01, 1 user, load average: 0.10, 0.26, 0.21', 1*60*60 + 1*60], ['10:49 up 22:31, 0 users, load average: 0.26, 0.34, 0.27', 22*60*60 + 31*60], ['12:18 up 1 day, 0 users, load average: 0.74, 0.20, 0.10', 1*24*60*60 ], [' 2:48pm up 1 day(s), 0 users, load average: 0.21, 0.20, 0.17', 1*24*60*60 ], ['12:18 up 2 days, 0 users, load average: 0.50, 0.27, 0.16', 2*24*60*60 ], [' 1:56pm up 25 day(s), 2 users, load average: 0.59, 0.56, 0.50', 25*24*60*60 ], [' 1:29pm up 485 days, 0 users, load average: 0.00, 0.01, 0.01', 485*24*60*60 ], [' 18:11:24 up 69 days, 0 min, 0 users, load average: 0.00, 0.00, 0.00', 69*24*60*60 ], ['12:19 up 1 day, 1 min, 0 users, load average: 0.07, 0.16, 0.13', 1*24*60*60 + 1*60], [' 3:23pm up 25 day(s), 27 min(s), 2 users, load average: 0.49, 0.45, 0.46', 25*24*60*60 + 27*60], [' 02:42PM up 1 day, 39 mins, 0 users, load average: 1.49, 1.74, 1.80', 1*24*60*60 + 39*60], [' 18:13:13 up 245 days, 44 min, 1 user, load average: 0.00, 0.00, 0.00', 245*24*60*60 + 44*60], [' 6:09pm up 350 days, 2 min, 1 user, load average: 0.02, 0.03, 0.00', 350*24*60*60 + 2*60], [' 1:07pm up 174 day(s), 16 hr(s), 0 users, load average: 0.05, 0.04, 0.03', 174*24*60*60 + 16*60*60 ], [' 02:34PM up 621 days, 18 hrs, 0 users, load average: 2.67, 2.52, 2.56', 621*24*60*60 + 18*60*60 ], [' 3:30am up 108 days, 1 hr, 31 users, load average: 0.39, 0.40, 0.41', 108*24*60*60 + 1*60*60 ], ['13:18 up 1 day, 1 hr, 0 users, load average: 0.78, 0.33, 0.18', 1*24*60*60 + 1*60*60 ], ['14:18 up 1 day, 2 hrs, 0 users, load average: 1.17, 0.48, 0.41', 1*24*60*60 + 2*60*60 ], ['15:56 up 152 days, 17 hrs, 0 users, load average: 0.01, 0.06, 0.07', 152*24*60*60 + 17*60*60 ], [' 5:37pm up 25 days, 21:00, 0 users, load average: 0.01, 0.02, 0.00', 25*24*60*60 + 21*60*60 ], [' 8:59pm up 94 day(s), 3:17, 46 users, load average: 0.66, 0.67, 0.70', 94*24*60*60 + 3*60*60 + 17*60], [' 3:01pm up 4496 day(s), 21:19, 32 users, load average: 0.61, 0.62, 0.62', 4496*24*60*60 + 21*60*60 + 19*60], [' 02:42PM up 41 days, 2:38, 0 users, load average: 0.38, 0.70, 0.55', 41*24*60*60 + 2*60*60 + 38*60], [' 18:13:29 up 25 days, 21:36, 0 users, load average: 0.00, 0.00, 0.00', 25*24*60*60 + 21*60*60 + 36*60], [' 13:36:05 up 118 days, 1:15, 1 user, load average: 0.00, 0.00, 0.00', 118*24*60*60 + 1*60*60 + 15*60] ] test_cases.each do |uptime, expected| it "should return #{expected} for #{uptime}" do Facter::Util::Resolution.stubs(:exec).with('uptime 2>/dev/null').returns(uptime) Facter.fact(:uptime_seconds).value.should == expected end end describe "nor is 'uptime' command" do before :each do Facter::Util::Uptime.stubs(:uptime_executable_cmd).returns("cat \"#{@nonexistent_file}\"") end it "should return nil" do Facter::Util::Uptime.get_uptime_seconds_unix.should == nil end end end end end end describe ".get_uptime_seconds_win", :if => Facter::Util::Config.is_windows? do it "should return a postive value" do Facter::Util::Uptime.get_uptime_seconds_win.should > 0 end end end facter-1.7.5/spec/unit/util/macaddress_spec.rb0000755005276200011600000001272012276213017021221 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/macaddress' describe "standardized MAC address" do it "should have zeroes added if missing" do Facter::Util::Macaddress::standardize("0:ab:cd:e:12:3").should == "00:ab:cd:0e:12:03" end it "should be identical if each octet already has two digits" do Facter::Util::Macaddress::standardize("00:ab:cd:0e:12:03").should == "00:ab:cd:0e:12:03" end it "should be nil if input is nil" do proc { result = Facter::Util::Macaddress.standardize(nil) }.should_not raise_error Facter::Util::Macaddress.standardize(nil).should be_nil end end describe "Darwin", :unless => Facter::Util::Config.is_windows? do test_cases = [ # version, iface, real macaddress, fallback macaddress ["9.8.0", 'en0', "00:17:f2:06:e4:2e", "00:17:f2:06:e4:2e"], ["10.3.0", 'en0', "00:17:f2:06:e3:c2", "00:17:f2:06:e3:c2"], ["10.6.4", 'en1', "58:b0:35:7f:25:b3", "58:b0:35:fa:08:b1"], ["10.6.6_dualstack", "en1", "00:25:00:48:19:ef", "00:25:4b:ca:56:72"] ] test_cases.each do |version, default_iface, macaddress, fallback_macaddress| netstat_file = fixtures("netstat", "darwin_#{version.tr('.', '_')}") ifconfig_file_no_iface = fixtures("ifconfig", "darwin_#{version.tr('.', '_')}") ifconfig_file = "#{ifconfig_file_no_iface}_#{default_iface}" describe "version #{version}" do describe Facter::Util::Macaddress::Darwin do describe ".default_interface" do describe "when netstat has a default interface" do before do Facter::Util::Macaddress::Darwin.stubs(:netstat_command).returns("cat \"#{netstat_file}\"") end it "should return the default interface name" do Facter::Util::Macaddress::Darwin.default_interface.should == default_iface end end end describe ".macaddress" do describe "when netstat has a default interface" do before do Facter.stubs(:warn) Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns('') Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat \"#{ifconfig_file}\"") end it "should return the macaddress of the default interface" do Facter::Util::Macaddress::Darwin.macaddress.should == macaddress end end describe "when netstat does not have a default interface" do before do Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns("") Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat \"#{ifconfig_file_no_iface}\"") end it "should warn about the lack of default" do Facter.expects(:warn).with("Could not find a default route. Using first non-loopback interface") Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns('') Facter::Util::Macaddress::Darwin.macaddress end it "should return the macaddress of the first non-loopback interface" do Facter::Util::Macaddress::Darwin.macaddress.should == fallback_macaddress end end end end end end end describe "The macaddress fact" do context "on Windows" do require 'facter/util/wmi' require 'facter/util/registry' require 'facter_spec/windows_network' include FacterSpec::WindowsNetwork before :each do Facter.fact(:kernel).stubs(:value).returns(:windows) Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings) end describe "when you have no active network adapter" do it "should return nil if there are no active (or any) network adapters" do Facter::Util::WMI.expects(:execquery).returns([]) Facter.value(:macaddress).should == nil end end describe "when you have one network adapter" do it "should return properly" do nic = given_a_valid_windows_nic_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns([nic]) Facter.value(:macaddress).should == macAddress0 end end describe "when you have more than one network adapter" do it "should return the macaddress of the adapter with the lowest IP connection metric (best connection)" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 nics[:nic1].expects(:IPConnectionMetric).returns(5) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:macaddress).should == macAddress1 end context "when the IP connection metric is the same" do it "should return the macaddress of the adapter with the lowest binding order" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:macaddress).should == macAddress0 end it "should return the macaddress of the adapter with the lowest MACAddress when multiple adapters have the same IP connection metric when the lowest MACAddress is not first" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter::Util::Registry.stubs(:hklm_read).returns(["\\Device\\#{settingId1}", "\\Device\\#{settingId0}" ]) Facter.value(:macaddress).should == macAddress1 end end end end end facter-1.7.5/spec/unit/util/xendomains_spec.rb0000755005276200011600000000130112276213017021251 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/xendomains' describe Facter::Util::Xendomains do describe ".get_domains" do it "should return a list of running Xen Domains on Xen0" do xen0_domains = my_fixture_read("xendomains") Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains) Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} end describe "when xm list isn't executable" do it "should be nil" do Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(nil) Facter::Util::Xendomains.get_domains.should == nil end end end end facter-1.7.5/spec/unit/util/vlans_spec.rb0000755005276200011600000000055312276213017020237 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/vlans' describe Facter::Util::Vlans do it "should return a list of vlans on Linux" do linux_vlanconfig = my_fixture_read("linux_vlan_config") Facter::Util::Vlans.stubs(:get_vlan_config).returns(linux_vlanconfig) Facter::Util::Vlans.get_vlans().should == %{400,300,200,100} end end facter-1.7.5/spec/unit/util/resolution_spec.rb0000755005276200011600000006620112276213017021321 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/resolution' describe Facter::Util::Resolution do include FacterSpec::ConfigHelper it "should require a name" do lambda { Facter::Util::Resolution.new }.should raise_error(ArgumentError) end it "should have a name" do Facter::Util::Resolution.new("yay").name.should == "yay" end it "should be able to set the value" do resolve = Facter::Util::Resolution.new("yay") resolve.value = "foo" resolve.value.should == "foo" end it "should have a method for setting the weight" do Facter::Util::Resolution.new("yay").should respond_to(:has_weight) end it "should have a method for setting the code" do Facter::Util::Resolution.new("yay").should respond_to(:setcode) end it "should support a timeout value" do Facter::Util::Resolution.new("yay").should respond_to(:timeout=) end it "should default to a timeout of 0 seconds" do Facter::Util::Resolution.new("yay").limit.should == 0 end it "should default to nil for code" do Facter::Util::Resolution.new("yay").code.should be_nil end it "should default to nil for interpreter" do Facter.expects(:warnonce).with("The 'Facter::Util::Resolution.interpreter' method is deprecated and will be removed in a future version.") Facter::Util::Resolution.new("yay").interpreter.should be_nil end it "should provide a 'limit' method that returns the timeout" do res = Facter::Util::Resolution.new("yay") res.timeout = "testing" res.limit.should == "testing" end describe "when overriding environment variables" do it "should execute the caller's block with the specified env vars" do test_env = { "LANG" => "C", "FOO" => "BAR" } Facter::Util::Resolution.with_env test_env do test_env.keys.each do |key| ENV[key].should == test_env[key] end end end it "should restore pre-existing environment variables to their previous values" do orig_env = {} new_env = {} # an arbitrary sentinel value to use to temporarily set the environment vars to sentinel_value = "Abracadabra" # grab some values from the existing ENV (arbitrarily choosing 3 here) ENV.keys.first(3).each do |key| # save the original values so that we can test against them later orig_env[key] = ENV[key] # create bogus temp values for the chosen keys new_env[key] = sentinel_value end # verify that, during the 'with_env', the new values are used Facter::Util::Resolution.with_env new_env do orig_env.keys.each do |key| ENV[key].should == new_env[key] end end # verify that, after the 'with_env', the old values are restored orig_env.keys.each do |key| ENV[key].should == orig_env[key] end end it "should not be affected by a 'return' statement in the yield block" do @sentinel_var = :resolution_test_foo.to_s # the intent of this test case is to test a yield block that contains a return statement. However, it's illegal # to use a return statement outside of a method, so we need to create one here to give scope to the 'return' def handy_method() ENV[@sentinel_var] = "foo" new_env = { @sentinel_var => "bar" } Facter::Util::Resolution.with_env new_env do ENV[@sentinel_var].should == "bar" return end end handy_method() ENV[@sentinel_var].should == "foo" end end describe "when setting the code" do before do Facter.stubs(:warnonce) @resolve = Facter::Util::Resolution.new("yay") end it "should deprecate the interpreter argument to 'setcode'" do Facter.expects(:warnonce).with("The interpreter parameter to 'setcode' is deprecated and will be removed in a future version.") @resolve.setcode "foo", "bar" @resolve.interpreter.should == "bar" end it "should deprecate the interpreter= method" do Facter.expects(:warnonce).with("The 'Facter::Util::Resolution.interpreter=' method is deprecated and will be removed in a future version.") @resolve.interpreter = "baz" @resolve.interpreter.should == "baz" end it "should deprecate the interpreter method" do Facter.expects(:warnonce).with("The 'Facter::Util::Resolution.interpreter' method is deprecated and will be removed in a future version.") @resolve.interpreter end it "should set the code to any provided string" do @resolve.setcode "foo" @resolve.code.should == "foo" end it "should set the code to any provided block" do block = lambda { } @resolve.setcode(&block) @resolve.code.should equal(block) end it "should prefer the string over a block" do @resolve.setcode("foo") { } @resolve.code.should == "foo" end it "should fail if neither a string nor block has been provided" do lambda { @resolve.setcode }.should raise_error(ArgumentError) end end describe 'callbacks when flushing facts' do class FlushFakeError < StandardError; end subject do Facter::Util::Resolution.new("jeff") end context '#on_flush' do it 'accepts a block with on_flush' do subject.on_flush() { raise NotImplementedError } end end context '#flush' do it 'calls the block passed to on_flush' do subject.on_flush() { raise FlushFakeError } expect { subject.flush }.to raise_error FlushFakeError end end end it "should be able to return a value" do Facter::Util::Resolution.new("yay").should respond_to(:value) end describe "when returning the value" do before do @resolve = Facter::Util::Resolution.new("yay") end it "should return any value that has been provided" do @resolve.value = "foo" @resolve.value.should == "foo" end describe "and setcode has not been called" do it "should return nil" do Facter::Util::Resolution.expects(:exec).with(nil, nil).never @resolve.value.should be_nil end end describe "and the code is a string" do describe "on windows" do before do given_a_configuration_of(:is_windows => true) end it "should return the result of executing the code" do @resolve.setcode "/bin/foo" Facter::Util::Resolution.expects(:exec).once.with("/bin/foo").returns "yup" @resolve.value.should == "yup" end it "should return nil if the value is an empty string" do @resolve.setcode "/bin/foo" Facter::Util::Resolution.expects(:exec).once.returns "" @resolve.value.should be_nil end end describe "on non-windows systems" do before do given_a_configuration_of(:is_windows => false) end it "should return the result of executing the code" do @resolve.setcode "/bin/foo" Facter::Util::Resolution.expects(:exec).once.with("/bin/foo").returns "yup" @resolve.value.should == "yup" end it "should return nil if the value is an empty string" do @resolve.setcode "/bin/foo" Facter::Util::Resolution.expects(:exec).once.returns "" @resolve.value.should be_nil end end end describe "and the code is a block" do it "should warn but not fail if the code fails" do @resolve.setcode { raise "feh" } Facter.expects(:warn) @resolve.value.should be_nil end it "should return the value returned by the block" do @resolve.setcode { "yayness" } @resolve.value.should == "yayness" end it "should return nil if the value is an empty string" do @resolve.setcode { "" } @resolve.value.should be_nil end it "should return nil if the value is an empty block" do @resolve.setcode { "" } @resolve.value.should be_nil end it "should use its limit method to determine the timeout, to avoid conflict when a 'timeout' method exists for some other reason" do @resolve.expects(:timeout).never @resolve.expects(:limit).returns "foo" Timeout.expects(:timeout).with("foo") @resolve.setcode { sleep 2; "raise This is a test"} @resolve.value end it "should timeout after the provided timeout" do Facter.expects(:warn) @resolve.timeout = 0.1 @resolve.setcode { sleep 2; raise "This is a test" } Thread.expects(:new).yields @resolve.value.should be_nil end it "should waitall to avoid zombies if the timeout is exceeded" do Facter.stubs(:warn) @resolve.timeout = 0.1 @resolve.setcode { sleep 2; raise "This is a test" } Thread.expects(:new).yields Process.expects(:waitall) @resolve.value end end end it "should return its value when converted to a string" do @resolve = Facter::Util::Resolution.new("yay") @resolve.expects(:value).returns "myval" @resolve.to_s.should == "myval" end it "should allow the adding of confines" do Facter::Util::Resolution.new("yay").should respond_to(:confine) end it "should provide a method for returning the number of confines" do @resolve = Facter::Util::Resolution.new("yay") @resolve.confine "one" => "foo", "two" => "fee" @resolve.weight.should == 2 end it "should return 0 confines when no confines have been added" do Facter::Util::Resolution.new("yay").weight.should == 0 end it "should provide a way to set the weight" do @resolve = Facter::Util::Resolution.new("yay") @resolve.has_weight(45) @resolve.weight.should == 45 end it "should allow the weight to override the number of confines" do @resolve = Facter::Util::Resolution.new("yay") @resolve.confine "one" => "foo", "two" => "fee" @resolve.weight.should == 2 @resolve.has_weight(45) @resolve.weight.should == 45 end it "should have a method for determining if it is suitable" do Facter::Util::Resolution.new("yay").should respond_to(:suitable?) end describe "when adding confines" do before do @resolve = Facter::Util::Resolution.new("yay") end it "should accept a hash of fact names and values" do lambda { @resolve.confine :one => "two" }.should_not raise_error end it "should create a Util::Confine instance for every argument in the provided hash" do Facter::Util::Confine.expects(:new).with("one", "foo") Facter::Util::Confine.expects(:new).with("two", "fee") @resolve.confine "one" => "foo", "two" => "fee" end end describe "when determining suitability" do before do @resolve = Facter::Util::Resolution.new("yay") end it "should always be suitable if no confines have been added" do @resolve.should be_suitable end it "should be unsuitable if any provided confines return false" do confine1 = mock 'confine1', :true? => true confine2 = mock 'confine2', :true? => false Facter::Util::Confine.expects(:new).times(2).returns(confine1).then.returns(confine2) @resolve.confine :one => :two, :three => :four @resolve.should_not be_suitable end it "should be suitable if all provided confines return true" do confine1 = mock 'confine1', :true? => true confine2 = mock 'confine2', :true? => true Facter::Util::Confine.expects(:new).times(2).returns(confine1).then.returns(confine2) @resolve.confine :one => :two, :three => :four @resolve.should be_suitable end end it "should have a class method for executing code" do Facter::Util::Resolution.should respond_to(:exec) end # taken from puppet: spec/unit/util_spec.rb describe "#absolute_path?" do context "when run on unix", :as_platform => :posix do %w[/ /foo /foo/../bar //foo //Server/Foo/Bar //?/C:/foo/bar /\Server/Foo /foo//bar/baz].each do |path| it "should return true for #{path}" do Facter::Util::Resolution.should be_absolute_path(path) end end %w[. ./foo \foo C:/foo \\Server\Foo\Bar \\?\C:\foo\bar \/?/foo\bar \/Server/foo foo//bar/baz].each do |path| it "should return false for #{path}" do Facter::Util::Resolution.should_not be_absolute_path(path) end end end context "when run on windows", :as_platform => :windows do %w[C:/foo C:\foo \\\\Server\Foo\Bar \\\\?\C:\foo\bar //Server/Foo/Bar //?/C:/foo/bar /\?\C:/foo\bar \/Server\Foo/Bar c:/foo//bar//baz].each do |path| it "should return true for #{path}" do Facter::Util::Resolution.should be_absolute_path(path) end end %w[/ . ./foo \foo /foo /foo/../bar //foo C:foo/bar foo//bar/baz].each do |path| it "should return false for #{path}" do Facter::Util::Resolution.should_not be_absolute_path(path) end end end end describe "#search_paths" do context "on windows", :as_platform => :windows do it "should use the PATH environment variable to determine locations" do ENV.expects(:[]).with('PATH').returns 'C:\Windows;C:\Windows\System32' Facter::Util::Resolution.search_paths.should == %w{C:\Windows C:\Windows\System32} end end context "on posix", :as_platform => :posix do it "should use the PATH environment variable plus /sbin and /usr/sbin on unix" do ENV.expects(:[]).with('PATH').returns "/bin:/usr/bin" Facter::Util::Resolution.search_paths.should == %w{/bin /usr/bin /sbin /usr/sbin} end end end describe "#which" do context "when run on posix", :as_platform => :posix do before :each do Facter::Util::Resolution.stubs(:search_paths).returns [ '/bin', '/sbin', '/usr/sbin'] end context "and provided with an absolute path" do it "should return the binary if executable" do File.expects(:executable?).with('/opt/foo').returns true Facter::Util::Resolution.which('/opt/foo').should == '/opt/foo' end it "should return nil if the binary is not executable" do File.expects(:executable?).with('/opt/foo').returns false Facter::Util::Resolution.which('/opt/foo').should be_nil end end context "and not provided with an absolute path" do it "should return the absolute path if found" do File.expects(:executable?).with('/bin/foo').returns false File.expects(:executable?).with('/sbin/foo').returns true File.expects(:executable?).with('/usr/sbin/foo').never Facter::Util::Resolution.which('foo').should == '/sbin/foo' end it "should return nil if not found" do File.expects(:executable?).with('/bin/foo').returns false File.expects(:executable?).with('/sbin/foo').returns false File.expects(:executable?).with('/usr/sbin/foo').returns false Facter::Util::Resolution.which('foo').should be_nil end end end context "when run on windows", :as_platform => :windows do before :each do Facter::Util::Resolution.stubs(:search_paths).returns ['C:\Windows\system32', 'C:\Windows', 'C:\Windows\System32\Wbem' ] ENV.stubs(:[]).with('PATHEXT').returns nil end context "and provided with an absolute path" do it "should return the binary if executable" do File.expects(:executable?).with('C:\Tools\foo.exe').returns true File.expects(:executable?).with('\\\\remote\dir\foo.exe').returns true Facter::Util::Resolution.which('C:\Tools\foo.exe').should == 'C:\Tools\foo.exe' Facter::Util::Resolution.which('\\\\remote\dir\foo.exe').should == '\\\\remote\dir\foo.exe' end it "should return the binary with added extension if executable" do ['.COM', '.BAT', '.CMD', '' ].each do |ext| File.stubs(:executable?).with('C:\Windows\system32\netsh'+ext).returns false end File.expects(:executable?).with('C:\Windows\system32\netsh.EXE').returns true Facter.expects(:warnonce).with('Using Facter::Util::Resolution.which with an absolute path like C:\\Windows\\system32\\netsh but no fileextension is deprecated. Please add the correct extension (.EXE)') Facter::Util::Resolution.which('C:\Windows\system32\netsh').should == 'C:\Windows\system32\netsh.EXE' end it "should return nil if the binary is not executable" do File.expects(:executable?).with('C:\Tools\foo.exe').returns false File.expects(:executable?).with('\\\\remote\dir\foo.exe').returns false Facter::Util::Resolution.which('C:\Tools\foo.exe').should be_nil Facter::Util::Resolution.which('\\\\remote\dir\foo.exe').should be_nil end end context "and not provided with an absolute path" do it "should return the absolute path if found" do File.expects(:executable?).with('C:\Windows\system32\foo.exe').returns false File.expects(:executable?).with('C:\Windows\foo.exe').returns true File.expects(:executable?).with('C:\Windows\System32\Wbem\foo.exe').never Facter::Util::Resolution.which('foo.exe').should == 'C:\Windows\foo.exe' end it "should return the absolute path with file extension if found" do ['.COM', '.EXE', '.BAT', '.CMD', '' ].each do |ext| File.stubs(:executable?).with('C:\Windows\system32\foo'+ext).returns false File.stubs(:executable?).with('C:\Windows\System32\Wbem\foo'+ext).returns false end ['.COM', '.BAT', '.CMD', '' ].each do |ext| File.stubs(:executable?).with('C:\Windows\foo'+ext).returns false end File.stubs(:executable?).with('C:\Windows\foo.EXE').returns true Facter::Util::Resolution.which('foo').should == 'C:\Windows\foo.EXE' end it "should return nil if not found" do File.expects(:executable?).with('C:\Windows\system32\foo.exe').returns false File.expects(:executable?).with('C:\Windows\foo.exe').returns false File.expects(:executable?).with('C:\Windows\System32\Wbem\foo.exe').returns false Facter::Util::Resolution.which('foo.exe').should be_nil end end end describe "#expand_command" do context "on windows", :as_platform => :windows do it "should expand binary" do Facter::Util::Resolution.expects(:which).with('cmd').returns 'C:\Windows\System32\cmd' Facter::Util::Resolution.expand_command( 'cmd /c echo foo > C:\bar' ).should == 'C:\Windows\System32\cmd /c echo foo > C:\bar' end it "should expand double quoted binary" do Facter::Util::Resolution.expects(:which).with('my foo').returns 'C:\My Tools\my foo.exe' Facter::Util::Resolution.expand_command('"my foo" /a /b').should == '"C:\My Tools\my foo.exe" /a /b' end it "should not expand single quoted binary" do Facter::Util::Resolution.expects(:which).with('\'C:\My').returns nil Facter::Util::Resolution.expand_command('\'C:\My Tools\foo.exe\' /a /b').should be_nil end it "should quote expanded binary if found in path with spaces" do Facter::Util::Resolution.expects(:which).with('foo').returns 'C:\My Tools\foo.exe' Facter::Util::Resolution.expand_command('foo /a /b').should == '"C:\My Tools\foo.exe" /a /b' end it "should return nil if not found" do Facter::Util::Resolution.expects(:which).with('foo').returns nil Facter::Util::Resolution.expand_command('foo /a | stuff >> /dev/null').should be_nil end end context "on unix", :as_platform => :posix do it "should expand binary" do Facter::Util::Resolution.expects(:which).with('foo').returns '/bin/foo' Facter::Util::Resolution.expand_command('foo -a | stuff >> /dev/null').should == '/bin/foo -a | stuff >> /dev/null' end it "should expand double quoted binary" do Facter::Util::Resolution.expects(:which).with('/tmp/my foo').returns '/tmp/my foo' Facter::Util::Resolution.expand_command(%q{"/tmp/my foo" bar}).should == %q{"/tmp/my foo" bar} end it "should expand single quoted binary" do Facter::Util::Resolution.expects(:which).with('my foo').returns '/home/bob/my path/my foo' Facter::Util::Resolution.expand_command(%q{'my foo' -a}).should == %q{'/home/bob/my path/my foo' -a} end it "should quote expanded binary if found in path with spaces" do Facter::Util::Resolution.expects(:which).with('foo.sh').returns '/home/bob/my tools/foo.sh' Facter::Util::Resolution.expand_command('foo.sh /a /b').should == %q{'/home/bob/my tools/foo.sh' /a /b} end it "should return nil if not found" do Facter::Util::Resolution.expects(:which).with('foo').returns nil Facter::Util::Resolution.expand_command('foo -a | stuff >> /dev/null').should be_nil end end end end # It's not possible, AFAICT, to mock %x{}, so I can't really test this bit. describe "when executing code" do # set up some command strings, making sure we get the right version for both unix and windows echo_command = Facter::Util::Config.is_windows? ? 'cmd.exe /c "echo foo"' : 'echo foo' echo_env_var_command = Facter::Util::Config.is_windows? ? 'cmd.exe /c "echo %%%s%%"' : 'echo $%s' it "should deprecate the interpreter parameter" do Facter.expects(:warnonce).with("The interpreter parameter to 'exec' is deprecated and will be removed in a future version.") Facter::Util::Resolution.exec("/something", "/bin/perl") end # execute a simple echo command it "should execute the binary" do Facter::Util::Resolution.exec(echo_command).should == "foo" end it "should override the LANG environment variable" do Facter::Util::Resolution.exec(echo_env_var_command % 'LANG').should == "C" end it "should respect other overridden environment variables" do Facter::Util::Resolution.with_env( {"FOO" => "foo"} ) do Facter::Util::Resolution.exec(echo_env_var_command % 'FOO').should == "foo" end end it "should restore overridden LANG environment variable after execution" do # we're going to call with_env in a nested fashion, to make sure that the environment gets restored properly # at each level Facter::Util::Resolution.with_env( {"LANG" => "foo"} ) do # Resolution.exec always overrides 'LANG' for its own execution scope Facter::Util::Resolution.exec(echo_env_var_command % 'LANG').should == "C" # But after 'exec' completes, we should see our value restored ENV['LANG'].should == "foo" # Now we'll do a nested call to with_env Facter::Util::Resolution.with_env( {"LANG" => "bar"} ) do # During 'exec' it should still be 'C' Facter::Util::Resolution.exec(echo_env_var_command % 'LANG').should == "C" # After exec it should be restored to our current value for this level of the nesting... ENV['LANG'].should == "bar" end # Now we've dropped out of one level of nesting, ENV['LANG'].should == "foo" # Call exec one more time just for kicks Facter::Util::Resolution.exec(echo_env_var_command % 'LANG').should == "C" # One last check at our current nesting level. ENV['LANG'].should == "foo" end end context "when run on unix", :as_platform => :posix do context "binary is present" do it "should run the command if path to binary is absolute" do Facter::Util::Resolution.expects(:expand_command).with('/usr/bin/uname -m').returns('/usr/bin/uname -m') Facter::Util::Resolution.expects(:`).with('/usr/bin/uname -m').returns 'x86_64' Facter::Util::Resolution.exec('/usr/bin/uname -m').should == 'x86_64' end it "should run the expanded command if path to binary not absolute" do Facter::Util::Resolution.expects(:expand_command).with('uname -m').returns('/usr/bin/uname -m') Facter::Util::Resolution.expects(:`).with('/usr/bin/uname -m').returns 'x86_64' Facter::Util::Resolution.exec('uname -m').should == 'x86_64' end end context "binary is not present" do it "should not run the command if path to binary is absolute" do Facter::Util::Resolution.expects(:expand_command).with('/usr/bin/uname -m').returns nil Facter::Util::Resolution.expects(:`).with('/usr/bin/uname -m').never Facter::Util::Resolution.exec('/usr/bin/uname -m').should be_nil end it "should not run the command if path to binary is not absolute" do Facter::Util::Resolution.expects(:expand_command).with('uname -m').returns nil Facter::Util::Resolution.expects(:`).with('uname -m').never Facter::Util::Resolution.exec('uname -m').should be_nil end end end context "when run on windows", :as_platform => :windows do context "binary is present" do it "should run the command if path to binary is absolute" do Facter::Util::Resolution.expects(:expand_command).with(%q{C:\Windows\foo.exe /a /b}).returns(%q{C:\Windows\foo.exe /a /b}) Facter::Util::Resolution.expects(:`).with(%q{C:\Windows\foo.exe /a /b}).returns 'bar' Facter::Util::Resolution.exec(%q{C:\Windows\foo.exe /a /b}).should == 'bar' end it "should run the expanded command if path to binary not absolute" do Facter::Util::Resolution.expects(:expand_command).with(%q{foo.exe /a /b}).returns(%q{C:\Windows\foo.exe /a /b}) Facter::Util::Resolution.expects(:`).with(%q{C:\Windows\foo.exe /a /b}).returns 'bar' Facter::Util::Resolution.exec(%q{foo.exe /a /b}).should == 'bar' end end context "binary is not present" do it "should not run the command if path to binary is absolute" do Facter::Util::Resolution.expects(:expand_command).with(%q{C:\Windows\foo.exe /a /b}).returns nil Facter::Util::Resolution.expects(:`).with(%q{C:\Windows\foo.exe /a /b}).never Facter::Util::Resolution.exec(%q{C:\Windows\foo.exe /a /b}).should be_nil end it "should try to run the command and return output of a shell-builtin" do Facter::Util::Resolution.expects(:expand_command).with(%q{echo foo}).returns nil Facter::Util::Resolution.expects(:`).with(%q{echo foo}).returns 'foo' Facter.expects(:warnonce).with 'Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass "cmd /c your_builtin" as a command (command responsible for this message was "echo foo")' Facter::Util::Resolution.exec(%q{echo foo}).should == 'foo' end it "should try to run the command and return nil if not shell-builtin" do Facter::Util::Resolution.expects(:expand_command).with(%q{echo foo}).returns nil Facter::Util::Resolution.stubs(:`).with(%q{echo foo}).raises Errno::ENOENT, 'some_error_message' Facter.expects(:warnonce).never Facter::Util::Resolution.exec(%q{echo foo}).should be_nil end end end end end facter-1.7.5/spec/unit/util/processor_spec.rb0000755005276200011600000001000412276213017021123 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/processor' require 'facter_spec/cpuinfo' describe Facter::Util::Processor do describe "on linux" do include FacterSpec::Cpuinfo before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exists?).with("/proc/cpuinfo").returns(true) end describe "with architecture amd64" do before :each do Facter.fact(:architecture).stubs(:value).returns("amd64") end it "should get the processor description from the amd64solo fixture" do File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64solo")) Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" end it "should get the processor descriptions from the amd64dual fixture" do File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64dual")) Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" end it "should get the processor descriptions from the amd64tri fixture" do File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64tri")) Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" Facter::Util::Processor.enum_cpuinfo[2].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz" end it "should get the processor descriptions from the amd64quad fixture" do File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64quad")) Facter::Util::Processor.enum_cpuinfo[0].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE" Facter::Util::Processor.enum_cpuinfo[1].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE" Facter::Util::Processor.enum_cpuinfo[2].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE" Facter::Util::Processor.enum_cpuinfo[3].should == "Quad-Core AMD Opteron(tm) Processor 2374 HE" end end describe "with architecture x86" do before :each do Facter.fact(:architecture).stubs(:value).returns("x86") File.stubs(:readlines).with("/proc/cpuinfo").returns(my_fixture_read("x86-pentium2").lines) end subject { Facter::Util::Processor.enum_cpuinfo } it "should have the correct processor titles" do subject[0].should == "Pentium II (Deschutes)" subject[1].should == "Pentium II (Deschutes)" end end end describe "on Solaris" do before :each do Facter.fact(:kernel).stubs(:value).returns("SunOS") end it "should get the processor description on Solaris (x86)" do Facter.fact(:architecture).stubs(:value).returns("i86pc") Facter::Util::Resolution.stubs(:exec).with("/usr/bin/kstat cpu_info").returns(my_fixture_read("solaris-i86pc")) Facter::Util::Processor.enum_kstat[0].should == "Intel(r) Core(tm) i5 CPU M 450 @ 2.40GHz" end it "should get the processor description on Solaris (SPARC64)" do Facter.fact(:architecture).stubs(:value).returns("sun4u") Facter::Util::Resolution.stubs(:exec).with("/usr/bin/kstat cpu_info").returns(my_fixture_read("solaris-sun4u")) Facter::Util::Processor.enum_kstat[0].should == "SPARC64-VII" Facter::Util::Processor.enum_kstat[1].should == "SPARC64-VII" Facter::Util::Processor.enum_kstat[2].should == "SPARC64-VII" Facter::Util::Processor.enum_kstat[3].should == "SPARC64-VII" Facter::Util::Processor.enum_kstat[4].should == "SPARC64-VII" Facter::Util::Processor.enum_kstat[5].should == "SPARC64-VII" Facter::Util::Processor.enum_kstat[6].should == "SPARC64-VII" Facter::Util::Processor.enum_kstat[7].should == "SPARC64-VII" end end end facter-1.7.5/spec/unit/util/file_read_spec.rb0000644005276200011600000000173712276213017021030 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'facter/util/file_read' require 'spec_helper' describe Facter::Util::FileRead do let(:issue) { "Ubuntu 10.04.4 LTS \\n \\l\n\n" } it "reads a file" do File.expects(:read).with("/etc/issue").returns(issue) Facter::Util::FileRead.read("/etc/issue").should == issue end it "returns nil if the file cannot be accessed" do File.stubs(:read).with("/etc/issue").raises(Errno::EACCES.new("/etc/issue")) Facter::Util::FileRead.read("/etc/issue").should be_nil end it "returns nil if the file does not exist" do File.stubs(:read).with("/etc/issue").raises(Errno::ENOENT.new("/etc/issue")) Facter::Util::FileRead.read("/etc/issue").should be_nil end it "logs a message when handing exceptions" do File.stubs(:read).with("/etc/issue").raises(Errno::EACCES.new("/etc/issue")) Facter.expects(:debug).with("Could not read /etc/issue: Permission denied - /etc/issue") Facter::Util::FileRead.read("/etc/issue") end end facter-1.7.5/spec/unit/util/virtual_spec.rb0000755005276200011600000002703412276213017020605 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/virtual' require 'stringio' describe Facter::Util::Virtual do after do Facter.clear end it "should detect openvz" do FileTest.stubs(:directory?).with("/proc/vz").returns(true) Dir.stubs(:glob).with("/proc/vz/*").returns(['vzquota']) Facter::Util::Virtual.should be_openvz end it "should not detect openvz when /proc/lve/list is present" do FileTest.stubs(:file?).with("/proc/lve/list").returns(true) Facter::Util::Virtual.should_not be_openvz end it "should not detect openvz when /proc/vz/ is empty" do FileTest.stubs(:file?).with("/proc/lve/list").returns(false) FileTest.stubs(:directory?).with("/proc/vz").returns(true) Dir.stubs(:glob).with("/proc/vz/*").returns([]) Facter::Util::Virtual.should_not be_openvz end it "should identify openvzhn when /proc/self/status has envID of 0" do Facter::Util::Virtual.stubs(:openvz?).returns(true) FileTest.stubs(:exists?).with("/proc/self/status").returns(true) Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 0") Facter::Util::Virtual.openvz_type().should == "openvzhn" end it "should identify openvzve when /proc/self/status has envID of 0" do Facter::Util::Virtual.stubs(:openvz?).returns(true) FileTest.stubs(:exists?).with('/proc/self/status').returns(true) Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 666") Facter::Util::Virtual.openvz_type().should == "openvzve" end it "should not attempt to identify openvz when /proc/self/status has no envID" do Facter::Util::Virtual.stubs(:openvz?).returns(true) FileTest.stubs(:exists?).with('/proc/self/status').returns(true) Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("") Facter::Util::Virtual.openvz_type().should be_nil end it "should identify Solaris zones when non-global zone" do Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("somezone") Facter::Util::Virtual.should be_zone end it "should not identify Solaris zones when global zone" do Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("global") Facter::Util::Virtual.should_not be_zone end it "(#14522) handles the unencoded binary data in /proc/self/status on Solaris" do Facter.fact(:osfamily).stubs(:value).returns("Solaris") File.stubs(:open).with('/proc/self/status', 'rb').returns(solaris_proc_self_status) FileTest.stubs(:exists?).with('/proc/self/status').returns(true) Facter::Util::Virtual.vserver?.should eq(false) end it "should not detect vserver if no self status" do FileTest.stubs(:exists?).with("/proc/self/status").returns(false) Facter::Util::Virtual.should_not be_vserver end it "should detect vserver when vxid present in process status" do FileTest.stubs(:exists?).with("/proc/self/status").returns(true) File.stubs(:open).with("/proc/self/status", "rb").returns(StringIO.new("VxID: 42\n")) Facter::Util::Virtual.should be_vserver end it "should detect vserver when s_context present in process status" do FileTest.stubs(:exists?).with("/proc/self/status").returns(true) File.stubs(:open).with("/proc/self/status", "rb").returns(StringIO.new("s_context: 42\n")) Facter::Util::Virtual.should be_vserver end it "should not detect vserver when vserver flags not present in process status" do FileTest.stubs(:exists?).with("/proc/self/status").returns(true) File.stubs(:open).with("/proc/self/status", "rb").returns(StringIO.new("wibble: 42\n")) Facter::Util::Virtual.should_not be_vserver end it "should identify kvm" do Facter::Util::Virtual.stubs(:kvm?).returns(true) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("something") Facter::Util::Virtual.kvm_type().should == "kvm" end it "should be able to detect RHEV via sysfs on Linux" do # Fake files are always hard to stub. :/ File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name"). returns("RHEV Hypervisor") Facter::Util::Virtual.should be_rhev end it "should be able to detect RHEV via sysfs on Linux improperly" do # Fake files are always hard to stub. :/ File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name"). returns("something else") Facter::Util::Virtual.should_not be_rhev end it "should be able to detect ovirt via sysfs on Linux" do # Fake files are always hard to stub. :/ File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name"). returns("oVirt Node") Facter::Util::Virtual.should be_ovirt end it "should be able to detect ovirt via sysfs on Linux improperly" do # Fake files are always hard to stub. :/ File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name"). returns("something else") Facter::Util::Virtual.should_not be_ovirt end fixture_path = fixtures('virtual', 'proc_self_status') test_cases = [ [File.join(fixture_path, 'vserver_2_1', 'guest'), true, 'vserver 2.1 guest'], [File.join(fixture_path, 'vserver_2_1', 'host'), true, 'vserver 2.1 host'], [File.join(fixture_path, 'vserver_2_3', 'guest'), true, 'vserver 2.3 guest'], [File.join(fixture_path, 'vserver_2_3', 'host'), true, 'vserver 2.3 host'] ] test_cases.each do |status_file, expected, description| describe "with /proc/self/status from #{description}" do it "should detect vserver as #{expected.inspect}" do status = File.read(status_file) FileTest.stubs(:exists?).with("/proc/self/status").returns(true) File.stubs(:open).with("/proc/self/status", "rb").returns(StringIO.new(status)) Facter::Util::Virtual.vserver?.should == expected end end end it "reads dmi entries as ascii data" do entries_file = my_fixture('invalid_unicode_dmi_entries') expected_contents = 'Virtual' entries = Facter::Util::Virtual.read_sysfs_dmi_entries(entries_file) entries.should =~ /#{expected_contents}/ end it "should identify vserver_host when /proc/virtual exists" do Facter::Util::Virtual.expects(:vserver?).returns(true) FileTest.stubs(:exists?).with("/proc/virtual").returns(true) Facter::Util::Virtual.vserver_type().should == "vserver_host" end it "should identify vserver_type as vserver when /proc/virtual does not exist" do Facter::Util::Virtual.expects(:vserver?).returns(true) FileTest.stubs(:exists?).with("/proc/virtual").returns(false) Facter::Util::Virtual.vserver_type().should == "vserver" end it "should detect xen when /proc/sys/xen exists" do FileTest.expects(:exists?).with("/proc/sys/xen").returns(true) Facter::Util::Virtual.should be_xen end it "should detect xen when /sys/bus/xen exists" do FileTest.expects(:exists?).with("/proc/sys/xen").returns(false) FileTest.expects(:exists?).with("/sys/bus/xen").returns(true) Facter::Util::Virtual.should be_xen end it "should detect xen when /proc/xen exists" do FileTest.expects(:exists?).with("/proc/sys/xen").returns(false) FileTest.expects(:exists?).with("/sys/bus/xen").returns(false) FileTest.expects(:exists?).with("/proc/xen").returns(true) Facter::Util::Virtual.should be_xen end it "should not detect xen when no sysfs/proc xen directories exist" do FileTest.expects(:exists?).with("/proc/sys/xen").returns(false) FileTest.expects(:exists?).with("/sys/bus/xen").returns(false) FileTest.expects(:exists?).with("/proc/xen").returns(false) Facter::Util::Virtual.should_not be_xen end it "should detect kvm" do FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(true) File.stubs(:read).with("/proc/cpuinfo").returns("model name : QEMU Virtual CPU version 0.9.1\n") Facter::Util::Virtual.should be_kvm end it "should detect kvm on FreeBSD" do FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false) Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns("QEMU Virtual CPU version 0.12.4") Facter::Util::Virtual.should be_kvm end it "should detect kvm on OpenBSD" do FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false) Facter.fact(:kernel).stubs(:value).returns("OpenBSD") Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns('QEMU Virtual CPU version (cpu64-rhel6) ("AuthenticAMD" 686-class, 512KB L2 cache)') Facter::Util::Virtual.should be_kvm end it "should identify FreeBSD jail when in jail" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1") Facter::Util::Virtual.should be_jail end it "should not identify GNU/kFreeBSD jail when not in jail" do Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD") Facter::Util::Resolution.stubs(:exec).with("/bin/sysctl -n security.jail.jailed").returns("0") Facter::Util::Virtual.should_not be_jail end it "should detect hpvm on HP-UX" do Facter.fact(:kernel).stubs(:value).returns("HP-UX") Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server Integrity Virtual Machine') Facter::Util::Virtual.should be_hpvm end it "should not detect hpvm on HP-UX when not in hpvm" do Facter.fact(:kernel).stubs(:value).returns("HP-UX") Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server rx660') Facter::Util::Virtual.should_not be_hpvm end it "should be able to detect virtualbox via sysfs on Linux" do # Fake files are always hard to stub. :/ File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name"). returns("VirtualBox") Facter::Util::Virtual.should be_virtualbox end it "should be able to detect virtualbox via sysfs on Linux improperly" do # Fake files are always hard to stub. :/ File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name"). returns("HP-Oracle-Sun-VMWare-funky-town") Facter::Util::Virtual.should_not be_virtualbox end let :solaris_proc_self_status do sample_data = my_fixture_read('solaris10_proc_self_status1') mockfile = mock('File') mockfile.stubs(:read).returns(sample_data) mockfile end shared_examples_for "virt-what" do |kernel, path, null_device| before(:each) do Facter.fact(:kernel).stubs(:value).returns(kernel) Facter::Util::Resolution.expects(:which).with("virt-what").returns(path) Facter::Util::Resolution.expects(:exec).with("#{path} 2>#{null_device}") end it "on #{kernel} virt-what is at #{path} and stderr is sent to #{null_device}" do Facter::Util::Virtual.virt_what end end context "on linux" do it_should_behave_like "virt-what", "linux", "/usr/bin/virt-what", "/dev/null" it "should strip out warnings on stdout from virt-what" do virt_what_warning = "virt-what: this script must be run as root" Facter.fact(:kernel).stubs(:value).returns('linux') Facter::Util::Resolution.expects(:which).with('virt-what').returns "/usr/bin/virt-what" Facter::Util::Resolution.expects(:exec).with('/usr/bin/virt-what 2>/dev/null').returns virt_what_warning Facter::Util::Virtual.virt_what.should_not match /^virt-what: / end end context "on unix" do it_should_behave_like "virt-what", "unix", "/usr/bin/virt-what", "/dev/null" end context "on windows" do it_should_behave_like "virt-what", "windows", 'c:\windows\system32\virt-what', "NUL" end end facter-1.7.5/spec/unit/util/macosx_spec.rb0000755005276200011600000001116312276213017020405 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/macosx' describe Facter::Util::Macosx do let(:badplist) do ' test file ' end let(:goodplist) do ' test file ' end it "should be able to retrieve profiler data as xml for a given data field" do Facter::Util::Resolution.expects(:exec).with("/usr/sbin/system_profiler -xml foo").returns "yay" Facter::Util::Macosx.profiler_xml("foo").should == "yay" end it 'should correct a bad XML doctype string' do Facter.expects(:debug).with('Had to fix plist with incorrect DOCTYPE declaration') Facter::Util::Macosx.intern_xml(badplist) end it 'should return a hash given XML data' do test_hash = { 'test' => 'file' } Facter::Util::Macosx.intern_xml(goodplist).should == test_hash end it 'should fail when trying to read invalid XML' do STDERR.stubs(:<<) expect { Facter::Util::Macosx.intern_xml('xml<--->') }.to raise_error(RuntimeError, /A plist file could not be properly read by Facter::Util::CFPropertyList/) end describe "when collecting profiler data" do it "should return the first value in the '_items' hash in the first value of the results of the system_profiler data, with the '_name' field removed, if the profiler returns data" do @result = [ '_items' => [ {'_name' => "foo", "yay" => "bar"} ] ] Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh" Facter::Util::Macosx.expects(:intern_xml).with("eh").returns @result Facter::Util::Macosx.profiler_data("foo").should == {"yay" => "bar"} end it "should return nil if an exception is thrown during parsing of xml" do Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh" Facter::Util::Macosx.expects(:intern_xml).with("eh").raises "boo!" Facter::Util::Macosx.profiler_data("foo").should be_nil end end it "should return the profiler data for 'SPHardwareDataType' as the hardware information" do Facter::Util::Macosx.expects(:profiler_data).with("SPHardwareDataType").returns "eh" Facter::Util::Macosx.hardware_overview.should == "eh" end it "should return the profiler data for 'SPSoftwareDataType' as the os information" do Facter::Util::Macosx.expects(:profiler_data).with("SPSoftwareDataType").returns "eh" Facter::Util::Macosx.os_overview.should == "eh" end describe "when working out software version" do before do Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productName").returns "Mac OS X" Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -buildVersion").returns "9J62" end it "should have called sw_vers three times when determining software version" do Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7" Facter::Util::Macosx.sw_vers end it "should return a hash with the correct keys when determining software version" do Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7" Facter::Util::Macosx.sw_vers.keys.sort.should == ["macosx_productName", "macosx_buildVersion", "macosx_productversion_minor", "macosx_productversion_major", "macosx_productVersion"].sort end it "should split a product version of 'x.y.z' into separate hash entries correctly" do Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "1.2.3" sw_vers = Facter::Util::Macosx.sw_vers sw_vers["macosx_productversion_major"].should == "1.2" sw_vers["macosx_productversion_minor"].should == "3" end it "should treat a product version of 'x.y' as 'x.y.0" do Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "2.3" Facter::Util::Macosx.sw_vers["macosx_productversion_minor"].should == "0" end end end facter-1.7.5/spec/unit/util/registry_spec.rb0000644005276200011600000000634412276213017020765 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/operatingsystem' require 'facter/util/registry' describe Facter::Util::Registry do describe "hklm_read", :if => Facter::Util::Config.is_windows? do before(:all) do require 'win32/registry' end describe "valid params" do [ {:key => "valid_key", :value => "valid_value", :expected => "valid"}, {:key => "valid_key", :value => "", :expected => "valid"}, {:key => "valid_key", :value => nil, :expected => "invalid"}, {:key => "", :value => "valid_value", :expected => "valid"}, {:key => "", :value => "", :expected => "valid"}, {:key => "", :value => nil, :expected => "invalid"}, {:key => nil, :value => "valid_value", :expected => "invalid"}, {:key => nil, :value => "", :expected => "invalid"}, {:key => nil, :value => nil, :expected => "invalid"} ].each do |scenario| describe "with key #{scenario[:key] || "nil"} and value #{scenario[:value] || "nil"}" do let :fake_registry_key do fake = {} fake[scenario[:value]] = scenario[:expected] fake end it "should return #{scenario[:expected]} value" do Win32::Registry::HKEY_LOCAL_MACHINE.stubs(:open).with(scenario[:key]).returns(fake_registry_key) fake_registry_key.stubs(:close) Facter::Util::Registry.hklm_read(scenario[:key], scenario[:value]).should == scenario[:expected] end end end end describe "invalid params" do [ {:key => "valid_key", :value => "invalid_value"}, {:key => "valid_key", :value => ""}, {:key => "valid_key", :value => nil}, ].each do |scenario| describe "with valid key and value #{scenario[:value] || "nil"}" do let :fake_registry_key do {} end it "should raise an error" do Win32::Registry::HKEY_LOCAL_MACHINE.stubs(:open).with(scenario[:key]).returns(fake_registry_key) fake_registry_key.stubs(:close) Facter::Util::Registry.hklm_read(scenario[:key], scenario[:value]).should raise_error end end end [ {:key => "invalid_key", :value => "valid_value"}, {:key => "invalid_key", :value => ""}, {:key => "invalid_key", :value => nil}, {:key => "", :value => "valid_value"}, {:key => "", :value => ""}, {:key => "", :value => nil}, {:key => nil, :value => "valid_value"}, {:key => nil, :value => ""}, {:key => nil, :value => nil} ].each do |scenario| describe "with invalid key #{scenario[:key] || "nil"} and value #{scenario[:value] || "nil"}" do it "should raise an error" do Win32::Registry::HKEY_LOCAL_MACHINE.stubs(:open).with(scenario[:key]).raises(Win32::Registry::Error, 2) expect do Facter::Util::Registry.hklm_read(scenario[:key], scenario[:value]) end.to raise_error Win32::Registry::Error end end end end end end facter-1.7.5/spec/unit/memory_spec.rb0000755005276200011600000004114312276213017017447 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Memory facts" do before(:each) do Facter.collection.internal_loader.load(:memory) end after(:each) do Facter.clear end describe "when returning scaled sizes" do [ "memorysize", "memoryfree", "swapsize", "swapfree" ].each do |fact| describe "when #{fact}_mb does not exist" do before(:each) do Facter.fact(fact + "_mb").stubs(:value).returns(nil) end it "#{fact} should not exist either" do Facter.fact(fact).value.should be_nil end end { "200.00" => "200.00 MB", "1536.00" => "1.50 GB", "1572864.00" => "1.50 TB", }.each do |mbval, scval| it "should scale #{fact} when given #{mbval} MB" do Facter.fact(fact + "_mb").stubs(:value).returns(mbval) Facter.fact(fact).value.should == scval end end end after(:each) do Facter.clear end end describe "on Darwin" do before(:each) do Facter.clear Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.memsize').returns('8589934592') sample_vm_stat = </dev/null').returns(swapusage) svmon = </dev/null').returns sample_prtconf vmstat_lines = </dev/null').returns sample_swap_line Facter.collection.internal_loader.load(:memory) end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "2048.00" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "465.06" end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "1023.99" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "1023.99" end end describe "when multiple swaps exist" do before(:each) do sample_swap_line = </dev/null').returns sample_swap_line Facter.collection.internal_loader.load(:memory) end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "2048.00" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "465.06" end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "2047.98" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "2047.98" end end describe "when no swap exists" do before(:each) do Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns "" Facter.collection.internal_loader.load(:memory) end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "2048.00" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "465.06" end it "should return 0 for the swap free in MB" do Facter.fact(:swapfree_mb).value.should == "0.00" end it "should return 0 for the swap size in MB" do Facter.fact(:swapsize_mb).value.should == "0.00" end end end describe "on DragonFly BSD" do before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("dragonfly") swapusage = "total: 148342k bytes allocated = 0k used, 148342k available" Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n hw.pagesize').returns("4096") Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_size').returns("128461") Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635") Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0") vmstat = < false) end it "should return ipaddress6 information for Darwin" do Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Darwin') Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") Facter::Util::IP.stubs(:exec_ifconfig).with(["-a"]). returns(ifconfig_fixture('darwin_ifconfig_all_with_multiple_interfaces')) Facter.value(:ipaddress6).should == "2610:10:20:209:223:32ff:fed5:ee34" end it "should return ipaddress6 information for Linux" do Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux') Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]). returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces')) Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201" end it "should return ipaddress6 information for Linux with recent net-tools" do Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux') Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") Facter::Util::IP.stubs(:exec_ifconfig).with(["2>/dev/null"]). returns(ifconfig_fixture('ifconfig_net_tools_1.60.txt')) Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201" end it "should return ipaddress6 information for Solaris" do Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS') Facter::Util::IP.stubs(:get_ifconfig).returns("/usr/sbin/ifconfig") Facter::Util::IP.stubs(:exec_ifconfig).with(["-a"]). returns(ifconfig_fixture('sunos_ifconfig_all_with_multiple_interfaces')) Facter.value(:ipaddress6).should == "2610:10:20:209:203:baff:fe27:a7c" end context "on Windows" do require 'facter/util/wmi' require 'facter/util/registry' require 'facter/util/ip/windows' require 'facter_spec/windows_network' include FacterSpec::WindowsNetwork before :each do Facter.fact(:kernel).stubs(:value).returns(:windows) Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings) given_a_configuration_of(:is_windows => true) end it "should do what when VPN is turned on?" context "when you have no active network adapter" do it "should return nil if there are no active (or any) network adapters" do Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY).returns([]) Facter.value(:ipaddress6).should == nil end end it "should return nil if the system doesn't have ipv6 installed", :if => Facter::Util::Config.is_windows? do Facter::Util::Resolution.any_instance.expects(:warn).never Facter::Util::Registry.stubs(:hklm_read).raises(Win32::Registry::Error, 2) Facter.value(:ipaddress6).should == nil end context "when you have one network adapter" do it "should return empty if ipv6 is not on" do nic = given_a_valid_windows_nic_with_ipv4_and_ipv6 nic.expects(:IPAddress).returns([ipAddress1]) Facter::Util::WMI.expects(:execquery).returns([nic]) Facter.value(:ipaddress6).should == nil end it "should return the ipv6 address properly" do Facter::Util::WMI.expects(:execquery).returns([given_a_valid_windows_nic_with_ipv4_and_ipv6]) Facter.value(:ipaddress6).should == ipv6Address0 end it "should return the first ipv6 address if there is more than one (multi-homing)" do nic = given_a_valid_windows_nic_with_ipv4_and_ipv6 nic.expects(:IPAddress).returns([ipAddress0, ipv6Address0,ipv6Address1]) Facter::Util::WMI.expects(:execquery).returns([nic]) Facter.value(:ipaddress6).should == ipv6Address0 end it "should return return nil if the ipv6 address is link local" do nic = given_a_valid_windows_nic_with_ipv4_and_ipv6 nic.expects(:IPAddress).returns([ipAddress0, ipv6LinkLocal]) Facter::Util::WMI.expects(:execquery).returns([nic]) Facter.value(:ipaddress6).should == nil end end context "when you have more than one network adapter" do it "should return empty if ipv6 is not on" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 nics[:nic0].expects(:IPAddress).returns([ipAddress0]) nics[:nic1].expects(:IPAddress).returns([ipAddress1]) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress6).should == nil end it "should return the ipv6 of the adapter with the lowest IP connection metric (best connection)" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 nics[:nic1].expects(:IPConnectionMetric).returns(5) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress6).should == ipv6Address1 end it "should return the ipv6 of the adapter with the lowest IP connection metric (best connection) that has ipv6 enabled" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 nics[:nic1].expects(:IPConnectionMetric).returns(5) nics[:nic1].expects(:IPAddress).returns([ipAddress1]) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress6).should == ipv6Address0 end context "when the IP connection metric is the same" do it "should return the ipv6 of the adapter with the lowest binding order" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress6).should == ipv6Address0 end it "should return the ipv6 of the adapter with the lowest binding order even if the adapter is not first" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::Registry.stubs(:hklm_read).returns(["\\Device\\#{settingId1}", "\\Device\\#{settingId0}" ]) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress6).should == ipv6Address1 end end end end end facter-1.7.5/spec/unit/ssh_spec.rb0000755005276200011600000000755712276213017016747 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' require 'facter/ssh' require 'pathname' describe "SSH fact" do dirs = [ '/etc/ssh', '/usr/local/etc/ssh', '/etc', '/usr/local/etc', '/etc/opt/ssh', ] before :each do # We need these facts loaded, but they belong to a file with a # different name, so load the file explicitly. Facter.collection.internal_loader.load(:ssh) end # fingerprints extracted from ssh-keygen -r '' -f /etc/ssh/ssh_host_dsa_key.pub { 'SSHRSAKey' => [ 'ssh_host_rsa_key.pub' , "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDrs+KtR8hjasELsyCiiBplUeIi77hEHzTSQt1ALG7N4IgtMg27ZAcq0tl2/O9ZarQuClc903pgionbM9Q98CtAIoqgJwdtsor7ETRmzwrcY/mvI7ne51UzQy4Eh9WrplfpNyg+EVO0FUC7mBcay6JY30QKasePp+g4MkwK5cuTzOCzd9up9KELonlH7tTm2L0YI4HhZugwVoTFulCAZvPICxSk1B/fEKyGSZVfY/UxZNqg9g2Wyvq5u40xQ5eO882UwhB3w4IbmRnPKcyotAcqOJxA7hToMKtEmFct+vjHE8T37w8axE/1X9mdvy8IZbkEBL1cupqqb8a8vU1QTg1z", "SSHFP 1 1 1e4f163a1747d0d1a08a29972c9b5d94ee5705d0\nSSHFP 1 2 4e834c91e423d6085ed6dfb880a59e2f1b04f17c1dc17da07708af67c5ab6045" ], 'SSHDSAKey' => [ 'ssh_host_dsa_key.pub' , "ssh-dss AAAAB3NzaC1kc3MAAACBAKjmRez14aZT6OKhHrsw19s7u30AdghwHFQbtC+L781YjJ3UV0/WQoZ8NaDL4ovuvW23RuO49tsqSNcVHg+PtRiN2iTVAS2h55TFhaPKhTs+i0NH3p3Ze8LNSYuz8uK7a+nTxysz47GYTHiE1ke8KXe5wGKDO1TO/MUgpDbwx72LAAAAFQD9yMJCnZMiKzA7J1RNkwvgCyBKSQAAAIAtWBAsuRM0F2fdCe+F/JmgyryQmRIT5vP8E1ww3t3ywdLHklN7UMkaEKBW/TN/jj1JOGXtZ2v5XI+0VNoNKD/7dnCGzNViRT/jjfyVi6l5UMg4Q52Gv0RXJoBJpxNqFOU2niSsy8hioyE39W6LJYWJtQozGpH/KKgkCSvxBn5hlAAAAIB1yo/YD0kQICOO0KE+UMMaKtV7FwyedFJsxsWYwZfHXGwWskf0d2+lPhd9qwdbmSvySE8Qrlvu+W+X8AipwGkItSnj16ORF8kO3lfABa+7L4BLDtumt7ybjBPcHOy3n28dd07TmMtyWvLjOb0mcxPo+TwDLtHd3L/3C1Dh41jRPg==\n", "SSHFP 2 1 f63dfe8da99f50ffbcfa40a61161cee29d109f70\nSSHFP 2 2 5f57aa6be9baddd71b6049ed5d8639664a7ddf92ce293e3887f16ad0f2d459d9" ], 'SSHECDSAKey' => [ 'ssh_host_ecdsa_key.pub' , 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIuKHtgXQUIrXSVNKC7uY+ZOF7jjfqYNU7Cb/IncDOZ7jW44dxsfBzRJwS5sTHERjBinJskY87mmwY07NFF5GoE=', "SSHFP 3 1 091a088fd3500ad9e35ce201c5101646cbf6ff98\nSSHFP 3 2 1dd2aa8f29b539337316e2862b28c196c68ffe0af78fccf9e50625635677e50f"] }.each_pair do |fact, data| describe "#{fact}" do let(:filename) { data[0] } let(:contents) { data[1] } let(:fingerprint) { data[2] } let(:fingerprint_fact) { "SSHFP_#{fact[3..-4]}" } let(:private_key) { /AAAA\S+/.match(contents).to_s } # Before we start testing, we'll say that the file # doesn't exist in any of our search locations. # Then, when we test a specific directory, we'll # toggle just that one on. # This doesn't test the search order, but it does # make testing each of the individual cases *way* # easier. --jeffweiss 24 May 2012 before(:each) do dirs.each do |dir| full_path = File.join(dir, filename) FileTest.stubs(:file?).with(full_path).returns false end end # Now, let's go through each and individually flip then # on for that test. dirs.each do |dir| describe "when data is in #{dir}" do let(:full_path) { File.join(dir, filename) } before(:each) do full_path = File.join(dir, filename) FileTest.stubs(:file?).with(full_path).returns true end it "should find in #{dir}" do FileTest.expects(:file?).with(full_path) Facter.fact(fact).value end it "should match the contents" do File.expects(:read).with(full_path).at_least_once.returns contents Facter.fact(fact).value.should == private_key end it "should have matching fingerprint" do File.expects(:read).with(full_path).at_least_once.returns contents Facter.fact(fingerprint_fact).value.should == fingerprint end end end end end end facter-1.7.5/spec/unit/ipaddress_spec.rb0000755005276200011600000000762612276213017020125 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/ip' describe "ipaddress fact" do before do Facter.collection.internal_loader.load(:ipaddress) end context 'using `ifconfig`' do before :each do Facter.fact(:hostname).stubs(:value) end context "on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end def expect_ifconfig_parse(address, fixture) Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture)) Facter.fact(:ipaddress).value.should == address end it "parses correctly on Ubuntu 12.04" do expect_ifconfig_parse "10.87.80.110", "ifconfig_ubuntu_1204.txt" end it "parses correctly on Fedora 17" do expect_ifconfig_parse "131.252.209.153", "ifconfig_net_tools_1.60.txt" end it "parses a real address over multiple loopback addresses" do expect_ifconfig_parse "10.0.222.20", "ifconfig_multiple_127_addresses.txt" end it "parses nothing with a non-english locale" do expect_ifconfig_parse nil, "ifconfig_non_english_locale.txt" end end end context "on Windows" do require 'facter/util/wmi' require 'facter/util/registry' require 'facter/util/ip/windows' require 'facter_spec/windows_network' include FacterSpec::WindowsNetwork before :each do Facter.fact(:kernel).stubs(:value).returns(:windows) Facter.fact(:kernelrelease).stubs(:value).returns('6.1.7601') Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings) end it "should do what when VPN is turned on?" context "when you have no active network adapter" do it "should return nil if there are no active (or any) network adapters" do Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY).returns([]) Facter::Util::Resolution.stubs(:exec) Facter.value(:ipaddress).should == nil end end context "when you have one network adapter" do it "should return the ip address properly" do nic = given_a_valid_windows_nic_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns([nic]) Facter.value(:ipaddress).should == ipAddress0 end end context "when you have more than one network adapter" do it "should return the ip of the adapter with the lowest IP connection metric (best connection)" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 nics[:nic1].expects(:IPConnectionMetric).returns(5) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress).should == ipAddress1 end it "should return the ip of the adapter with the lowest IP connection metric (best connection) that has ipv4 enabled" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 nics[:nic1].expects(:IPConnectionMetric).returns(5) nics[:nic1].expects(:IPAddress).returns([ipv6Address1]) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress).should == ipAddress0 end context "when the IP connection metric is the same" do it "should return the ip of the adapter with the lowest binding order" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:ipaddress).should == ipAddress0 end it "should return the ip of the adapter with the lowest binding order even if the adapter is not first" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter::Util::Registry.stubs(:hklm_read).returns(["\\Device\\#{settingId1}", "\\Device\\#{settingId0}" ]) Facter.value(:ipaddress).should == ipAddress1 end end end end end facter-1.7.5/spec/unit/filesystems_spec.rb0000644005276200011600000000266612276213017020512 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' describe 'Filesystem facts' do describe 'on non-Linux OS' do it 'should not exist' do Facter.fact(:kernel).stubs(:value).returns('SunOS') Facter.fact(:filesystems).value.should == nil end end describe 'on Linux' do before :each do Facter.fact(:kernel).stubs(:value).returns('Linux') fixture_data = my_fixture_read('linux') Facter::Util::Resolution.expects(:exec) \ .with('cat /proc/filesystems 2> /dev/null').returns(fixture_data) Facter.collection.internal_loader.load(:filesystems) end after :each do Facter.clear end it 'should exist' do Facter.fact(:filesystems).value.should_not == nil end it 'should detect the correct number of filesystems' do Facter.fact(:filesystems).value.split(',').length.should == 6 end # Check that lines from /proc/filesystems that start with 'nodev' are # skipped it 'should not detect sysfs' do Facter.fact(:filesystems).value.split(',').should_not include('sysfs') end # Check that all other lines are counted as valid filesystems it 'should detect ext4' do Facter.fact(:filesystems).value.split(',').should include('ext4') end # fuseblk is never included in the filesystem list it 'should not detect fuseblk' do Facter.fact(:filesystems).value.split(',').should_not include('fuseblk') end end end facter-1.7.5/spec/unit/operatingsystemmajrelease_spec.rb0000644005276200011600000000122612276213017023420 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' require 'facter' describe "OS Major Release fact" do ['Amazon','CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC'].each do |operatingsystem| context "on #{operatingsystem} operatingsystems" do it "should be derived from operatingsystemrelease" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:operatingsystem).stubs(:value).returns(operatingsystem) Facter.fact(:operatingsystemrelease).stubs(:value).returns("6.3") Facter.fact(:operatingsystemmajrelease).value.should == "6" end end end end facter-1.7.5/spec/unit/lsbmajdistrelease_spec.rb0000755005276200011600000000055012276213017021631 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' describe "LSB distribution major release fact" do it "should be derived from lsb_release" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.stubs(:value).with(:lsbdistrelease).returns("10.10") Facter.fact(:lsbmajdistrelease).value.should == "10" end end facter-1.7.5/spec/unit/version_spec.rb0000644005276200011600000000177212276213017017625 0ustar jenkinsjenkinsrequire "spec_helper" require "facter/version" require 'pathname' describe "Facter.version Public API" do before :each do Facter.instance_eval do if @facter_version @facter_version = nil end end end context "without a VERSION file" do before :each do Facter.stubs(:read_version_file).returns(nil) end it "is Facter::FACTERVERSION" do Facter.version.should == Facter::FACTERVERSION end it "respects the version= setter" do Facter.version = '1.2.3' Facter.version.should == '1.2.3' end end context "with a VERSION file" do it "is the content of the file" do Facter.expects(:read_version_file).with() do |path| pathname = Pathname.new(path) pathname.basename.to_s == "VERSION" end.returns('1.6.14-6-gea42046') Facter.version.should == '1.6.14-6-gea42046' end it "respects the version= setter" do Facter.version = '1.2.3' Facter.version.should == '1.2.3' end end end facter-1.7.5/spec/unit/operatingsystemrelease_spec.rb0000755005276200011600000001572512276213017022744 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'facter/util/file_read' require 'spec_helper' describe "Operating System Release fact" do before do Facter.clear end after do Facter.clear end test_cases = { "OpenWrt" => "/etc/openwrt_version", "CentOS" => "/etc/redhat-release", "RedHat" => "/etc/redhat-release", "Scientific" => "/etc/redhat-release", "Fedora" => "/etc/fedora-release", "MeeGo" => "/etc/meego-release", "OEL" => "/etc/enterprise-release", "oel" => "/etc/enterprise-release", "OVS" => "/etc/ovs-release", "ovs" => "/etc/ovs-release", "OracleLinux" => "/etc/oracle-release", "Ascendos" => "/etc/redhat-release", } test_cases.each do |system, file| describe "with operatingsystem reported as #{system.inspect}" do it "should read the #{file.inspect} file" do Facter.fact(:operatingsystem).stubs(:value).returns(system) Facter::Util::FileRead.expects(:read).with(file).at_least(1) Facter.fact(:operatingsystemrelease).value end end end it "does not include trailing whitespace on Debian" do Facter.fact(:operatingsystem).stubs(:value).returns("Debian") Facter::Util::FileRead.stubs(:read).returns("6.0.6\n") Facter.fact(:operatingsystemrelease).value.should == "6.0.6" end it "for VMWareESX it should run the vmware -v command" do Facter.fact(:kernel).stubs(:value).returns("VMkernel") Facter.fact(:kernelrelease).stubs(:value).returns("4.1.0") Facter.fact(:operatingsystem).stubs(:value).returns("VMwareESX") Facter::Util::Resolution.stubs(:exec).with('vmware -v').returns('foo') Facter.fact(:operatingsystemrelease).value end it "for Alpine it should use the contents of /etc/alpine-release" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:operatingsystem).stubs(:value).returns("Alpine") File.expects(:read).with("/etc/alpine-release").returns("foo") Facter.fact(:operatingsystemrelease).value.should == "foo" end describe "with operatingsystem reported as Solaris" do before :each do Facter.fact(:kernel).stubs(:value).returns('SunOS') Facter.fact(:osfamily).stubs(:value).returns('Solaris') end { 'Solaris 8 s28_38shwp2 SPARC' => '28', 'Solaris 8 6/00 s28s_u1wos_08 SPARC' => '28_u1', 'Solaris 8 10/00 s28s_u2wos_11b SPARC' => '28_u2', 'Solaris 8 1/01 s28s_u3wos_08 SPARC' => '28_u3', 'Solaris 8 4/01 s28s_u4wos_08 SPARC' => '28_u4', 'Solaris 8 7/01 s28s_u5wos_08 SPARC' => '28_u5', 'Solaris 8 10/01 s28s_u6wos_08a SPARC' => '28_u6', 'Solaris 8 2/02 s28s_u7wos_08a SPARC' => '28_u7', 'Solaris 8 HW 12/02 s28s_hw1wos_06a SPARC' => '28', 'Solaris 8 HW 5/03 s28s_hw2wos_06a SPARC' => '28', 'Solaris 8 HW 7/03 s28s_hw3wos_05a SPARC' => '28', 'Solaris 8 2/04 s28s_hw4wos_05a SPARC' => '28', 'Solaris 9 s9_58shwpl3 SPARC' => '9', 'Solaris 9 9/02 s9s_u1wos_08b SPARC' => '9_u1', 'Solaris 9 12/02 s9s_u2wos_10 SPARC' => '9_u2', 'Solaris 9 4/03 s9s_u3wos_08 SPARC' => '9_u3', 'Solaris 9 8/03 s9s_u4wos_08a SPARC' => '9_u4', 'Solaris 9 12/03 s9s_u5wos_08b SPARC' => '9_u5', 'Solaris 9 4/04 s9s_u6wos_08a SPARC' => '9_u6', 'Solaris 9 9/04 s9s_u7wos_09 SPARC' => '9_u7', 'Solaris 9 9/05 s9s_u8wos_05 SPARC' => '9_u8', 'Solaris 9 9/05 HW s9s_u9wos_06b SPARC' => '9_u9', 'Solaris 10 3/05 s10_74L2a SPARC' => '10', 'Solaris 10 3/05 HW1 s10s_wos_74L2a SPARC' => '10', 'Solaris 10 3/05 HW2 s10s_hw2wos_05 SPARC' => '10', 'Solaris 10 1/06 s10s_u1wos_19a SPARC' => '10_u1', 'Solaris 10 6/06 s10s_u2wos_09a SPARC' => '10_u2', 'Solaris 10 11/06 s10s_u3wos_10 SPARC' => '10_u3', 'Solaris 10 8/07 s10s_u4wos_12b SPARC' => '10_u4', 'Solaris 10 5/08 s10s_u5wos_10 SPARC' => '10_u5', 'Solaris 10 10/08 s10s_u6wos_07b SPARC' => '10_u6', 'Solaris 10 5/09 s10s_u7wos_08 SPARC' => '10_u7', 'Solaris 10 10/09 s10s_u8wos_08a SPARC' => '10_u8', 'Oracle Solaris 10 9/10 s10s_u9wos_14a SPARC' => '10_u9', 'Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC' => '10_u10', 'Solaris 10 3/05 HW1 s10x_wos_74L2a X86' => '10', 'Solaris 10 1/06 s10x_u1wos_19a X86' => '10_u1', 'Solaris 10 6/06 s10x_u2wos_09a X86' => '10_u2', 'Solaris 10 11/06 s10x_u3wos_10 X86' => '10_u3', 'Solaris 10 8/07 s10x_u4wos_12b X86' => '10_u4', 'Solaris 10 5/08 s10x_u5wos_10 X86' => '10_u5', 'Solaris 10 10/08 s10x_u6wos_07b X86' => '10_u6', 'Solaris 10 5/09 s10x_u7wos_08 X86' => '10_u7', 'Solaris 10 10/09 s10x_u8wos_08a X86' => '10_u8', 'Oracle Solaris 10 9/10 s10x_u9wos_14a X86' => '10_u9', 'Oracle Solaris 10 8/11 s10x_u10wos_17b X86' => '10_u10', }.each do |fakeinput,expected_output| it "should be able to parse a release of #{fakeinput}" do Facter::Util::FileRead.stubs(:read).with('/etc/release').returns fakeinput Facter.fact(:operatingsystemrelease).value.should == expected_output end end context "malformed /etc/release files" do before :each do Facter::Util::Resolution.any_instance.stubs(:warn) end it "should fallback to the kernelrelease fact if /etc/release is empty" do Facter::Util::FileRead.stubs(:read).with('/etc/release'). raises EOFError Facter.fact(:operatingsystemrelease).value. should == Facter.fact(:kernelrelease).value end it "should fallback to the kernelrelease fact if /etc/release is not present" do Facter::Util::FileRead.stubs(:read).with('/etc/release'). raises Errno::ENOENT Facter.fact(:operatingsystemrelease).value. should == Facter.fact(:kernelrelease).value end it "should fallback to the kernelrelease fact if /etc/release cannot be parsed" do Facter::Util::FileRead.stubs(:read).with('/etc/release'). returns 'some future release string' Facter.fact(:operatingsystemrelease).value. should == Facter.fact(:kernelrelease).value end end end context "Ubuntu" do let(:lsbrelease) { 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=10.04\nDISTRIB_CODENAME=lucid\nDISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"'} before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:operatingsystem).stubs(:value).returns("Ubuntu") end it "Returns only the major and minor version (not patch version)" do Facter::Util::FileRead.stubs(:read).with("/etc/lsb-release").returns(lsbrelease) Facter.fact(:operatingsystemrelease).value.should == "10.04" end end end facter-1.7.5/spec/unit/hardwareisa_spec.rb0000755005276200011600000000240012276213017020422 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' describe "Hardwareisa fact" do it "should match uname -p on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Inky") Facter.fact(:hardwareisa).value.should == "Inky" end it "should match uname -p on Darwin" do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Blinky") Facter.fact(:hardwareisa).value.should == "Blinky" end it "should match uname -p on SunOS" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Pinky") Facter.fact(:hardwareisa).value.should == "Pinky" end it "should match uname -p on FreeBSD" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with("uname -p").returns("Clyde") Facter.fact(:hardwareisa).value.should == "Clyde" end it "should match uname -m on HP-UX" do Facter.fact(:kernel).stubs(:value).returns("HP-UX") Facter::Util::Resolution.stubs(:exec).with("uname -m").returns("Pac-Man") Facter.fact(:hardwareisa).value.should == "Pac-Man" end end facter-1.7.5/spec/unit/domain_spec.rb0000755005276200011600000002264612276213017017415 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'stringio' describe "Domain name facts" do def resolv_conf_contains(*lines) file_handle = StringIO.new(lines.join("\n")) FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(true) File.stubs(:open).with("/etc/resolv.conf").yields(file_handle) end [ { :kernel => "Linux", :hostname_command => "hostname -f 2> /dev/null" }, { :kernel => "SunOS", :hostname_command => "hostname 2> /dev/null" }, { :kernel => "Darwin", :hostname_command => "hostname -f 2> /dev/null" }, { :kernel => "FreeBSD", :hostname_command => "hostname -f 2> /dev/null" }, { :kernel => "HP-UX", :hostname_command => "hostname 2> /dev/null" }, ].each do |scenario| describe "on #{scenario[:kernel]}" do let(:hostname_command) { scenario[:hostname_command] } let(:dnsdomain_command) { "dnsdomainname 2> /dev/null" } def the_hostname_is(value) Facter::Util::Resolution.stubs(:exec).with(hostname_command).returns(value) end def the_dnsdomainname_is(value) Facter::Util::Resolution.stubs(:exec).with(dnsdomain_command).returns(value) end before do Facter.fact(:kernel).stubs(:value).returns(scenario[:kernel]) end it "should use the hostname binary" do the_hostname_is("test.example.com") Facter.fact(:domain).value.should == "example.com" end it "should fall back to the dnsdomainname binary" do the_hostname_is("myhost") the_dnsdomainname_is("example.com") Facter.fact(:domain).value.should == "example.com" end it "should fall back to /etc/resolv.conf" do the_hostname_is("myhost") the_dnsdomainname_is("") resolv_conf_contains("domain testing.com") Facter.fact(:domain).value.should == "testing.com" end describe "Top level domain" do it "should find the domain name" do the_hostname_is("ns01.tld") Facter.fact(:domain).value.should == "tld" end end describe "when using /etc/resolv.conf" do before do the_hostname_is("") the_dnsdomainname_is("") end it "should use the domain field over the search field" do resolv_conf_contains( "nameserver 4.2.2.1", "search example.org", "domain example.com" ) Facter.fact(:domain).value.should == 'example.com' end it "should fall back to the search field" do resolv_conf_contains( "nameserver 4.2.2.1", "search example.org" ) Facter.fact(:domain).value.should == 'example.org' end it "should use the first domain in the search field" do resolv_conf_contains("search example.org example.net") Facter.fact(:domain).value.should == 'example.org' end # Test permutations of domain and search, where 'domain' can be a value of # the search keyword and the domain keyword # and also where 'search' can be a value of the search keyword and the # domain keyword # For example, /etc/resolv.conf may look like: # domain domain # or # search search # or # domain search # # # Why someone would have their machines named 'www.domain' or 'www.search', I # don't know, but we'll at least handle it properly [ [["domain domain"], "domain"], [["domain search"], "search"], [["search domain"], "domain"], [["search search"], "search"], [["search domain notdomain"], "domain"], [["#search notdomain", "search search"], "search"], [["# search notdomain", "search search"], "search"], [["#domain notdomain", "domain domain"], "domain"], [["# domain notdomain", "domain domain"], "domain"], ].each do |tuple| conf = tuple[0] expect = tuple[1] it "should return #{expect} from \"#{conf}\"" do resolv_conf_contains(*conf) Facter.fact(:domain).value.should == expect end end end end end describe "on Windows" do before(:each) do Facter.fact(:kernel).stubs(:value).returns("windows") require 'facter/util/registry' end describe "with primary dns suffix" do before(:each) do Facter::Util::Registry.stubs(:hklm_read).returns('baz.com') end it "should get the primary dns suffix" do Facter.fact(:domain).value.should == 'baz.com' end it "should not execute the wmi query" do require 'facter/util/wmi' Facter::Util::WMI.expects(:execquery).never Facter.fact(:domain).value end end describe "without primary dns suffix" do before(:each) do Facter::Util::Registry.stubs(:hklm_read).returns('') end def expects_dnsdomains(domains) nics = [] domains.each do |domain| nic = stubs 'nic' nic.stubs(:DNSDomain).returns(domain) nics << nic end require 'facter/util/wmi' Facter::Util::WMI.stubs(:execquery).with("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").returns(nics) end it "uses the first DNSDomain" do expects_dnsdomains(['foo.com', 'bar.com']) Facter.fact(:domain).value.should == 'foo.com' end it "uses the first non-nil DNSDomain" do expects_dnsdomains([nil, 'bar.com']) Facter.fact(:domain).value.should == 'bar.com' end it "uses the first non-empty DNSDomain" do expects_dnsdomains(['', 'bar.com']) Facter.fact(:domain).value.should == 'bar.com' end context "without any network adapters with a specified DNSDomain" do let(:hostname_command) { 'hostname > NUL' } it "should return nil" do expects_dnsdomains([nil]) Facter::Util::Resolution.stubs(:exec).with(hostname_command).returns('sometest') FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(false) Facter.fact(:domain).value.should be_nil end end end end describe "with trailing dots" do describe "on Windows" do before do Facter.fact(:kernel).stubs(:value).returns("windows") require 'facter/util/registry' require 'facter/util/wmi' end [{:registry => 'testdomain.', :wmi => '', :expect => 'testdomain'}, {:registry => '', :wmi => 'testdomain.', :expect => 'testdomain'}, ].each do |scenario| describe "scenarios" do before(:each) do Facter::Util::Registry.stubs(:hklm_read).returns(scenario[:registry]) nic = stubs 'nic' nic.stubs(:DNSDomain).returns(scenario[:wmi]) Facter::Util::WMI.stubs(:execquery).with("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").returns([nic]) end it "should return #{scenario[:expect]}" do Facter.fact(:domain).value.should == scenario[:expect] end it "should remove trailing dots" do Facter.fact(:domain).value.should_not =~ /\.$/ end end end end describe "on everything else" do before do Facter.fact(:kernel).stubs(:value).returns("Linux") FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(true) end [ { :scenario => 'when there is only a hostname', :hostname => 'host.testdomain.', :dnsdomainname => '', :resolve_domain => '', :resolve_search => '', :expect => 'testdomain' }, { :scenario => 'when there is only a domain name', :hostname => '', :dnsdomainname => 'testdomain.', :resolve_domain => '', :resolve_search => '', :expect => 'testdomain' }, { :scenario => 'when there is only a resolve domain', :hostname => '', :dnsdomainname => '', :resolve_domain => 'testdomain.', :resolve_search => '', :expect => 'testdomain' }, { :scenario => 'when there is only a resolve search', :hostname => '', :dnsdomainname => '', :resolve_domain => '', :resolve_search => 'testdomain.', :expect => 'testdomain' }, { :scenario => 'when there is no information available', :hostname => '', :dnsdomainname => '', :resolve_domain => '', :resolve_search => '', :expect => nil } ].each do |scenario| describe scenario[:scenario] do before(:each) do Facter::Util::Resolution.stubs(:exec).with("hostname -f 2> /dev/null").returns(scenario[:hostname]) Facter::Util::Resolution.stubs(:exec).with("dnsdomainname 2> /dev/null").returns(scenario[:dnsdomainname]) resolv_conf_contains( "search #{scenario[:resolve_search]}", "domain #{scenario[:resolve_domain]}" ) end it "should remove trailing dots" do Facter.fact(:domain).value.should_not =~ /\.$/ end it "should return #{scenario[:expect]}" do Facter.fact(:domain).value.should == scenario[:expect] end end end end end end facter-1.7.5/spec/unit/kernelrelease_spec.rb0000644005276200011600000000277612276213017020766 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "Kernel release fact" do describe "on Windows" do before do Facter.fact(:kernel).stubs(:value).returns("windows") require 'facter/util/wmi' version = stubs 'version' version.stubs(:Version).returns("test_kernel") Facter::Util::WMI.stubs(:execquery).with("SELECT Version from Win32_OperatingSystem").returns([version]) end it "should return the kernel release" do Facter.fact(:kernelrelease).value.should == "test_kernel" end end describe "on AIX" do before do Facter.fact(:kernel).stubs(:value).returns("aix") Facter::Util::Resolution.stubs(:exec).with('oslevel -s').returns("test_kernel") end it "should return the kernel release" do Facter.fact(:kernelrelease).value.should == "test_kernel" end end describe "on HP-UX" do before do Facter.fact(:kernel).stubs(:value).returns("hp-ux") Facter::Util::Resolution.stubs(:exec).with('uname -r').returns("B.11.31") end it "should remove preceding letters" do Facter.fact(:kernelrelease).value.should == "11.31" end end describe "on everything else" do before do Facter.fact(:kernel).stubs(:value).returns("linux") Facter::Util::Resolution.stubs(:exec).with('uname -r').returns("test_kernel") end it "should return the kernel release" do Facter.fact(:kernelrelease).value.should == "test_kernel" end end end facter-1.7.5/spec/unit/facter_spec.rb0000755005276200011600000001616512276213017017411 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe Facter do it "should have a method for returning its collection" do Facter.should respond_to(:collection) end it "should cache the collection" do Facter.collection.should equal(Facter.collection) end it "should delegate the :flush method to the collection" do Facter.collection.expects(:flush) Facter.flush end it "should delegate the :fact method to the collection" do Facter.collection.expects(:fact) Facter.fact end it "should delegate the :list method to the collection" do Facter.collection.expects(:list) Facter.list end it "should load all facts when listing" do Facter.collection.expects(:load_all) Facter.collection.stubs(:list) Facter.list end it "should delegate the :to_hash method to the collection" do Facter.collection.expects(:to_hash) Facter.to_hash end it "should load all facts when calling :to_hash" do Facter.collection.expects(:load_all) Facter.collection.stubs(:to_hash) Facter.to_hash end it "should delegate the :value method to the collection" do Facter.collection.expects(:value) Facter.value end it "should delegate the :each method to the collection" do Facter.collection.expects(:each) Facter.each end it "should load all facts when calling :each" do Facter.collection.expects(:load_all) Facter.collection.stubs(:each) Facter.each end it "should yield to the block when using :each" do Facter.collection.stubs(:load_all) Facter.collection.stubs(:each).yields "foo" result = [] Facter.each { |f| result << f } result.should == %w{foo} end describe "when provided code as a string" do it "should execute the code in the shell" do test_command = Facter::Util::Config.is_windows? ? 'cmd.exe /c echo yup' : 'echo yup' Facter.add("shell_testing") do setcode test_command end Facter["shell_testing"].value.should == "yup" end end describe "when asked for a fact as an undefined Facter class method" do describe "and the collection is already initialized" do it "should return the fact's value" do Facter.collection Facter.ipaddress.should == Facter['ipaddress'].value end end describe "and the collection has been just reset" do it "should return the fact's value" do Facter.reset Facter.ipaddress.should == Facter['ipaddress'].value end end end describe "when passed code as a block" do it "should execute the provided block" do Facter.add("block_testing") { setcode { "foo" } } Facter["block_testing"].value.should == "foo" end end describe "Facter[:hostname]" do it "should have its ldapname set to 'cn'" do Facter[:hostname].ldapname.should == "cn" end end describe "Facter[:ipaddress]" do it "should have its ldapname set to 'iphostnumber'" do Facter[:ipaddress].ldapname.should == "iphostnumber" end end # #33 Make sure we only get one mac address it "should only return one mac address" do if macaddress = Facter.value(:macaddress) macaddress.should_not be_include(" ") end end it "should have a method for registering directories to search" do Facter.should respond_to(:search) end it "should have a method for returning the registered search directories" do Facter.should respond_to(:search_path) end it "should have a method to query debugging mode" do Facter.should respond_to(:debugging?) end it "should have a method to query timing mode" do Facter.should respond_to(:timing?) end it "should have a method to show timing information" do Facter.should respond_to(:show_time) end it "should have a method to warn" do Facter.should respond_to(:warn) end describe "when warning" do it "should warn if debugging is enabled" do Facter.debugging(true) Kernel.stubs(:warn) Kernel.expects(:warn).with('foo') Facter.warn('foo') end it "should not warn if debugging is enabled but nil is passed" do Facter.debugging(true) Kernel.stubs(:warn) Kernel.expects(:warn).never Facter.warn(nil) end it "should not warn if debugging is enabled but an empyt string is passed" do Facter.debugging(true) Kernel.stubs(:warn) Kernel.expects(:warn).never Facter.warn('') end it "should not warn if debugging is disabled" do Facter.debugging(false) Kernel.stubs(:warn) Kernel.expects(:warn).never Facter.warn('foo') end it "should warn for any given element for an array if debugging is enabled" do Facter.debugging(true) Kernel.stubs(:warn) Kernel.expects(:warn).with('foo') Kernel.expects(:warn).with('bar') Facter.warn( ['foo','bar']) end end describe "when warning once" do it "should only warn once" do Kernel.stubs(:warnonce) Kernel.expects(:warn).with('foo').once Facter.warnonce('foo') Facter.warnonce('foo') end it "should not warnonce if nil is passed" do Kernel.stubs(:warn) Kernel.expects(:warnonce).never Facter.warnonce(nil) end it "should not warnonce if an empty string is passed" do Kernel.stubs(:warn) Kernel.expects(:warnonce).never Facter.warnonce('') end end describe "when setting debugging mode" do it "should have debugging enabled using 1" do Facter.debugging(1) Facter.should be_debugging end it "should have debugging enabled using true" do Facter.debugging(true) Facter.should be_debugging end it "should have debugging enabled using any string except off" do Facter.debugging('aaaaa') Facter.should be_debugging end it "should have debugging disabled using 0" do Facter.debugging(0) Facter.should_not be_debugging end it "should have debugging disabled using false" do Facter.debugging(false) Facter.should_not be_debugging end it "should have debugging disabled using the string 'off'" do Facter.debugging('off') Facter.should_not be_debugging end end describe "when setting timing mode" do it "should have timing enabled using 1" do Facter.timing(1) Facter.should be_timing end it "should have timing enabled using true" do Facter.timing(true) Facter.should be_timing end it "should have timing disabled using 0" do Facter.timing(0) Facter.should_not be_timing end it "should have timing disabled using false" do Facter.timing(false) Facter.should_not be_timing end end describe "when registering directories to search" do after { Facter.instance_variable_set("@search_path", []) } it "should allow registration of a directory" do Facter.search "/my/dir" end it "should allow registration of multiple directories" do Facter.search "/my/dir", "/other/dir" end it "should return all registered directories when asked" do Facter.search "/my/dir", "/other/dir" Facter.search_path.should == %w{/my/dir /other/dir} end end end facter-1.7.5/spec/unit/application_spec.rb0000644005276200011600000000321712276213017020437 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/application' describe Facter::Application do describe '.parse' do it 'returns an empty hash when given no options' do Facter::Application.parse([]).should == {} Facter::Application.parse(['architecture', 'kernel']).should == {} end [:yaml, :json, :trace].each do |option_key| it "sets options[:#{option_key}] when given --#{option_key}" do options = Facter::Application.parse(["--#{option_key}"]) options[option_key].should be_true end end [['-y', :yaml], ['-j', :json]].each do |option, key| it "sets options[:#{key}] when given #{option}" do options = Facter::Application.parse([option]) options[key].should be_true end end ['-d', '--debug'].each do |option| it "enables debugging when given #{option}" do Facter.debugging(false) Facter::Application.parse([option]) Facter.should be_debugging Facter.debugging(false) end end ['-t', '--timing'].each do |option| it "enables timing when given #{option}" do Facter.timing(false) Facter::Application.parse([option]) Facter.should be_timing Facter.timing(false) end end ['-p', '--puppet'].each do |option| it "calls load_puppet when given #{option}" do Facter::Application.expects(:load_puppet) Facter::Application.parse([option]) end end it 'mutates argv so that non-option arguments are left' do argv = ['-y', '--trace', 'uptime', 'virtual'] Facter::Application.parse(argv) argv.should == ['uptime', 'virtual'] end end end facter-1.7.5/spec/unit/selinux_spec.rb0000755005276200011600000000763512276213017017636 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "SELinux facts" do describe "should detect if SELinux is enabled" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end it "and return true with default /selinux" do mounts_does_not_exist File.stubs(:read).with("/proc/self/attr/current").returns("notkernel") FileTest.expects(:exists?).with("/proc/self/attr/current").returns true File.expects(:read).with("/proc/self/attr/current").returns("kernel") FileTest.expects(:exists?).with("/selinux/enforce").returns true Facter.fact(:selinux).value.should == "true" end it "and return true with selinuxfs path from /proc" do selinux_root = "/sys/fs/selinux" mounts_contains("selinuxfs #{selinux_root} selinuxfs rw,relatime 0 0") FileTest.expects(:exists?).with("#{selinux_root}/enforce").returns true FileTest.expects(:exists?).with("/proc/self/attr/current").returns true File.expects(:read).with("/proc/self/attr/current").returns("kernel") Facter.fact(:selinux).value.should == "true" end it "and return true with multiple selinuxfs mounts from /proc" do selinux_root = "/sys/fs/selinux" mounts_contains( "selinuxfs #{selinux_root} selinuxfs rw,relatime 0 0", "selinuxfs /var/tmp/imgcreate-R2wmE6/install_root/sys/fs/selinux selinuxfs rw,relatime 0 0" ) FileTest.expects(:exists?).with("#{selinux_root}/enforce").returns true FileTest.expects(:exists?).with("/proc/self/attr/current").returns true File.expects(:read).with("/proc/self/attr/current").returns("kernel") Facter.fact(:selinux).value.should == "true" end end describe "when selinux is present" do before :each do Facter.fact(:selinux).stubs(:value).returns("true") end it "should return true if SELinux policy enabled" do mounts_does_not_exist FileTest.expects(:exists?).with("/selinux/enforce").returns true File.expects(:read).with("/selinux/enforce").returns("1") Facter.fact(:selinux_enforced).value.should == "true" end it "should return an SELinux policy version" do mounts_does_not_exist FileTest.expects(:exists?).with("/selinux/policyvers").returns true File.expects(:read).with("/selinux/policyvers").returns("1") Facter.fact(:selinux_policyversion).value.should == "1" end it "it should return 'unknown' SELinux policy version if /selinux/policyvers doesn't exist" do mounts_does_not_exist FileTest.expects(:exists?).with("/selinux/policyvers").returns false Facter.fact(:selinux_policyversion).value.should == "unknown" end it "should return the SELinux current mode" do sestatus_is(my_fixture_read("selinux_sestatus")) Facter.fact(:selinux_current_mode).value.should == "permissive" end it "should return the SELinux mode from the configuration file" do sestatus_is(my_fixture_read("selinux_sestatus")) Facter.fact(:selinux_config_mode).value.should == "permissive" end it "should return the SELinux configuration file policy" do sestatus_is(my_fixture_read("selinux_sestatus")) Facter.fact(:selinux_config_policy).value.should == "targeted" end it "should ensure legacy selinux_mode facts returns same value as selinux_config_policy fact" do Facter.fact(:selinux_config_policy).stubs(:value).returns("targeted") Facter.fact(:selinux_mode).value.should == "targeted" end end def sestatus_is(status) Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(status) end def mounts_does_not_exist FileTest.stubs(:exists?).with("/proc/self/mounts").returns false end def mounts_contains(*lines) FileTest.expects(:exists?).with("/proc/self/mounts").returns true Facter::Util::Resolution.expects(:exec).with("cat /proc/self/mounts").returns(lines.join("\n")) end end facter-1.7.5/spec/unit/netmask_spec.rb0000755005276200011600000000557012276213017017605 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'shared_formats/parses' require 'facter/util/ip' shared_examples_for "netmask from ifconfig output" do |platform, address, fixture| it "correctly on #{platform}" do Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture)) Facter.collection.internal_loader.load(:netmask) Facter.fact(:netmask).value.should eq(address) end end describe "The netmask fact" do context "on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end example_behavior_for "netmask from ifconfig output", "Archlinux (net-tools 1.60)", "255.255.255.0", "ifconfig_net_tools_1.60.txt" example_behavior_for "netmask from ifconfig output", "Ubuntu 12.04", "255.255.255.255", "ifconfig_ubuntu_1204.txt" end context "on Windows" do require 'facter/util/wmi' require 'facter/util/registry' require 'facter_spec/windows_network' include FacterSpec::WindowsNetwork before :each do Facter.fact(:kernel).stubs(:value).returns(:windows) Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings) end describe "when you have no active network adapter" do it "should return nil if there are no active (or any) network adapters" do Facter::Util::WMI.expects(:execquery).returns([]) Facter.value(:netmask).should == nil end end describe "when you have one network adapter" do it "should return properly" do nic = given_a_valid_windows_nic_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns([nic]) Facter.value(:netmask).should == subnet0 end end describe "when you have more than one network adapter" do it "should return the netmask of the adapter with the lowest IP connection metric (best connection)" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 nics[:nic1].expects(:IPConnectionMetric).returns(5) Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:netmask).should == subnet1 end context "when the IP connection metric is the same" do it "should return the netmask of the adapter with the lowest binding order" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter.value(:netmask).should == subnet0 end it "should return the netmask of the adapter with the lowest binding even if the adapter is not first" do nics = given_two_valid_windows_nics_with_ipv4_and_ipv6 Facter::Util::WMI.expects(:execquery).returns(nics.values) Facter::Util::Registry.stubs(:hklm_read).returns(["\\Device\\#{settingId1}", "\\Device\\#{settingId0}" ]) Facter.value(:netmask).should == subnet1 end end end end end facter-1.7.5/spec/unit/blockdevices_spec.rb0000644005276200011600000001033212276213017020565 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' require 'facter/util/nothing_loader' describe "Block device facts" do describe "on non-Linux OS" do it "should not exist when kernel isn't Linux" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter.fact(:blockdevices).should == nil end end describe "on Linux" do describe "with /sys/block/" do describe "with valid entries" do before :each do Facter::Util::Config.ext_fact_loader = Facter::Util::NothingLoader.new Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exist?).with('/sys/block/').returns(true) Dir.stubs(:entries).with("/sys/block/").returns([".", "..", "hda", "sda", "sdb"]) File.stubs(:exist?).with("/sys/block/./device").returns(false) File.stubs(:exist?).with("/sys/block/../device").returns(false) stubdevices = [ #device, size, vendor, model ["hda"], ["sda", "976773168", "ATA", "WDC WD5000AAKS-0"], ["sdb", "8787591168", "DELL", "PERC H700"] ] stubdevices.each do |device, size, vendor, model| stubdir = "/sys/block/#{device}" File.stubs(:exist?).with(stubdir + "/device").returns(true) File.stubs(:exist?).with(stubdir + "/size").returns(size ? true : false) File.stubs(:exist?).with(stubdir + "/device/model").returns(model ? true : false) File.stubs(:exist?).with(stubdir + "/device/vendor").returns(vendor ? true : false) IO.stubs(:read).with(stubdir + "/size").returns(size) if size IO.stubs(:read).with(stubdir + "/device/vendor").returns(vendor) if vendor IO.stubs(:read).with(stubdir + "/device/model").returns(model) if model end end it "should report three block devices, hda, sda, and sdb, with accurate information from sda and sdb, and without invalid . or .. entries" do Facter.fact(:blockdevices).value.should == "hda,sda,sdb" # handle facts that should not exist %w{ . .. hda }.each do |device| Facter.fact("blockdevice_#{device}_size".to_sym).should == nil Facter.fact("blockdevice_#{device}_vendor".to_sym).should == nil Facter.fact("blockdevice_#{device}_model".to_sym).should == nil end # handle facts that should exist %w{ sda sdb }.each do |device| Facter.fact("blockdevice_#{device}_size".to_sym).should_not == nil Facter.fact("blockdevice_#{device}_vendor".to_sym).should_not == nil Facter.fact("blockdevice_#{device}_model".to_sym).should_not == nil end Facter.fact(:blockdevice_sda_model).value.should == "WDC WD5000AAKS-0" Facter.fact(:blockdevice_sda_vendor).value.should == "ATA" Facter.fact(:blockdevice_sda_size).value.should == 500107862016 Facter.fact(:blockdevice_sdb_model).value.should == "PERC H700" Facter.fact(:blockdevice_sdb_vendor).value.should == "DELL" Facter.fact(:blockdevice_sdb_size).value.should == 4499246678016 end end describe "with invalid entries in /sys/block" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exist?).with('/sys/block/').returns(true) Dir.stubs(:entries).with("/sys/block/").returns([".", "..", "xda", "ydb"]) File.stubs(:exist?).with("/sys/block/./device").returns(false) File.stubs(:exist?).with("/sys/block/../device").returns(false) File.stubs(:exist?).with("/sys/block/xda/device").returns(false) File.stubs(:exist?).with("/sys/block/ydb/device").returns(false) end it "should not exist with invalid entries in /sys/block" do Facter.fact(:blockdevices).should == nil end end end describe "without /sys/block/" do it "should not exist without /sys/block/ on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exist?).with('/sys/block/').returns(false) Facter.fact(:blockdevices).should == nil end end end end facter-1.7.5/spec/unit/zpool_version_spec.rb0000644005276200011600000000536112276213017021046 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' describe "zpool_version fact" do # http://blogs.oracle.com/bobn/entry/live_upgrade_and_zfs_versioning # # Solaris Release ZPOOL Version ZFS Version # Solaris 10 10/08 (u6) 10 3 # Solaris 10 5/09 (u7) 10 3 # Solaris 10 10/09 (u8) 15 4 # Solaris 10 9/10 (u9) 22 4 # Solaris 10 8/11 (u10) 29 5 # Solaris 11 11/11 (ga) 33 5 before :each do Facter::Util::Resolution.stubs(:which).with("zpool").returns("/usr/bin/zpool") end it "should return correct version on Solaris 10" do Facter::Util::Resolution.stubs(:exec).with("zpool upgrade -v").returns(my_fixture_read('solaris_10')) Facter.fact(:zpool_version).value.should == "22" end it "should return correct version on Solaris 11" do Facter::Util::Resolution.stubs(:exec).with("zpool upgrade -v").returns(my_fixture_read('solaris_11')) Facter.fact(:zpool_version).value.should == "33" end it "should return correct version on FreeBSD 8.2" do Facter::Util::Resolution.stubs(:exec).with("zpool upgrade -v").returns(my_fixture_read('freebsd_8.2')) Facter.fact(:zpool_version).value.should == "15" end it "should return correct version on FreeBSD 9.0" do Facter::Util::Resolution.stubs(:exec).with("zpool upgrade -v").returns(my_fixture_read('freebsd_9.0')) Facter.fact(:zpool_version).value.should == "28" end it "should return correct version on Linux with ZFS-fuse" do Facter::Util::Resolution.stubs(:exec).with("zpool upgrade -v").returns(my_fixture_read('linux-fuse_0.6.9')) Facter.fact(:zpool_version).value.should == "23" end it "should return nil if zpool is not available" do Facter::Util::Resolution.stubs(:which).with("zpool").returns(nil) Facter::Util::Resolution.stubs(:exec).with("zpool upgrade -v").returns(my_fixture_read('linux-fuse_0.6.9')) Facter.fact(:zpool_version).value.should == nil end it "should return nil if zpool fails to run" do Facter::Util::Resolution.stubs(:exec).with("zpool upgrade -v").returns(nil) Facter.fact(:zpool_version).value.should == nil end it "handles the zpool command becoming available" do # Simulate Puppet configuring the zfs tools from a persistent daemon by # simulating three sequential responses to which('zpool'). Facter::Util::Resolution.stubs(:which). with("zpool"). returns(nil,nil,"/usr/bin/zpool") Facter::Util::Resolution.stubs(:exec). with("zpool upgrade -v"). returns(my_fixture_read('linux-fuse_0.6.9')) fact = Facter.fact(:zpool_version) # zfs is not present the first two times the fact is resolved. fact.value.should be_nil fact.value.should be_nil # zfs was configured between the second and third resolutions. fact.value.should == "23" end end facter-1.7.5/spec/unit/interfaces_spec.rb0000755005276200011600000000326312276213017020263 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'shared_formats/parses' require 'facter/util/ip' shared_examples_for "netmask_* from ifconfig output" do |platform, interface, address, fixture| it "correctly on #{platform} interface #{interface}" do Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture)) Facter::Util::IP.stubs(:get_output_for_interface_and_label). returns(my_fixture_read("#{fixture}.#{interface}")) Facter.collection.internal_loader.load(:interfaces) fact = Facter.fact("netmask_#{interface}".intern) fact.value.should eq(address) end end describe "Per Interface IP facts" do it "should replace the ':' in an interface list with '_'" do # So we look supported Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter::Util::IP.stubs(:get_interfaces).returns %w{eth0:1 eth1:2} Facter.fact(:interfaces).value.should == %{eth0_1,eth1_2} end it "should replace non-alphanumerics in an interface list with '_'" do Facter.fact(:kernel).stubs(:value).returns("windows") Facter::Util::IP.stubs(:get_interfaces).returns ["Local Area Connection", "Loopback \"Pseudo-Interface\" (#1)"] Facter.fact(:interfaces).value.should == %{Local_Area_Connection,Loopback__Pseudo_Interface____1_} end end describe "Netmask handling on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end example_behavior_for "netmask_* from ifconfig output", "Archlinux (net-tools 1.60)", "em1", "255.255.255.0", "ifconfig_net_tools_1.60.txt" example_behavior_for "netmask_* from ifconfig output", "Archlinux (net-tools 1.60)", "lo", "255.0.0.0", "ifconfig_net_tools_1.60.txt" end facter-1.7.5/spec/unit/id_spec.rb0000755005276200011600000000161312276213017016531 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "id fact" do include FacterSpec::ConfigHelper kernel = [ 'Linux', 'Darwin', 'windows', 'FreeBSD', 'OpenBSD', 'NetBSD', 'AIX', 'HP-UX' ] kernel.each do |k| describe "with kernel reported as #{k}" do it "should return the current user" do given_a_configuration_of(:is_windows => k == 'windows') Facter.fact(:kernel).stubs(:value).returns(k) Facter::Util::Resolution.expects(:exec).once.with('whoami').returns 'bar' Facter.fact(:id).value.should == 'bar' end end end it "should return the current user on Solaris" do given_a_configuration_of(:is_windows => false) Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS') Facter::Util::Resolution.expects(:exec).once.with('/usr/xpg4/bin/id -un').returns 'bar' Facter.fact(:id).value.should == 'bar' end end facter-1.7.5/spec/unit/zfs_version_spec.rb0000644005276200011600000000533012276213017020501 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' describe "zfs_version fact" do # http://blogs.oracle.com/bobn/entry/live_upgrade_and_zfs_versioning # # Solaris Release ZPOOL Version ZFS Version # Solaris 10 10/08 (u6) 10 3 # Solaris 10 5/09 (u7) 10 3 # Solaris 10 10/09 (u8) 15 4 # Solaris 10 9/10 (u9) 22 4 # Solaris 10 8/11 (u10) 29 5 # Solaris 11 11/11 (ga) 33 5 before :each do Facter::Util::Resolution.stubs(:which).with("zfs").returns("/usr/bin/zfs") end it "should return correct version on Solaris 10" do Facter::Util::Resolution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('solaris_10')) Facter.fact(:zfs_version).value.should == "3" end it "should return correct version on Solaris 11" do Facter::Util::Resolution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('solaris_11')) Facter.fact(:zfs_version).value.should == "5" end it "should return correct version on FreeBSD 8.2" do Facter::Util::Resolution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('freebsd_8.2')) Facter.fact(:zfs_version).value.should == "4" end it "should return correct version on FreeBSD 9.0" do Facter::Util::Resolution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('freebsd_9.0')) Facter.fact(:zfs_version).value.should == "5" end it "should return correct version on Linux with ZFS-fuse" do Facter::Util::Resolution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('linux-fuse_0.6.9')) Facter.fact(:zfs_version).value.should == "4" end it "should return nil if zfs command is not available" do Facter::Util::Resolution.stubs(:which).with("zfs").returns(nil) Facter::Util::Resolution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('linux-fuse_0.6.9')) Facter.fact(:zfs_version).value.should == nil end it "should return nil if zfs fails to run" do Facter::Util::Resolution.stubs(:exec).with("zfs upgrade -v").returns(nil) Facter.fact(:zfs_version).value.should == nil end it "handles the zfs command becoming available at a later point in time" do # Simulate Puppet configuring the zfs tools from a persistent daemon by # simulating three sequential responses to which('zfs'). Facter::Util::Resolution.stubs(:which). with("zfs"). returns(nil,nil,"/usr/bin/zfs") Facter::Util::Resolution.stubs(:exec). with("zfs upgrade -v"). returns(my_fixture_read('linux-fuse_0.6.9')) fact = Facter.fact(:zfs_version) # zfs is not present the first two times the fact is resolved. fact.value.should be_nil fact.value.should be_nil # zfs was configured between the second and third resolutions. fact.value.should == "4" end end facter-1.7.5/spec/unit/manufacturer_spec.rb0000644005276200011600000000755612276213017020642 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' require 'facter/util/manufacturer' describe "Hardware manufacturer facts" do describe "on OS'es without DMI support" do it "no DMI facts should be reported" do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter.fact(:boardmanufacturer).should == nil Facter.fact(:boardproductname).should == nil Facter.fact(:boardserialnumber).should == nil Facter.fact(:bios_vendor).should == nil Facter.fact(:bios_version).should == nil Facter.fact(:bios_release_date).should == nil Facter.fact(:type).should == nil end end describe "on OS'es with DMI support" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") dmidecode_output = <<-eos Handle 0x0000, DMI type 0, 24 bytes BIOS Information Vendor: Dell Inc. Version: 1.2.5 Release Date: 03/16/2011 Address: 0xF0000 Runtime Size: 64 kB ROM Size: 4096 kB Characteristics: ISA is supported PCI is supported PNP is supported BIOS is upgradeable BIOS shadowing is allowed Boot from CD is supported Selectable boot is supported EDD is supported 8042 keyboard services are supported (int 9h) Serial services are supported (int 14h) CGA/mono video services are supported (int 10h) ACPI is supported USB legacy is supported BIOS boot specification is supported Function key-initiated network boot is supported Targeted content distribution is supported BIOS Revision: 1.2 Handle 0x0100, DMI type 1, 27 bytes System Information Manufacturer: Dell Inc. Product Name: PowerEdge R515 Version: Not Specified Serial Number: ABCD124 UUID: 1A2B3456-7890-1A23-4567-B8C91D123456 Wake-up Type: Power Switch SKU Number: Not Specified Family: Not Specified Handle 0x0200, DMI type 2, 9 bytes Base Board Information Manufacturer: Dell Inc. Product Name: 03X0MN Version: A03 Serial Number: ..AB1234567B1234. Asset Tag: Not Specified Handle 0x0300, DMI type 3, 21 bytes Chassis Information Manufacturer: Dell Inc. Type: Rack Mount Chassis Lock: Present Version: Not Specified Serial Number: ABCD124 Asset Tag: Not Specified Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: Unknown OEM Information: 0x00000000 Height: 2 U Number Of Power Cords: Unspecified Contained Elements: 0 Handle 0x7F00, DMI type 127, 4 bytes End Of Table eos Facter::Manufacturer.stubs(:get_dmi_table).returns(dmidecode_output) end it "should report the correct details from the DMI query" do Facter.fact(:manufacturer).value.should == "Dell Inc." Facter.fact(:boardmanufacturer).value.should == "Dell Inc." Facter.fact(:boardproductname).value.should == "03X0MN" Facter.fact(:boardserialnumber).value.should == "..AB1234567B1234." Facter.fact(:bios_vendor).value.should == "Dell Inc." Facter.fact(:bios_version).value.should == "1.2.5" Facter.fact(:bios_release_date).value.should == "03/16/2011" Facter.fact(:manufacturer).value.should == "Dell Inc." Facter.fact(:productname).value.should == "PowerEdge R515" Facter.fact(:serialnumber).value.should == "ABCD124" Facter.fact(:type).value.should == "Rack Mount Chassis" Facter.fact(:productname).value.should_not == Facter.fact(:boardproductname).value Facter.fact(:serialnumber).value.should_not == Facter.fact(:boardserialnumber).value end end endfacter-1.7.5/spec/unit/physicalprocessorcount_spec.rb0000755005276200011600000000601012276213017022756 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Physical processor count facts" do describe "on linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exists?).with('/sys/devices/system/cpu').returns(true) end it "should return one physical CPU" do Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(["/sys/devices/system/cpu/cpu0/topology/physical_package_id"]) Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu0/topology/physical_package_id").returns("0") Facter.fact(:physicalprocessorcount).value.should == 1 end it "should return four physical CPUs" do Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(%w{ /sys/devices/system/cpu/cpu0/topology/physical_package_id /sys/devices/system/cpu/cpu1/topology/physical_package_id /sys/devices/system/cpu/cpu2/topology/physical_package_id /sys/devices/system/cpu/cpu3/topology/physical_package_id }) Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu0/topology/physical_package_id").returns("0") Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu1/topology/physical_package_id").returns("1") Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu2/topology/physical_package_id").returns("2") Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu3/topology/physical_package_id").returns("3") Facter.fact(:physicalprocessorcount).value.should == 4 end end describe "on windows" do it "should return 4 physical CPUs" do Facter.fact(:kernel).stubs(:value).returns("windows") require 'facter/util/wmi' ole = stub 'WIN32OLE' Facter::Util::WMI.expects(:execquery).with("select Name from Win32_Processor").returns(ole) ole.stubs(:Count).returns(4) Facter.fact(:physicalprocessorcount).value.should == 4 end end describe "on solaris" do let(:psrinfo) do "0 on-line since 10/16/2012 14:06:12\n" + "1 on-line since 10/16/2012 14:06:14\n" end %w{ 5.8 5.9 5.10 5.11 }.each do |release| it "should use the output of psrinfo -p on #{release}" do Facter.fact(:kernel).stubs(:value).returns(:sunos) Facter.stubs(:value).with(:kernelrelease).returns(release) Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo -p").returns("1") Facter.fact(:physicalprocessorcount).value.should == "1" end end %w{ 5.5.1 5.6 5.7 }.each do |release| it "uses psrinfo with no -p for kernelrelease #{release}" do Facter.fact(:kernel).stubs(:value).returns(:sunos) Facter.stubs(:value).with(:kernelrelease).returns(release) Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo").returns(psrinfo) Facter.fact(:physicalprocessorcount).value.should == "2" end end end end facter-1.7.5/spec/unit/zones_spec.rb0000644005276200011600000000304512276213017017271 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "on Solaris" do before do Facter.fact(:kernel).stubs(:value).returns("SunOS") zone_list = <<-EOF 0:global:running:/::native:shared -:local:configured:/::native:shared -:zoneA:stopped:/::native:shared EOF Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/zoneadm list -cp').returns(zone_list) Facter.collection.internal_loader.load(:zones) end describe "number of zones" do it "should output number of zones" do Facter.fact(:zones).value.should == 3 end end describe "zone specific values" do it "Fact#zone__status" do {'global' => 'running', 'local' => 'configured', 'zoneA' => 'stopped'}.each do |key, val| Facter.value("zone_%s_status" % key).should == val end end it "Fact#zone__id" do {'global' => '0', 'local' => '-', 'zoneA' => '-'}.each do |key, val| Facter.value("zone_%s_id" % key).should == val end end it "Fact#zone__path" do {'global' => '/', 'local' => '/', 'zoneA' => '/'}.each do |key, val| Facter.value("zone_%s_path" % key).should == val end end it "Fact#zone__brand" do {'global' => 'native', 'local' => 'native', 'zoneA' => 'native'}.each do |key, val| Facter.value("zone_%s_brand" % key).should == val end end it "Fact#zone__iptype" do {'global' => 'shared', 'local' => 'shared', 'zoneA' => 'shared'}.each do |key, val| Facter.value("zone_%s_iptype" % key).should == val end end end end facter-1.7.5/spec/unit/uptime_spec.rb0000755005276200011600000000571312276213017017445 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/uptime' describe "uptime facts:" do before { Facter.clear } after { Facter.clear } describe "when uptime information is available" do describe "uptime" do test_cases = [ [60 * 60 * 24 * 3, '3 days'], [60 * 60 * 24 * 3 + 25, '3 days'], [60 * 60 * 24 * 1, '1 day'], [60 * 60 * 24 * 1 + 25, '1 day'], [60 * (60 * 3 + 45), '3:45 hours'], [60 * (60 * 3 + 4), '3:04 hours'], [60 * 60, '1:00 hours'], [60 * 35, '0:35 hours'] ] test_cases.each do |seconds, expected| it "should return #{expected.inspect} for #{seconds} seconds" do Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(seconds) Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(seconds) Facter.fact(:uptime).value.should == expected end end end end describe "when uptime information is available" do before do Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(60 * 60 * 24 + 23) Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(60 * 60 * 24 + 23) end describe "uptime_seconds" do it "should return the uptime in seconds" do Facter.fact(:uptime_seconds).value.should == 60 * 60 * 24 + 23 end end describe "uptime_hours" do it "should return the uptime in hours" do Facter.fact(:uptime_hours).value.should == 24 end end describe "uptime_days" do it "should return the uptime in days" do Facter.fact(:uptime_days).value.should == 1 end end end describe "when uptime information is not available" do before do Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(nil) Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(nil) $stderr, @old = StringIO.new, $stderr end after do $stderr = @old end describe "uptime" do it "should return 'unknown'" do Facter.fact(:uptime).value.should == "unknown" end end describe "uptime_seconds" do it "should return nil" do Facter.fact(:uptime_seconds).value.should == nil end it "should not print a warn message to stderr" do Facter.fact(:uptime_seconds).value $stderr.string.should == "" end end describe "uptime_hours" do it "should return nil" do Facter.fact(:uptime_hours).value.should == nil end it "should not print a warn message to stderr" do Facter.fact(:uptime_hours).value $stderr.string.should == "" end end describe "uptime_days" do it "should return nil" do Facter.fact(:uptime_days).value.should == nil end it "should not print a warn message to stderr" do Facter.fact(:uptime_days).value $stderr.string.should == "" end end end end facter-1.7.5/spec/unit/kernelmajversion_spec.rb0000644005276200011600000000051712276213017021512 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "Kernel major version fact" do before do Facter.fact(:kernelversion).stubs(:value).returns("12.34.56") end it "should return the kernel major release using the kernel release" do Facter.fact(:kernelmajversion).value.should == "12.34" end end facter-1.7.5/spec/unit/lsbdistrelease_spec.rb0000755005276200011600000000134412276213017021143 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistrelease fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do before :each do Facter.fact(:kernel).stubs(:value).returns kernel end it "should return the release through lsb_release -r -s 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns '2.1' Facter.fact(:lsbdistrelease).value.should == '2.1' end it "should return nil if lsb_release is not installed" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns nil Facter.fact(:lsbdistrelease).value.should be_nil end end end end facter-1.7.5/spec/unit/macaddress_spec.rb0000755005276200011600000000367312276213017020253 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/ip' def ifconfig_fixture(filename) File.read(fixtures('ifconfig', filename)) end describe "macaddress fact" do include FacterSpec::ConfigHelper before do given_a_configuration_of(:is_windows => false) end describe "when run on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:operatingsystem).stubs(:value).returns("Linux") Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") end it "should return the macaddress of the first interface" do Facter::Util::IP.stubs(:exec_ifconfig).with(["-a","2>/dev/null"]). returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces')) Facter.value(:macaddress).should == "00:12:3f:be:22:01" end it "should return nil when no macaddress can be found" do Facter::Util::IP.stubs(:exec_ifconfig).with(["-a","2>/dev/null"]). returns(ifconfig_fixture('linux_ifconfig_no_mac')) proc { Facter.value(:macaddress) }.should_not raise_error Facter.value(:macaddress).should be_nil end # some interfaces dont have a real mac addresses (like venet inside a container) it "should return nil when no interface has a real macaddress" do Facter::Util::IP.stubs(:exec_ifconfig).with(["-a","2>/dev/null"]). returns(ifconfig_fixture('linux_ifconfig_venet')) proc { Facter.value(:macaddress) }.should_not raise_error Facter.value(:macaddress).should be_nil end end describe "when run on BSD" do it "should return macaddress information" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") Facter::Util::IP.stubs(:exec_ifconfig). returns(ifconfig_fixture('bsd_ifconfig_all_with_multiple_interfaces')) Facter.value(:macaddress).should == "00:0b:db:93:09:67" end end end facter-1.7.5/spec/unit/hostname_spec.rb0000755005276200011600000000233712276213017017757 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Hostname facts" do describe "on linux" do before do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:kernelrelease).stubs(:value).returns("2.6") end it "should use the hostname command" do Facter::Util::Resolution.expects(:exec).with('hostname').at_least_once Facter.fact(:hostname).value.should be_nil end it "should use hostname as the fact if unqualified" do Facter::Util::Resolution.stubs(:exec).with('hostname').returns('host1') Facter.fact(:hostname).value.should == "host1" end it "should truncate the domain name if qualified" do Facter::Util::Resolution.stubs(:exec).with('hostname').returns('host1.example.com') Facter.fact(:hostname).value.should == "host1" end end describe "on darwin release R7" do before do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter.fact(:kernelrelease).stubs(:value).returns("R7") end it "should use scutil to get the hostname" do Facter::Util::Resolution.expects(:exec).with('/usr/sbin/scutil --get LocalHostName').returns("host1") Facter.fact(:hostname).value.should == "host1" end end end facter-1.7.5/spec/unit/ldom_spec.rb0000644005276200011600000000424312276213017017067 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' def ldom_fixtures(filename) File.read(fixtures('ldom', filename)) end describe "ldom fact" do before do Facter.fact(:kernel).stubs(:value).returns("SunOS") end describe "when running on ldom hardware" do before :each do # For virtinfo documentation: # http://docs.oracle.com/cd/E23824_01/html/821-1462/virtinfo-1m.html Facter::Util::Resolution.stubs(:exec).with("virtinfo -ap"). returns(ldom_fixtures('ldom_v1')) Facter.collection.internal_loader.load(:ldom) end it "should return correct impl on version 1.0" do Facter.fact(:ldom_domainrole_impl).value.should == "LDoms" end it "should return correct control on version 1.0" do Facter.fact(:ldom_domainrole_control).value.should == "false" end it "should return correct io on version 1.0" do Facter.fact(:ldom_domainrole_io).value.should == "true" end it "should return correct service on version 1.0" do Facter.fact(:ldom_domainrole_service).value.should == "true" end it "should return correct root on version 1.0" do Facter.fact(:ldom_domainrole_root).value.should == "true" end it "should return correct domain name on version 1.0" do Facter.fact(:ldom_domainname).value.should == "primary" end it "should return correct uuid on version 1.0" do Facter.fact(:ldom_domainuuid).value.should == "8e0d6ec5-cd55-e57f-ae9f-b4cc050999a4" end it "should return correct ldomcontrol on version 1.0" do Facter.fact(:ldom_domaincontrol).value.should == "san-t2k-6" end it "should return correct serial on version 1.0" do Facter.fact(:ldom_domainchassis).value.should == "0704RB0280" end it "should return correct virtual on version 1.0" do Facter.fact(:virtual).value.should == "LDoms" end end describe "when running on non ldom hardware" do before :each do Facter::Util::Resolution.stubs(:exec).with("virtinfo -ap").returns(nil) Facter.collection.internal_loader.load(:ldom) end it "should return correct virtual" do Facter.fact(:ldom_domainrole_impl).should == nil end end end facter-1.7.5/spec/unit/processor_spec.rb0000755005276200011600000003473112276213017020163 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'facter/util/processor' require 'spec_helper' require 'facter_spec/cpuinfo' describe "Processor facts" do describe "on Windows" do before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("windows") end def load(procs) require 'facter/util/wmi' Facter::Util::WMI.stubs(:execquery).with("select * from Win32_Processor").returns(procs) # This is to workaround #14674 Facter.fact(:architecture).stubs(:value).returns("x64") # processor facts belong to a file with a different name, # so load the file explicitly (after stubbing kernel), # but we have to stub execquery first Facter.collection.internal_loader.load(:processor) end describe "2003" do before :each do proc = stubs 'proc' proc.stubs(:Name).returns("Intel(R) Celeron(R) processor") load(Array.new(2, proc)) end it "should count 2 processors" do proc.expects(:NumberOfLogicalProcessors).never Facter.fact(:processorcount).value.should == "2" end it "should squeeze the processor name 2 times" do 2.times do |i| Facter.fact("processor#{i}".to_sym).value.should == "Intel(R) Celeron(R) processor" end end end describe "2008" do before :each do proc = stubs 'proc' proc.stubs(:NumberOfLogicalProcessors).returns(2) proc.stubs(:Name).returns("Intel(R) Celeron(R) processor") load(Array.new(2, proc)) end it "should count 4 processors" do Facter.fact(:processorcount).value.should == "4" end it "should squeeze the processor name 4 times" do 4.times do |i| Facter.fact("processor#{i}".to_sym).value.should == "Intel(R) Celeron(R) processor" end end end end describe "on Linux" do include FacterSpec::Cpuinfo shared_context 'Linux processor stubs' do before :each do Facter.collection.internal_loader.load(:processor) Facter.fact(:kernel).stubs(:value).returns 'Linux' Facter.fact(:operatingsystem).stubs(:value).returns 'Linux' File.stubs(:exists?).with("/proc/cpuinfo").returns(true) end end shared_examples_for 'a /proc/cpuinfo based processor fact' do |processor_fact| include_context 'Linux processor stubs' it "should be 1 in SPARC fixture" do Facter.fact(:architecture).stubs(:value).returns("sparc") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("sparc")) Facter.fact(processor_fact).value.should == "1" end it "should be 2 in ppc64 fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("ppc64") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("ppc64")) Facter.fact(processor_fact).value.should == "2" end it "should be 2 in panda-armel fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("arm") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("panda-armel")) Facter.fact(processor_fact).value.should == "2" end it "should be 1 in bbg3-armel fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("arm") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("bbg3-armel")) Facter.fact(processor_fact).value.should == "1" end it "should be 1 in beaglexm-armel fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("arm") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("beaglexm-armel")) Facter.fact(processor_fact).value.should == "1" end it "should be 1 in amd64solo fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64solo")) Facter.fact(processor_fact).value.should == "1" end it "should be 2 in amd64dual fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64dual")) Facter.fact(processor_fact).value.should == "2" end it "should be 3 in amd64tri fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64tri")) Facter.fact(processor_fact).value.should == "3" end it "should be 4 in amd64quad fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64quad")) Facter.fact(processor_fact).value.should == "4" end end it_behaves_like 'a /proc/cpuinfo based processor fact', :processorcount def sysfs_cpu_stubs(count) (0...count).map { |index| "/sys/devices/system/cpu/cpu#{index}" } end describe 'when /proc/cpuinfo returns 0 processors (#2945)' do include_context 'Linux processor stubs' before do File.stubs(:readlines).with("/proc/cpuinfo").returns([]) File.stubs(:exists?).with("/sys/devices/system/cpu").returns(true) end it "should be 2 via sysfs when cpu0 and cpu1 are present" do Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns( sysfs_cpu_stubs(2) ) Facter.fact(:processorcount).value.should == "2" end it "should be 16 via sysfs when cpu0 through cpu15 are present" do Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns( sysfs_cpu_stubs(16) ) Facter.fact(:processorcount).value.should == "16" end end end describe "on Unixes" do before :each do Facter.collection.internal_loader.load(:processor) end it "should be 2 on dual-processor Darwin box" do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2') Facter.fact(:processorcount).value.should == "2" end it "should be 2 on dual-processor OpenBSD box" do Facter.fact(:kernel).stubs(:value).returns("OpenBSD") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2') Facter.fact(:processorcount).value.should == "2" end it "should be 2 on dual-processor FreeBSD box" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2') Facter.fact(:processorcount).value.should == "2" end it "should print the correct CPU Model on FreeBSD" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.model").returns('SomeVendor CPU 3GHz') Facter.fact(:processor).value.should == "SomeVendor CPU 3GHz" end it "should be 2 on dual-processor DragonFly box" do Facter.fact(:kernel).stubs(:value).returns("DragonFly") Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2') Facter.fact(:processorcount).value.should == "2" end end describe "on solaris" do before :each do Facter::Util::Processor.stubs(:kernel_fact_value).returns :sunos Facter.fact(:kernel).stubs(:value).returns(:sunos) Facter.collection.internal_loader.load(:processor) end before :all do @fixture_kstat_sparc = File.read(fixtures('processorcount','solaris-sparc-kstat-cpu-info')) @fixture_kstat_x86_64 = File.read(fixtures('processorcount','solaris-x86_64-kstat-cpu-info')) end let(:kstat_sparc) { @fixture_kstat_sparc } let(:kstat_x86_64) { @fixture_kstat_x86_64 } %w{ 5.8 5.9 5.10 5.11 }.each do |release| %w{ sparc x86_64 }.each do |arch| it "uses kstat on release #{release} (#{arch})" do Facter.stubs(:value).with(:kernelrelease).returns(release) Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo").never Facter::Util::Resolution.expects(:exec).with("/usr/bin/kstat cpu_info").returns(self.send("kstat_#{arch}".intern)) Facter.fact(:processorcount).value.should == 8 end end end %w{ 5.5.1 5.6 5.7 }.each do |release| it "uses psrinfo on release #{release}" do Facter.stubs(:value).with(:kernelrelease).returns(release) fixture_data = File.read(fixtures('processorcount','solaris-psrinfo')) Facter::Util::Resolution.expects(:exec).with("/usr/bin/kstat cpu_info").never Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo").returns(fixture_data) Facter.fact(:processorcount).value.should == 24 end end end end describe "processorX facts" do describe "on AIX" do def self.lsdev_examples examples = [] examples << "proc0 Available 00-00 Processor\n" + "proc4 Available 00-04 Processor\n" + "proc8 Defined 00-08 Processor\n" + "proc12 Defined 00-12 Processor\n" examples end let(:lsattr) do "type PowerPC_POWER5 Processor type False\n" end lsdev_examples.each_with_index do |lsdev_example, i| context "lsdev example ##{i}" do before :each do Facter.fact(:kernel).stubs(:value).returns("AIX") Facter::Util::Processor.stubs(:lsdev).returns(lsdev_example) Facter::Util::Processor.stubs(:lsattr).returns(lsattr) Facter.collection.internal_loader.load(:processor) end lsdev_example.split("\n").each_with_index do |line, idx| aix_idx = idx * 4 it "maps proc#{aix_idx} to processor#{idx} (#11609)" do Facter.value("processor#{idx}").should == "PowerPC_POWER5" end end end end end describe "on HP-UX" do def self.machinfo_examples examples = [] examples << [File.read(fixtures('hpux','machinfo','ia64-rx2620')), "Intel(R) Itanium 2 processor"] examples << [File.read(fixtures('hpux','machinfo','ia64-rx6600')), "Intel(R) Itanium 2 9100 series processor (1.59 GHz, 18 MB)"] examples << [File.read(fixtures('hpux','machinfo','ia64-rx8640')), "Intel(R) Itanium 2 9100 series"] examples << [File.read(fixtures('hpux','machinfo','hppa-rp4440')), "PA-RISC 8800 processor (1000 MHz, 64 MB)"] examples << [File.read(fixtures('hpux','machinfo','superdome-server-SD32B')), "Intel(R) Itanium 2 9000 series"] examples << [File.read(fixtures('hpux','machinfo','superdome2-16s')), "Intel(R) Itanium(R) Processor 9340 (1.6 GHz, 15 MB)"] examples end let(:ioscan) do "Class I H/W Path Driver S/W State H/W Type Description\n" + "===================================================================\n" + "processor 0 0/120 processor CLAIMED PROCESSOR Processor\n" + "processor 1 0/123 processor CLAIMED PROCESSOR Processor\n" end describe "when machinfo is available" do machinfo_examples.each_with_index do |example, i| machinfo_example, expected_cpu = example context "machinfo example ##{i}" do before :each do Facter.fact(:kernel).stubs(:value).returns("HP-UX") Facter::Util::Processor.stubs(:ioscan).returns(ioscan) Facter::Util::Processor.stubs(:machinfo).returns(machinfo_example) Facter.collection.internal_loader.load(:processor) end %w{ 0 1 }.each do |j| it "should find #{expected_cpu}" do Facter.value("processor#{j}").should == expected_cpu end end end end end def self.model_and_getconf_examples examples = [] examples << ["9000/800/L3000-5x", "sched.models_present", "unistd.h_present", "532", "616", "PA-RISC 8600 processor"] examples << ["9000/800/L3000-5x", "", "unistd.h_present", "532", "616", "HP PA-RISC2.0 CHIP TYPE #616"] examples << ["9000/800/L3000-5x", "", "", "532", "616", "CPU v532 CHIP TYPE #616"] examples << ["ia64 hp server rx2660", "sched.models_present", "unistd.h_present", "768", "536936708", "IA-64 archrev 0 CHIP TYPE #536936708"] examples << ["ia64 hp server rx2660", "", "unistd.h_present", "768", "536936708", "IA-64 archrev 0 CHIP TYPE #536936708"] examples << ["ia64 hp server rx2660", "", "", "768", "536936708", "CPU v768 CHIP TYPE #536936708"] examples end sched_models = File.readlines(fixtures('hpux','sched.models')) unistd_h = File.readlines(fixtures('hpux','unistd.h')) describe "when machinfo is not available" do model_and_getconf_examples.each_with_index do |example, i| model_example, sm, unistd, getconf_cpu_ver, getconf_chip_type, expected_cpu = example context "and model and getconf example ##{i}" do before :each do Facter.fact(:kernel).stubs(:value).returns("HP-UX") Facter::Util::Processor.stubs(:ioscan).returns(ioscan) Facter::Util::Processor.stubs(:getconf_cpu_version).returns(getconf_cpu_ver) Facter::Util::Processor.stubs(:getconf_cpu_chip_type).returns(getconf_chip_type) Facter::Util::Processor.stubs(:machinfo).returns(nil) Facter::Util::Processor.stubs(:model).returns(model_example) end if unistd == "unistd.h_present" then before :each do Facter::Util::Processor.stubs(:read_unistd_h).returns(unistd_h) end else before :each do Facter::Util::Processor.stubs(:read_unistd_h).returns(nil) end end if sm == "sched.models_present" then before :each do Facter::Util::Processor.stubs(:read_sched_models).returns(sched_models) Facter.collection.internal_loader.load(:processor) end else before :each do Facter::Util::Processor.stubs(:read_sched_models).returns(nil) Facter.collection.internal_loader.load(:processor) end end %w{ 0 1 }.each do |j| it "should find #{expected_cpu}" do Facter.value("processor#{j}").should == expected_cpu end end end end end end end facter-1.7.5/spec/unit/virtual_spec.rb0000755005276200011600000005001312276213017017621 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/virtual' require 'facter/util/macosx' describe "Virtual fact" do before(:each) do Facter::Util::Virtual.stubs(:zone?).returns(false) Facter::Util::Virtual.stubs(:openvz?).returns(false) Facter::Util::Virtual.stubs(:vserver?).returns(false) Facter::Util::Virtual.stubs(:xen?).returns(false) Facter::Util::Virtual.stubs(:kvm?).returns(false) Facter::Util::Virtual.stubs(:hpvm?).returns(false) Facter::Util::Virtual.stubs(:zlinux?).returns(false) Facter::Util::Virtual.stubs(:virt_what).returns(nil) Facter::Util::Virtual.stubs(:rhev?).returns(false) Facter::Util::Virtual.stubs(:ovirt?).returns(false) Facter::Util::Virtual.stubs(:virtualbox?).returns(false) end it "should be zone on Solaris when a zone" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter::Util::Virtual.stubs(:zone?).returns(true) Facter::Util::Virtual.stubs(:vserver?).returns(false) Facter::Util::Virtual.stubs(:xen?).returns(false) Facter.fact(:virtual).value.should == "zone" end it "should be jail on FreeBSD when a jail in kvm" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Virtual.stubs(:jail?).returns(true) Facter::Util::Virtual.stubs(:kvm?).returns(true) Facter.fact(:virtual).value.should == "jail" end it "should be hpvm on HP-UX when in HP-VM" do Facter.fact(:kernel).stubs(:value).returns("HP-UX") Facter::Util::Virtual.stubs(:hpvm?).returns(true) Facter.fact(:virtual).value.should == "hpvm" end it "should be zlinux on s390x" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:architecture).stubs(:value).returns("s390x") Facter::Util::Virtual.stubs(:zlinux?).returns(true) Facter.fact(:virtual).value.should == "zlinux" end describe "on Darwin" do before do Facter.fact(:kernel).stubs(:value).returns("Darwin") end it "should be parallels with Parallels vendor id" do Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor-id" => "0x1ab8" }) Facter.fact(:virtual).value.should == "parallels" end it "should be parallels with Parallels vendor name" do Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor" => "Parallels" }) Facter.fact(:virtual).value.should == "parallels" end it "should be vmware with VMWare vendor id" do Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor-id" => "0x15ad" }) Facter.fact(:virtual).value.should == "vmware" end it "should be vmware with VMWare vendor name" do Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor" => "VMWare" }) Facter.fact(:virtual).value.should == "vmware" end end describe "on Linux" do before(:each) do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:operatingsystem).stubs(:value).returns("Linux") Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false FileTest.stubs(:exists?).with("/proc/sys/xen").returns false FileTest.stubs(:exists?).with("/sys/bus/xen").returns false FileTest.stubs(:exists?).with("/proc/xen").returns false Facter.fact(:architecture).stubs(:value).returns(true) end it "should be parallels with Parallels vendor id from lspci 2>/dev/null" do Facter::Util::Virtual.stubs(:lspci).returns("01:00.0 VGA compatible controller: Unknown device 1ab8:4005") Facter.fact(:virtual).value.should == "parallels" end it "should be parallels with Parallels vendor name from lspci 2>/dev/null" do Facter::Util::Virtual.stubs(:lspci).returns("01:00.0 VGA compatible controller: Parallels Display Adapter") Facter.fact(:virtual).value.should == "parallels" end it "should be vmware with VMware vendor name from lspci 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter") Facter.fact(:virtual).value.should == "vmware" end it "should be virtualbox with VirtualBox vendor name from lspci 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter") Facter.fact(:virtual).value.should == "virtualbox" end it "should be vmware with VMWare vendor name from dmidecode" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II") Facter.fact(:virtual).value.should == "vmware" end it "should be xen0 with xen dom0 files in /proc" do Facter.fact(:hardwaremodel).stubs(:value).returns("i386") Facter::Util::Virtual.expects(:xen?).returns(true) FileTest.expects(:exists?).with("/dev/xen/evtchn").returns(true) Facter.fact(:virtual).value.should == "xen0" end it "should be xenu with xen domU files in /proc" do Facter.fact(:hardwaremodel).stubs(:value).returns("i386") Facter::Util::Virtual.expects(:xen?).returns(true) FileTest.expects(:exists?).with("/dev/xen/evtchn").returns(false) FileTest.expects(:exists?).with("/proc/xen").returns(true) Facter.fact(:virtual).value.should == "xenu" end it "should be xenhvm with Xen HVM vendor name from lspci 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)") Facter.fact(:virtual).value.should == "xenhvm" end it "should be xenhvm with Xen HVM vendor name from dmidecode" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU") Facter.fact(:virtual).value.should == "xenhvm" end it "should be parallels with Parallels vendor name from dmidecode" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter") Facter.fact(:virtual).value.should == "parallels" end it "should be virtualbox with VirtualBox vendor name from dmidecode" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine") Facter.fact(:virtual).value.should == "virtualbox" end it "should be rhev with RHEV Hypervisor product name from dmidecode" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Product Name: RHEV Hypervisor") Facter.fact(:virtual).value.should == "rhev" end it "should be ovirt with oVirt Node product name from dmidecode" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Product Name: oVirt Node") Facter.fact(:virtual).value.should == "ovirt" end it "should be hyperv with Microsoft vendor name from lspci 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA") Facter.fact(:virtual).value.should == "hyperv" end it "should be hyperv with Microsoft vendor name from dmidecode" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine") Facter.fact(:virtual).value.should == "hyperv" end context "In Google Compute Engine" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end context "Without /sys/firmware/dmi/entries/1-0/raw" do before :each do Facter::Util::Virtual.stubs(:read_sysfs_dmi_entries).returns(nil) end it "should be gce with gce vendor name from lspci 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:05.0 Class 8007: Google, Inc. Device 6442") Facter.fact(:virtual).value.should == "gce" end end context "With /sys/firmware/dmi/entries/1-0/raw" do let :sysfs_dmi_raw do my_fixture_read('sysfs_dmi_entries_raw.txt') end before :each do Facter::Util::Virtual.stubs(:read_sysfs_dmi_entries).returns(sysfs_dmi_raw) end it "(#17612) is 'gce'" do Facter.fact(:virtual).value.should == "gce" end end end it "(#20236) is vmware when dmidecode contains vmware and lspci returns insufficient information" do Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("garbage\ninformation\n") Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II") Facter.fact(:virtual).value.should eq("vmware") end end describe "on Solaris" do before(:each) do Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false Facter.fact(:kernel).stubs(:value).returns("SunOS") end it "should be vmware with VMWare vendor name from prtdiag" do Facter.fact(:hardwaremodel).stubs(:value).returns(nil) Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform") Facter.fact(:virtual).value.should == "vmware" end it "should be parallels with Parallels vendor name from prtdiag" do Facter.fact(:hardwaremodel).stubs(:value).returns(nil) Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform") Facter.fact(:virtual).value.should == "parallels" end it "should be virtualbox with VirtualBox vendor name from prtdiag" do Facter.fact(:hardwaremodel).stubs(:value).returns(nil) Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox") Facter.fact(:virtual).value.should == "virtualbox" end end describe "on OpenBSD" do before do Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false Facter.fact(:kernel).stubs(:value).returns("OpenBSD") Facter.fact(:hardwaremodel).stubs(:value).returns(nil) Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) end it "should be parallels with Parallels product name from sysctl" do Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("Parallels Virtual Platform") Facter.fact(:virtual).value.should == "parallels" end it "should be vmware with VMware product name from sysctl" do Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VMware Virtual Platform") Facter.fact(:virtual).value.should == "vmware" end it "should be virtualbox with VirtualBox product name from sysctl" do Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VirtualBox") Facter.fact(:virtual).value.should == "virtualbox" end it "should be xenhvm with Xen HVM product name from sysctl" do Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("HVM domU") Facter.fact(:virtual).value.should == "xenhvm" end end describe "on Windows" do require 'facter/util/wmi' before do Facter.fact(:kernel).stubs(:value).returns("windows") Facter.fact(:architecture).stubs(:value).returns("x64") end it "should be kvm with KVM model name from Win32_ComputerSystem" do computersystem = mock('computersystem', :model => 'KVM') Facter::Util::WMI.expects(:execquery).returns([computersystem]) Facter.fact(:virtual).value.should == "kvm" end it "should be hyperv with Virtual Machine model name and Microsoft Corporation manufacturer from Win32_ComputerSystem" do computersystem = mock('computersystem', :manufacturer => 'Microsoft Corporation', :model => 'Virtual Machine') Facter::Util::WMI.expects(:execquery).returns([computersystem]) Facter.fact(:virtual).value.should == "hyperv" end it "should be virtualbox with VirtualBox model name from Win32_ComputerSystem" do computersystem = mock('computersystem', :model => 'VirtualBox') Facter::Util::WMI.expects(:execquery).returns([computersystem]) Facter.fact(:virtual).value.should == "virtualbox" end it "should be vmware with VMware like model name from Win32_ComputerSystem" do computersystem = mock('computersystem', :model => 'VMware Virtual Platform') Facter::Util::WMI.expects(:execquery).returns([computersystem]) Facter.fact(:virtual).value.should == "vmware" end it "resolves as Xen with a manufacturer name like xen" do computersystem = mock('computersystem', :model => nil, :manufacturer => 'Xen') Facter::Util::WMI.expects(:execquery).returns([computersystem]) Facter.fact(:virtual).value.should == "xen" end end describe "with the virt-what command available (#8210)" do describe "when the output of virt-what disagrees with lower weight facts" do virt_what_map = { 'xen-hvm' => 'xenhvm', 'xen-dom0' => 'xen0', 'xen-domU' => 'xenu', 'ibm_systemz' => 'zlinux', } virt_what_map.each do |input,output| it "maps #{input} to #{output}" do Facter::Util::Virtual.expects(:virt_what).returns(input) Facter.value(:virtual).should == output end end end describe "arbitrary outputs of virt-what" do it "returns the last line output from virt-what" do Facter::Util::Virtual.expects(:virt_what).returns("one\ntwo\nthree space\n") Facter.value(:virtual).should == "three space" end end describe "when virt-what returns linux_vserver" do it "delegates to Facter::Util::Virtual.vserver_type" do Facter::Util::Virtual.expects(:virt_what).returns("linux_vserver") Facter::Util::Virtual.expects(:vserver_type).returns("fake_vserver_type") Facter.value(:virtual).should == "fake_vserver_type" end end end end describe "is_virtual fact" do it "should be virtual when running on xen" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("xenu") Facter.fact(:is_virtual).value.should == "true" end it "should be false when running on xen0" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("xen0") Facter.fact(:is_virtual).value.should == "false" end it "should be true when running on xenhvm" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("xenhvm") Facter.fact(:is_virtual).value.should == "true" end it "should be false when running on physical" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("physical") Facter.fact(:is_virtual).value.should == "false" end it "should be true when running on vmware" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("vmware") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on virtualbox" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("virtualbox") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on openvzve" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("openvzve") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on vserver" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("vserver") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on kvm" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("kvm") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running in jail" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter.fact(:virtual).stubs(:value).returns("jail") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running in zone" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter.fact(:virtual).stubs(:value).returns("zone") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on hp-vm" do Facter.fact(:kernel).stubs(:value).returns("HP-UX") Facter.fact(:virtual).stubs(:value).returns("hpvm") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on S390" do Facter.fact(:architecture).stubs(:value).returns("s390x") Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("zlinux") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on parallels" do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter.fact(:virtual).stubs(:value).returns("parallels") Facter.fact(:is_virtual).value.should == "true" end it "should be false on vmware_server" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("vmware_server") Facter.fact(:is_virtual).value.should == "false" end it "should be false on openvz host nodes" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("openvzhn") Facter.fact(:is_virtual).value.should == "false" end it "should be false on vserver host nodes" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("vserver_host") Facter.fact(:is_virtual).value.should == "false" end it "should be true when running on hyperv" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("hyperv") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on rhev" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("rhev") Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on ovirt" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("ovirt") Facter.fact(:is_virtual).value.should == "true" end end facter-1.7.5/spec/unit/lsbdistcodename_spec.rb0000755005276200011600000000135012276213017021273 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistcodename fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do before :each do Facter.fact(:kernel).stubs(:value).returns kernel end it "should return the codename through lsb_release -c -s 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns 'n/a' Facter.fact(:lsbdistcodename).value.should == 'n/a' end it "should return nil if lsb_release is not installed" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns nil Facter.fact(:lsbdistcodename).value.should be_nil end end end end facter-1.7.5/spec/unit/lsbdistdescription_spec.rb0000755005276200011600000000145412276213017022050 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistdescription fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do before :each do Facter.fact(:kernel).stubs(:value).returns kernel end it "should return the description through lsb_release -d -s 2>/dev/null" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns '"Gentoo Base System release 2.1"' Facter.fact(:lsbdistdescription).value.should == 'Gentoo Base System release 2.1' end it "should return nil if lsb_release is not installed" do Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns nil Facter.fact(:lsbdistdescription).value.should be_nil end end end end facter-1.7.5/spec/integration/0000755005276200011600000000000012276213023016133 5ustar jenkinsjenkinsfacter-1.7.5/spec/integration/facter_spec.rb0000755005276200011600000000146312276213017020750 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe Facter do before do Facter.reset end after do Facter.reset end it "should create a new collection if one does not exist" do Facter.reset coll = mock('coll') Facter::Util::Collection.stubs(:new).returns coll Facter.collection.should equal(coll) Facter.reset end it "should remove the collection when reset" do old = Facter.collection Facter.reset Facter.collection.should_not equal(old) end it "should raise an error if a recursion is detected" do Facter.clear Facter.add(:foo) do confine :bar => 'some_value' end Facter.add(:bar) do confine :foo => 'some_value' end lambda { Facter.value(:foo) }.should raise_error(RuntimeError, /Caught recursion on foo/) end end