facter-2.4.6/0000775005276200011600000000000012651736742012676 5ustar jenkinsjenkinsfacter-2.4.6/COMMITTERS.md0000664005276200011600000001765412651736735014725 0ustar jenkinsjenkinsCommitting changes to Facter ==== We would like to make it easier for community members to contribute to facter using pull requests, even if it makes the task of reviewing and committing these changes a little harder. Pull requests are only ever based on a single branch, however, we maintain more than one active branch. As a result contributors should target their changes at the master branch. This makes the process of contributing a little easier for the contributor since they don't need to concern themselves with the question, "What branch do I base my changes on?" This is already called out in the [CONTRIBUTING.md](http://goo.gl/XRH2J). Therefore, it is the responsibility of the committer to re-base the change set on the appropriate branch which should receive the contribution. The rest of this document addresses the concerns of the committer. This document will help guide the committer decide which branch to base, or re-base a contribution on top of. This document also describes our branch management strategy, which is closely related to the decision of what branch to commit changes into. Terminology ==== Many of these terms have more than one meaning. For the purposes of this document, the following terms refer to specific things. **contributor** - A person who makes a change to facter and submits a change set in the form of a pull request. **change set** - A set of discrete patches which combined together form a contribution. A change set takes the form of Git commits and is submitted to facter in the form of a pull request. **committer** - A person responsible for reviewing a pull request and then making the decision what base branch to merge the change set into. **base branch** - A branch in Git that contains an active history of changes and will eventually be released using semantic version guidelines. The branch named master will always exist as a base branch. All other base branches will be associated with a specific released version of facter, e.g. 1.6.x and 1.7.x. Committer Guide ==== This section provides a guide to follow while committing change sets to facter base branches. How to decide what release(s) should be patched --- This section provides a guide to help a committer decide the specific base branch that a change set should be merged into. The latest minor release of a major release is the only base branch that should be patched. Older minor releases in a major release do not get patched. Before the switch to [semantic versions](http://semver.org/) committers did not have to think about the difference between minor and major releases. Committing to the latest minor release of a major release is a policy intended to limit the number of active base branches that must be managed. Security patches are handled as a special case. Security patches may be applied to earlier minor releases of a major release. How to commit a change set to multiple base branches --- A change set may apply to multiple releases. In this situation the change set needs to be committed to multiple base branches. This section provides a guide for how to merge patches across releases, e.g. 2.7 is patched, how should the changes be applied to 3.0? First, merge the change set into the lowest numbered base branch, e.g. 2.7. Next, merge the changed base branch up through all later base branches by using the `--no-ff --log` git merge options. We commonly refer to this as our "merge up process" because we merge in once, then merge up multiple times. When a new minor release branch is created (e.g. 3.1.x) then the previous one is deleted (e.g. 3.0.x). Any security or urgent fixes that might have to be applied to the older code line is done by creating an ad-hoc branch from the tag of the last patch release of the old minor line. Code review checklist --- This section aims to provide a checklist of things to look for when reviewing a pull request and determining if the change set should be merged into a base branch: * All tests pass * Are there any platform gotchas? (Does a change make an assumption about platform specific behavior that is incompatible with other platforms? e.g. Windows paths vs. POSIX paths.) * Is the change backwards compatible? (It should be) * Are there YARD docs for API changes? * Does the change set also require documentation changes? If so is the documentation being kept up to date? * Does the change set include clean code? (software code that is formatted correctly and in an organized manner so that another coder can easily read or modify it.) HINT: `git diff master --check` * Does the change set conform to the contributing guide? Commit citizen guidelines: --- This section aims to provide guidelines for being a good commit citizen by paying attention to our automated build tools. * Don’t push on a broken build. (A broken build is defined as a failing job in the [Facter](https://jenkins.puppetlabs.com/view/Facter/) page.) * Watch the build until your changes have gone through green * Update the ticket status and target version. The target version field in our issue tracker should be updated to be the next release of facter. For example, if the most recent release of facter is 1.6.17 and you merge a backwards compatible change set into master, then the target version should be 1.7.0 in the issue tracker.) * Ensure the pull request is closed (Hint: amend your merge commit to contain the string `closes #123` where 123 is the pull request number. Example Procedure ==== This section helps a committer rebase a contribution onto an earlier base branch, then merge into the base branch and up through all active base branches. Suppose a contributor submits a pull request based on master. The change set fixes a bug reported against facter 1.7.1 which is the most recently released version of facter. In this example the committer should rebase the change set onto the 1.7.x branch since this is a bug rather than new functionality. First, the committer pulls down the branch using the `hub` gem. This tool automates the process of adding the remote repository and creating a local branch to track the remote branch. $ hub checkout https://github.com/puppetlabs/facter/pull/1234 Branch jeffmccune-fix_foo_error set up to track remote branch fix_foo_error from jeffmccune. Switched to a new branch 'jeffmccune-fix_foo_error' At this point the topic branch is a descendant of master, but we want it to descend from 1.7.x. The committer creates a new branch then re-bases the change set: $ git branch bug/1.7.x/fix_foo_error $ git rebase --onto 1.7.x master bug/1.7.x/fix_foo_error First, rewinding head to replay your work on top of it... Applying: (#23456) Fix FooError that always bites users in 1.7.1 The `git rebase` command may be interpreted as, "First, check out the branch named `bug/1.7.x/fix_foo_error`, then take the changes that were previously based on `master` and re-base them onto `1.7.x`. Now that we have a topic branch containing the change set based on the correct release branch, the committer merges in: $ git checkout 1.7.x Switched to branch '1.7.x' $ git merge --no-ff --log bug/1.7.x/fix_foo_error Merge made by the 'recursive' strategy. foo | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo Once merged into the first base branch, the committer merges up: $ git checkout master Switched to branch 'master' $ git merge --no-ff --log 1.7.x Merge made by the 'recursive' strategy. foo | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo Once the change set has been merged "in and up." the committer pushes. (Note, the checklist should be complete at this point.) Note that both the 1.7.x and master branches are being pushed at the same time. $ git push puppetlabs master:master 1.7.x:1.7.x That's it! The committer then updates the pull request, updates the issue in our issue tracker, and keeps an eye on the build status. facter-2.4.6/CONTRIBUTING.md0000664005276200011600000000762212651736735015140 0ustar jenkinsjenkins# How to contribute Third-party patches are essential for keeping facter great. We simply can't access the huge number of platforms and myriad configurations for running facter. We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. ## Getting Started * Make sure you have a [Jira account](http://tickets.puppetlabs.com) * Make sure you have a [GitHub account](https://github.com/signup/free) * Submit a ticket for your issue, assuming one does not already exist. * Clearly describe the issue including steps to reproduce when it is a bug. * Make sure you fill in the earliest version that you know has the issue. * Fork the repository on GitHub ## New Facts All new facts should also be included in `schema/facter.json`. Without this facts won't pass acceptance tests. ## Making Changes * Create a topic branch from where you want to base your work. * This is usually the master branch. * Only target release branches if you are certain your fix must be on that branch. * To quickly create a topic branch based on master; `git branch fix/master/my_contribution master` then checkout the new branch with `git checkout fix/master/my_contribution`. Please avoid working directly on the `master` branch. * 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. ```` (#99999) Make the example in CONTRIBUTING imperative and concrete Without this patch applied the example commit message in the CONTRIBUTING document is not a concrete example. This is a problem because the contributor is left to imagine what the commit message should look like based on a description rather than an example. This patch fixes the problem by making the example concrete and imperative. The first line is a real life imperative statement with a ticket number from our issue tracker. The body describes the behavior without the patch, why this is a problem, and how the patch fixes the problem when applied. ```` * Make sure you have added the necessary tests for your changes. * Run _all_ the tests to assure nothing else was accidentally broken. ## Making Trivial Changes ### Documentation For changes of a trivial nature to comments and documentation, it is not always necessary to create a new ticket in Jira. In this case, it is appropriate to start the first line of a commit with '(doc)' instead of a ticket number. ```` (doc) Add documentation commit example to CONTRIBUTING There is no example for contributing a documentation commit to the Facter repository. This is a problem because the contributor is left to assume how a commit of this nature may appear. The first line is a real life imperative statement with '(doc)' in place of what would have been the ticket number in a non-documentation related commit. The body describes the nature of the new documentation or comments added. ```` ## Submitting Changes * Sign the [Contributor License Agreement](http://links.puppetlabs.com/cla). * 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 ticket to mark that you have submitted code and are ready for it to be reviewed. * Include a link to the pull request in the ticket # Additional Resources * [More information on contributing](http://links.puppetlabs.com/contribute-to-puppet) * [Bug tracker (Jira)](http://tickets.puppetlabs.com) * [Contributor License Agreement](http://links.puppetlabs.com/cla) * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) * #puppet-dev IRC channel on freenode.org facter-2.4.6/Gemfile0000664005276200011600000000310412651736735014171 0ustar jenkinsjenkinssource ENV['GEM_SOURCE'] || "https://rubygems.org" # 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 'yarjuf', "~> 1.0" gem 'rake', "~> 10.1.0" gem 'rspec', "~> 2.11.0" gem 'mocha', "~> 0.10.5" gem 'json', "~> 1.7", :platforms => :ruby gem 'json-schema', :platforms => :ruby gem 'puppetlabs_spec_helper' end require 'yaml' data = YAML.load_file(File.join(File.dirname(__FILE__), 'ext', 'project_data.yaml')) bundle_platforms = data['bundle_platforms'] data['gem_platform_dependencies'].each_pair do |gem_platform, info| next if gem_platform =~ /mingw/ if bundle_deps = info['gem_runtime_dependencies'] bundle_platform = bundle_platforms[gem_platform] or raise "Missing bundle_platform" platform(bundle_platform.intern) do bundle_deps.each_pair do |name, version| gem(name, version, :require => false) end end end end platform(:mingw_19) do gem 'win32console', '~> 1.3.2', :require => false end mingw = [:mingw] mingw << :x64_mingw if Bundler::Dsl::VALID_PLATFORMS.include?(:x64_mingw) platform(*mingw) do gem 'ffi', '~> 1.9.5', :require => false gem 'win32-dir', '~> 0.4.8', :require => false gem 'win32-security', '~> 0.2.5', :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-2.4.6/LICENSE0000664005276200011600000000113112651736735013701 0ustar jenkinsjenkinsFacter - Host Fact Detection and Reporting Copyright 2005-2014 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-2.4.6/README.md0000664005276200011600000000433512651736735014164 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 keys, the number of processors, etc. See `bin/facter` for an example of the interface. Installation ------------ Generally, you need the following things installed: * A supported Ruby version. Ruby 1.8.7, 1.9.3, and 2.0.0 (at least p195) are fully supported. 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. Support ------- Please log tickets and issues at our [JIRA tracker](http://tickets.puppetlabs.com). A [mailing list](https://groups.google.com/forum/?fromgroups#!forum/puppet-users) is available for asking questions and getting help from others. In addition there is an active #puppet channel on Freenode. We use semantic version numbers for our releases, and recommend that users stay as up-to-date as possible by upgrading to patch releases and minor releases as they become available. Bugfixes and ongoing development will occur in minor releases for the current major version. Security fixes will be backported to a previous major version on a best-effort basis, until the previous major version is no longer maintained. For example: If a security vulnerability is discovered in Facter 2.1.0, we would fix it in the 2 series, most likely as 2.1.1. Maintainers would then make a best effort to backport that fix onto the latest Facter 1.7 release. Long-term support, including security patches and bug fixes, is available for commercial customers. Please see the following page for more details: [Puppet Enterprise Support Lifecycle](http://puppetlabs.com/misc/puppet-enterprise-lifecycle) facter-2.4.6/Rakefile0000664005276200011600000000402012651736735014341 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' Dir['tasks/**/*.rake'].each { |t| load t } 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 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-2.4.6/acceptance/0000775005276200011600000000000012651736742014764 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/Gemfile0000664005276200011600000000154412651736735016265 0ustar jenkinsjenkinssource ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) if place =~ /^(git:[^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else [place, { :require => false }] end end gem "beaker", *location_for(ENV['BEAKER_VERSION'] || 'git://github.com/puppetlabs/beaker#master') gem 'rake', "~> 10.1.0" # json-schema does not support windows, so use the 'ruby' platform to exclude it on windows platforms :ruby do # json-schema uses multi_json, but chokes with multi_json 1.7.9, so prefer 1.7.7 gem "multi_json", "~> 1.10", :require => false gem "json-schema", "2.1.1", :require => false end if File.exists? "#{__FILE__}.local" eval(File.read("#{__FILE__}.local"), binding) end facter-2.4.6/acceptance/Rakefile0000664005276200011600000002433512651736735016442 0ustar jenkinsjenkinsrequire 'rake/clean' require 'pp' require 'yaml' $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), 'lib')) require 'puppet/acceptance/git_utils' extend Puppet::Acceptance::GitUtils ONE_DAY_IN_SECS = 24 * 60 * 60 REPO_CONFIGS_DIR = "repo-configs" CLEAN.include('*.tar', REPO_CONFIGS_DIR, 'merged_options.rb') module HarnessOptions DEFAULTS = { :type => 'git', :helper => ['lib/helper.rb'], :tests => ['tests'], :log_level => 'debug', :color => false, :root_keys => true, :ssh => { :keys => ["~/.ssh/id_rsa-acceptance"], }, :xml => true, :timesync => false, :repo_proxy => true, :add_el_extras => true, :preserve_hosts => 'onfail', } class Aggregator attr_reader :mode def initialize(mode) @mode = mode end def get_options(file_path) puts file_path if File.exists? file_path options = eval(File.read(file_path), binding) else puts "No options file found at #{File.expand_path(file_path)}" end options || {} end def get_mode_options get_options("./config/#{mode}/options.rb") end def get_local_options get_options("./local_options.rb") end def final_options(intermediary_options = {}) mode_options = get_mode_options local_overrides = get_local_options final_options = DEFAULTS.merge(mode_options) final_options.merge!(intermediary_options) final_options.merge!(local_overrides) return final_options end end def self.options(mode, options) final_options = Aggregator.new(mode).final_options(options) final_options end end def beaker_test(mode = :packages, options = {}) final_options = HarnessOptions.options(mode, options) if mode == :git final_options[:install] ||= [] final_options[:install] << "#{build_giturl('facter')}##{sha}" end options_file = 'merged_options.rb' File.open(options_file, 'w') do |merged| merged.puts <<-EOS # Copy this file to local_options.rb and adjust as needed if you wish to run # with some local overrides. EOS merged.puts(final_options.pretty_inspect) end tests = ENV['TESTS'] || ENV['TEST'] tests_opt = "--tests=#{tests}" if tests config_opt = "--hosts=#{config}" if config overriding_options = ENV['OPTIONS'] args = ["--options-file", options_file, config_opt, tests_opt, overriding_options].compact begin sh("beaker", *args) ensure if (hosts_file = config || final_options[:hosts_file]) && hosts_file !~ /preserved_config/ cp(hosts_file, "log/latest/config.yml") generate_config_for_latest_hosts if final_options[:preserve_hosts] || overriding_options =~ /--preserve-hosts/ end mv(options_file, "log/latest") puts "\n\n" end end def generate_config_for_latest_hosts preserved_config_hash = { 'HOSTS' => {} } config_hash = YAML.load_file('log/latest/config.yml').to_hash nodes = config_hash['HOSTS'].map do |node_label,hash| { :node_label => node_label, :platform => hash['platform'] } end pre_suite_log = File.read('log/latest/pre_suite-run.log') nodes.each do |node_info| possible_hostname_match = /^(\w+) \(#{node_info[:node_label]}\)/.match(pre_suite_log) hostname = (possible_hostname_match || Array.new)[1] fqdn = hostname ? "#{hostname}.delivery.puppetlabs.net" : "unknown" preserved_config_hash['HOSTS'][fqdn] = { 'roles' => [ 'agent'], 'platform' => node_info[:platform], } preserved_config_hash['HOSTS'][fqdn]['roles'].unshift('master') if node_info[:node_label] =~ /master/ end puts "\n\n" pp preserved_config_hash puts "\n\n" File.open('log/latest/preserved_config.yaml', 'w') do |config_file| YAML.dump(preserved_config_hash, config_file) end rescue Errno::ENOENT => e puts "Couldn't generate log #{e}" end def list_preserved_configurations(secs_ago = ONE_DAY_IN_SECS) preserved = {} Dir.glob('log/*_*').each do |dir| preserved_config_path = "#{dir}/preserved_config.yaml" yesterday = Time.now - secs_ago.to_i if preserved_config = File.exists?(preserved_config_path) directory = File.new(dir) if directory.ctime > yesterday hosts = [] preserved_config = YAML.load_file(preserved_config_path).to_hash preserved_config['HOSTS'].each do |hostname,values| hosts << "#{hostname}: #{values['platform']}, #{values['roles']}" end preserved[hosts] = directory.to_path end end end preserved.map { |k,v| [v,k] }.sort { |a,b| a[0] <=> b[0] }.reverse end def list_preserved_hosts(secs_ago = ONE_DAY_IN_SECS) hosts = Set.new Dir.glob('log/**/pre*suite*run.log').each do |log| yesterday = Time.now - secs_ago.to_i File.open(log, 'r') do |file| if file.ctime > yesterday file.each_line do |line| matchdata = /^(\w+) \(.*?\) \$/.match(line.encode!('UTF-8', 'UTF-8', :invalid => :replace)) hosts.add(matchdata[1]) if matchdata end end end end hosts end # Plagiarized from Beaker::Vcloud#cleanup def destroy_preserved_hosts(hosts = nil, secs_ago = ONE_DAY_IN_SECS) secs_ago ||= ONE_DAY_IN_SECS hosts ||= list_preserved_hosts(secs_ago) require 'beaker/hypervisor/vsphere_helper' vsphere_credentials = VsphereHelper.load_config("#{ENV['HOME']}/.fog") puts "Connecting to vSphere at #{vsphere_credentials[:server]}" + " with credentials for #{vsphere_credentials[:user]}" vsphere_helper = VsphereHelper.new( vsphere_credentials ) vm_names = hosts.to_a pp vm_names vms = vsphere_helper.find_vms vm_names vm_names.each do |name| unless vm = vms[name] puts "Couldn't find VM #{name} in vSphere!" next end if vm.runtime.powerState == 'poweredOn' puts "Shutting down #{vm.name}" start = Time.now vm.PowerOffVM_Task.wait_for_completion puts "Spent %.2f seconds halting #{vm.name}" % (Time.now - start) end start = Time.now vm.Destroy_Task puts "Spent %.2f seconds destroying #{vm.name}" % (Time.now - start) end vsphere_helper.close end def print_preserved(preserved) preserved.each_with_index do |entry,i| puts "##{i}: #{entry[0]}" entry[1].each { |h| puts " #{h}" } end end def beaker_run_type type = ENV['TYPE'] || :packages type = type.to_sym end def sha ENV['SHA'] end def config ENV['CONFIG'] end namespace :ci do task :check_env do raise(USAGE) unless sha end namespace :test do USAGE = <<-EOS Requires commit SHA to be put under test as environment variable: SHA=''. Also must set CONFIG=config/nodes/foo.yaml or include it in an options.rb for Beaker. You may set TESTS=path/to/test,and/more/tests. You may set additional Beaker OPTIONS='--more --options' If testing from git checkouts, you may optionally set the github fork to checkout from using FORK='other-puppet-fork'. You may also optionally set the git server to checkout from using GIT_SERVER='my.host.with.git.daemon', if you have set up a `git daemon` to pull local commits from. (In this case, the FORK should be set to the path to the repository, and you will need to allow the git daemon to serve the repo (see `git help daemon`)). If there is a Beaker options hash in a ./local_options.rb, it will be included. Commandline options set through the above environment variables will override settings in this file. EOS desc <<-EOS Run the acceptance tests through Beaker and install packages on the configuration targets. #{USAGE} EOS task :packages => 'ci:check_env' do beaker_test end desc <<-EOS Run the acceptance tests through Beaker and install packages as part of the AIO puppet-agent installation. #{USAGE} EOS task :aio => 'ci:check_env' do beaker_test(:aio) end desc <<-EOS Run the acceptance tests through Beaker and install from git on the configuration targets. #{USAGE} EOS task :git => 'ci:check_env' do beaker_test(:git) end end desc "Capture the master and agent hostname from the latest log and construct a preserved_config.yaml for re-running against preserved hosts without provisioning." task :extract_preserved_config do generate_config_for_latest_hosts end desc <<-EOS Run an acceptance test for a given node configuration and preserve the hosts. Defaults to a packages run, but you can set it to 'git' with TYPE='git'. #{USAGE} EOS task :test_and_preserve_hosts => 'ci:check_env' do beaker_test(beaker_run_type, :preserve_hosts => 'always', :__preserve_config__ => true) end desc "List acceptance runs from the past day which had hosts preserved." task :list_preserved do preserved = list_preserved_configurations print_preserved(preserved) end desc <<-EOS Shutdown and destroy any hosts that we have preserved for testing. These should be reaped daily by scripts, but this will free up resources immediately. Specify a list of comma separated HOST_NAMES if you have a set of dynamic vcloud host names you want to purge outside of what can be grepped from the logs. You can go back through the last SECS_AGO logs. Default is one day ago in secs. EOS task :destroy_preserved_hosts do host_names = ENV['HOST_NAMES'].split(',') if ENV['HOST_NAMES'] secs_ago = ENV['SECS_AGO'] destroy_preserved_hosts(host_names, secs_ago) end desc <<-EOS Rerun an acceptance test using the last captured preserved_config.yaml to skip provisioning. Or specify a CONFIG_NUMBER from `rake ci:list_preserved`. Uses the setup/rsync/pre-suite to rsync the local puppet source onto master and agent. You may specify an RSYNC_FILTER_FILE as well. You may skip purgeing and reinstalling puppet packages by including SKIP_PACKAGE_REINSTALL. You may skip rsyncing local puppet files over to the tests hosts by including SKIP_RSYNC. Defaults to a packages run, but you can set it to 'git' with TYPE='git'. EOS task :test_against_preserved_hosts do config_number = (ENV['CONFIG_NUMBER'] || 0).to_i preserved = list_preserved_configurations print_preserved(preserved) config_path = preserved[config_number][0] puts "Using ##{config_number}: #{config_path}" beaker_test(beaker_run_type, :hosts_file => "#{config_path}/preserved_config.yaml", :no_provision => true, :preserve_hosts => 'always', :pre_suite => ['setup/rsync/pre-suite'] ) end end task :default do sh('rake -T') end facter-2.4.6/acceptance/bin/0000775005276200011600000000000012651736741015533 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/bin/ci-bootstrap-from-artifacts.sh0000775005276200011600000000267312651736735023432 0ustar jenkinsjenkins#! /usr/bin/env bash ############################################################################### # Initial preparation for a ci acceptance job in Jenkins. Crucially, it # handles the untarring of the build artifact and bundle install, getting us to # a state where we can then bundle exec rake the particular ci:test we want to # run. # # Having this checked in in a script makes it much easier to have multiple # acceptance jobs. It must be kept agnostic between Linux/Solaris/Windows # builds, however. set -x # If $GEM_SOURCE is not set, fall back to rubygems.org if [ -z $GEM_SOURCE ]; then export GEM_SOURCE='https://rubygems.org' fi echo "SHA: ${SHA}" echo "FORK: ${FORK}" echo "BUILD_SELECTOR: ${BUILD_SELECTOR}" echo "PACKAGE_BUILD_STATUS: ${PACKAGE_BUILD_STATUS}" rm -rf acceptance tar -xzf acceptance-artifacts.tar.gz cd acceptance mkdir -p log/latest echo "===== This artifact is from =====" cat creator.txt bundle install --without=development --path=.bundle/gems if [[ "${platform}" =~ 'solaris' ]]; then repo_proxy=" :repo_proxy => false," fi # If the platform is Windows, append $ruby_arch if [[ "${platform}" =~ 'win' ]]; then platform="${platform}-${ruby_arch}" fi cat > local_options.rb <<-EOF { :hosts_file => 'config/nodes/${platform}.yaml', :ssh => { :keys => ["${HOME}/.ssh/id_rsa-acceptance"], }, ${repo_proxy} } EOF [[ (-z "${PACKAGE_BUILD_STATUS}") || ("${PACKAGE_BUILD_STATUS}" = "success") ]] || exit 1 facter-2.4.6/acceptance/config/0000775005276200011600000000000012651736741016230 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/config/aio/0000775005276200011600000000000012651736741017000 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/config/aio/options.rb0000664005276200011600000000012712651736735021023 0ustar jenkinsjenkins{ :type => 'aio', :pre_suite => [ 'setup/aio/pre-suite/010_Install.rb', ], } facter-2.4.6/acceptance/config/git/0000775005276200011600000000000012651736741017013 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/config/git/options.rb0000664005276200011600000000015112651736735021033 0ustar jenkinsjenkins{ :pre_suite => [ 'setup/common/00_EnvSetup.rb', 'setup/git/pre-suite/01_TestSetup.rb', ], } facter-2.4.6/acceptance/config/nodes/0000775005276200011600000000000012651736741017340 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/config/nodes/centos-5-i386.yaml0000664005276200011600000000047312651736735022357 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: centos-5-i386 hypervisor: vcloud template: centos-5-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/centos-5-x86_64.yaml0000664005276200011600000000047712651736735022630 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: centos-5-x86_64 hypervisor: vcloud template: centos-5-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/centos-6-i386.yaml0000664005276200011600000000047312651736735022360 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: centos-6-i386 hypervisor: vcloud template: centos-6-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/centos-6-x86_64.yaml0000664005276200011600000000047712651736735022631 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: centos-6-x86_64 hypervisor: vcloud template: centos-6-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/debian-6-i386.yaml0000664005276200011600000000050112651736735022277 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: debian-squeeze-i386 hypervisor: vcloud template: debian-6-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/debian-6-x86_64.yaml0000664005276200011600000000050512651736735022550 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: debian-squeeze-x86_64 hypervisor: vcloud template: debian-6-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/debian-7-i386.yaml0000664005276200011600000000050012651736735022277 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: debian-wheezy-i386 hypervisor: vcloud template: debian-7-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/debian-7-x86_64.yaml0000664005276200011600000000050412651736735022550 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: debian-wheezy-x86_64 hypervisor: vcloud template: debian-7-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/debian-8-i386.yaml0000664005276200011600000000050012651736735022300 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: debian-jessie-i386 hypervisor: vcloud template: debian-8-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/debian-8-x86_64.yaml0000664005276200011600000000050412651736735022551 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: debian-jessie-x86_64 hypervisor: vcloud template: debian-8-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/fedora-20-i386.yaml0000664005276200011600000000047512651736735022403 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: fedora-20-i386 hypervisor: vcloud template: fedora-20-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/fedora-20-x86_64.yaml0000664005276200011600000000050112651736735022636 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: fedora-20-x86_64 hypervisor: vcloud template: fedora-20-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/fedora-21-i386.yaml0000664005276200011600000000047512651736735022404 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: fedora-21-i386 hypervisor: vcloud template: fedora-21-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/fedora-21-x86_64.yaml0000664005276200011600000000050112651736735022637 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: fedora-21-x86_64 hypervisor: vcloud template: fedora-21-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/redhat-5-i386.yaml0000664005276200011600000000046712651736735022336 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: el-5-i386 hypervisor: vcloud template: redhat-5-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/redhat-5-x86_64.yaml0000664005276200011600000000047312651736735022600 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: el-5-x86_64 hypervisor: vcloud template: redhat-5-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/redhat-6-i386.yaml0000664005276200011600000000046712651736735022337 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: el-6-i386 hypervisor: vcloud template: redhat-6-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/redhat-6-x86_64.yaml0000664005276200011600000000047312651736735022601 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: el-6-x86_64 hypervisor: vcloud template: redhat-6-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/redhat-7-x86_64.yaml0000664005276200011600000000047312651736735022602 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: el-7-x86_64 hypervisor: vcloud template: redhat-7-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/ubuntu-1204-i386.yaml0000664005276200011600000000050412651736735022623 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: ubuntu-precise-i386 hypervisor: vcloud template: ubuntu-1204-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/ubuntu-1204-x86_64.yaml0000664005276200011600000000051012651736735023065 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: ubuntu-precise-x86_64 hypervisor: vcloud template: ubuntu-1204-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/ubuntu-1404-i386.yaml0000664005276200011600000000050312651736735022624 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: ubuntu-trusty-i386 hypervisor: vcloud template: ubuntu-1404-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/ubuntu-1404-x86_64.yaml0000664005276200011600000000050712651736735023075 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: ubuntu-trusty-x86_64 hypervisor: vcloud template: ubuntu-1404-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/ubuntu-1410-i386.yaml0000664005276200011600000000050312651736735022621 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: ubuntu-utopic-i386 hypervisor: vcloud template: ubuntu-1410-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/ubuntu-1410-x86_64.yaml0000664005276200011600000000050712651736735023072 0ustar jenkinsjenkins--- HOSTS: agent: roles: - agent platform: ubuntu-utopic-x86_64 hypervisor: vcloud template: ubuntu-1410-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2003r2x64-rubyx64.yaml0000664005276200011600000000055412651736735023464 0ustar jenkinsjenkins--- HOSTS: agent-2003r2-x86_64-rubyx64: roles: - agent platform: windows-2003r2-64 ruby_arch: x64 hypervisor: vcloud template: win-2003r2-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2003r2x64-rubyx86.yaml0000664005276200011600000000055412651736735023470 0ustar jenkinsjenkins--- HOSTS: agent-2003r2-x86_64-rubyx86: roles: - agent platform: windows-2003r2-64 ruby_arch: x86 hypervisor: vcloud template: win-2003r2-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2003r2x86-rubyx86.yaml0000664005276200011600000000054012651736735023467 0ustar jenkinsjenkins--- HOSTS: agent-2003r2-i386: roles: - agent platform: windows-2003r2-32 ruby_arch: x86 hypervisor: vcloud template: win-2003r2-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2003x64-rubyx64.yaml0000664005276200011600000000054612651736735023221 0ustar jenkinsjenkins--- HOSTS: agent-2003-x86_64-rubyx64: roles: - agent platform: windows-2003-64 ruby_arch: x64 hypervisor: vcloud template: win-2003-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2003x64-rubyx86.yaml0000664005276200011600000000054612651736735023225 0ustar jenkinsjenkins--- HOSTS: agent-2003-x86_64-rubyx86: roles: - agent platform: windows-2003-64 ruby_arch: x86 hypervisor: vcloud template: win-2003-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2003x86-rubyx86.yaml0000664005276200011600000000053212651736735023224 0ustar jenkinsjenkins--- HOSTS: agent-2003-i386: roles: - agent platform: windows-2003-32 ruby_arch: x86 hypervisor: vcloud template: win-2003-i386 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2008-rubyx64.yaml0000664005276200011600000000054612651736735022664 0ustar jenkinsjenkins--- HOSTS: agent-2008-x86_64-rubyx64: roles: - agent platform: windows-2008-64 ruby_arch: x64 hypervisor: vcloud template: win-2008-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2008-rubyx86.yaml0000664005276200011600000000054612651736735022670 0ustar jenkinsjenkins--- HOSTS: agent-2008-x86_64-rubyx86: roles: - agent platform: windows-2008-64 ruby_arch: x86 hypervisor: vcloud template: win-2008-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2008r2-rubyx64.yaml0000664005276200011600000000055412651736735023127 0ustar jenkinsjenkins--- HOSTS: agent-2008r2-x86_64-rubyx64: roles: - agent platform: windows-2008r2-64 ruby_arch: x64 hypervisor: vcloud template: win-2008r2-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2008r2-rubyx86.yaml0000664005276200011600000000055412651736735023133 0ustar jenkinsjenkins--- HOSTS: agent-2008r2-x86_64-rubyx86: roles: - agent platform: windows-2008r2-64 ruby_arch: x86 hypervisor: vcloud template: win-2008r2-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2012-rubyx64.yaml0000664005276200011600000000054612651736735022657 0ustar jenkinsjenkins--- HOSTS: agent-2012-x86_64-rubyx64: roles: - agent platform: windows-2012-64 ruby_arch: x64 hypervisor: vcloud template: win-2012-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2012-rubyx86.yaml0000664005276200011600000000054612651736735022663 0ustar jenkinsjenkins--- HOSTS: agent-2012-x86_64-rubyx86: roles: - agent platform: windows-2012-64 ruby_arch: x86 hypervisor: vcloud template: win-2012-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2012r2-rubyx64.yaml0000664005276200011600000000055412651736735023122 0ustar jenkinsjenkins--- HOSTS: agent-2012r2-x86_64-rubyx64: roles: - agent platform: windows-2012r2-64 ruby_arch: x64 hypervisor: vcloud template: win-2012r2-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/nodes/win2012r2-rubyx86.yaml0000664005276200011600000000055412651736735023126 0ustar jenkinsjenkins--- HOSTS: agent-2012r2-x86_64-rubyx86: roles: - agent platform: windows-2012r2-64 ruby_arch: x86 hypervisor: vcloud template: win-2012r2-x86_64 CONFIG: datastore: instance0 resourcepool: delivery/Quality Assurance/FOSS/Dynamic folder: Delivery/Quality Assurance/FOSS/Dynamic pooling_api: http://vmpooler.delivery.puppetlabs.net/ facter-2.4.6/acceptance/config/packages/0000775005276200011600000000000012651736741020006 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/config/packages/options.rb0000664005276200011600000000015512651736735022032 0ustar jenkinsjenkins{ :pre_suite => [ 'setup/common/00_EnvSetup.rb', 'setup/packages/pre-suite/010_Install.rb', ], } facter-2.4.6/acceptance/lib/0000775005276200011600000000000012651736741015531 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/lib/helper.rb0000664005276200011600000000006712651736735017343 0ustar jenkinsjenkins$LOAD_PATH << File.expand_path(File.dirname(__FILE__)) facter-2.4.6/acceptance/lib/puppet/0000775005276200011600000000000012651736741017046 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/lib/puppet/acceptance/0000775005276200011600000000000012651736742021135 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/lib/puppet/acceptance/common_utils.rb0000664005276200011600000000074312651736735024200 0ustar jenkinsjenkinsmodule Puppet module Acceptance module CommandUtils def ruby_command(host) "env PATH=\"#{host['privatebindir']}:${PATH}\" ruby" end module_function :ruby_command def gem_command(host) if host['platform'] =~ /windows/ "env PATH=\"#{host['privatebindir']}:${PATH}\" cmd /c gem" else "env PATH=\"#{host['privatebindir']}:${PATH}\" gem" end end module_function :gem_command end end end facter-2.4.6/acceptance/lib/puppet/acceptance/git_utils.rb0000664005276200011600000000131612651736735023470 0ustar jenkinsjenkinsmodule Puppet module Acceptance module GitUtils def lookup_in_env(env_variable_name, project_name, default) project_specific_name = "#{project_name.upcase.gsub("-","_")}_#{env_variable_name}" ENV[project_specific_name] || ENV[env_variable_name] || default end def build_giturl(project_name, git_fork = nil, git_server = nil) git_fork ||= lookup_in_env('FORK', project_name, 'puppetlabs') git_server ||= lookup_in_env('GIT_SERVER', project_name, 'github.com') repo = (git_server == 'github.com') ? "#{git_fork}/#{project_name}.git" : "#{git_fork}-#{project_name}.git" "git://#{git_server}/#{repo}" end end end end facter-2.4.6/acceptance/lib/puppet/acceptance/install_utils.rb0000664005276200011600000002416612651736735024363 0ustar jenkinsjenkinsrequire 'open-uri' require 'open3' require 'uri' require 'puppet/acceptance/common_utils' module Puppet module Acceptance module InstallUtils PLATFORM_PATTERNS = { :debian => /debian|ubuntu/, :debian_ruby18 => /debian|ubuntu-lucid|ubuntu-precise/, :redhat => /fedora|el|centos/, :sles => /sles/, :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 def fetch(base_url, file_name, dst_dir) FileUtils.makedirs(dst_dir) src = "#{base_url}/#{file_name}" dst = File.join(dst_dir, file_name) if File.exists?(dst) logger.notify "Already fetched #{dst}" else logger.notify "Fetching: #{src}" logger.notify " and saving to #{dst}" open(src) do |remote| File.open(dst, "w") do |file| FileUtils.copy_stream(remote, file) end end end return dst end def fetch_remote_dir(url, dst_dir) logger.notify "fetch_remote_dir (url: #{url}, dst_dir #{dst_dir})" if url[-1, 1] !~ /\// url += '/' end url = URI.parse(url) chunks = url.path.split('/') dst = File.join(dst_dir, chunks.last) #determine directory structure to cut #only want to keep the last directory, thus cut total number of dirs - 2 (hostname + last dir name) cut = chunks.length - 2 wget_command = "wget -nv -P #{dst_dir} --reject \"index.html*\",\"*.gif\" --cut-dirs=#{cut} -np -nH --no-check-certificate -r #{url}" logger.notify "Fetching remote directory: #{url}" logger.notify " and saving to #{dst}" logger.notify " using command: #{wget_command}" #in ruby 1.9+ we can upgrade this to popen3 to gain access to the subprocess pid result = `#{wget_command} 2>&1` result.each_line do |line| logger.debug(line) end if $?.to_i != 0 raise "Failed to fetch_remote_dir '#{url}' (exit code #{$?}" end dst end def stop_firewall_on(host) case host['platform'] when /debian/ on host, 'iptables -F' when /fedora|el-7/ on host, puppet('resource', 'service', 'firewalld', 'ensure=stopped') when /el|centos/ on host, puppet('resource', 'service', 'iptables', 'ensure=stopped') when /ubuntu/ on host, puppet('resource', 'service', 'ufw', 'ensure=stopped') else logger.notify("Not sure how to clear firewall on #{host['platform']}") end end def install_repos_on(host, project, sha, repo_configs_dir) platform = host['platform'].with_version_codename platform_configs_dir = File.join(repo_configs_dir,platform) tld = sha == 'nightly' ? 'nightlies.puppetlabs.com' : 'builds.puppetlabs.lan' project = sha == 'nightly' ? project + '-latest' : project sha = sha == 'nightly' ? nil : sha case platform when /^(fedora|el|centos)-(\d+)-(.+)$/ variant = (($1 == 'centos') ? 'el' : $1) fedora_prefix = ((variant == 'fedora') ? 'f' : '') version = $2 arch = $3 rpm = fetch( "http://yum.puppetlabs.com", "puppetlabs-release-%s-%s.noarch.rpm" % [variant, version], platform_configs_dir ) pattern = "pl-%s%s-%s-%s%s-%s.repo" repo_filename = pattern % [ project, sha ? '-' + sha : '', variant, fedora_prefix, version, arch ] repo = fetch( "http://%s/%s/%s/repo_configs/rpm/" % [tld, project, sha], repo_filename, platform_configs_dir ) link = "http://%s/%s/%s/repos/%s/%s%s/PC1/%s/" % [ tld, project, sha, variant, fedora_prefix, version, arch ] if not link_exists?(link) link = "http://%s/%s/%s/repos/%s/%s%s/products/%s/" % [ tld, project, sha, variant, fedora_prefix, version, arch ] end if not link_exists?(link) link = "http://%s/%s/%s/repos/%s/%s%s/devel/%s/" % [ tld, project, sha, variant, fedora_prefix, version, arch ] end if not link_exists?(link) raise "Unable to reach a repo directory at #{link}" end repo_dir = fetch_remote_dir(link, platform_configs_dir) repo_loc = "/root/#{project}" on host, "rm -rf #{repo_loc}" on host, "mkdir -p #{repo_loc}" scp_to host, rpm, repo_loc scp_to host, repo, repo_loc scp_to host, repo_dir, repo_loc on host, "cp #{repo_loc}/*.repo /etc/yum.repos.d" on host, "find /etc/yum.repos.d/ -name \"*.repo\" -exec sed -i \"s/baseurl\\s*=\\s*http:\\/\\/#{tld}.*$/baseurl=file:\\/\\/\\/root\\/#{project}\\/#{arch}/\" {} \\;" on host, "rpm -Uvh --force #{repo_loc}/*.rpm" when /^(debian|ubuntu)-([^-]+)-(.+)$/ variant = $1 version = $2 arch = $3 deb = fetch( "http://apt.puppetlabs.com/", "puppetlabs-release-%s.deb" % version, platform_configs_dir ) list = fetch( "http://%s/%s/%s/repo_configs/deb/" % [tld, project, sha], "pl-%s%s-%s.list" % [project, sha ? '-' + sha : '', version], platform_configs_dir ) repo_dir = fetch_remote_dir("http://%s/%s/%s/repos/apt/%s" % [tld, project, sha, version], platform_configs_dir) repo_loc = "/root/#{project}" on host, "rm -rf #{repo_loc}" on host, "mkdir -p #{repo_loc}" scp_to host, deb, repo_loc scp_to host, list, repo_loc scp_to host, repo_dir, repo_loc pc1_check = on(host, "[[ -d /root/#{project}/#{version}/pool/PC1 ]]", :acceptable_exit_codes => [0,1]) repo_name = pc1_check.exit_code == 0 ? 'PC1' : 'main' on host, "cp #{repo_loc}/*.list /etc/apt/sources.list.d" on host, "find /etc/apt/sources.list.d/ -name \"*.list\" -exec sed -i \"s/deb\\s\\+http:\\/\\/#{tld}.*$/deb file:\\/\\/\\/root\\/#{project}\\/#{version} #{version} #{repo_name}/\" {} \\;" on host, "dpkg -i --force-all #{repo_loc}/*.deb" on host, "apt-get update" else host.logger.notify("No repository installation step for #{platform} yet...") end end # Configures gem sources on hosts to use a mirror, if specified # This is a duplicate of the Gemfile logic. def configure_gem_mirror(hosts) hosts = [hosts] unless hosts.kind_of?(Array) gem_source = ENV['GEM_SOURCE'] || 'https://rubygems.org' hosts.each do |host| case host['platform'] when /windows/ gem = 'cmd /c gem' else gem = 'gem' end on host, "#{gem} source --clear-all" on host, "#{gem} source --add #{gem_source}" end end def install_puppet_from_msi( host, opts ) if not link_exists?(opts[:url]) raise "Puppet does not exist at #{opts[:url]}!" end # `start /w` blocks until installation is complete, but needs to be wrapped in `cmd.exe /c` on host, "cmd.exe /c start /w msiexec /qn /i #{opts[:url]} /L*V C:\\\\Windows\\\\Temp\\\\Puppet-Install.log" # make sure the background service isn't running while the test executes on host, "net stop puppet" # make sure install is sane, beaker has already added puppet and ruby # to PATH in ~/.ssh/environment on host, puppet('--version') ruby = Puppet::Acceptance::CommandUtils.ruby_command(host) on host, "#{ruby} --version" end end end end facter-2.4.6/acceptance/setup/0000775005276200011600000000000012651736742016124 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/aio/0000775005276200011600000000000012651736742016674 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/aio/pre-suite/0000775005276200011600000000000012651736742020611 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/aio/pre-suite/010_Install.rb0000664005276200011600000000167612651736735023140 0ustar jenkinsjenkinsrequire 'puppet/acceptance/install_utils' extend Puppet::Acceptance::InstallUtils require 'beaker/dsl/install_utils' extend Beaker::DSL::InstallUtils test_name "Install Packages" step "Install repositories on target machines..." do sha = ENV['SHA'] repo_configs_dir = 'repo-configs' hosts.each do |host| install_repos_on(host, 'puppet-agent', sha, repo_configs_dir) end end PACKAGES = { :redhat => [ 'puppet-agent', ], :debian => [ 'puppet-agent', ], # :solaris => [ # 'puppet', # ], # :windows => [ # 'puppet', # ], } install_packages_on(hosts, PACKAGES) agents.each do |agent| if agent['platform'] =~ /windows/ arch = agent[:ruby_arch] || 'x86' base_url = ENV['MSI_BASE_URL'] || "http://builds.puppetlabs.lan/puppet-agent/#{ENV['SHA']}/artifacts/windows" filename = ENV['MSI_FILENAME'] || "puppet-agent-#{arch}.msi" install_puppet_from_msi(agent, :url => "#{base_url}/#{filename}") end end facter-2.4.6/acceptance/setup/common/0000775005276200011600000000000012651736742017414 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/common/00_EnvSetup.rb0000664005276200011600000000333012651736735022012 0ustar jenkinsjenkinstest_name "Setup environment" step "Ensure Git and Ruby" require 'puppet/acceptance/install_utils' extend Puppet::Acceptance::InstallUtils require 'puppet/acceptance/git_utils' extend Puppet::Acceptance::GitUtils require 'beaker/dsl/install_utils' extend Beaker::DSL::InstallUtils PACKAGES = { :redhat => [ 'git', 'ruby', 'rubygem-json', ], :debian => [ ['git', 'git-core'], 'ruby', ], :debian_ruby18 => [ 'libjson-ruby', ], :solaris => [ ['git', 'developer/versioning/git'], ['ruby', 'runtime/ruby-18'], # there isn't a package for json, so it is installed later via gems ], :windows => [ 'git', # there isn't a need for json on windows because it is bundled in ruby 1.9 ], } install_packages_on(hosts, PACKAGES, :check_if_exists => true) hosts.each do |host| case host['platform'] when /windows/ step "#{host} Install ruby from git" ruby_arch = host[:ruby_arch] || 'x86' revision = if ruby_arch == 'x64' '2.0.0-x64' else '1.9.3-x86' end install_from_git(host, "/opt/puppet-git-repos", :name => 'puppet-win32-ruby', :path => build_giturl('puppet-win32-ruby'), :rev => revision) 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, 'cd /; icacls bin /grant "Everyone:(OI)(CI)(RX)"' on host, 'cd /; icacls bin /reset /T' on host, 'ruby --version' on host, 'cmd /c gem list' when /solaris/ step "#{host} Install json from rubygems" on host, 'gem install json' end end facter-2.4.6/acceptance/setup/git/0000775005276200011600000000000012651736742016707 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/git/pre-suite/0000775005276200011600000000000012651736742020624 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/git/pre-suite/01_TestSetup.rb0000775005276200011600000000177412651736735023427 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-2.4.6/acceptance/setup/packages/0000775005276200011600000000000012651736742017702 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/packages/pre-suite/0000775005276200011600000000000012651736742021617 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/setup/packages/pre-suite/010_Install.rb0000664005276200011600000000110612651736735024132 0ustar jenkinsjenkinsrequire 'puppet/acceptance/install_utils' extend Puppet::Acceptance::InstallUtils require 'beaker/dsl/install_utils' extend Beaker::DSL::InstallUtils test_name "Install Packages" step "Install repositories on target machines..." do sha = ENV['SHA'] repo_configs_dir = 'repo-configs' hosts.each do |host| install_repos_on(host, 'facter', sha, repo_configs_dir) end end PACKAGES = { :redhat => [ 'facter', ], :debian => [ 'facter', ], # :solaris => [ # 'puppet', # ], # :windows => [ # 'puppet', # ], } install_packages_on(hosts, PACKAGES) facter-2.4.6/acceptance/tests/0000775005276200011600000000000012651736742016126 5ustar jenkinsjenkinsfacter-2.4.6/acceptance/tests/facter_json_output_validates.rb0000664005276200011600000000071512651736735024431 0ustar jenkinsjenkinsrequire 'json' require 'json-schema' test_name "Running facter --json should validate against the schema" agents.each do |agent| step "Agent #{agent}: run 'facter --json' and validate" on(agent, facter('--json')) do # Validate that the output facts match the facter schema FACTER_SCHEMA = JSON.parse(File.read('../schema/facter.json')) fail_test "facter --json was invalid" unless JSON::Validator.validate!(FACTER_SCHEMA, stdout) end end facter-2.4.6/acceptance/tests/no_errors_on_stderr.rb0000664005276200011600000000040712651736735022545 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-2.4.6/acceptance/tests/operatingsystem_detection_after_clear_on_ubuntu.rb0000664005276200011600000000076612651736735030406 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, "#{agent['privatebindir']}/ruby #{script_name}") end facter-2.4.6/acceptance/tests/runs_external_facts_once.rb0000664005276200011600000000270112651736735023532 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 = '/opt/puppetlabs/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-2.4.6/acceptance/tests/ticket_7039_facter_multiple_facts_one_file.rb0000664005276200011600000000165112651736735026704 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-2.4.6/bin/0000775005276200011600000000000012651736742013446 5ustar jenkinsjenkinsfacter-2.4.6/bin/facter0000775005276200011600000000112512651736735014641 0ustar jenkinsjenkins#!/usr/bin/env ruby # For security reasons, ensure that '.' is not on the load path # This is primarily for 1.8.7 since 1.9.2+ doesn't put '.' on the load path $LOAD_PATH.delete '.' # 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-2.4.6/documentation/0000775005276200011600000000000012651736742015547 5ustar jenkinsjenkinsfacter-2.4.6/documentation/custom.page0000664005276200011600000000131512651736735017721 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-2.4.6/documentation/index.page0000664005276200011600000000120212651736735017511 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-2.4.6/etc/0000775005276200011600000000000012651736742013451 5ustar jenkinsjenkinsfacter-2.4.6/etc/facter.conf0000664005276200011600000000010012651736735015555 0ustar jenkinsjenkinsHostname OperatingSystem OperatingSystemRelease SSHDSAKey CfKey facter-2.4.6/ext/0000775005276200011600000000000012651736742013476 5ustar jenkinsjenkinsfacter-2.4.6/ext/build_defaults.yaml0000664005276200011600000000174512651736735017361 0ustar jenkinsjenkins--- packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master' packaging_repo: 'packaging' default_cow: 'base-squeeze-i386.cow' cows: 'base-precise-i386.cow base-precise-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-trusty-i386.cow base-trusty-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-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-2.4.6/ext/debian/0000775005276200011600000000000012651736742014720 5ustar jenkinsjenkinsfacter-2.4.6/ext/debian/compat0000664005276200011600000000000212651736735016120 0ustar jenkinsjenkins7 facter-2.4.6/ext/debian/control0000664005276200011600000000113612651736735016326 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: all Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter, virt-what, pciutils Recommends: lsb-release, dmidecode 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-2.4.6/ext/debian/copyright0000664005276200011600000000067212651736735016662 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-2.4.6/ext/debian/docs0000664005276200011600000000001212651736735015566 0ustar jenkinsjenkinsREADME.md facter-2.4.6/ext/debian/lintian-overrides0000664005276200011600000000000012651736735020271 0ustar jenkinsjenkinsfacter-2.4.6/ext/debian/rules0000775005276200011600000000067112651736735016006 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-2.4.6/ext/debian/source/0000775005276200011600000000000012651736742016220 5ustar jenkinsjenkinsfacter-2.4.6/ext/debian/source/format0000664005276200011600000000001412651736735017430 0ustar jenkinsjenkins3.0 (quilt) facter-2.4.6/ext/debian/changelog0000664005276200011600000000444212651736742016576 0ustar jenkinsjenkinsfacter (2.4.6-1puppetlabs1) lucid unstable sid wheezy lucid squeeze precise quantal raring; urgency=low * Update to version -- Puppet Labs Release Tue, 26 Jan 2016 10:41:38 -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-2.4.6/ext/facter-diff0000775005276200011600000000311212651736735015575 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-2.4.6/ext/ips/0000775005276200011600000000000012651736742014271 5ustar jenkinsjenkinsfacter-2.4.6/ext/ips/rules0000775005276200011600000000042112651736735015350 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-2.4.6/ext/ips/transforms0000664005276200011600000000126712651736735016422 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-2.4.6/ext/ips/facter.p5m0000664005276200011600000000114312651736742016157 0ustar jenkinsjenkinsset name=pkg.fmri value=pkg://puppetlabs.com/application/@2.4.6,14.5.0-0 set name=pkg.summary value="Facter, a system inventory tool" set name=pkg.human-version value="2.4.6" 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-2.4.6/ext/osx/0000775005276200011600000000000012651736742014307 5ustar jenkinsjenkinsfacter-2.4.6/ext/osx/file_mapping.yaml0000664005276200011600000000110212651736735017621 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' man/man8: path: 'usr/share/man/man8' owner: 'root' group: 'wheel' perms: '0755' files: '[A-Z]*': path: 'usr/share/doc/facter' owner: 'root' group: 'wheel' perms: '0644' facter-2.4.6/ext/osx/preflight.erb0000664005276200011600000000203112651736735016763 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-2.4.6/ext/osx/prototype.plist.erb0000664005276200011600000000212612651736735020203 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-2.4.6/ext/project_data.yaml0000664005276200011600000000207312651736735017025 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' gem_platform_dependencies: universal-darwin: gem_runtime_dependencies: CFPropertyList: '~> 2.2.6' x86-mingw32: gem_runtime_dependencies: ffi: '~> 1.9.5' win32-dir: '~> 0.4.8' win32-security: '~> 0.2.5' win32console: '~> 1.3.2' x64-mingw32: gem_runtime_dependencies: ffi: '~> 1.9.5' win32-dir: '~> 0.4.8' win32-security: '~> 0.2.5' bundle_platforms: universal-darwin: ruby x86-mingw32: mingw x64-mingw32: x64_mingw pre_tasks: 'package:apple': 'cfpropertylist' facter-2.4.6/ext/redhat/0000775005276200011600000000000012651736742014745 5ustar jenkinsjenkinsfacter-2.4.6/ext/redhat/facter.spec0000664005276200011600000001603712651736742017074 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 2.4.6 %global rpmversion 2.4.6 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.7 Requires: which # dmidecode and pciutils are not available on all arches %ifarch %ix86 x86_64 ia64 Requires: dmidecode Requires: pciutils %endif Requires: virt-what # In Fedora 19+ or RHEL 7+ net-tools is required for interface facts %if 0%{?fedora} >= 19 || 0%{?rhel} >= 7 Requires: net-tools %endif BuildRequires: ruby >= 1.8.7 # 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 * Tue Jan 26 2016 Puppet Labs Release - 1:2.4.6-1 - Build for 2.4.6 * 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-2.4.6/ext/solaris/0000775005276200011600000000000012651736742015152 5ustar jenkinsjenkinsfacter-2.4.6/ext/solaris/pkginfo0000664005276200011600000000033712651736735016537 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-2.4.6/install.rb0000775005276200011600000002602212651736735014700 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('--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 if (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-2.4.6/lib/0000775005276200011600000000000012651736742013444 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter.rb0000664005276200011600000001426112651736735015243 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' # Functions as a hash of 'facts' about your system system, such as MAC # address, IP address, architecture, etc. # # @example Retrieve a fact # puts Facter['operatingsystem'].value # # @example Retrieve all facts # Facter.to_hash # => { "kernel"=>"Linux", "uptime_days"=>0, "ipaddress"=>"10.0.0.1" } # # @api public module Facter # Most core functionality of facter is implemented in `Facter::Util`. # @api public module Util; end require 'facter/util/fact' require 'facter/util/collection' include Comparable include Enumerable require 'facter/core/logging' extend Facter::Core::Logging # module methods # Accessor for the collection object which holds all the facts # @return [Facter::Util::Collection] the collection of facts # # @api private 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 # Returns whether the JSON "feature" is available. # # @api private def self.json? begin require 'json' true rescue LoadError false end end # Returns a fact object by name. If you use this, you still have to # call {Facter::Util::Fact#value `value`} on it to retrieve the actual # value. # # @param name [String] the name of the fact # # @return [Facter::Util::Fact, nil] The fact object, or nil if no fact # is found. # # @api public def self.[](name) collection.fact(name) end # (see []) def self.fact(name) collection.fact(name) end # Flushes cached values for all facts. This does not cause code to be # reloaded; it only clears the cached results. # # @return [void] # # @api public def self.flush collection.flush end # Lists all fact names # # @return [Array] array of fact names # # @api public def self.list collection.list end # Gets the value for a fact. Returns `nil` if no such fact exists. # # @param name [String] the fact name # @return [Object, nil] the value of the fact, or nil if no fact is # found # # @api public def self.value(name) collection.value(name) end # Gets a hash mapping fact names to their values # # @return [Hash{String => Object}] the hash of fact names and values # # @api public def self.to_hash collection.load_all collection.to_hash end # Define a new fact or extend an existing fact. # # @param name [Symbol] The name of the fact to define # @param options [Hash] A hash of options to set on the fact # # @return [Facter::Util::Fact] The fact that was defined # # @api public # @see {Facter::Util::Collection#define_fact} def self.define_fact(name, options = {}, &block) collection.define_fact(name, options, &block) end # Adds a {Facter::Util::Resolution resolution} mechanism for a named # fact. This does not distinguish between adding a new fact and adding # a new way to resolve a fact. # # @overload add(name, options = {}, { || ... }) # @param name [String] the fact name # @param options [Hash] optional parameters for the fact - attributes # of {Facter::Util::Fact} and {Facter::Util::Resolution} can be # supplied here # @option options [Integer] :timeout set the # {Facter::Util::Resolution#timeout timeout} for this resolution # @param block [Proc] a block defining a fact resolution # # @return [Facter::Util::Fact] the fact object, which includes any previously # defined resolutions # # @api public def self.add(name, options = {}, &block) collection.add(name, options, &block) end # Iterates over fact names and values # # @yieldparam [String] name the fact name # @yieldparam [String] value the current value of the fact # # @return [void] # # @api public def self.each # Make sure all facts are loaded. collection.load_all collection.each do |*args| yield(*args) end end # Clears all cached values and removes all facts from memory. # # @return [void] # # @api public def self.clear Facter.flush Facter.reset end # Removes all facts from memory. Use this when the fact code has # changed on disk and needs to be reloaded. # # @return [void] # # @api public def self.reset @collection = nil reset_search_path! end # Loads all facts. # # @return [void] # # @api public def self.loadfacts collection.load_all end # Register directories to be searched for facts. The registered directories # must be absolute paths or they will be ignored. # # @param dirs [String] directories to search # # @return [void] # # @api public def self.search(*dirs) @search_path += dirs end # Returns the registered search directories. # # @return [Array] An array of the directories searched # # @api public def self.search_path @search_path.dup end # Reset the Facter search directories. # # @api private # @return [void] def self.reset_search_path! @search_path = [] end reset_search_path! # Registers directories to be searched for external facts. # # @param dirs [Array] directories to search # # @return [void] # # @api public def self.search_external(dirs) Facter::Util::Config.external_facts_dirs += dirs end # Returns the registered search directories. # # @return [Array] An array of the directories searched # # @api public def self.search_external_path Facter::Util::Config.external_facts_dirs.dup end end facter-2.4.6/lib/facter/0000775005276200011600000000000012651736742014710 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/Cfkey.rb0000664005276200011600000000162612651736735016305 0ustar jenkinsjenkins# Fact: cfkey # # Purpose: Return the public key(s) for CFengine. # # Resolution: # Tries each file of standard `localhost.pub` and `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-2.4.6/lib/facter/application.rb0000664005276200011600000001257512651736735017554 0ustar jenkinsjenkinsrequire 'optparse' require 'facter' require 'facter/util/formatter' module 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 Facter.log_exception(error, "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) 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 Facter.log_exception(error, "Could not retrieve #{name}: #{error.message}") exit(10) end end end # Print everything if they didn't ask for specific facts. facts ||= Facter.to_hash output = nil if options[:yaml] output = Facter::Util::Formatter.format_yaml(facts) elsif options[:json] output = Facter::Util::Formatter.format_json(facts) elsif options[:plaintext] output = Facter::Util::Formatter.format_plaintext(facts) else output = Facter::Util::Formatter.format_plaintext(facts) end puts output exit(0) rescue => e Facter.log_exception(e) exit(12) 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 facter(8) -- Gather system information ====== SYNOPSIS -------- Collect and display facts about the system. USAGE ----- facter [-h|--help] [-t|--timing] [-d|--debug] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [--plaintext] [--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 ------- Display all facts: $ facter architecture => amd64 blockdevices => sda,sr0 domain => example.com fqdn => puppet.example.com hardwaremodel => x86_64 [...] Display a single fact: $ facter kernel Linux Format facts as JSON: $ facter --json architecture kernel hardwaremodel { "architecture": "amd64", "kernel": "Linux", "hardwaremodel": "x86_64" } AUTHOR ------ Luke Kanies COPYRIGHT --------- Copyright (c) 2011-2014 Puppet Labs, Inc Licensed under the Apache 2.0 license OPTIONS ------- 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("--plaintext", "Emit facts in plaintext format.") { |v| options[:plaintext] = v } opts.on("--trace", "Enable backtraces.") { |v| Facter.trace(true) } 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", "(Deprecated: use `puppet facts` instead) Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.") do |v| load_puppet end 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.initialize_settings # 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-2.4.6/lib/facter/architecture.rb0000664005276200011600000000212512651736735017721 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-2.4.6/lib/facter/augeasversion.rb0000664005276200011600000000143312651736735020113 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-2.4.6/lib/facter/blockdevices.rb0000664005276200011600000000563512651736735017705 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 separated 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-2.4.6/lib/facter/core/0000775005276200011600000000000012651736742015640 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/core/aggregate.rb0000664005276200011600000001343412651736735020122 0ustar jenkinsjenkinsrequire 'facter' require 'facter/core/directed_graph' require 'facter/core/suitable' require 'facter/core/resolvable' require 'facter/util/values' # Aggregates provide a mechanism for facts to be resolved in multiple steps. # # Aggregates are evaluated in two parts: generating individual chunks and then # aggregating all chunks together. Each chunk is a block of code that generates # a value, and may depend on other chunks when it runs. After all chunks have # been evaluated they are passed to the aggregate block as Hash. # The aggregate block converts the individual chunks into a single value that is # returned as the final value of the aggregate. # # @api public # @since 2.0.0 class Facter::Core::Aggregate include Facter::Core::Suitable include Facter::Core::Resolvable # @!attribute [r] name # @return [Symbol] The name of the aggregate resolution attr_reader :name # @!attribute [r] deps # @api private # @return [Facter::Core::DirectedGraph] attr_reader :deps # @!attribute [r] confines # @return [Array] An array of confines restricting # this to a specific platform # @see Facter::Core::Suitable attr_reader :confines # @!attribute [r] fact # @return [Facter::Util::Fact] # @api private attr_reader :fact def initialize(name, fact) @name = name @fact = fact @confines = [] @chunks = {} @aggregate = nil @deps = Facter::Core::DirectedGraph.new end def set_options(options) if options[:name] @name = options.delete(:name) end if options.has_key?(:timeout) @timeout = options.delete(:timeout) end if options.has_key?(:weight) @weight = options.delete(:weight) end if not options.keys.empty? raise ArgumentError, "Invalid aggregate options #{options.keys.inspect}" end end def evaluate(&block) instance_eval(&block) end # Define a new chunk for the given aggregate # # @api public # # @example Defining a chunk with no dependencies # aggregate.chunk(:mountpoints) do # # generate mountpoint information # end # # @example Defining an chunk to add mount options # aggregate.chunk(:mount_options, :require => [:mountpoints]) do |mountpoints| # # `mountpoints` is the result of the previous chunk # # generate mount option information based on the mountpoints # end # # @param name [Symbol] A name unique to this aggregate describing the chunk # @param opts [Hash] # @options opts [Array, Symbol] :require One or more chunks # to evaluate and pass to this block. # @yield [*Object] Zero or more chunk results # # @return [void] def chunk(name, opts = {}, &block) if not block_given? raise ArgumentError, "#{self.class.name}#chunk requires a block" end deps = Array(opts.delete(:require)) if not opts.empty? raise ArgumentError, "Unexpected options passed to #{self.class.name}#chunk: #{opts.keys.inspect}" end @deps[name] = deps @chunks[name] = block end # Define how all chunks should be combined # # @api public # # @example Merge all chunks # aggregate.aggregate do |chunks| # final_result = {} # chunks.each_value do |chunk| # final_result.deep_merge(chunk) # end # final_result # end # # @example Sum all chunks # aggregate.aggregate do |chunks| # total = 0 # chunks.each_value do |chunk| # total += chunk # end # total # end # # @yield [Hash] A hash containing chunk names and # chunk values # # @return [void] def aggregate(&block) if block_given? @aggregate = block else raise ArgumentError, "#{self.class.name}#aggregate requires a block" end end def resolution_type :aggregate end private # Evaluate the results of this aggregate. # # @see Facter::Core::Resolvable#value # @return [Object] def resolve_value chunk_results = run_chunks() aggregate_results(chunk_results) end # Order all chunks based on their dependencies and evaluate each one, passing # dependent chunks as needed. # # @return [Hash] A hash containing the chunk that # generated value and the related value. def run_chunks results = {} order_chunks.each do |(name, block)| input = @deps[name].map { |dep_name| results[dep_name] } output = block.call(*input) results[name] = Facter::Util::Values.deep_freeze(output) end results end # Process the results of all chunks with the aggregate block and return the # results. If no aggregate block has been specified, fall back to deep # merging the given data structure # # @param results [Hash] A hash of chunk names and the output # of that chunk. # @return [Object] def aggregate_results(results) if @aggregate @aggregate.call(results) else default_aggregate(results) end end def default_aggregate(results) results.values.inject do |result, current| Facter::Util::Values.deep_merge(result, current) end rescue Facter::Util::Values::DeepMergeError => e raise ArgumentError, "Could not deep merge all chunks (Original error: " + "#{e.message}), ensure that chunks return either an Array or Hash or " + "override the aggregate block", e.backtrace end # Order chunks based on their dependencies # # @return [Array] A list of chunk names and blocks in evaluation order. def order_chunks if not @deps.acyclic? raise DependencyError, "Could not order chunks; found the following dependency cycles: #{@deps.cycles.inspect}" end sorted_names = @deps.tsort sorted_names.map do |name| [name, @chunks[name]] end end class DependencyError < StandardError; end end facter-2.4.6/lib/facter/core/directed_graph.rb0000664005276200011600000000174212651736735021137 0ustar jenkinsjenkinsrequire 'set' require 'tsort' module Facter module Core class DirectedGraph < Hash include TSort def acyclic? cycles.empty? end def cycles cycles = [] each_strongly_connected_component do |component| cycles << component if component.size > 1 end cycles end alias tsort_each_node each_key def tsort_each_child(node) fetch(node, []).each do |child| yield child end end def tsort missing = Set.new(self.values.flatten) - Set.new(self.keys) if not missing.empty? raise MissingVertex, "Cannot sort elements; cannot depend on missing elements #{missing.to_a}" end super rescue TSort::Cyclic raise CycleError, "Cannot sort elements; found the following cycles: #{cycles.inspect}" end class CycleError < StandardError; end class MissingVertex < StandardError; end end end end facter-2.4.6/lib/facter/core/execution.rb0000664005276200011600000000774312651736735020205 0ustar jenkinsjenkinsrequire 'facter/util/config' module Facter module Core module Execution require 'facter/core/execution/base' require 'facter/core/execution/windows' require 'facter/core/execution/posix' @@impl = if Facter::Util::Config.is_windows? Facter::Core::Execution::Windows.new else Facter::Core::Execution::Posix.new end def self.impl @@impl end module_function # 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 # # @return [Array] the paths to be searched for binaries # @api private def search_paths @@impl.search_paths end # Determines the full path to a binary. If the supplied filename does not # already describe an absolute path then different locations (determined # by {search_paths}) will be searched for a match. # # Returns nil if no matching executable can be found otherwise returns # the expanded pathname. # # @param bin [String] the executable to locate # @return [String,nil] the full path to the executable or nil if not # found # # @api public def which(bin) @@impl.which(bin) end # Determine in a platform-specific way whether a path is absolute. This # defaults to the local platform if none is specified. # # @param path [String] the path to check # @param platform [:posix,:windows,nil] the platform logic to use def absolute_path?(path, platform = nil) @@impl.absolute_path?(path, platform) end # Given a command line, this returns the command line with the # executable written as an absolute path. If the executable contains # spaces, it has be put in double quotes to be properly recognized. # # @param command [String] the command line # # @return [String, nil] the command line with the executable's path # expanded, or nil if the executable cannot be found. def expand_command(command) @@impl.expand_command(command) end # Overrides environment variables within a block of code. The # specified values will be set for the duration of the block, after # which the original values (if any) will be restored. # # @overload with_env(values, { || ... }) # # @param values [HashString>] A hash of the environment # variables to override # # @return [void] # # @api public def with_env(values, &block) @@impl.with_env(values, &block) end # Try to execute a command and return the output. # # @param code [String] the program to run # # @return [String] the output of the program, or nil if the command does # not exist or could not be executed. # # @deprecated Use #{execute} instead # @api public def exec(command) @@impl.execute(command, :on_fail => nil) end # Execute a command and return the output of that program. # # @param code [String] the program to run # @param options [Hash] # # @option options [Object] :on_fail How to behave when the command could # not be run. Specifying :raise will raise an error, anything else will # return that object on failure. Default is :raise. # # @raise [Facter::Core::Execution::ExecutionFailure] If the command does # not exist or could not be executed. # # @return [String] the output of the program, or the value of :on_fail if # command execution failed and :on_fail was specified. # # @api public # @since 2.0.1 def execute(command, options = {}) @@impl.execute(command, options) end class ExecutionFailure < StandardError; end end end end facter-2.4.6/lib/facter/core/execution/0000775005276200011600000000000012651736742017643 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/core/execution/base.rb0000664005276200011600000000524412651736735021111 0ustar jenkinsjenkinsclass Facter::Core::Execution::Base def 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 def execute(command, options = {}) on_fail = options.fetch(:on_fail, :raise) # Set LC_ALL and 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 'LC_ALL' => 'C', 'LANG' => 'C' do expanded_command = expand_command(command) if expanded_command.nil? if on_fail == :raise raise Facter::Core::Execution::ExecutionFailure.new, "Could not execute '#{command}': command not found" else return on_fail end end out = '' begin wait_for_child = true out = %x{#{expanded_command}}.chomp wait_for_child = false rescue => detail if on_fail == :raise raise Facter::Core::Execution::ExecutionFailure.new, "Failed while executing '#{expanded_command}': #{detail.message}" else return on_fail end ensure if wait_for_child # We need to ensure that if this command exits early then any spawned # children will be reaped. Process execution is frequently # terminated using Timeout.timeout but since the timeout isn't in # this scope we can't rescue the raised exception. The best that # we can do is determine if the child has exited, and if it hasn't # then we need to spawn a thread to wait for the child. # # Due to the limitations of Ruby 1.8 there aren't good ways to # asynchronously run a command and grab the PID of that command # using the standard library. The best we can do is blindly wait # on all processes and hope for the best. This issue is described # at https://tickets.puppetlabs.com/browse/FACT-150 Thread.new { Process.waitall } end end out end end end facter-2.4.6/lib/facter/core/execution/posix.rb0000664005276200011600000000246512651736735021343 0ustar jenkinsjenkinsclass Facter::Core::Execution::Posix < Facter::Core::Execution::Base DEFAULT_SEARCH_PATHS = ['/sbin', '/usr/sbin'] def search_paths # Make sure facter is usable even for non-root users. Most commands # in /sbin (like ifconfig) can be run as non privileged users as # long as they do not modify anything - which we do not do with facter ENV['PATH'].split(File::PATH_SEPARATOR) + DEFAULT_SEARCH_PATHS end def which(bin) if absolute_path?(bin) return bin if File.executable?(bin) and File.file?(bin) else search_paths.each do |dir| dest = File.join(dir, bin) return dest if File.executable?(dest) and File.file?(dest) end end nil end ABSOLUTE_PATH_REGEX = %r{^/} def absolute_path?(path) !! (path =~ ABSOLUTE_PATH_REGEX) end DOUBLE_QUOTED_COMMAND = /^"(.+?)"(?:\s+(.*))?/ SINGLE_QUOTED_COMMAND = /^'(.+?)'(?:\s+(.*))?/ def expand_command(command) exe = nil args = nil if (match = (command.match(DOUBLE_QUOTED_COMMAND) || command.match(SINGLE_QUOTED_COMMAND))) exe, args = match.captures else exe, args = command.split(/ /,2) end if exe and (expanded = which(exe)) expanded = "'#{expanded}'" if expanded.match(/\s/) expanded << " #{args}" if args return expanded end end end facter-2.4.6/lib/facter/core/execution/windows.rb0000664005276200011600000000267212651736735021673 0ustar jenkinsjenkinsclass Facter::Core::Execution::Windows < Facter::Core::Execution::Base def search_paths ENV['PATH'].split(File::PATH_SEPARATOR) end DEFAULT_COMMAND_EXTENSIONS = %w[.COM .EXE .BAT .CMD] def which(bin) if absolute_path?(bin) return bin if File.executable?(bin) else search_paths.each do |dir| dest = File.join(dir, bin) dest.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File.extname(dest).empty? exts = ENV['PATHEXT'] exts = exts ? exts.split(File::PATH_SEPARATOR) : DEFAULT_COMMAND_EXTENSIONS exts.each do |ext| destext = dest + ext return destext if File.executable?(destext) end end return dest if File.executable?(dest) end end nil end slash = '[\\\\/]' name = '[^\\\\/]+' ABSOLUTE_PATH_REGEX = %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i def absolute_path?(path) !! (path =~ ABSOLUTE_PATH_REGEX) end DOUBLE_QUOTED_COMMAND = /^"(.+?)"(?:\s+(.*))?/ def expand_command(command) exe = nil args = nil if (match = command.match(DOUBLE_QUOTED_COMMAND)) exe, args = match.captures else exe, args = command.split(/ /,2) end if exe and (expanded = which(exe)) expanded = "\"#{expanded}\"" if expanded.match(/\s+/) expanded << " #{args}" if args return expanded end end end facter-2.4.6/lib/facter/core/logging.rb0000664005276200011600000001047412651736735017623 0ustar jenkinsjenkinsrequire 'facter' module Facter::Core::Logging extend self # @api private GREEN = "" # @api private RESET = "" # @api private @@debug = false # @api private @@timing = false # @api private @@trace = false # @api private @@warn_messages = {} # @api private @@debug_messages = {} # @api private @@message_callback = nil # Used to register a callback that is called when a message is logged. # If a block is given, Facter will not log messages. # If a block is not given, Facter will resume logging messages. # @param block [Proc] the callback to call when a message is logged. # The first argument to the callback will be a symbol representing a level. The supported # levels are: :trace, :debug, :info, :warn, :error, and :fatal. # The second argument to the callback will be a string containing the message # that was logged. # @api public def on_message(&block) @@message_callback = block end # Prints a debug message if debugging is turned on # # @param msg [String] the debug message # @return [void] def debug(msg) if self.debugging? if msg.nil? or msg.empty? invoker = caller[0].slice(/.*:\d+/) self.warn "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}" elsif @@message_callback @@message_callback.call(:debug, msg) else puts GREEN + msg + RESET end end end # Prints a debug message only once. # # @note Uniqueness is based on the string, not the specific location # of the method call. # # @param msg [String] the debug message # @return [void] def debugonce(msg) if msg and not msg.empty? and @@debug_messages[msg].nil? @@debug_messages[msg] = true debug(msg) end end # Prints a warning message. The message is only printed if debugging # is enabled. # # @param msg [String] the warning message to be printed # # @return [void] def warn(msg) if msg.nil? or msg.empty? invoker = caller[0].slice(/.*:\d+/) msg = "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}" end if @@message_callback @@message_callback.call(:warn, msg) else Kernel.warn msg end end # Prints a warning message only once per process. Each unique string # is printed once. # # @note Unlike {warn} the message will be printed even if debugging is # not turned on. This behavior is likely to change and should not be # relied on. # # @param msg [String] the warning message to be printed # # @return [void] def warnonce(msg) if @@warn_messages[msg].nil? self.warn(msg) @@warn_messages[msg] = true end end def log_exception(exception, message = :default) self.warn(format_exception(exception, message, @@trace)) end def format_exception(exception, message, trace) arr = [] if message == :default arr << exception.message elsif message arr << message end if trace arr.concat(exception.backtrace) end arr.flatten.join("\n") end # Print an exception message, and optionally a backtrace if trace is set # Print timing information # # @param string [String] the time to print # @return [void] # # @api private def show_time(string) return unless string && self.timing? if @@message_callback @@message_callback.call(:info, string) else $stderr.puts "#{GREEN}#{string}#{RESET}" end end # Enable or disable logging of debug messages # # @param bool [true, false] # @return [void] # # @api private def debugging(bool) @@debug = bool end # Is debugging enabled? # # @return [true, false] # # @api private def debugging? @@debug end # Enable or disable logging of timing information # # @param bool [true, false] # @return [void] # # @api private def timing(bool) @@timing = bool end # Returns whether timing output is turned on # # @api private def timing? @@timing end def trace(bool) @@trace = bool end def trace? @@trace end # Clears the seen state of debug and warning messages. See {debugonce} and {warnonce}. # # @return [void] # # @api private def clear_messages @@debug_messages.clear @@warn_messages.clear end end facter-2.4.6/lib/facter/core/resolvable.rb0000664005276200011600000000536312651736735020334 0ustar jenkinsjenkinsrequire 'timeout' # The resolvable mixin defines behavior for evaluating and returning fact # resolutions. # # Classes including this mixin should implement at #name method describing # the value being resolved and a #resolve_value that actually executes the code # to resolve the value. module Facter::Core::Resolvable # The timeout, in seconds, for evaluating this resolution. # @return [Integer] # @api public attr_accessor :timeout # Return the timeout period for resolving a value. # (see #timeout) # @return [Numeric] # @comment requiring 'timeout' stdlib class causes Object#timeout to be # defined which delegates to Timeout.timeout. This method may potentially # overwrite the #timeout attr_reader on this class, so we define #limit to # avoid conflicts. def limit @timeout || 0 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 value result = nil with_timing do Timeout.timeout(limit) do result = resolve_value end end Facter::Util::Normalization.normalize(result) rescue Timeout::Error => detail Facter.log_exception(detail, "Timed out after #{limit} seconds while resolving #{qualified_name}") return nil rescue Facter::Util::Normalization::NormalizationError => detail Facter.log_exception(detail, "Fact resolution #{qualified_name} resolved to an invalid value: #{detail.message}") return nil rescue => detail Facter.log_exception(detail, "Could not retrieve #{qualified_name}: #{detail.message}") return nil end private def with_timing starttime = Time.now.to_f yield finishtime = Time.now.to_f ms = (finishtime - starttime) * 1000 Facter.show_time "#{qualified_name}: #{"%.2f" % ms}ms" end def qualified_name "fact='#{@fact.name.to_s}', resolution='#{@name || ''}'" end end facter-2.4.6/lib/facter/core/suitable.rb0000664005276200011600000000752012651736735020003 0ustar jenkinsjenkinsrequire 'facter' # The Suitable mixin provides mechanisms for confining objects to run on # certain platforms and determining the run precedence of these objects. # # Classes that include the Suitable mixin should define a `#confines` method # that returns an Array of zero or more Facter::Util::Confine objects. module Facter::Core::Suitable attr_writer :weight # Sets the weight of this resolution. If multiple suitable resolutions # are found, the one with the highest weight will be used. If weight # is not given, the number of confines set on a resolution will be # used as its weight (so that the most specific resolution is used). # # @param weight [Integer] the weight of this resolution # # @return [void] # # @api public def has_weight(weight) @weight = weight end # Sets the conditions for this resolution to be used. This method accepts # multiple forms of arguments to determine suitability. # # @return [void] # # @api public # # @overload confine(confines) # Confine a fact to a specific fact value or values. This form takes a # hash of fact names and values. Every fact must match the values given for # that fact, otherwise this resolution will not be considered suitable. The # values given for a fact can be an array, in which case the value of the # fact must be in the array for it to match. # @param [Hash{String,Symbol=>String,Array}] confines set of facts identified by the hash keys whose # fact value must match the argument value. # @example Confining to Linux # Facter.add(:powerstates) do # # This resolution only makes sense on linux systems # confine :kernel => "Linux" # setcode do # File.read('/sys/power/states') # end # end # # @overload confine(confines, &block) # Confine a fact to a block with the value of a specified fact yielded to # the block. # @param [String,Symbol] confines the fact name whose value should be # yielded to the block # @param [Proc] block determines the suitability of the fact. If the block # evaluates to `false` or `nil` then the confined fact will not be # evaluated. # @yield [value] the value of the fact identified by {confines} # @example Confine the fact to a host with an ipaddress in a specific # subnet # confine :ipaddress do |addr| # require 'ipaddr' # IPAddr.new('192.168.0.0/16').include? addr # end # # @overload confine(&block) # Confine a fact to a block. The fact will be evaluated only if the block # evaluates to something other than `false` or `nil`. # @param [Proc] block determines the suitability of the fact. If the block # evaluates to `false` or `nil` then the confined fact will not be # evaluated. # @example Confine the fact to systems with a specific file. # confine { File.exist? '/bin/foo' } def confine(confines = nil, &block) case confines when Hash confines.each do |fact, values| @confines.push Facter::Util::Confine.new(fact, *values) end else if block if confines @confines.push Facter::Util::Confine.new(confines, &block) else @confines.push Facter::Util::Confine.new(&block) end else end end end # Returns the importance of this resolution. If the weight was not # given, the number of confines is used instead (so that a more # specific resolution wins over a less specific one). # # @return [Integer] the weight of this resolution # # @api private def weight if @weight @weight else @confines.length end end # Is this resolution mechanism suitable on the system in question? # # @api private def suitable? @confines.all? { |confine| confine.true? } end end facter-2.4.6/lib/facter/dhcp_servers.rb0000664005276200011600000000227312651736735017732 0ustar jenkinsjenkins# Fact: dhcp_servers # # Purpose: # Return the DHCP server addresses for all interfaces as a hash. # If the interface that is the default gateway is DHCP assigned, there # will also be a `"system"` entry in the hash. # # This fact is structured. Values are returned as a group of key-value pairs. # # Resolution: # Parses the output of `nmcli` to find the DHCP server for the interface if available. # # Caveats: # Requires `nmcli` to be available and the interface must use network-manager. # require 'facter' require 'facter/util/dhcp_servers' Facter.add(:dhcp_servers) do confine :kernel => :linux confine do Facter::Core::Execution.which('nmcli') end confine do s = Facter::Util::DHCPServers.network_manager_state !s.empty? && (s != 'unknown') end setcode do gwdev = Facter::Util::DHCPServers.gateway_device devices = Facter::Util::DHCPServers.devices dhcp_servers = {} devices.each do |device| if server = Facter::Util::DHCPServers.device_dhcp_server(device) dhcp_servers['system'] = server if device == gwdev dhcp_servers[device] = server end end dhcp_servers.keys.length > 0 ? dhcp_servers : nil end end facter-2.4.6/lib/facter/domain.rb0000664005276200011600000000563412651736735016516 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::Core::Execution.exec(hostname_command) \ and name =~ /.*?\.(.+$)/ return_value = $1 elsif Facter.value(:kernel) != "windows" and domain = Facter::Core::Execution.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 if return_value return_value.gsub(/\.$/, '') end end end Facter.add(:domain) do confine :kernel => :windows setcode do require 'facter/util/registry' domain = nil regvalue = Facter::Util::Registry.hklm_read('SYSTEM\CurrentControlSet\Services\Tcpip\Parameters', 'Domain') if regvalue and not regvalue.empty? domain = regvalue else 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 if domain domain.gsub(/\.$/, '') end end end facter-2.4.6/lib/facter/ec2.rb0000664005276200011600000000324012651736735015707 0ustar jenkinsjenkins# Fact: ec2_ # # Purpose: # Returns info retrieved in bulk from the EC2 API. The names of these facts # should be self explanatory, and they are otherwise undocumented. The full # list of these facts is: ec2_ami_id, ec2_ami_launch_index, # ec2_ami_manifest_path, ec2_block_device_mapping_ami, # ec2_block_device_mapping_ephemeral0, ec2_block_device_mapping_root, # ec2_hostname, ec2_instance_id, ec2_instance_type, ec2_kernel_id, # ec2_local_hostname, ec2_local_ipv4, ec2_placement_availability_zone, # ec2_profile, ec2_public_hostname, ec2_public_ipv4, # ec2_public_keys_0_openssh_key, ec2_reservation_id, and ec2_security_groups. # # Resolution: # Directly queries the EC2 metadata endpoint. # require 'facter/ec2/rest' unless defined?(Facter::EC2) Facter.define_fact(:ec2_metadata) do define_resolution(:rest) do confine do Facter.value(:virtual).match /^(xen|kvm)/ end @querier = Facter::EC2::Metadata.new confine do @querier.reachable? end setcode do @querier.fetch end end end Facter.define_fact(:ec2_userdata) do define_resolution(:rest) do confine do Facter.value(:virtual).match /^(xen|kvm)/ end @querier = Facter::EC2::Userdata.new confine do @querier.reachable? end setcode do @querier.fetch end end end # The flattened version of the EC2 facts are deprecated and will be removed in # a future release of Facter. if (ec2_metadata = Facter.value(:ec2_metadata)) ec2_facts = Facter::Util::Values.flatten_structure("ec2", ec2_metadata) ec2_facts.each_pair do |factname, factvalue| Facter.add(factname, :value => factvalue) end end facter-2.4.6/lib/facter/ec2/0000775005276200011600000000000012651736742015361 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/ec2/rest.rb0000664005276200011600000000721412651736735016671 0ustar jenkinsjenkinsrequire 'timeout' require 'open-uri' module Facter module EC2 CONNECTION_ERRORS = [ Errno::EHOSTDOWN, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, ] # Contains metadata keys that should not be collected FILTERED_KEYS = [ 'security-credentials/' ].freeze class Base def reachable?(retry_limit = 3) timeout = 0.2 able_to_connect = false attempts = 0 begin Timeout.timeout(timeout) do open(@baseurl, :proxy => nil).read end able_to_connect = true rescue OpenURI::HTTPError => e if e.message.match /404 Not Found/i able_to_connect = false else attempts = attempts + 1 retry if attempts < retry_limit end rescue Timeout::Error attempts = attempts + 1 retry if attempts < retry_limit rescue *CONNECTION_ERRORS attempts = attempts + 1 retry if attempts < retry_limit end able_to_connect end end class Metadata < Base DEFAULT_URI = "http://169.254.169.254/latest/meta-data/" def initialize(uri = DEFAULT_URI) @baseurl = uri end def fetch(path = '') results = {} keys = fetch_endpoint(path) keys.each do |key| next if FILTERED_KEYS.include? key if key.match(%r[/$]) # If a metadata key is suffixed with '/' then it's a general metadata # resource, so we have to recursively look up all the keys in the given # collection. name = key[0..-2] results[name] = fetch("#{path}#{key}") else # This is a simple key/value pair, we can just query the given endpoint # and store the results. ret = fetch_endpoint("#{path}#{key}") results[key] = ret.size > 1 ? ret : ret.first end end results end # @param path [String] The path relative to the object base url # # @return [Array, NilClass] def fetch_endpoint(path) uri = @baseurl + path body = open(uri, :proxy => nil).read parse_results(body) rescue OpenURI::HTTPError => e if e.message.match /404 Not Found/i return nil else Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}") return nil end rescue *CONNECTION_ERRORS => e Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}") return nil rescue Timeout::Error => e Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}") return nil end private def parse_results(body) lines = body.split("\n") lines.map do |line| if (match = line.match(/^(\d+)=.*$/)) # Metadata arrays are formatted like '=/', so # we need to extract the index from that output. "#{match[1]}/" else line end end end end class Userdata < Base DEFAULT_URI = "http://169.254.169.254/latest/user-data/" def initialize(uri = DEFAULT_URI) @baseurl = uri end def fetch open(@baseurl).read rescue OpenURI::HTTPError => e if e.message.match /404 Not Found/i return nil else Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}") return nil end end end end end facter-2.4.6/lib/facter/facterversion.rb0000664005276200011600000000037112651736735020112 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-2.4.6/lib/facter/filesystems.rb0000664005276200011600000000247612651736735017617 0ustar jenkinsjenkins# Fact: filesystems # # Purpose: # This fact provides an alphabetic list of usable file systems that can # be used for block devices like hard drives, media cards, etc. # # Resolution: # Checks `/proc/filesystems`. # # Caveats: # Only supports Linux. # 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::Core::Execution.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-2.4.6/lib/facter/fqdn.rb0000664005276200011600000000103612651736735016167 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(".") elsif host host else nil end end end facter-2.4.6/lib/facter/gce.rb0000664005276200011600000000040212651736735015771 0ustar jenkinsjenkinsrequire 'facter/gce/metadata' Facter.define_fact(:gce) do define_resolution(:rest) do confine :virtual => 'gce' confine do Facter.json? end setcode do querier = Facter::GCE::Metadata.new querier.fetch end end end facter-2.4.6/lib/facter/gce/0000775005276200011600000000000012651736742015446 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/gce/metadata.rb0000664005276200011600000000410312651736735017553 0ustar jenkinsjenkinsrequire 'open-uri' module Facter module GCE # @api private class Metadata CONNECTION_ERRORS = [ OpenURI::HTTPError, Errno::EHOSTDOWN, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Timeout::Error, ] METADATA_URL = "http://metadata/computeMetadata/v1beta1/?recursive=true&alt=json" def initialize(url = METADATA_URL) @url = url end def fetch with_metadata_server do |body| # This will only be reached if the confine associated with this class # was true which means that JSON was required, but it's a bit # questionable that we're relying on JSON being loaded as a side # effect of that. hash = ::JSON.parse(body) transform_metadata!(hash) hash end end private def with_metadata_server retry_limit = 3 timeout = 0.05 body = nil attempts = 0 begin Timeout.timeout(timeout) do body = open(@url).read end rescue *CONNECTION_ERRORS => e attempts = attempts + 1 if attempts < retry_limit retry else Facter.log_exception(e, "Unable to fetch metadata from #{@url}: #{e.message}") return nil end end if body yield body end end # @return [void] def transform_metadata!(data) case data when Hash data.keys.each do |key| value = data[key] if ["image", "machineType", "zone", "network"].include? key data[key] = value.split('/').last elsif key == "sshKeys" data['sshKeys'] = value.split("\n") end transform_metadata!(value) end when Array data.each do |value| transform_metadata!(value) end end nil end end end end facter-2.4.6/lib/facter/gid.rb0000664005276200011600000000101312651736735015775 0ustar jenkinsjenkins# Fact: gid # # Purpose: Return the GID (group identifier) of the user running puppet. # # Resolution: # # Caveats: # Not supported in Windows yet. # Facter.add(:gid) do confine do Facter::Core::Execution.which('id') && !["SunOS", "windows"].include?(Facter.value(:kernel)) end setcode { Facter::Core::Execution.exec('id -ng') } end Facter.add(:gid) do confine :kernel => :SunOS setcode do if File.exist? '/usr/xpg4/bin/id' Facter::Core::Execution.exec('/usr/xpg4/bin/id -ng') end end end facter-2.4.6/lib/facter/hardwareisa.rb0000664005276200011600000000065712651736735017541 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-2.4.6/lib/facter/hardwaremodel.rb0000664005276200011600000000505012651736735020055 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::Core::Execution.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-2.4.6/lib/facter/hostname.rb0000664005276200011600000000125412651736735017057 0ustar jenkinsjenkins# Fact: hostname # # Purpose: Return the system's short hostname. # # Resolution: # On all systems but 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) do setcode do hostname = nil if name = Facter::Core::Execution.execute('hostname') if name =~ /(.*?)\./ hostname = $1 else hostname = name end end hostname end end Facter.add(:hostname) do confine :kernel => :darwin, :kernelrelease => "R7" setcode '/usr/sbin/scutil --get LocalHostName' end facter-2.4.6/lib/facter/id.rb0000664005276200011600000000072012651736735015632 0ustar jenkinsjenkins# Fact: id # # Purpose: Internal fact used to specity the program to return the currently # running user ID. # # Resolution: # On all Unixes but Solaris, just returns the output from `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-2.4.6/lib/facter/interfaces.rb0000664005276200011600000000322212651736735017361 0ustar jenkinsjenkins# Fact: interfaces # # Purpose: # Returns a comma-separated list of the system's network interfaces. # # In addition to the main `interfaces` fact, this code will generate the # following facts for each interface: # # * `ipaddress_` # * `ipaddress6_` # * `macaddress_` # * `netmask_` # * `mtu_` # # 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' require 'facter/util/macaddress' # 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 value = Facter::Util::IP.get_interface_value(interface, label) if label == "macaddress" value = Facter::Util::Macaddress.standardize(value) elsif label == "mtu" value = value.to_i end value end end end end facter-2.4.6/lib/facter/ipaddress.rb0000664005276200011600000000750412651736735017223 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 do |str| if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ tmp = $1 unless tmp =~ /^127\./ ip = tmp break end 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 do |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 end ip end end Facter.add(:ipaddress) do confine :kernel => %w{AIX} setcode do ip = nil default_interface = Facter::Util::IP.exec_netstat(["-rn | grep default | awk '{ print $6 }'"]) output = Facter::Util::IP.exec_ifconfig([default_interface]) output.split(/^\S/).each do |str| if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ ip = $1 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, :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::Core::Execution.execute("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-2.4.6/lib/facter/ipaddress6.rb0000664005276200011600000000410112651736735017277 0ustar jenkinsjenkins# Fact: ipaddress6 # # Purpose: Returns the "main" IPv6 IP address of a system. # # Resolution: # OS-dependent 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 routable interface. Guessing # an interface is currently only possible with BSD-type systems; # too many assumptions have to be made on other platforms to make # this work with the current code. Most of this code is 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-2.4.6/lib/facter/iphostnumber.rb0000664005276200011600000000120012651736735017747 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-2.4.6/lib/facter/kernel.rb0000664005276200011600000000070512651736735016521 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, then # returns `windows`, otherwise returns the output of `uname -s` verbatim. # # Caveats: # Facter.add(:kernel) do setcode do require 'facter/util/config' if Facter::Util::Config.is_windows? 'windows' else Facter::Core::Execution.exec("uname -s") end end end facter-2.4.6/lib/facter/kernelmajversion.rb0000664005276200011600000000101412651736735020611 0ustar jenkinsjenkins# Fact: kernelmajversion # # Purpose: Return the operating system's release number's major value. # # Resolution: # Takes the first two elements of the kernel version as delimited by periods. # Takes the first element of the kernel version on FreeBSD. # # Caveats: # Facter.add("kernelmajversion") do setcode do Facter.value(:kernelversion).split('.')[0..1].join('.') end end Facter.add("kernelmajversion") do confine :kernel => :FreeBSD setcode do Facter.value(:kernelversion).split('.')[0] end end facter-2.4.6/lib/facter/kernelrelease.rb0000664005276200011600000000214712651736735020064 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: # require 'facter/util/posix' 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 => :openbsd setcode do Facter::Util::POSIX.sysctl("kern.version").split(' ')[1] end end Facter.add(:kernelrelease) do confine :kernel => "hp-ux" setcode do version = Facter::Core::Execution.execute('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-2.4.6/lib/facter/kernelversion.rb0000664005276200011600000000076712651736735020137 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-2.4.6/lib/facter/ldom.rb0000664005276200011600000000272212651736735016175 0ustar jenkinsjenkins# Fact: ldom # # Purpose: # Returns a list of dynamic facts that describe the attributes of # a Solaris logical domain. The facts returned will include: domainrole, # domainname, domainuuid, domaincontrol, and domainchassis. # # Resolution: # Uses the output of `virtinfo -ap`. # if Facter.value(:kernel) == 'SunOS' && Facter.value(:hardwareisa) == 'sparc' && Facter::Core::Execution.which('virtinfo') virtinfo = Facter::Core::Execution.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 end end facter-2.4.6/lib/facter/lsbdistcodename.rb0000664005276200011600000000110712651736735020376 0ustar jenkinsjenkins# Fact: lsbdistcodename # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsbdistcodename key of the os structured fact, which # itself 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 do !Facter.value(:os)["lsb"].nil? end setcode { Facter.value("os")["lsb"]["distcodename"] } end facter-2.4.6/lib/facter/lsbdistdescription.rb0000664005276200011600000000112412651736735021145 0ustar jenkinsjenkins# Fact: lsbdistdescription # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsbdistdescription key of the os structured fact, which itself # 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 do !Facter.value(:os)["lsb"].nil? end setcode { Facter.value("os")["lsb"]["distdescription"] } end facter-2.4.6/lib/facter/lsbdistid.rb0000664005276200011600000000105612651736735017222 0ustar jenkinsjenkins# Fact: lsbdistid # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsbdistid key of the os structured fact, which itself # 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 do !Facter.value(:os)["lsb"].nil? end setcode { Facter.value("os")["lsb"]["distid"] } end facter-2.4.6/lib/facter/lsbdistrelease.rb0000664005276200011600000000110212651736735020236 0ustar jenkinsjenkins# Fact: lsbdistrelease # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsbdistrelease key of the os structured fact, which itself # 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 do !Facter.value(:os)["lsb"].nil? end setcode { Facter.value("os")["lsb"]["distrelease"] } end facter-2.4.6/lib/facter/lsbmajdistrelease.rb0000664005276200011600000000106012651736735020731 0ustar jenkinsjenkins# Fact: lsbmajdistrelease # # Purpose: Returns the major version of the operation system version as gleaned # from the lsbdistrelease fact. # # Resolution: # Uses the lsbmajdistrelease key of the os structured fact, which itself # parses the lsbdistrelease fact for numbers followed by a period and # returns those, or just the lsbdistrelease fact if none were found. # # Caveats: # require 'facter' Facter.add(:lsbmajdistrelease) do confine do !Facter.value("os")["lsb"].nil? end setcode { Facter.value("os")["lsb"]["majdistrelease"] } end facter-2.4.6/lib/facter/lsbminordistrelease.rb0000664005276200011600000000114512651736735021312 0ustar jenkinsjenkins# Fact: lsbminordistrelease # # Purpose: Returns the minor version of the operation system version as gleaned # from the lsbdistrelease fact. # # Resolution: # Parses the lsbdistrelease fact for x.y and returns y. If y is not present, # the fact is not present. # # For both values '1.2.3' and '1.2' of lsbdistrelease, lsbminordistrelease # would return '2'. For the value '1', no fact would be set for # lsbminordistrelease. # require 'facter' Facter.add('lsbminordistrelease') do confine do !Facter.value("os")["lsb"].nil? end setcode { Facter.value("os")["lsb"]["minordistrelease"] } end facter-2.4.6/lib/facter/lsbrelease.rb0000664005276200011600000000106212651736735017357 0ustar jenkinsjenkins# Fact: lsbrelease # # Purpose: Return Linux Standard Base information for the host. # # Resolution: # Uses the lsbrelease key of the os structured fact, which itself # 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 do !Facter.value(:os)["lsb"].nil? end setcode { Facter.value("os")["lsb"]["release"] } end facter-2.4.6/lib/facter/macaddress.rb0000664005276200011600000000467412651736735017360 0ustar jenkinsjenkins# Fact: macaddress # # Purpose: # Returns the MAC address of the primary network interface. # # Resolution: # # Caveats: # require 'facter/util/macaddress' require 'facter/util/ip' 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::Core::Execution.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 default_interface = Facter::Util::IP.exec_netstat(["-rn | grep default | awk '{ print $6 }'"]) output = Facter::Util::IP.exec_ifconfig([default_interface]) 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-2.4.6/lib/facter/macosx.rb0000664005276200011600000000234612651736735016536 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. if Facter.value(:kernel) == "Darwin" require 'facter/util/macosx' Facter::Util::Macosx.hardware_overview.each do |fact, value| Facter.add("sp_#{fact}") do confine :kernel => :darwin setcode do value end end end Facter::Util::Macosx.os_overview.each do |fact, value| Facter.add("sp_#{fact}") do confine :kernel => :darwin setcode do value 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-2.4.6/lib/facter/manufacturer.rb0000664005276200011600000000376312651736735017744 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 `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-2.4.6/lib/facter/memory.rb0000664005276200011600000001032512651736735016550 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 Facter.add("SwapEncrypted") do confine :kernel => :openbsd setcode do sysctl_encrypted = Facter::Util::POSIX.sysctl("vm.swapencrypt.enable").to_i !(sysctl_encrypted.zero?) end end Facter.add("SwapEncrypted") do confine :kernel => :Darwin setcode do swap = Facter::Util::POSIX.sysctl('vm.swapusage') encrypted = false if swap =~ /\(encrypted\)/ then encrypted = true; end encrypted end end if Facter.value(:kernel) == "SunOS" Facter.add("memorysize_mb") do confine :kernel => :sunos # Total memory size available from prtconf pconf = Facter::Core::Execution.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::POSIX.sysctl("hw.pagesize").to_f swaptotal = Facter::Util::POSIX.sysctl("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::POSIX.sysctl("hw.pagesize").to_f swaptotal = Facter::Util::POSIX.sysctl("vm.swap_size").to_f * page_size swap_anon_use = Facter::Util::POSIX.sysctl("vm.swap_anon_use").to_f * page_size swap_cache_use = Facter::Util::POSIX.sysctl("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 facter-2.4.6/lib/facter/netmask.rb0000664005276200011600000000172612651736735016707 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, :AIX ] 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-2.4.6/lib/facter/network.rb0000664005276200011600000000070412651736735016731 0ustar jenkinsjenkins# Fact: network # # Purpose: # Get IP, network, and netmask information for available network # interfaces. # # 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-2.4.6/lib/facter/operatingsystem.rb0000664005276200011600000000117012651736735020473 0ustar jenkinsjenkins# Fact: operatingsystem # # Purpose: Return the name of the operating system. # # Resolution: # Uses the name key of the os structured fact, which itself # operates on the following conditions: # # # 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 fact's value. # # Caveats: # Facter.add(:operatingsystem) do confine do !Facter.value("os")["name"].nil? end setcode { Facter.value("os")["name"] } end facter-2.4.6/lib/facter/operatingsystem/0000775005276200011600000000000012651736742020145 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/operatingsystem/base.rb0000664005276200011600000000273412651736735021414 0ustar jenkinsjenkinsrequire 'facter/util/operatingsystem' module Facter module Operatingsystem class Base def get_operatingsystem @operatingsystem ||= Facter.value(:kernel) @operatingsystem end def get_osfamily Facter.value(:kernel) end def get_operatingsystemrelease @operatingsystemrelease = Facter.value(:kernelrelease) @operatingsystemrelease end def get_operatingsystemmajorrelease if operatingsystemrelease = get_operatingsystemrelease if (releasemajor = operatingsystemrelease.split(".")[0]) releasemajor end end end def get_operatingsystemminorrelease if operatingsystemrelease = get_operatingsystemrelease if (releaseminor = operatingsystemrelease.split(".")[1]) if releaseminor.include? "-" releaseminor.split("-")[0] else releaseminor end end end end def get_operatingsystemrelease_hash release_hash = {} if releasemajor = get_operatingsystemmajorrelease release_hash["major"] = releasemajor end if releaseminor = get_operatingsystemminorrelease release_hash["minor"] = releaseminor end if release = get_operatingsystemrelease release_hash["full"] = release end release_hash end def has_lsb? false end end end end facter-2.4.6/lib/facter/operatingsystem/cumuluslinux.rb0000664005276200011600000000116312651736735023252 0ustar jenkinsjenkinsrequire 'facter/util/operatingsystem' require 'facter/operatingsystem/linux' module Facter module Operatingsystem class CumulusLinux < Linux def get_operatingsystem "CumulusLinux" end def get_osfamily "Debian" end def get_operatingsystemrelease @operatingsystemrelease ||= Facter::Util::Operatingsystem.os_release['VERSION_ID'] @operatingsystemrelease end def get_operatingsystemmajrelease if operatingsystemrelease = get_operatingsystemrelease operatingsystemrelease.split(".").first end end end end end facter-2.4.6/lib/facter/operatingsystem/implementation.rb0000664005276200011600000000204512651736735023522 0ustar jenkinsjenkinsrequire 'facter/operatingsystem/base' require 'facter/operatingsystem/osreleaselinux' require 'facter/operatingsystem/cumuluslinux' require 'facter/operatingsystem/linux' require 'facter/operatingsystem/sunos' require 'facter/operatingsystem/vmkernel' require 'facter/operatingsystem/windows' module Facter module Operatingsystem def self.implementation(kernel = Facter.value(:kernel)) case kernel when "Linux", "GNU/kFreeBSD" release_info = Facter::Util::Operatingsystem.os_release if release_info['NAME'] == "Cumulus Linux" Facter::Operatingsystem::CumulusLinux.new elsif release_info['NAME'] == "CoreOS" Facter::Operatingsystem::OsReleaseLinux.new else Facter::Operatingsystem::Linux.new end when "SunOS" Facter::Operatingsystem::SunOS.new when "VMkernel" Facter::Operatingsystem::VMkernel.new when "windows" Facter::Operatingsystem::Windows.new else Facter::Operatingsystem::Base.new end end end end facter-2.4.6/lib/facter/operatingsystem/linux.rb0000664005276200011600000003463212651736735021643 0ustar jenkinsjenkinsrequire 'facter/util/file_read' require 'facter/util/operatingsystem' require 'facter/operatingsystem/base' module Facter module Operatingsystem class Linux < Base def get_operatingsystem if Facter.value(:kernel) == "GNU/kFreeBSD" "GNU/kFreeBSD" elsif lsbdistid = get_lsbdistid if lsbdistid == "Ubuntu" @operatingsystem ||= "Ubuntu" elsif lsbdistid == "LinuxMint" @operatingsystem ||= "LinuxMint" else @operatingsystem ||= get_operatingsystem_with_release_files end else @operatingsystem ||= get_operatingsystem_with_release_files end end def get_osfamily case get_operatingsystem when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon", "XenServer" "RedHat" when "LinuxMint", "Ubuntu", "Debian" "Debian" when "SLES", "SLED", "OpenSuSE", "SuSE" "Suse" when "Gentoo" "Gentoo" when "Archlinux", "Manjarolinux" "Archlinux" when "Mageia", "Mandriva", "Mandrake" "Mandrake" else Facter.value("kernel") end end def get_operatingsystemrelease case get_operatingsystem when "Alpine" get_alpine_release_with_release_file when "Amazon" get_amazon_release_with_lsb when "AristaEOS" get_arista_release_with_release_file when "BlueWhite64" get_bluewhite_release_with_release_file when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "XenServer", "Fedora", "MeeGo", "OracleLinux", "OEL", "oel", "OVS", "ovs" get_redhatish_release_with_release_file when "Debian" get_debian_release_with_release_file when "LinuxMint" get_linux_mint_release_with_release_file when "Mageia" get_mageia_release_with_release_file when "OpenWrt" get_openwrt_release_with_release_file when "Slackware" get_slackware_release_with_release_file when "Slamd64" get_slamd64_release_with_release_file when "SLES", "SLED", "OpenSuSE" get_suse_release_with_release_file when "Ubuntu" get_ubuntu_release_with_release_file when "VMwareESX" get_vmwareESX_release_with_release_file else Facter.value(:kernelrelease) end end def get_operatingsystemmajorrelease if operatingsystemrelease = get_operatingsystemrelease if get_operatingsystem == "Ubuntu" if (releasemajor = operatingsystemrelease.split(".")) if releasemajor.length >= 2 "#{releasemajor[0]}.#{releasemajor[1]}" else releasemajor[0] end end else if (releasemajor = operatingsystemrelease.split(".")[0]) releasemajor end end end end def get_operatingsystemminorrelease if operatingsystemrelease = get_operatingsystemrelease if get_operatingsystem == "Ubuntu" if (releaseminor = operatingsystemrelease.split(".")[2]) releaseminor end else if (releaseminor = operatingsystemrelease.split(".")[1]) if releaseminor.include? "-" releaseminor.split("-")[0] else releaseminor end end end end end def has_lsb? true end def get_lsbdistcodename if (lsb_data = collect_lsb_information) lsb_data["Codename"] end end def get_lsbdistid if (lsb_data = collect_lsb_information) lsb_data["Distributor ID"] end end def get_lsbdistdescription if (lsb_data = collect_lsb_information) lsb_data["Description"].sub(/^"(.*)"$/,'\1') end end def get_lsbrelease if (lsb_data = collect_lsb_information) lsb_data["LSB Version"] end end def get_lsbdistrelease if (lsb_data = collect_lsb_information) lsb_data["Release"] end end def get_lsbmajdistrelease lsbdistrelease = get_lsbdistrelease if get_operatingsystem == "Ubuntu" if (lsbreleasemajor = lsbdistrelease.split(".")) if lsbreleasemajor.length >= 2 result = "#{lsbreleasemajor[0]}.#{lsbreleasemajor[1]}" else result = lsbreleasemajor end end else if /(\d*)\./i =~ lsbdistrelease result = $1 else result = lsbdistrelease end end result end def get_lsbminordistrelease lsbdistrelease = get_lsbdistrelease if get_operatingsystem == "Ubuntu" mdata = /(\d+).(\d+).(\d+)/i.match(lsbdistrelease) if mdata == nil result = nil else result = mdata[3] end else mdata = /(\d+).(\d+)/i.match(lsbdistrelease) if mdata == nil result = nil else result = mdata[2] end end result end def get_lsb_facts_hash lsb_hash = {} if lsbdistcodename = get_lsbdistcodename lsb_hash["distcodename"] = lsbdistcodename end if lsbdistid = get_lsbdistid lsb_hash["distid"] = lsbdistid end if lsbdistdescription = get_lsbdistdescription lsb_hash["distdescription"] = lsbdistdescription end if lsbrelease = get_lsbrelease lsb_hash["release"] = lsbrelease end if lsbdistrelease = get_lsbdistrelease lsb_hash["distrelease"] = lsbdistrelease end if lsbmajdistrelease = get_lsbmajdistrelease lsb_hash["majdistrelease"] = lsbmajdistrelease end if lsbminordistrelease = get_lsbminordistrelease lsb_hash["minordistrelease"] = lsbminordistrelease end lsb_hash end def collect_lsb_information @lsb_data ||= Facter::Core::Execution.exec("lsb_release -cidvr 2>/dev/null") @data_hash = {} if @lsb_data && @data_hash.empty? @lsb_data.split("\n").each do |element| lsbvar, value = element.split("\t") lsbvar.gsub!(":", "") @data_hash["#{lsbvar}"] = value end end @data_hash unless @data_hash.empty? end private # Sequentially searches the filesystem for the existence of a release file # # @return [String, NilClass] def get_operatingsystem_with_release_files operatingsystem = nil release_files = { "AristaEOS" => "/etc/Eos-release", "Debian" => "/etc/debian_version", "Gentoo" => "/etc/gentoo-release", "Fedora" => "/etc/fedora-release", "Mageia" => "/etc/mageia-release", "Mandriva" => "/etc/mandriva-release", "Mandrake" => "/etc/mandrake-release", "MeeGo" => "/etc/meego-release", "Archlinux" => "/etc/arch-release", "Manjarolinux"=> "/etc/manjaro-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" } release_files.each do |os, releasefile| if FileTest.exists?(releasefile) operatingsystem = os end end unless operatingsystem if FileTest.exists?("/etc/enterprise-release") if FileTest.exists?("/etc/ovs-release") operatingsystem = "OVS" else operatingsystem = "OEL" end elsif FileTest.exists?("/etc/redhat-release") operatingsystem = get_redhat_operatingsystem_name elsif FileTest.exists?("/etc/SuSE-release") operatingsystem = get_suse_operatingsystem_name elsif FileTest.exists?("/etc/system-release") operatingsystem = "Amazon" end end operatingsystem end # Uses a regex search on /etc/redhat-release to determine OS # # @return [String] def get_redhat_operatingsystem_name txt = File.read("/etc/redhat-release") matches = { "CentOS" => "centos", "Scientific" => "Scientific", "CloudLinux" => "^cloudlinux", "PSBM" => "^Parallels Server Bare Metal", "Ascendos" => "Ascendos", "XenServer" => "^XenServer", "XCP" => "XCP" } if txt =~ /CERN/ "SLC" else match = regex_search_release_file_for_operatingsystem(matches, txt) match = "RedHat" if match == nil match end end # Uses a regex search on /etc/SuSE-release to determine OS # # @return [String] def get_suse_operatingsystem_name txt = File.read("/etc/SuSE-release") matches = { "SLES" => "^SUSE LINUX Enterprise Server", "SLED" => "^SUSE LINUX Enterprise Desktop", "OpenSuSE" => "^openSUSE" } match = regex_search_release_file_for_operatingsystem(matches, txt) match = "SuSE" if match == nil match end # Iterates over potential matches from a hash argument and returns # result of search # # @return [String, NilClass] def regex_search_release_file_for_operatingsystem(regex_os_hash, filecontent) match = nil regex_os_hash.each do |os, regex| match = os if filecontent =~ /#{regex}/i end match end # Read release files to determine operatingsystemrelease # # @return [String] def get_alpine_release_with_release_file if release = Facter::Util::FileRead.read('/etc/alpine-release') release.sub!(/\s*$/, '') release end end def get_arista_release_with_release_file if release = Facter::Util::FileRead.read('/etc/Eos-release') if match = /\d+\.\d+(:?\.\d+)?[A-M]?$/.match(release) match[0] end end end def get_amazon_release_with_lsb if lsbdistrelease = get_lsbdistrelease lsbdistrelease else if release = Facter::Util::FileRead.read('/etc/system-release') if match = /\d+\.\d+/.match(release) match[0] end end end end def get_bluewhite_release_with_release_file 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 def get_redhatish_release_with_release_file case get_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 def get_debian_release_with_release_file if release = Facter::Util::FileRead.read('/etc/debian_version') release.sub!(/\s*$/, '') release end end def get_linux_mint_release_with_release_file regex_search_releasefile_for_release(/RELEASE\=(\d+)/, "/etc/linuxmint/info") end def get_mageia_release_with_release_file regex_search_releasefile_for_release(/Mageia release ([0-9.]+)/, "/etc/mageia-release") end def get_openwrt_release_with_release_file regex_search_releasefile_for_release(/^(\d+\.\d+.*)/, "/etc/openwrt_version") end def get_slackware_release_with_release_file regex_search_releasefile_for_release(/Slackware ([0-9.]+)/, "/etc/slackware-version") end def get_slamd64_release_with_release_file regex_search_releasefile_for_release(/^\s*\w+\s+(\d+)\.(\d+)/, "/etc/slamd64-version") end def get_ubuntu_release_with_release_file 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 def get_vmwareESX_release_with_release_file release = Facter::Core::Execution.exec('vmware -v') if match = /VMware ESX .*?(\d.*)/.match(release) match[1] end end def get_suse_release_with_release_file 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 def regex_search_releasefile_for_release(regex, releasefile) if release = Facter::Util::FileRead.read(releasefile) if match = release.match(regex) match[1] end end end end end end facter-2.4.6/lib/facter/operatingsystem/osreleaselinux.rb0000664005276200011600000000136212651736735023540 0ustar jenkinsjenkinsrequire 'facter/util/operatingsystem' require 'facter/operatingsystem/linux' module Facter module Operatingsystem class OsReleaseLinux < Linux def get_operatingsystem # Native cfacter also uses the NAME field. Facter::Util::Operatingsystem.os_release['NAME'] end def get_osfamily Facter::Util::Operatingsystem.os_release['NAME'] end def get_operatingsystemrelease @operatingsystemrelease ||= Facter::Util::Operatingsystem.os_release['VERSION_ID'] @operatingsystemrelease end def get_operatingsystemmajrelease if operatingsystemrelease = get_operatingsystemrelease operatingsystemrelease.split(".").first end end end end end facter-2.4.6/lib/facter/operatingsystem/sunos.rb0000664005276200011600000000276012651736735021650 0ustar jenkinsjenkinsrequire 'facter/util/file_read' require 'facter/operatingsystem/base' module Facter module Operatingsystem class SunOS < Base def get_operatingsystem output = Facter::Core::Execution.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 def get_osfamily "Solaris" end def get_operatingsystemrelease if release = Facter::Util::FileRead.read('/etc/release') line = release.split("\n").first # Solaris 10: Solaris 10 10/09 s10x_u8wos_08a X86 # Solaris 11 (old naming scheme): Oracle Solaris 11 11/11 X86 # Solaris 11 (new naming scheme): Oracle Solaris 11.1 SPARC if match = /\s+s(\d+)[sx]?(_u\d+)?.*(?:SPARC|X86)/.match(line) match.captures.join('') elsif match = /Solaris ([0-9\.]+(?:\s*[0-9\.\/]+))\s*(?:SPARC|X86)/.match(line) match.captures[0] else Facter[:kernelrelease].value end else Facter[:kernelrelease].value end end def get_operatingsystemmajorrelease if get_operatingsystem == "Solaris" if match = get_operatingsystemrelease.match(/^(\d+)/) match.captures[0] end end end end end end facter-2.4.6/lib/facter/operatingsystem/vmkernel.rb0000664005276200011600000000026112651736735022316 0ustar jenkinsjenkinsrequire 'facter/operatingsystem/base' module Facter module Operatingsystem class VMkernel < Base def get_operatingsystem "ESXi" end end end end facter-2.4.6/lib/facter/operatingsystem/windows.rb0000664005276200011600000000260412651736735022170 0ustar jenkinsjenkinsrequire 'facter/operatingsystem/base' module Facter module Operatingsystem class Windows < Base def get_operatingsystemrelease require 'facter/util/wmi' result = nil Facter::Util::WMI.execquery("SELECT version, producttype FROM Win32_OperatingSystem").each do |os| result = case os.version when /^6\.4/ # As of October 2014, there are no Win server releases with kernel 6.4.x. # This case prevents future releases from resolving to nil before we # can update the fact regexes. os.producttype == 1 ? "10" : Facter[:kernelrelease].value when /^6\.3/ os.producttype == 1 ? "8.1" : "2012 R2" when /^6\.2/ os.producttype == 1 ? "8" : "2012" when /^6\.1/ os.producttype == 1 ? "7" : "2008 R2" when /^6\.0/ os.producttype == 1 ? "Vista" : "2008" when /^5\.2/ if os.producttype == 1 "XP" else begin os.othertypedescription == "R2" ? "2003 R2" : "2003" rescue NoMethodError "2003" end end else Facter[:kernelrelease].value end break end result end end end end facter-2.4.6/lib/facter/operatingsystemmajrelease.rb0000664005276200011600000000261012651736735022524 0ustar jenkinsjenkins# Fact: operatingsystemmajrelease # # Purpose: Returns the major release of the operating system. # # Resolution: # Uses the release['major'] entry of the os structured fact, which itself # attempts to use its own release['full'] entry to determine the major release value. # In RedHat osfamily derivatives and Debian, splits down the release string for a decimal point # and uses the first non-decimal character. # In Solaris, uses the first non-decimal character of the release string. # In Ubuntu, uses the characters before and after the first decimal point, as in '14.04'. # In Windows, uses the full release string in the case of server releases, such as '2012 R2', # and uses the first non-decimal character in the cases of releases such as '8.1'. # # 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" "Solaris" "SuSE" "Ubuntu" "VMWareESX" # Facter.add(:operatingsystemmajrelease) do confine do !Facter.value("os")["release"]["major"].nil? end setcode { Facter.value("os")["release"]["major"].to_s } end facter-2.4.6/lib/facter/operatingsystemrelease.rb0000664005276200011600000000164012651736735022036 0ustar jenkinsjenkins# Fact: operatingsystemrelease # # Purpose: Returns the release of the operating system. # # Resolution: # Uses the release key of the os structured hash, which itself # operates on the following conditions: # # 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 fact's value. # # Caveats: # Facter.add(:operatingsystemrelease) do confine do !Facter.value("os")["release"]["full"].nil? end setcode { Facter.value("os")["release"]["full"].to_s } end facter-2.4.6/lib/facter/os.rb0000664005276200011600000000717412651736735015671 0ustar jenkinsjenkins# Fact: os # # Purpose: # Return various facts related to the machine's operating system, including: # Name: The name of the operating system. # Family: A mapping of the operating system to an operating system family. # Release: The release version of the operating system. Includes entries for the # major and minor release versions, as well as the full release string. # Lsb: Linux Standard Base information for the system. # # This fact is structured. These values are returned as a group of key-value pairs. # # Resolution: # For the name entry, if the kernel is a Linux kernel, check for the existence of a # selection of files in `/etc` to find the specific flavor. # On SunOS based kernels, attempt to determine the flavor, otherwise return Solaris. # On systems other than Linux, use the kernel value. # # For the family entry, map 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. # # For the release entry, on RedHat derivatives, returns `/etc/-release` file. # On Debian, returns `/etc/debian_version`. # On Ubuntu, parses `/etc/lsb-release` for the release version # On Suse and derivatives, parses `/etc/SuSE-release` for a selection of version # information. # On Slackware, parses `/etc/slackware-version`. # On Amazon Linux, returns the lsbdistrelease fact's value. # On Mageia, parses `/etc/mageia-release` for the release version. # On all remaining systems, returns the kernelrelease fact's value. # # For the major version, uses the value of the full release string to determine the major # release version. # In RedHat osfamily derivatives and Debian, splits down the release string for a decimal point # and uses the first non-decimal character. # In Solaris, uses the first non-decimal character of the release string. # In Ubuntu, uses the characters before and after the first decimal point, as in '14.04'. # In Windows, uses the full release string in the case of server releases, such as '2012 R2', # and uses the first non-decimal character in the cases of releases such as '8.1'. # # For the minor version, attempts to split the full release version string and return # the value of the character after the first decimal. # # For the lsb entries, uses the `lsb_release` system command. # # Caveats: # The family entry is completely reliant on the name key, and no heuristics are used. # # The major and minor release sub-facts of the release entry are not currenty # supported on all platforms. # # The lsb entries only work on Linux (and the kfreebsd derivative) systems. Requires # the `lsb_release` program, which may not be installed by default. It is only as # accurate as the output of `lsb_release`. # require 'facter/operatingsystem/implementation' Facter.add(:os, :type => :aggregate) do def os @os ||= Facter::Operatingsystem.implementation end chunk(:name) do os_hash = {} if (operatingsystem = os.get_operatingsystem) os_hash["name"] = operatingsystem os_hash end end chunk(:family) do os_hash = {} if (osfamily = os.get_osfamily) os_hash["family"] = osfamily os_hash end end chunk(:release) do os_hash = {} if (releasedata = os.get_operatingsystemrelease_hash) os_hash["release"] = releasedata os_hash unless os_hash["release"].empty? end end chunk(:lsb) do os_hash = {} if os.has_lsb? if (lsbdata = os.get_lsb_facts_hash) os_hash["lsb"] = lsbdata os_hash unless os_hash["lsb"].empty? end end end end facter-2.4.6/lib/facter/osfamily.rb0000664005276200011600000000100712651736735017060 0ustar jenkinsjenkins# Fact: osfamily # # Purpose: Returns the operating system # # Resolution: # Uses the family key of the os structured fact, which itself # 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 { Facter.value("os")["family"] } end facter-2.4.6/lib/facter/partitions.rb0000664005276200011600000000220712651736735017434 0ustar jenkinsjenkins# Fact: partitions # # Purpose: # Return the details of the disk partitions. # # This fact is structured. Values are returned as a group of key-value pairs. # # Resolution: # Parse the contents of `/sys/block//size` to receive the size (multiplying by 512 to correct for blocks-to-bytes). # # Caveats: # For Linux, only 2.6+ is supported at this time due to the reliance on sysfs. # # Author: Chris Portman require 'facter' require 'facter/util/partitions' Facter.add(:partitions) do confine do Facter::Util::Partitions.available? ? true : nil end setcode do partitions = {} Facter::Util::Partitions.list.each do |part| details = {} details['uuid'] = Facter::Util::Partitions.uuid(part) details['size'] = Facter::Util::Partitions.size(part) details['mount'] = Facter::Util::Partitions.mount(part) details['label'] = Facter::Util::Partitions.label(part) details['filesystem'] = Facter::Util::Partitions.filesystem(part) details.reject! {|k,v| v.nil? || v.to_s.empty? } partitions[part] = details end partitions end end facter-2.4.6/lib/facter/path.rb0000664005276200011600000000026712651736735016200 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-2.4.6/lib/facter/physicalprocessorcount.rb0000664005276200011600000000120112651736735022056 0ustar jenkinsjenkins# Fact: physicalprocessorcount # # Purpose: Return the number of physical processors. # # Resolution: # Uses the physicalprocessorcount key of the processors structured # fact, which itself attempts to use sysfs to get the physical IDs of # the processors and falls back to `/proc/cpuinfo` and `physical id` if # sysfs is not available. # # Caveats: # Facter.add('physicalprocessorcount') do confine do !Facter.value(:processors).nil? end setcode do processors = Facter.value(:processors) if (physicalprocessorcount = processors["physicalcount"]) physicalprocessorcount else nil end end end facter-2.4.6/lib/facter/processor.rb0000664005276200011600000000225312651736735017260 0ustar jenkinsjenkins# Fact: processor # # Purpose: # Additional Facts about the machine's CPUs. # # Resolution: # Utilizes values from the processors structured fact, which itself # uses various methods to collect CPU information, with implementation # dependent upon the OS of the system in question. # # Caveats: # # processor.rb # # Copyright (C) 2006 Mooter Media Ltd # Author: Matthew Palmer # # 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) processors = Facter.value(:processors) if processors && (processor_list = processors["models"]) processor_list.each_with_index do |processor, i| Facter.add("processor#{i}") do setcode { processor } end end end Facter.add("ProcessorCount") do confine do !Facter.value(:processors).nil? end setcode do if (processorcount = processors["count"]) processorcount else nil end end end Facter.add("Processor") do confine :kernel => [:dragonfly,:freebsd,:openbsd] setcode do Facter::Util::POSIX.sysctl("hw.model") end end facter-2.4.6/lib/facter/processors.rb0000664005276200011600000000346212651736735017446 0ustar jenkinsjenkins# Fact: processors # # Purpose: # Provide additional facts about the machine's CPUs, including: # Models: A list of processors present on the system. # Count: The number of hardware threads. # Physicalcount: The number of physical processors. # Speed: The speed of the processors on the system. # # This fact is structured. These values are returned as a group of key-value pairs. # # Resolution: # Linux and kFreeBSD parse `/proc/cpuinfo` for each processor. # AIX parses the output of `lsdev` for its processor section. # Solaris parses the output of `kstat` for each processor. # OpenBSD uses the sysctl variables `hw.model` and `hw.ncpu` for the CPU model # and the CPU count respectively. # Darwin utilizes the system profiler to collect the physical CPU count and speed. # # Caveats: # The 'speed' sub-fact is not currently supported on all platforms. require 'facter/processors/os' Facter.add(:processors, :type => :aggregate) do confine do !os.nil? end def os @os ||= Facter::Processors.implementation end chunk(:models) do processor_hash = {} processor_list = os.get_processor_list if processor_list.length > 0 processor_hash["models"] = processor_list processor_hash end end chunk(:count) do processor_hash = {} if (processor_count = os.get_processor_count) processor_hash["count"] = processor_count processor_hash end end chunk(:physicalcount) do processor_hash = {} if (physical_processor_count = os.get_physical_processor_count) processor_hash["physicalcount"] = physical_processor_count processor_hash end end chunk(:speed) do processor_hash = {} if (processor_speed = os.get_processor_speed) processor_hash["speed"] = processor_speed processor_hash end end end facter-2.4.6/lib/facter/processors/0000775005276200011600000000000012651736742017112 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/processors/os.rb0000664005276200011600000001365112651736735020070 0ustar jenkinsjenkins# Processor OS classes # # Implements processor data collection with the help # of the Util::Processor module. require 'facter/util/processor' require 'facter/util/posix' module Facter module Processors def self.implementation(kernel = Facter.value(:kernel)) case kernel when "Linux" Facter::Processors::Linux.new when "GNU/kFreeBSD" Facter::Processors::GNU.new when "Darwin" Facter::Processors::Darwin.new when "AIX" Facter::Processors::AIX.new when "HP-UX" Facter::Processors::HP_UX.new when "DragonFly", "FreeBSD" Facter::Processors::BSD.new when "OpenBSD" Facter::Processors::OpenBSD.new when "SunOS" Facter::Processors::SunOS.new when "windows" Facter::Processors::Windows.new end end class Base def get_processor_list Facter::Util::Processor.enum_cpuinfo end def get_processor_count get_processor_list.length end def get_physical_processor_count nil end def get_processor_speed nil end end class GNU < Base def get_processor_count processor_list = get_processor_list if processor_list.length != 0 processor_list.length else count_cpu_from_sysfs end end private def count_cpu_from_sysfs sysfs_cpu_directory = "/sys/devices/system/cpu" if File.exists?(sysfs_cpu_directory) lookup_pattern = "#{sysfs_cpu_directory}" + "/cpu[0-9]*" Dir.glob(lookup_pattern).length end end end class Linux < GNU def get_physical_processor_count if count = count_physical_cpu_from_sysfs count else count_physical_cpu_from_cpuinfo end end private def count_physical_cpu_from_sysfs sysfs_cpu_directory = "/sys/devices/system/cpu" if File.exists?(sysfs_cpu_directory) lookup_pattern = "#{sysfs_cpu_directory}" + "/cpu*/topology/physical_package_id" Dir.glob(lookup_pattern).collect { |f| Facter::Core::Execution.exec("cat #{f}")}.uniq.size else nil end end def count_physical_cpu_from_cpuinfo str = Facter::Core::Execution.exec("grep 'physical.\+:' /proc/cpuinfo") if str str.scan(/\d+/).uniq.size else nil end end end class Windows < Base def initialize require 'facter/util/wmi' end def get_processor_list processor_list = [] # get each physical processor Facter::Util::WMI.execquery("select * from Win32_Processor").each do |proc| # not supported before 2008 if proc.ole_respond_to?(:NumberOfLogicalProcessors) processor_num = proc.NumberOfLogicalProcessors else processor_num = 1 end processor_num.times do |i| processor_list << proc.Name.squeeze(" ") end end processor_list end def get_physical_processor_count Facter::Util::WMI.execquery("select Name from Win32_Processor").Count end end class AIX < Base def get_processor_list Facter::Util::Processor.aix_processor_list end end class HP_UX < Base def get_processor_list Facter::Util::Processor.hpux_processor_list end end class Darwin < Base def initialize require "cfpropertylist" @system_hardware_data = query_system_profiler end def get_processor_count Facter::Util::POSIX.sysctl("hw.ncpu").to_i end def get_processor_speed @system_hardware_data["current_processor_speed"] end private def query_system_profiler output = Facter::Core::Execution.exec("/usr/sbin/system_profiler -xml SPHardwareDataType 2>/dev/null") plist = CFPropertyList::List.new plist.load_str(output) parsed_xml = CFPropertyList.native_types(plist.value) parsed_xml[0]['_items'][0] end end class BSD < Base def get_processor_count Facter::Util::POSIX.sysctl("hw.ncpu").to_i end end class OpenBSD < BSD def get_physical_processor_count Facter::Util::POSIX.sysctl("hw.ncpufound").to_i end def get_processor_speed speed = Facter::Util::POSIX.sysctl("hw.cpuspeed").to_i if speed < 1000 "#{speed} MHz" else speed = speed.to_f / 1000 "#{(speed * 100).round.to_f / 100.0} GHz" end end end class SunOS < Base def initialize kernelrelease = Facter.value(:kernelrelease) @major_version = kernelrelease.split(".")[0].to_i @minor_version = kernelrelease.split(".")[1].to_i end def get_processor_list Facter::Util::Processor.enum_kstat end def get_processor_count if @major_version < 5 or (@major_version == 5 and @minor_version < 8) if count = count_cpu_with_kstat count else count_cpu_with_psrinfo end else count_cpu_with_psrinfo end end def get_physical_processor_count if @major_version > 5 or (@major_version == 5 and @minor_version >= 8) if output = Facter::Core::Execution.exec("/usr/sbin/psrinfo -p") output.to_i end else count_cpu_with_psrinfo end end private def count_cpu_with_kstat if output = Facter::Core::Execution.exec("/usr/bin/kstat cpu_info") output.scan(/\bcore_id\b\s+\d+/).uniq.length else nil end end def count_cpu_with_psrinfo if output = Facter::Core::Execution.exec("/usr/sbin/psrinfo") output.split("\n").length else nil end end end end end facter-2.4.6/lib/facter/ps.rb0000664005276200011600000000115412651736735015662 0ustar jenkinsjenkins# Fact: ps # # Purpose: # Internal fact for what to use to list all processes. Used by # the 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-2.4.6/lib/facter/puppetversion.rb0000664005276200011600000000052612651736735020165 0ustar jenkinsjenkins# Fact: puppetversion # # Purpose: Return the version of puppet installed. # # Resolution: # Requires puppet via Ruby and returns the value of its version constant. # # Caveats: # Facter.add(:puppetversion) do setcode do begin require 'puppet/version' Puppet.version.to_s rescue LoadError nil end end end facter-2.4.6/lib/facter/rackspace.rb0000664005276200011600000000161612651736735017177 0ustar jenkinsjenkins# Fact: rsc_ # # Purpose: Determine information about Rackspace cloud instances. # # Resolution: # If this is a Rackspace Cloud instance, populates `rsc_` facts: `is_rsc`, `rsc_region`, # and `rsc_instance_id`. # # Caveats: # Depends on Xenstore. # Facter.add(:is_rsc) do setcode do result = Facter::Util::Resolution.exec("/usr/bin/xenstore-read vm-data/provider_data/provider 2> /dev/null") if result == "Rackspace" "true" end end end Facter.add(:rsc_region) do confine :is_rsc => "true" setcode do Facter::Util::Resolution.exec("/usr/bin/xenstore-read vm-data/provider_data/region 2> /dev/null") end end Facter.add(:rsc_instance_id) do confine :is_rsc => "true" setcode do result = Facter::Util::Resolution.exec("/usr/bin/xenstore-read name") if result and (match = result.match(/instance-(.*)/)) match[1] end end end facter-2.4.6/lib/facter/rubyplatform.rb0000664005276200011600000000036212651736735017766 0ustar jenkinsjenkins# Fact: rubyplatform # # Purpose: Returns the platform of Ruby that facter is running under. # # Resolution: Returns the value of the `RUBY_PLATFORM` constant. # # Caveats: # Facter.add(:rubyplatform) do setcode { RUBY_PLATFORM.to_s } end facter-2.4.6/lib/facter/rubysitedir.rb0000664005276200011600000000034212651736735017603 0ustar jenkinsjenkins# Fact: rubysitedir # # Purpose: Returns Ruby's site library directory. # # Resolution: # Uses the RbConfig module. # require 'rbconfig' Facter.add :rubysitedir do setcode do RbConfig::CONFIG["sitelibdir"] end end facter-2.4.6/lib/facter/rubyversion.rb0000664005276200011600000000035512651736735017631 0ustar jenkinsjenkins# Fact: rubyversion # # Purpose: Returns the version of Ruby that facter is running under. # # Resolution: Returns the value of the `RUBY_VERSION` constant. # # Caveats: # Facter.add(:rubyversion) do setcode { RUBY_VERSION.to_s } end facter-2.4.6/lib/facter/selinux.rb0000664005276200011600000000756412651736735016742 0ustar jenkinsjenkins# Fact: selinux # # Purpose: # Determine whether SE Linux is enabled on the node. # # Resolution: # Checks for the existence of the enforce file under the SE Linux mount # point (e.g. `/selinux/enforce`) and returns true if `/proc/self/attr/current` # does not contain the kernel. # # Caveats: # # Fact: selinux_config_mode # # Purpose: # Returns the configured SE Linux mode (e.g., `enforcing`, `permissive`, or `disabled`). # # Resolution: # Parses the output of `sestatus_cmd` and returns the value of the line beginning # with `Mode from config file:`. # # Caveats: # # Fact: selinux_config_policy # # Purpose: # Returns the configured SE Linux policy (e.g., `targeted`, `MLS`, or `minimum`). # # Resolution: # Parses the output of `sestatus_cmd` and returns the value of the line beginning # with `Policy from config file:`. # # Caveats: # # Fact: selinux_enforced # # Purpose: # Returns whether SE Linux is enabled (`true`) or not (`false`). # # Resolution: # Returns the value found in the `enforce` file under the SE Linux mount # point (e.g. `/selinux/enforce`). # # Caveats: # # Fact: selinux_policyversion # # Purpose: # Returns the current SE Linux policy version. # # Resolution: # Reads the content of the `policyvers` file found under the SE Linux mount point, # e.g. `/selinux/policyvers`. # # 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::Core::Execution.exec('cat /proc/self/mounts').each_line.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") begin if (File.read("/proc/self/attr/current") != "kernel\0") result = true end rescue 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::Core::Execution.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::Core::Execution.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::Core::Execution.exec(sestatus_cmd) mode.each_line { |l| result = $2 if l =~ /^(Policy from config file|Loaded policy name)\:\s+(\w+)$/i } result.chomp end end facter-2.4.6/lib/facter/ssh.rb0000664005276200011600000000307212651736735016036 0ustar jenkinsjenkins# Fact: ssh # # Purpose: # Gather facts related to SSH. # # 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 }, "SSHED25519Key" => { :file => "ssh_host_ed25519_key.pub", :sshfprrtype => 4 } }.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-2.4.6/lib/facter/system32.rb0000664005276200011600000000116612651736735016734 0ustar jenkinsjenkins# Fact: system32 # # Purpose: Returns the directory of the native system32 directory. # For 32-bit ruby on 32-bit Windows, typically: 'C:\Windows\system32'. # For 32-bit ruby on 64-bit Windows, typically: 'C:\Windows\sysnative'. # For 64-bit ruby on 64-bit Windows, typically: 'C:\Windows\system32'. # # Resolution: Checks for the existence of the `sysnative` directory, otherwise # uses `system32` # Facter.add(:system32) do confine :kernel => :windows setcode do if File.exist?("#{ENV['SYSTEMROOT']}\\sysnative") "#{ENV['SYSTEMROOT']}\\sysnative" else "#{ENV['SYSTEMROOT']}\\system32" end end end facter-2.4.6/lib/facter/system_uptime.rb0000664005276200011600000000231512651736735020147 0ustar jenkinsjenkins# Fact: system_uptime # # Purpose: # Return the system uptime in a hash in the forms of # seconds, hours, days and a general, human # readable uptime. # # This fact is structured. These values are returned as a group of key-value pairs. # # Resolution: # Does basic math on the get_uptime_seconds utility # to calculate seconds, hours and days. # # Caveats: # require 'facter/util/uptime' Facter.add(:system_uptime) do setcode do system_uptime = {} if Facter.value(:kernel) == 'windows' seconds = Facter::Util::Uptime.get_uptime_seconds_win else seconds = Facter::Util::Uptime.get_uptime_seconds_unix end if seconds system_uptime['seconds'] = seconds minutes = seconds / 60 % 60 system_uptime['hours'] = seconds / (60 * 60) system_uptime['days'] = system_uptime['hours'] / 24 case system_uptime['days'] when 0 then system_uptime['uptime'] = "#{system_uptime['hours']}:#{"%02d" % minutes} hours" when 1 then system_uptime['uptime'] = "1 day" else system_uptime['uptime'] = "#{system_uptime['days']} days" end else system_uptime['uptime'] = 'unknown' end system_uptime end end facter-2.4.6/lib/facter/timezone.rb0000664005276200011600000000027212651736735017072 0ustar jenkinsjenkins# Fact: timezone # # Purpose: Return the machine's time zone. # # Resolution: Uses Ruby's Time module. # # Caveats: # Facter.add("timezone") do setcode do Time.new.zone end end facter-2.4.6/lib/facter/uniqueid.rb0000664005276200011600000000014612651736735017063 0ustar jenkinsjenkinsFacter.add(:uniqueid) do setcode 'hostid' confine :kernel => %w{SunOS Linux AIX GNU/kFreeBSD} end facter-2.4.6/lib/facter/uptime.rb0000664005276200011600000000053612651736735016546 0ustar jenkinsjenkins# Fact: uptime # # Purpose: Return the system uptime in a human-readable format. # # Resolution: # Uses the structured system_uptime fact, which does basic math # on the number of seconds of uptime to return a count of days # and hours of uptime. # # Caveats: # Facter.add(:uptime) do setcode { Facter.value(:system_uptime)['uptime'] } end facter-2.4.6/lib/facter/uptime_days.rb0000664005276200011600000000043112651736735017560 0ustar jenkinsjenkins# Fact: uptime_days # # Purpose: Return just the number of days of uptime. # # Resolution: Uses the "days" key of the system_uptime fact, which divides # its own "hours" key by 24 # # Caveats: # Facter.add(:uptime_days) do setcode { Facter.value(:system_uptime)['days'] } end facter-2.4.6/lib/facter/uptime_hours.rb0000664005276200011600000000044312651736735017763 0ustar jenkinsjenkins# Fact: uptime_hours # # Purpose: Return just the number of hours of uptime. # # Resolution: Uses the "hours" key of the system_uptime fact, which divides # its own 'seconds' key by 3600. # # Caveats: # Facter.add(:uptime_hours) do setcode { Facter.value(:system_uptime)['hours'] } end facter-2.4.6/lib/facter/uptime_seconds.rb0000664005276200011600000000102612651736735020257 0ustar jenkinsjenkins# Fact: uptime_seconds # # Purpose: Return just the number of seconds of uptime. # # Resolution: # Acquires the uptime in seconds via the 'seconds' key of the system_uptime fact, # which uses the `facter/util/uptime.rb` module to try a variety 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.value(:system_uptime)['seconds'] } end facter-2.4.6/lib/facter/util/0000775005276200011600000000000012651736742015665 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/util/architecture.rb0000664005276200011600000000115412651736735020677 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::Core::Execution.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::Core::Execution.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-2.4.6/lib/facter/util/collection.rb0000664005276200011600000000644212651736735020355 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. # # @api private 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. def [](name) value(name) end # Define a new fact or extend an existing fact. # # @param name [Symbol] The name of the fact to define # @param options [Hash] A hash of options to set on the fact # # @return [Facter::Util::Fact] The fact that was defined def define_fact(name, options = {}, &block) fact = create_or_return_fact(name, options) if block_given? fact.instance_eval(&block) end fact rescue => e Facter.log_exception(e, "Unable to add fact #{name}: #{e}") 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. # # @param name [Symbol] The name of the fact to define # @param options [Hash] A hash of options to set on the fact and resolution # # @return [Facter::Util::Fact] The fact that was defined def add(name, options = {}, &block) fact = create_or_return_fact(name, options) fact.add(options, &block) 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 create_or_return_fact(name, options) name = canonicalize(name) fact = @facts[name] if fact.nil? fact = Facter::Util::Fact.new(name, options) @facts[name] = fact else fact.extract_ldapname_option!(options) end fact end 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-2.4.6/lib/facter/util/composite_loader.rb0000664005276200011600000000040312651736735021541 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-2.4.6/lib/facter/util/config.rb0000664005276200011600000000436512651736735017471 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=(dir) @external_facts_dirs = dir end def self.external_facts_dirs @external_facts_dirs end def self.setup_default_ext_facts_dirs if Facter::Util::Root.root? windows_dir = windows_data_dir if windows_dir.nil? then # Note: Beginning with Facter 3, /opt/puppetlabs/facter/facts.d will be the only # default external fact directory. @external_facts_dirs = ["/opt/puppetlabs/facter/facts.d", "/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"] else @external_facts_dirs = [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')] end elsif ENV['HOME'] # Note: Beginning with Facter 3, ~/.puppetlabs/opt/facter/facts.d will be the only # default external fact directory. @external_facts_dirs = [File.expand_path(File.join(ENV['HOME'], ".puppetlabs", "opt", "facter", "facts.d")), File.expand_path(File.join(ENV['HOME'], ".facter", "facts.d"))] else @external_facts_dirs = [] end end if Facter::Util::Config.is_windows? require 'win32/dir' require 'facter/util/windows_root' else require 'facter/util/unix_root' end setup_default_ext_facts_dirs def self.override_binary_dir=(dir) @override_binary_dir = dir end def self.override_binary_dir @override_binary_dir end def self.setup_default_override_binary_dir if Facter::Util::Config.is_windows? @override_binary_dir = nil else @override_binary_dir = "/opt/puppetlabs/puppet/bin" end end setup_default_override_binary_dir end facter-2.4.6/lib/facter/util/confine.rb0000664005276200011600000000363612651736735017645 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. # # @param fact [Symbol] Name of the fact # @param values [Array] One or more values to match against. # They can be any type that provides a === method. # @param block [Proc] Alternatively a block can be supplied as a check. The fact # value will be passed as the argument to the block. If the block returns # true then the fact will be enabled, otherwise it will be disabled. def initialize(fact = nil, *values, &block) raise ArgumentError, "The fact name must be provided" unless fact or block_given? if values.empty? and not block_given? raise ArgumentError, "One or more values or a block must be provided" end @fact = fact @values = values @block = block end def to_s return @block.to_s if @block return "'%s' '%s'" % [@fact, @values.join(",")] end # Evaluate the fact, returning true or false. # if we have a block paramter then we only evaluate that instead def true? if @block and not @fact then begin return !! @block.call rescue StandardError => error Facter.debug "Confine raised #{error.class} #{error}" return false end end unless fact = Facter[@fact] Facter.debug "No fact for %s" % @fact return false end value = convert(fact.value) return false if value.nil? if @block then begin return !! @block.call(value) rescue StandardError => error Facter.debug "Confine raised #{error.class} #{error}" return false end end return @values.any? do |v| convert(v) === value end end end facter-2.4.6/lib/facter/util/dhcp_servers.rb0000664005276200011600000000336612651736735020713 0ustar jenkinsjenkinsrequire 'facter/util/file_read' module Facter::Util::DHCPServers def self.gateway_device interface = nil if routes = Facter::Util::FileRead.read('/proc/net/route') routes.each_line do |line| device, destination = line.split(' ') if destination == '00000000' interface = device break end end end interface end def self.devices if Facter::Core::Execution.which('nmcli') Facter::Core::Execution.exec("nmcli d").split("\n").select {|d| d =~ /\sconnected/i }.collect{ |line| line.split[0] } else [] end end def self.device_dhcp_server(device) if Facter::Core::Execution.which('nmcli') # If the version is >= 0.9.9, use show instead of list if is_newer_nmcli? Facter::Core::Execution.exec("nmcli -f all d show #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first else Facter::Core::Execution.exec("nmcli -f all d list iface #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first end end end def self.network_manager_state # If the version is >= 0.9.9, use g instead of nm if is_newer_nmcli? output = Facter::Core::Execution.exec('nmcli -t -f STATE g 2>/dev/null') else output = Facter::Core::Execution.exec('nmcli -t -f STATE nm 2>/dev/null') end return nil unless output output.strip end def self.nmcli_version if version = Facter::Core::Execution.exec("nmcli --version") version.scan(/version\s(\d+)\.?(\d+)?\.?(\d+)?\.?(\d+)?/).flatten.map(&:to_i) end end def self.is_newer_nmcli? version = nmcli_version version && (version[0] > 0 || version[1] > 9 || (version[1] == 9 && version[2] >= 9)) end end facter-2.4.6/lib/facter/util/directory_loader.rb0000664005276200011600000000444512651736735021555 0ustar jenkinsjenkins# A Facter plugin that loads external facts. # # Default Unix Directories: # /opt/puppetlabs/facter/facts.d, /etc/facter/facts.d, /etc/puppetlabs/facter/facts.d # # Beginning with Facter 3, only /opt/puppetlabs/facter/facts.d will be a default external fact # directory in Unix. # # 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, weight = nil) @directory = dir @weight = weight || EXTERNAL_FACT_WEIGHT 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) weight = @weight 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(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-2.4.6/lib/facter/util/ec2.rb0000664005276200011600000000673212651736735016675 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) Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead") 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.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead") !!(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.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead") !!(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? Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead") 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::Core::Execution.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") Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead") 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-2.4.6/lib/facter/util/fact.rb0000664005276200011600000001221612651736735017133 0ustar jenkinsjenkinsrequire 'facter' require 'facter/util/resolution' require 'facter/core/aggregate' # This class represents a fact. Each fact has a name and multiple # {Facter::Util::Resolution resolutions}. # # Create facts using {Facter.add} # # @api public class Facter::Util::Fact # The name of the fact # @return [String] attr_accessor :name # @return [String] # @deprecated attr_accessor :ldapname # Creates a new fact, with no resolution mechanisms. See {Facter.add} # for the public API for creating facts. # @param name [String] the fact name # @param options [Hash] optional parameters # @option options [String] :ldapname set the ldapname property on the fact # # @api private def initialize(name, options = {}) @name = name.to_s.downcase.intern extract_ldapname_option!(options) @ldapname ||= @name.to_s @resolves = [] @searching = false @value = nil end # Adds a new {Facter::Util::Resolution resolution}. This requires a # block, which will then be evaluated in the context of the new # resolution. # # @param options [Hash] A hash of options to set on the resolution # # @return [Facter::Util::Resolution] # # @api private def add(options = {}, &block) define_resolution(nil, options, &block) end # Define a new named resolution or return an existing resolution with # the given name. # # @param resolution_name [String] The name of the resolve to define or look up # @param options [Hash] A hash of options to set on the resolution # @return [Facter::Util::Resolution] # # @api public def define_resolution(resolution_name, options = {}, &block) resolution_type = options.delete(:type) || :simple resolve = create_or_return_resolution(resolution_name, resolution_type) resolve.set_options(options) unless options.empty? resolve.evaluate(&block) if block resolve rescue => e Facter.log_exception(e, "Unable to add resolve #{resolution_name.inspect} for fact #{@name}: #{e.message}") end # Retrieve an existing resolution by name # # @param name [String] # # @return [Facter::Util::Resolution, nil] The resolution if exists, nil if # it doesn't exist or name is nil def resolution(name) return nil if name.nil? @resolves.find { |resolve| resolve.name == name } end # Flushes any cached values. # # @return [void] # # @api private def flush @resolves.each { |r| r.flush } @value = nil end # Returns the value for this fact. This searches all resolutions by # suitability and weight (see {Facter::Util::Resolution}). If no # suitable resolution is found, it returns nil. # # @api public 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 # @api private # @deprecated def extract_ldapname_option!(options) if options[:ldapname] Facter.warnonce("ldapname is deprecated and will be removed in a future version") self.ldapname = options.delete(:ldapname) 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 = 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 create_or_return_resolution(resolution_name, resolution_type) resolve = self.resolution(resolution_name) if resolve if resolution_type != resolve.resolution_type raise ArgumentError, "Cannot return resolution #{resolution_name} with type" + " #{resolution_type}; already defined as #{resolve.resolution_type}" end else case resolution_type when :simple resolve = Facter::Util::Resolution.new(resolution_name, self) when :aggregate resolve = Facter::Core::Aggregate.new(resolution_name, self) else raise ArgumentError, "Expected resolution type to be one of (:simple, :aggregate) but was #{resolution_type}" end @resolves << resolve end resolve end end facter-2.4.6/lib/facter/util/file_read.rb0000664005276200011600000000223412651736735020127 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::Core::Execution.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 # # @param path [String] the path to be read # # @return [String, nil] the raw contents of the file 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-2.4.6/lib/facter/util/formatter.rb0000664005276200011600000000164712651736735020227 0ustar jenkinsjenkinsrequire 'yaml' module Facter module Util module Formatter def self.format_json(hash) if Facter.json? JSON.pretty_generate(hash) else raise "Cannot format facts as JSON; 'json' library is not present" end end def self.format_yaml(hash) YAML.dump(hash) end def self.format_plaintext(hash) output = '' # Print the value of a single fact, otherwise print a list sorted by fact # name and separated by "=>" if hash.length == 1 if !(value = hash.values.first).nil? output = value.is_a?(String) ? value : value.inspect end else hash.sort_by { |(name, value)| name }.each do |name,value| value = value.is_a?(String) ? value : value.inspect output << "#{name} => #{value}\n" end end output end end end end facter-2.4.6/lib/facter/util/ip.rb0000664005276200011600000002664612651736735016642 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:?\s*(\d+)/i }, :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.*/ }, :aix => { :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})/, :netmask => /netmask\s+0x(\w{8})/, :mtu => /mtu\s+(\d+)/, :macaddress => /^Hardware\sAddress:\s(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ }, :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, :aix] 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', 'AIX' 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::Core::Execution.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 ## # exec_netstat uses the netstat command # # @return [String] the output of `netstat #{arguments} 2>/dev/null` or nil def self.exec_netstat(additional_arguments=[]) Facter::Core::Execution.exec("#{self.get_netstat} #{additional_arguments.join(' ')}") end ## # get_netstat looks up the netstat binary # # @return [String] path to the netstat binary def self.get_netstat common_paths=["/bin/netstat","/sbin/netstat","/usr/sbin/netstat","/usr/bin/netstat"] 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::Core::Execution.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 when 'AIX' output = Facter::Util::IP.ifconfig_interface(interface) + "\n" + aix_get_mtu(interface) + "\n" + aix_get_macadress(interface) output end output end def self.hpux_ifconfig_interface(interface) Facter::Util::IP.exec_ifconfig([interface]) end def self.hpux_lanscan Facter::Core::Execution.exec("/usr/sbin/lanscan") end def self.aix_lsattr_interface(interface) Facter::Core::Execution.exec("/usr/sbin/lsattr -El #{interface}") end def self.aix_entstat_interface(interface) if interface[0..1] != "lo" Facter::Core::Execution.exec("/usr/bin/entstat #{interface}") else return "" end end def self.aix_get_mtu(interface) aix_lsattr_interface(interface).each_line do |s| if s =~ /mtu\s+(\d+)/ return s end end end def self.aix_get_macadress(interface) aix_entstat_interface(interface).each_line do |s| if s =~ /^Hardware\sAddress:\s(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ return s end end 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' if 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-2.4.6/lib/facter/util/ip/0000775005276200011600000000000012651736742016275 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/util/ip/windows.rb0000664005276200011600000001445212651736735020324 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 |sub_nic| interface_names << sub_nic.NetConnectionId unless sub_nic.NetConnectionId.nil? or sub_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-2.4.6/lib/facter/util/loader.rb0000664005276200011600000000750212651736735017466 0ustar jenkinsjenkinsrequire 'facter' require 'pathname' require 'facter/util/directory_loader' # Load facts on demand. class Facter::Util::Loader def initialize(environment_vars = ENV) @loaded = [] @environment_vars = environment_vars end # Load all resolutions for a single fact. # # @api public # @param name [Symbol] def load(fact) # Now load from the search path shortname = fact.to_s.downcase load_env(shortname) filename = shortname + ".rb" paths = search_path unless paths.nil? paths.each do |dir| # Load individual files file = File.join(dir, filename) load_file(file) if File.file?(file) end end end # Load all facts from all directories. # # @api public def load_all return if defined?(@loaded_all) load_env paths = search_path unless paths.nil? paths.each do |dir| # dir is already an absolute path Dir.glob(File.join(dir, '*.rb')).each do |path| # exclude dirs that end with .rb load_file(path) if File.file?(path) end end end @loaded_all = true end # List directories to search for fact files. # # Search paths are gathered from the following sources: # # 1. $LOAD_PATH entries are expanded to absolute paths # 2. ENV['FACTERLIB'] is split and used verbatim # 3. Entries from Facter.search_path are used verbatim # # A warning will be generated for paths in Facter.search_path that are not # absolute directories. # # @api public # @return [Array] def search_path search_paths = [] search_paths += $LOAD_PATH.map { |path| File.expand_path('facter', path) } if @environment_vars.include?("FACTERLIB") search_paths += @environment_vars["FACTERLIB"].split(File::PATH_SEPARATOR) end search_paths.delete_if { |path| ! valid_search_path?(path) } Facter.search_path.each do |path| if valid_search_path?(path) search_paths << path else Facter.warn "Excluding #{path} from search path. Fact file paths must be an absolute directory" end end search_paths.delete_if { |path| ! File.directory?(path) } search_paths.uniq end private # Validate that the given path is valid, ie it is an absolute path. # # @api private # @param path [String] # @return [Boolean] def valid_search_path?(path) Pathname.new(path).absolute? end # Load a file and record is paths to prevent duplicate loads. # # @api private # @params file [String] The *absolute path* to the file to load 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.log_exception(detail, "Error loading fact #{file}: #{detail.message}") end end # Load and execute the Ruby program specified in the file. This exists # for testing purposes. # # @api private # @return [Boolean] def kernel_load(file) Kernel.load(file) 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 @environment_vars.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-2.4.6/lib/facter/util/macaddress.rb0000664005276200011600000000202212651736735020316 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-2.4.6/lib/facter/util/macosx.rb0000664005276200011600000000435712651736735017517 0ustar jenkinsjenkins## macosx.rb ## Support methods for Apple OSX facts ## ## Copyright (C) 2007 Jeff McCune ## Author: Jeff McCune ## module Facter::Util::Macosx require '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::Core::Execution.exec("/usr/sbin/system_profiler -xml #{data_field} 2>/dev/null") end def self.intern_xml(xml) return nil unless xml bad_xml_doctype = /^.* e raise RuntimeError, "A plist file could not be properly read by CFPropertyList: #{e.message}", e.backtrace end 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::Core::Execution.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-2.4.6/lib/facter/util/manufacturer.rb0000664005276200011600000000524112651736735020712 0ustar jenkinsjenkins# mamufacturer.rb # Support methods for manufacturer specific facts require 'facter/util/posix' module Facter::Manufacturer def self.get_dmi_table() case Facter.value(:kernel) when 'Linux', 'GNU/kFreeBSD' cmd = '/usr/sbin/dmidecode' when 'FreeBSD' cmd = '/usr/local/sbin/dmidecode' when 'NetBSD', 'DragonFly' cmd = '/usr/pkg/sbin/dmidecode' when 'SunOS' cmd = '/usr/sbin/smbios' end if cmd and (output = Facter::Core::Execution.exec("#{cmd} 2>/dev/null")) if output.respond_to?(:force_encoding) output.force_encoding(Encoding::ASCII_8BIT) end return output end 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 { Facter::Util::POSIX.sysctl(sysctlkey) } 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::Core::Execution.exec('/usr/sbin/prtdiag 2>/dev/null | /usr/bin/head -n 10') # 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 "/usr/sbin/sneep" 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-2.4.6/lib/facter/util/memory.rb0000664005276200011600000001405212651736735017526 0ustar jenkinsjenkins## memory.rb ## Support module for memory related facts ## require 'facter/util/posix' 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::Core::Execution.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::Core::Execution.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::Core::Execution.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 /Dragonfly/i, /FreeBSD/i, /OpenBSD/i Facter::Util::POSIX.sysctl("hw.physmem") when /Darwin/i Facter::Util::POSIX.sysctl("hw.memsize") when /AIX/i if Facter::Core::Execution.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::Core::Execution.exec('swap -l 2>/dev/null') : nil when /OpenBSD/i Facter::Core::Execution.exec('swapctl -s') when /FreeBSD/i Facter::Core::Execution.exec('swapinfo -k') when /Darwin/i Facter::Util::POSIX.sysctl('vm.swapusage') when /SunOS/i Facter::Core::Execution.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+) (\d+)-blocks allocated, (\d+) used, (\d+) available$/ (is_size) ? ($1.to_i * $2.to_i) : ($4.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 /FreeBSD/i value.to_f / 1024.0 when /OpenBSD/i value.to_f / 1024.0 / 1024.0 when /SunOS/i value.to_f / 2 / 1024.0 else value.to_f end end end facter-2.4.6/lib/facter/util/netmask.rb0000664005276200011600000000236512651736735017664 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.value(:ipaddress)}.*?(?:Mask:|netmask)\s*(#{ipregex})}x, :munge => nil, } when 'SunOS' ops = { :ifconfig_opts => ['-a'], :regex => %r{\s+ inet \s #{Facter.value(: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', 'AIX' ops = { :ifconfig_opts => ['-a'], :regex => %r{\s+ inet \s #{Facter.value(: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-2.4.6/lib/facter/util/normalization.rb0000664005276200011600000000573712651736735021116 0ustar jenkinsjenkinsmodule Facter module Util module Normalization class NormalizationError < StandardError; end VALID_TYPES = [Integer, Float, TrueClass, FalseClass, NilClass, String, Array, Hash] module_function # Recursively normalize the given data structure # # @api public # @raise [NormalizationError] If the data structure contained an invalid element. # @return [void] def normalize(value) case value when Integer, Float, TrueClass, FalseClass, NilClass value when String normalize_string(value) when Array normalize_array(value) when Hash normalize_hash(value) else raise NormalizationError, "Expected #{value} to be one of #{VALID_TYPES.inspect}, but was #{value.class}" end end # @!method normalize_string(value) # # Attempt to normalize and validate the given string. # # On Ruby 1.8 the string is checked by stripping out all non UTF-8 # characters and comparing the converted string to the original. If they # do not match then the string is considered invalid. # # On Ruby 1.9+, the string is validate by checking that the string encoding # is UTF-8 and that the string content matches the encoding. If the string # is not an expected encoding then it is converted to UTF-8. # # @api public # @raise [NormalizationError] If the string used an unsupported encoding or did not match its encoding # @param value [String] # @return [void] if RUBY_VERSION =~ /^1\.8/ require 'iconv' def normalize_string(value) converted = Iconv.conv('UTF-8//IGNORE', 'UTF-8', value) if converted != value raise NormalizationError, "String #{value.inspect} is not valid UTF-8" end value end else def normalize_string(value) value = value.encode(Encoding::UTF_8) unless value.valid_encoding? raise NormalizationError, "String #{value.inspect} doesn't match the reported encoding #{value.encoding}" end value rescue EncodingError raise NormalizationError, "String encoding #{value.encoding} is not UTF-8 and could not be converted to UTF-8" end end # Validate all elements of the array. # # @api public # @raise [NormalizationError] If one of the elements failed validation # @param value [Array] # @return [void] def normalize_array(value) value.collect do |elem| normalize(elem) end end # Validate all keys and values of the hash. # # @api public # @raise [NormalizationError] If one of the keys or values failed normalization # @param value [Hash] # @return [void] def normalize_hash(value) Hash[value.collect { |k, v| [ normalize(k), normalize(v) ] } ] end end end end facter-2.4.6/lib/facter/util/nothing_loader.rb0000664005276200011600000000035512651736735021213 0ustar jenkinsjenkinsmodule Facter module Util # An external fact loader that doesn't load anything # This makes it possible to disable loading # of external facts class NothingLoader def load(collection) end end end end facter-2.4.6/lib/facter/util/operatingsystem.rb0000664005276200011600000000073312651736735021454 0ustar jenkinsjenkinsmodule Facter module Util module Operatingsystem # @see http://www.freedesktop.org/software/systemd/man/os-release.html def self.os_release(file = '/etc/os-release') values = {} if File.readable?(file) File.readlines(file).each do |line| if (match = line.match(/^(\w+)=["']?(.+?)["']?$/)) values[match[1]] = match[2] end end end values end end end end facter-2.4.6/lib/facter/util/parser.rb0000664005276200011600000001055612651736735017517 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.log_exception(detail, "Failed to handle #{filename} as #{self.class} facts: #{detail.message}") 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::Core::Execution.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 powershell = if File.exists?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe") "#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe" elsif File.exists?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe") "#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe" else 'powershell.exe' end shell_command = "\"#{powershell}\" -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{filename}\"" output = Facter::Core::Execution.exec(shell_command) KeyValuePairOutputFormat.parse(output) 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-2.4.6/lib/facter/util/partitions.rb0000664005276200011600000000146512651736735020416 0ustar jenkinsjenkinsrequire 'facter/util/partitions/linux' require 'facter/util/partitions/openbsd' module Facter::Util::Partitions IMPLEMENTATIONS = { 'Linux' => Linux, 'OpenBSD' => OpenBSD, } module NoImplementation def self.list [] end end def self.implementation IMPLEMENTATIONS[Facter.fact(:kernel).value] || NoImplementation end def self.list implementation.list end def self.uuid(partition) implementation.uuid(partition) end def self.size(partition) implementation.size(partition) end def self.mount(partition) implementation.mount(partition) end def self.filesystem(partition) implementation.filesystem(partition) end def self.label(partition) implementation.label(partition) end def self.available? !self.list.empty? end end facter-2.4.6/lib/facter/util/partitions/0000775005276200011600000000000012651736742020061 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/util/partitions/linux.rb0000664005276200011600000000432712651736735021555 0ustar jenkinsjenkinsmodule Facter::Util::Partitions module Linux # Only Linux 2.6+ kernels support sysfs which is required to easily get device details SYSFS_BLOCK_DIRECTORY = '/sys/block/' DEVDISK_BY_UUID_DIRECTORY = '/dev/disk/by-uuid/' def self.list if File.exist?(SYSFS_BLOCK_DIRECTORY) devices = Dir.entries(SYSFS_BLOCK_DIRECTORY).select { |d| File.exist?( SYSFS_BLOCK_DIRECTORY + d + "/device" ) } if devices.empty? [] else devices.collect do |device| Dir.glob( SYSFS_BLOCK_DIRECTORY + device + "/#{device}*" ).collect do |d| File.basename(d) end end.flatten end else [] end end def self.uuid(partition) uuid = nil if File.exist?(DEVDISK_BY_UUID_DIRECTORY) Dir.entries(DEVDISK_BY_UUID_DIRECTORY).each do |file| qualified_file = File.join(DEVDISK_BY_UUID_DIRECTORY, file) #A uuid is 16 octets long (RFC4122) which is 32hex chars + 4 '-'s next unless file.length == 36 next unless File.symlink?(qualified_file) next unless File.readlink(qualified_file).match(%r[(?:\.\./\.\./|/dev/)#{partition}$]) uuid = file end end uuid end def self.size(partition) read_size(partition) end def self.mount(partition) if Facter::Core::Execution.which('mount') Facter::Core::Execution.exec('mount').scan(/\/dev\/#{partition}\son\s(\S+)/).flatten.first end end def self.filesystem(partition) if Facter::Core::Execution.which('blkid') Facter::Core::Execution.exec("blkid #{File.join('/dev', partition)}").scan(/TYPE="([^"]*)"/).flatten.first end end def self.label(partition) if Facter::Core::Execution.which('blkid') Facter::Core::Execution.exec("blkid #{File.join('/dev', partition)}").scan(/LABEL="([^"]*)"/).flatten.first end end private def self.read_size(partition) if device = partition.match(/(\D+)/)[1] and File.readable?(File.join(SYSFS_BLOCK_DIRECTORY, device, partition, 'size')) File.read(File.join(SYSFS_BLOCK_DIRECTORY, device, partition, 'size')).chomp end end end end facter-2.4.6/lib/facter/util/partitions/openbsd.rb0000664005276200011600000000170712651736735022047 0ustar jenkinsjenkinsmodule Facter::Util::Partitions module OpenBSD def self.list Facter::Core::Execution.exec('df').scan(/\/dev\/(\S+)/).flatten end # On OpenBSD partitions don't have a UUID; disks have DUID but that's not # compatible. def self.uuid(partition) nil end def self.mount(partition) scan_mount(/\/dev\/#{partition}\son\s(\S+)/) end # Reported size is in 1K blocks def self.size(partition) scan_df(/\/dev\/#{partition}\s+(\S+)/) end def self.filesystem(partition) scan_mount(/\/dev\/#{partition}\son\s\S+\stype\s(\S+)/) end # On OpenBSD there are no labels for partitions def self.label(partition) nil end private def self.scan_mount(scan_regex) Facter::Core::Execution.exec('mount').scan(scan_regex).flatten.first end def self.scan_df(scan_regex) Facter::Core::Execution.exec('df -k').scan(scan_regex).flatten.first end end end facter-2.4.6/lib/facter/util/plist.rb0000664005276200011600000000130012651736735017341 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-2.4.6/lib/facter/util/plist/0000775005276200011600000000000012651736742017020 5ustar jenkinsjenkinsfacter-2.4.6/lib/facter/util/plist/generator.rb0000664005276200011600000001577012651736735021347 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(Plist::Emit.dump(obj)) 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-2.4.6/lib/facter/util/plist/parser.rb0000664005276200011600000001143112651736735020643 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-2.4.6/lib/facter/util/posix.rb0000664005276200011600000000047312651736735017362 0ustar jenkinsjenkinsmodule Facter module Util module POSIX # Provides a consistent way of invoking sysctl(8) across POSIX platforms # # @param mib [String] the sysctl(8) MIB name # # @api private def sysctl(mib) Facter::Util::Resolution.exec("sysctl -n #{mib} 2>/dev/null") end module_function :sysctl end end end facter-2.4.6/lib/facter/util/processor.rb0000664005276200011600000002074412651736735020242 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::Core::Execution.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::Core::Execution.exec(command) end ## # lsattr is intended to directly delegate to Facter::Core::Execution.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::Core::Execution.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::Core::Execution.exec, as with lsdev # above. def self.machinfo(command="/usr/contrib/bin/machinfo") Facter::Core::Execution.exec(command) end ## # model delegates directly to Facter::Core::Execution.exec. def self.model(command="model") Facter::Core::Execution.exec(command) end ## # ioscan delegates directly to Facter::Core::Execution.exec. def self.ioscan(command="ioscan -fknCprocessor") Facter::Core::Execution.exec(command) end ## # getconf_cpu_version delegates directly to Facter::Core::Execution.exec. def self.getconf_cpu_version(command="getconf CPU_VERSION") Facter::Core::Execution.exec(command) end ## # getconf_cpu_chip_type delegates directly to Facter::Core::Execution.exec. def self.getconf_cpu_chip_type(command="getconf CPU_CHIP_TYPE") Facter::Core::Execution.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", "ppc64le" 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 = [] kstat = Facter::Core::Execution.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 processor_list end end end end facter-2.4.6/lib/facter/util/registry.rb0000664005276200011600000000035212651736735020064 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-2.4.6/lib/facter/util/resolution.rb0000664005276200011600000001035212651736735020420 0ustar jenkinsjenkinsrequire 'facter/util/confine' require 'facter/util/config' require 'facter/util/normalization' require 'facter/core/execution' require 'facter/core/resolvable' require 'facter/core/suitable' # This represents a fact resolution. A resolution is a concrete # implementation of a fact. A single fact can have many resolutions and # the correct resolution will be chosen at runtime. Each time # {Facter.add} is called, a new resolution is created and added to the # set of resolutions for the fact named in the call. Each resolution # has a {#has_weight weight}, which defines its priority over other # resolutions, and a set of {#confine _confinements_}, which defines the # conditions under which it will be chosen. All confinements must be # satisfied for a fact to be considered _suitable_. # # @api public class Facter::Util::Resolution # @api private attr_accessor :code attr_writer :value extend Facter::Core::Execution class << self # Expose command execution methods that were extracted into # Facter::Core::Execution from Facter::Util::Resolution in Facter 2.0.0 for # compatibility. # # @deprecated public :search_paths, :which, :absolute_path?, :expand_command, :with_env, :exec end include Facter::Core::Resolvable include Facter::Core::Suitable # @!attribute [rw] name # The name of this resolution. The resolution name should be unique with # respect to the given fact. # @return [String] # @api public attr_accessor :name # @!attribute [r] fact # @return [Facter::Util::Fact] # @api private attr_reader :fact # Create a new resolution mechanism. # # @param name [String] The name of the resolution. # @return [void] # # @api private def initialize(name, fact) @name = name @fact = fact @confines = [] @value = nil @timeout = 0 @weight = nil end def resolution_type :simple end # Evaluate the given block in the context of this resolution. If a block has # already been evaluated emit a warning to that effect. # # @return [void] def evaluate(&block) if @last_evaluated msg = "Already evaluated #{@name}" msg << " at #{@last_evaluated}" if msg.is_a? String msg << ", reevaluating anyways" Facter.warn msg end instance_eval(&block) # Ruby 1.9+ provides the source location of procs which can provide useful # debugging information if a resolution is being evaluated twice. Since 1.8 # doesn't support this we opportunistically provide this information. if block.respond_to? :source_location @last_evaluated = block.source_location.join(':') else @last_evaluated = true end end def set_options(options) if options[:name] @name = options.delete(:name) end if options.has_key?(:value) @value = options.delete(:value) end if options.has_key?(:timeout) @timeout = options.delete(:timeout) end if options.has_key?(:weight) @weight = options.delete(:weight) end if not options.keys.empty? raise ArgumentError, "Invalid resolution options #{options.keys.inspect}" end end # Sets the code block or external program that will be evaluated to # get the value of the fact. # # @return [void] # # @overload setcode(string) # Sets an external program to call to get the value of the resolution # @param [String] string the external program to run to get the # value # # @overload setcode(&block) # Sets the resolution's value by evaluating a block at runtime # @param [Proc] block The block to determine the resolution's value. # This block is run when the fact is evaluated. Errors raised from # inside the block are rescued and printed to stderr. # # @api public def setcode(string = nil, &block) if string @code = Proc.new do output = Facter::Core::Execution.execute(string, :on_fail => nil) if output.nil? or output.empty? nil else output end end elsif block_given? @code = block else raise ArgumentError, "You must pass either code or a block" end end private def resolve_value if @value @value elsif @code.nil? nil elsif @code @code.call() end end end facter-2.4.6/lib/facter/util/solaris_zones.rb0000664005276200011600000001125112651736735021106 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::Core::Execution.execute(zoneadm_cmd, {:on_fail => nil}) 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-2.4.6/lib/facter/util/unix_root.rb0000664005276200011600000000011212651736735020234 0ustar jenkinsjenkinsmodule Facter::Util::Root def self.root? Process.uid == 0 end end facter-2.4.6/lib/facter/util/uptime.rb0000664005276200011600000000433112651736735017520 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 output = Facter::Core::Execution.execute("/bin/cat #{uptime_file} 2>/dev/null") if not output.empty? output.chomp.split(" ").first.to_i end end def self.uptime_sysctl require 'facter/util/posix' output = Facter::Util::POSIX.sysctl(uptime_sysctl_variable) if output compute_uptime(Time.at(output.match(/\d+/)[0].to_i)) end end def self.uptime_executable output = Facter::Core::Execution.execute("#{uptime_executable_cmd} 2>/dev/null", :on_fail => nil) if output 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. Certain versions of uptime on # Solaris may insert a '-' into the minutes field. 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_variable 'kern.boottime' end def self.uptime_executable_cmd "uptime" end end facter-2.4.6/lib/facter/util/values.rb0000664005276200011600000000641012651736735017514 0ustar jenkinsjenkins module Facter module Util # A util module for facter containing helper methods module Values module_function class DeepFreezeError < StandardError; end # Duplicate and deeply freeze a given data structure # # @param value [Object] The structure to freeze # @return [void] def deep_freeze(value) case value when Numeric, Symbol, TrueClass, FalseClass, NilClass # These are immutable values, we can safely ignore them value when String value.dup.freeze when Array value.map do |entry| deep_freeze(entry) end.freeze when Hash value.inject({}) do |hash, (key, value)| hash[deep_freeze(key)] = deep_freeze(value) hash end.freeze else raise DeepFreezeError, "Cannot deep freeze #{value}:#{value.class}" end end class DeepMergeError < StandardError; end # Perform a deep merge of two nested data structures. # # @param left [Object] # @param right [Object] # @param path [Array] The traversal path followed when merging nested hashes # # @return [Object] The merged data structure. def deep_merge(left, right, path = [], &block) ret = nil if left.is_a? Hash and right.is_a? Hash ret = left.merge(right) do |key, left_val, right_val| path.push(key) merged = deep_merge(left_val, right_val, path) path.pop merged end elsif left.is_a? Array and right.is_a? Array ret = left.dup.concat(right) elsif right.nil? ret = left elsif left.nil? ret = right elsif left.nil? and right.nil? ret = nil else msg = "Cannot merge #{left.inspect}:#{left.class} and #{right.inspect}:#{right.class}" if not path.empty? msg << " at root" msg << path.map { |part| "[#{part.inspect}]" }.join end raise DeepMergeError, msg end ret end def convert(value) value = value.to_s if value.is_a?(Symbol) value = value.downcase if value.is_a?(String) value end # Flatten the given data structure to something that's suitable to return # as flat facts. # # @param path [String] The fact path to be prefixed to the given value. # @param structure [Object] The data structure to flatten. Nested hashes # will be recursively flattened, everything else will be returned as-is. # # @return [Hash] The given data structure prefixed with the given path def flatten_structure(path, structure) results = {} if structure.is_a? Hash structure.each_pair do |name, value| new_path = "#{path}_#{name}".gsub(/\-|\//, '_') results.merge! flatten_structure(new_path, value) end elsif structure.is_a? Array structure.each_with_index do |value, index| new_path = "#{path}_#{index}" results.merge! flatten_structure(new_path, value) end else results[path] = structure end results end end end end facter-2.4.6/lib/facter/util/virtual.rb0000664005276200011600000001432212651736735017704 0ustar jenkinsjenkinsrequire 'facter/util/posix' require 'facter/util/file_read' require 'pathname' 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::Core::Execution.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(cmd = "virt-what") if bindir = Facter::Util::Config.override_binary_dir command = Facter::Core::Execution.which(File.join(bindir, cmd)) else command = nil end if !command command = Facter::Core::Execution.which(cmd) return unless command end if Facter.value(:kernel) == 'windows' redirected_cmd = "#{command} 2>NUL" else redirected_cmd = "#{command} 2>/dev/null" end output = Facter::Core::Execution.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::Core::Execution.exec def self.lspci(command = nil) if command.nil? if ["FreeBSD", "OpenBSD"].include? Facter.value(:kernel) command = "pciconf -lv 2>/dev/null" else command = "lspci 2>/dev/null" end end Facter::Core::Execution.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::Core::Execution.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::Core::Execution.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::POSIX.sysctl("hw.model") elsif Facter.value(:kernel) == "SunOS" and FileTest.exists?("/usr/sbin/prtconf") Facter::Core::Execution.exec("/usr/sbin/prtconf -v") end (txt =~ /QEMU Virtual (CPU|Machine)/i) ? 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.gce? File.read("/sys/devices/virtual/dmi/id/product_name") =~ /Google/ rescue false end def self.jail? path = case Facter.value(:kernel) when "FreeBSD" then "/sbin" when "GNU/kFreeBSD" then "/bin" end Facter::Core::Execution.exec("#{path}/sysctl -n security.jail.jailed") == "1" end def self.hpvm? Facter::Core::Execution.exec("/usr/bin/getconf MACHINE_MODEL").chomp =~ /Virtual Machine/ end ## # lxc? returns true if the process is running inside of a linux container. # Implementation derived from # http://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker def self.lxc? path = Pathname.new('/proc/1/cgroup') return false unless path.readable? begin in_lxc = path.readlines.any? {|l| l.split(":")[2].to_s.include? '/lxc' } rescue Errno::EPERM => exc # If we get "operation not permitted" here, it probably means we are # running OpenVZ. We are not running LXC anyway, so... return false end return true if in_lxc return false end ## # docker? returns true if the process is running inside of a docker container. # Implementation derived from observation of a boot2docker system def self.docker? path = Pathname.new('/proc/1/cgroup') return false unless path.readable? begin in_docker = path.readlines.any? {|l| l.split(":")[2].to_s.include? '/docker' } rescue Errno::EPERM => exc # This can fail under OpenVZ, just like in .lxc? return false end return true if in_docker return false 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 or is unreadable def self.read_sysfs_dmi_entries(path="/sys/firmware/dmi/entries/1-0/raw") if File.readable?(path) begin Facter::Util::FileRead.read_binary(path) rescue Errno::EINVAL end end end end facter-2.4.6/lib/facter/util/vlans.rb0000664005276200011600000000101612651736735017335 0ustar jenkinsjenkins# A module to gather vlan facts # module Facter::Util::Vlans def self.get_vlan_config if File.exist?('/proc/net/vlan/config') and File.readable?('/proc/net/vlan/config') File.read('/proc/net/vlan/config') end end def self.get_vlans if (config = self.get_vlan_config) vlans = [] config.each_line do |line| if (match = line.match(/^([0-9A-Za-z]+)\.([0-9]+) /)) vlans << match[2] if match[2] end end vlans.join(',') unless vlans.empty? end end end facter-2.4.6/lib/facter/util/windows_root.rb0000664005276200011600000000016612651736735020754 0ustar jenkinsjenkinsrequire 'win32/security' module Facter::Util::Root def self.root? Win32::Security.elevated_security? end end facter-2.4.6/lib/facter/util/wmi.rb0000664005276200011600000000052212651736735017007 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-2.4.6/lib/facter/util/xendomains.rb0000664005276200011600000000146612651736735020370 0ustar jenkinsjenkins# A module to gather running Xen Domains # module Facter::Util::Xendomains XEN_COMMANDS = ['/usr/sbin/xl', '/usr/sbin/xm'] def self.xen_command if File.file?('/usr/lib/xen-common/bin/xen-toolstack') xen_toolstack_cmd = Facter::Util::Resolution.exec('/usr/lib/xen-common/bin/xen-toolstack') if xen_toolstack_cmd xen_toolstack_cmd.chomp else nil end else XEN_COMMANDS.find { |cmd| Facter::Util::Resolution.which(cmd) } end end def self.get_domains command = self.xen_command if command if domains_list = Facter::Util::Resolution.exec("#{command} list 2>/dev/null") domains = domains_list.split("\n").reject { |line| line =~ /^(Name|Domain-0)/ } domains.map { |line| line.split(/\s/)[0] }.join(',') end end end end facter-2.4.6/lib/facter/version.rb0000664005276200011600000000642012651736735016726 0ustar jenkinsjenkinsmodule Facter if not defined? FACTERVERSION then FACTERVERSION = '2.4.6' end # Returns the running version of Facter. # # @comment 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 of # 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 # Sets the Facter version # # @return [void] # # @api private def self.version=(version) @facter_version = version end # This reads the content of the "VERSION" file that lives in the # same directory as this source code file. # # @api private # # @return [String] the version -- 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-2.4.6/lib/facter/virtual.rb0000664005276200011600000002234712651736735016735 0ustar jenkinsjenkins# Fact: virtual # # Purpose: Determine if the system's hardware is real or virtualized. # # Resolution: # Assumes physical unless proven otherwise. # # On Darwin, use the macosx util module to acquire the SPHardwareDataType # and SPEthernetDataType, from which it is possible to determine if the host is # a VMware, Parallels, or VirtualBox. This previously used SPDisplaysDataType, # which was not reliable if running headless, and also caused lagging issues # on actual Macs. # # On Linux, BSD, Solaris and HPUX: Much of the logic here is obscured behind # `util/virtual.rb`, which you can consult directly for more detailed resolution # information. # 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 that # it's VMware. # # Caveats: # Many checks rely purely on existence of files. # # Fact: is_virtual # # Purpose: Return `true` or `false` depending on whether a machine is virtualized 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: # require 'facter/util/virtual' Facter.add("virtual") do confine :kernel => "Darwin" setcode do require 'facter/util/macosx' result = "physical" # use SPHardwareDataType for VMware and VirtualBox, since it is the most # reliable source. output = Facter::Util::Macosx.profiler_data("SPHardwareDataType") if output.is_a?(Hash) result = "vmware" if output["machine_model"] =~ /VMware/ result = "virtualbox" if output["boot_rom_version"] =~ /VirtualBox/ end # Parallels passes through almost all of the host's hardware info to the # virtual machine, so use a different field. output = Facter::Util::Macosx.profiler_data("SPEthernetDataType") if output.is_a?(Hash) result = "parallels" if output["spethernet_subsystem-vendor-id"] =~ /0x1ab8/ 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 self.timeout = 20 setcode do next "zone" if Facter::Util::Virtual.zone? output = Facter::Core::Execution.exec('prtdiag 2>/dev/null') 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 => 'SunOS' confine :hardwareisa => 'sparc' confine :ldom_domainrole_control => 'false' has_weight 20 # Weight this before the default solaris implementation setcode do Facter.value(:ldom_domainrole_impl) 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::POSIX.sysctl("hw.product") 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 "ovirt" if lines.any? {|l| l =~ /oVirt Node/ } next "kvm" if lines.any? {|l| l =~ /KVM/ } 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") || FileTest.exists?("/dev/xvda1") 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/ } next "kvm" if lines.any? {|l| l =~ /virtio/i } end # Parse dmidecode output = Facter::Core::Execution.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/ } next "bochs" if lines.any? {|l| l =~ /Bochs/ } next "kvm" if lines.any? {|l| l =~ /Manufacturer: QEMU/ } end # Default to 'physical' next 'physical' end end Facter.add("virtual") do confine do Facter::Core::Execution.which('vmware') end setcode do # Sample output of vmware -v `VMware Server 1.0.5 build-80187` output = Facter::Core::Execution.exec("vmware -v") if output mdata = output.match /(\S+)\s+(\S+)/ next "#{mdata[1]}_#{mdata[2]}".downcase if mdata end 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 ## # virtual fact specific to linux containers. This also works for Docker # containers running in lxc. Facter.add("virtual") do has_weight 700 confine :kernel => "Linux" setcode do "lxc" if Facter::Util::Virtual.lxc? end end ## # virtual fact specific to docker containers. Facter.add("virtual") do has_weight 750 confine :kernel => "Linux" setcode do "docker" if Facter::Util::Virtual.docker? end end Facter.add("virtual") do has_weight 600 confine :kernel => "Linux" setcode do "gce" if Facter::Util::Virtual.gce? end end 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-2.4.6/lib/facter/vlans.rb0000664005276200011600000000051012651736735016356 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-2.4.6/lib/facter/xendomains.rb0000664005276200011600000000063212651736735017405 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-2.4.6/lib/facter/zfs_version.rb0000664005276200011600000000070212651736735017605 0ustar jenkinsjenkinsrequire 'facter' Facter.add('zfs_version') do setcode do if Facter::Core::Execution.which('zfs') zfs_help = Facter::Core::Execution.exec('zfs -? 2> /dev/null') zfs_has_upgrade = zfs_help.match(/\A.*upgrade.*\z/m) unless zfs_help.nil? if zfs_has_upgrade zfs_v = Facter::Core::Execution.exec('zfs upgrade -v') zfs_version = zfs_v.scan(/^\s+(\d+)\s+/m).flatten.last unless zfs_v.nil? end end end end facter-2.4.6/lib/facter/zonename.rb0000664005276200011600000000014212651736735017050 0ustar jenkinsjenkinsrequire 'facter' Facter.add('zonename') do confine :kernel => :sunos setcode('zonename') end facter-2.4.6/lib/facter/zones.rb0000664005276200011600000000105212651736735016373 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: # Only supported on Solaris 10 and up. # require 'facter/util/solaris_zones' if Facter.value(:kernel) == 'SunOS' Facter::Util::SolarisZones.add_facts end facter-2.4.6/lib/facter/zpool_version.rb0000664005276200011600000000042412651736735020147 0ustar jenkinsjenkinsrequire 'facter' Facter.add('zpool_version') do setcode do if Facter::Core::Execution.which('zpool') zpool_v = Facter::Core::Execution.exec('zpool upgrade -v') zpool_version = zpool_v.scan(/^\s+(\d+)\s+/m).flatten.last unless zpool_v.nil? end end end facter-2.4.6/libexec/0000775005276200011600000000000012651736742014311 5ustar jenkinsjenkinsfacter-2.4.6/libexec/ext/0000775005276200011600000000000012651736742015111 5ustar jenkinsjenkinsfacter-2.4.6/libexec/ext/README0000664005276200011600000000022612651736735015773 0ustar jenkinsjenkinsThis directory is for external facts. For more information see the documentation available here: http://docs.puppetlabs.com/guides/custom_facts.html facter-2.4.6/man/0000775005276200011600000000000012651736742013451 5ustar jenkinsjenkinsfacter-2.4.6/man/man8/0000775005276200011600000000000012651736742014314 5ustar jenkinsjenkinsfacter-2.4.6/man/man8/facter.80000664005276200011600000000416212651736735015656 0ustar jenkinsjenkins.\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . .TH "FACTER" "8" "February 2014" "" "" . .SH "NAME" \fBfacter\fR \- Gather system information . .SH "SYNOPSIS" Collect and display facts about the system\. . .SH "USAGE" . .nf facter [\-h|\-\-help] [\-t|\-\-timing] [\-d|\-\-debug] [\-p|\-\-puppet] [\-v|\-\-version] [\-y|\-\-yaml] [\-j|\-\-json] [\-\-plaintext] [\-\-external\-dir DIR] [\-\-no\-external\-dir] [fact] [fact] [\.\.\.] . .fi . .SH "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\. . .P If no facts are specifically asked for, then all facts will be returned\. . .SH "EXAMPLE" Display all facts: . .IP "" 4 . .nf $ facter architecture => amd64 blockdevices => sda,sr0 domain => example\.com fqdn => puppet\.example\.com hardwaremodel => x86_64 [\.\.\.] . .fi . .IP "" 0 . .P Display a single fact: . .IP "" 4 . .nf $ facter kernel Linux . .fi . .IP "" 0 . .P Format facts as JSON: . .IP "" 4 . .nf $ facter \-\-json architecture kernel hardwaremodel { "architecture": "amd64", "kernel": "Linux", "hardwaremodel": "x86_64" } . .fi . .IP "" 0 . .SH "AUTHOR" Luke Kanies . .SH "COPYRIGHT" Copyright (c) 2011\-2014 Puppet Labs, Inc Licensed under the Apache 2\.0 license . .SH "OPTIONS" . .nf \-y, \-\-yaml Emit facts in YAML format\. \-j, \-\-json Emit facts in JSON format\. \-\-plaintext Emit facts in plaintext format\. \-\-trace Enable backtraces\. \-\-external\-dir DIR The directory to use for external facts\. \-\-no\-external\-dir Turn off external facts\. \-d, \-\-debug Enable debugging\. \-t, \-\-timing Enable timing\. \-p, \-\-puppet Load the Puppet libraries, thus allowing Facter to load Puppet\-specific facts\. \-v, \-\-version Print the version and exit\. \-h, \-\-help Print this help message\. . .fi facter-2.4.6/spec/0000775005276200011600000000000012651736742013630 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/0000775005276200011600000000000012651736742015501 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/cpuinfo/0000775005276200011600000000000012651736742017144 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/cpuinfo/amd64dual0000664005276200011600000000236112651736735020654 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-2.4.6/spec/fixtures/cpuinfo/amd64dual-grep0000664005276200011600000000005012651736735021600 0ustar jenkinsjenkinsphysical id : 0 physical id : 0 facter-2.4.6/spec/fixtures/cpuinfo/amd64quad0000664005276200011600000000512712651736735020664 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-2.4.6/spec/fixtures/cpuinfo/amd64solo0000664005276200011600000000105212651736735020677 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-2.4.6/spec/fixtures/cpuinfo/amd64tri0000664005276200011600000000355212651736735020530 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-2.4.6/spec/fixtures/cpuinfo/amd64twentyfour0000664005276200011600000004777612651736735022200 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-2.4.6/spec/fixtures/cpuinfo/amd64twentyfour-grep0000664005276200011600000000074012651736735023107 0ustar jenkinsjenkinsphysical id : 0 physical id : 0 physical id : 0 physical id : 0 physical id : 0 physical id : 0 physical id : 1 physical id : 1 physical id : 1 physical id : 1 physical id : 1 physical id : 1 physical id : 0 physical id : 0 physical id : 0 physical id : 0 physical id : 0 physical id : 0 physical id : 1 physical id : 1 physical id : 1 physical id : 1 physical id : 1 physical id : 1 facter-2.4.6/spec/fixtures/cpuinfo/bbg3-armel0000664005276200011600000000045612651736735021011 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-2.4.6/spec/fixtures/cpuinfo/beaglexm-armel0000664005276200011600000000043312651736735021753 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-2.4.6/spec/fixtures/cpuinfo/panda-armel0000664005276200011600000000052712651736735021256 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-2.4.6/spec/fixtures/cpuinfo/ppc640000664005276200011600000000067612651736735020036 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-2.4.6/spec/fixtures/cpuinfo/ppc64le0000664005276200011600000000065412651736735020353 0ustar jenkinsjenkinsprocessor : 0 cpu : POWER8E (raw), altivec supported clock : 3690.000000MHz revision : 2.1 (pvr 004b 0201) processor : 1 cpu : POWER8E (raw), altivec supported clock : 3690.000000MHz revision : 2.1 (pvr 004b 0201) timebase : 512000000 platform : PowerNV model : 8247-22L machine : PowerNV 8247-22L firmware : OPAL v3 facter-2.4.6/spec/fixtures/cpuinfo/sparc0000664005276200011600000000036512651736735020205 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-2.4.6/spec/fixtures/cpuinfo/two_multicore-grep0000664005276200011600000000012012651736735022711 0ustar jenkinsjenkinsphysical id : 0 physical id : 0 physical id : 1 physical id : 1 facter-2.4.6/spec/fixtures/cpuinfo/two_singlecore-grep0000664005276200011600000000005012651736735023042 0ustar jenkinsjenkinsphysical id : 0 physical id : 1 facter-2.4.6/spec/fixtures/hpux/0000775005276200011600000000000012651736742016465 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/hpux/machinfo/0000775005276200011600000000000012651736742020251 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/hpux/machinfo/hppa-rp44400000664005276200011600000000121712651736735022062 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-2.4.6/spec/fixtures/hpux/machinfo/ia64-rx26200000664005276200011600000000313412651736735021703 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-2.4.6/spec/fixtures/hpux/machinfo/ia64-rx66000000664005276200011600000000132612651736735021706 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-2.4.6/spec/fixtures/hpux/machinfo/ia64-rx86400000664005276200011600000000345412651736735021720 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-2.4.6/spec/fixtures/hpux/machinfo/superdome-server-SD32B0000664005276200011600000000350412651736735024262 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-2.4.6/spec/fixtures/hpux/machinfo/superdome2-16s0000664005276200011600000000153312651736735022674 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-2.4.6/spec/fixtures/hpux/sched.models0000664005276200011600000000604712651736735020771 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-2.4.6/spec/fixtures/hpux/unistd.h0000664005276200011600000017721712651736735020165 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-2.4.6/spec/fixtures/ifconfig/0000775005276200011600000000000012651736742017265 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces0000664005276200011600000000151512651736735027631 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-2.4.6/spec/fixtures/ifconfig/centos_5_50000664005276200011600000000157112651736735021161 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-2.4.6/spec/fixtures/ifconfig/centos_5_5_eth00000664005276200011600000000076612651736735022106 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-2.4.6/spec/fixtures/ifconfig/darwin_10_3_00000664005276200011600000000235712651736735021446 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-2.4.6/spec/fixtures/ifconfig/darwin_10_3_0_en00000664005276200011600000000050112651736735022175 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-2.4.6/spec/fixtures/ifconfig/darwin_10_6_40000664005276200011600000000227512651736735021454 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-2.4.6/spec/fixtures/ifconfig/darwin_10_6_4_en10000664005276200011600000000041512651736735022211 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-2.4.6/spec/fixtures/ifconfig/darwin_10_6_6_dualstack0000664005276200011600000000045212651736735023504 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-2.4.6/spec/fixtures/ifconfig/darwin_10_6_6_dualstack_en10000664005276200011600000000045012651736735024245 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-2.4.6/spec/fixtures/ifconfig/darwin_9_8_00000664005276200011600000000401212651736735021371 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-2.4.6/spec/fixtures/ifconfig/darwin_9_8_0_en00000664005276200011600000000126712651736735022144 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-2.4.6/spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces0000664005276200011600000000177612651736735030356 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-2.4.6/spec/fixtures/ifconfig/fedora_100000664005276200011600000000355112651736735020756 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-2.4.6/spec/fixtures/ifconfig/fedora_10_eth00000664005276200011600000000104012651736735021665 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-2.4.6/spec/fixtures/ifconfig/fedora_130000664005276200011600000000166212651736735020762 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-2.4.6/spec/fixtures/ifconfig/fedora_13_eth00000664005276200011600000000103512651736735021674 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-2.4.6/spec/fixtures/ifconfig/fedora_80000664005276200011600000000346012651736735020704 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-2.4.6/spec/fixtures/ifconfig/fedora_8_eth00000664005276200011600000000102512651736735021617 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-2.4.6/spec/fixtures/ifconfig/freebsd_6_00000664005276200011600000000117212651736735021271 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-2.4.6/spec/fixtures/ifconfig/ifconfig_net_tools_1.60.txt0000664005276200011600000000204012651736735024342 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-2.4.6/spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt0000664005276200011600000000146612651736735023673 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-2.4.6/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces0000664005276200011600000000176412651736735030226 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-2.4.6/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces_and_fe800000664005276200011600000000176412651736735031672 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:fe80: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-2.4.6/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces_and_no_public_ipv60000664005276200011600000000165412651736735034044 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: 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-2.4.6/spec/fixtures/ifconfig/linux_ifconfig_no_addr0000664005276200011600000000204012651736735023677 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-2.4.6/spec/fixtures/ifconfig/linux_ifconfig_no_mac0000664005276200011600000000053212651736735023531 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-2.4.6/spec/fixtures/ifconfig/linux_ifconfig_venet0000664005276200011600000000254212651736735023421 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-2.4.6/spec/fixtures/ifconfig/open_solaris_100000664005276200011600000000123412651736735022207 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-2.4.6/spec/fixtures/ifconfig/open_solaris_b1320000664005276200011600000000214312651736735022436 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-2.4.6/spec/fixtures/ifconfig/openbsd_bridge_rules0000664005276200011600000000054712651736735023400 0ustar jenkinsjenkinsbridge0: flags=41 groups: bridge priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp vlan1 flags=3 port 5 ifpriority 0 ifcost 0 em0 flags=7 port 1 ifpriority 0 ifcost 0 block out on em0 src 00:24:21:ef:1b:de pflog0: flags=41 mtu 33152 priority: 0 groups: pflog facter-2.4.6/spec/fixtures/ifconfig/sunos_ifconfig_all_with_multiple_interfaces0000664005276200011600000000113612651736735030227 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-2.4.6/spec/fixtures/ifconfig/ubuntu_7_040000664005276200011600000000356412651736735021275 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-2.4.6/spec/fixtures/ifconfig/ubuntu_7_04_eth00000664005276200011600000000100312651736735022177 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-2.4.6/spec/fixtures/ldom/0000775005276200011600000000000012651736742016434 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/ldom/ldom_v10000664005276200011600000000033312651736735017721 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-2.4.6/spec/fixtures/netstat/0000775005276200011600000000000012651736742017163 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/netstat/centos_5_50000664005276200011600000000052112651736735021051 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-2.4.6/spec/fixtures/netstat/darwin_10_3_00000664005276200011600000000470612651736735021344 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-2.4.6/spec/fixtures/netstat/darwin_10_6_40000664005276200011600000000320412651736735021343 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-2.4.6/spec/fixtures/netstat/darwin_10_6_6_dualstack0000664005276200011600000000500312651736735023377 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-2.4.6/spec/fixtures/netstat/darwin_9_8_00000664005276200011600000000342312651736735021274 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-2.4.6/spec/fixtures/netstat/fedora_100000664005276200011600000000076112651736735020654 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-2.4.6/spec/fixtures/netstat/open_solaris_100000664005276200011600000000206012651736735022103 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-2.4.6/spec/fixtures/netstat/open_solaris_b1320000664005276200011600000000217112651736735022335 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-2.4.6/spec/fixtures/netstat/ubuntu_7_040000664005276200011600000000075512651736735021172 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-2.4.6/spec/fixtures/processorcount/0000775005276200011600000000000012651736742020571 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/processorcount/solaris-psrinfo0000664005276200011600000000204012651736735023644 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-2.4.6/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info0000664005276200011600000014643412651736735026156 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-2.4.6/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info0000664005276200011600000002316612651736735026000 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-2.4.6/spec/fixtures/unit/0000775005276200011600000000000012651736742016460 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/dhcp_servers/0000775005276200011600000000000012651736742021147 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/dhcp_servers/nmcli_devices0000664005276200011600000000024712651736735023703 0ustar jenkinsjenkinsDEVICE TYPE STATE wlan0 802-11-wireless connected eth0 802-3-ethernet connected eth1 802-3-ethernet disconnected facter-2.4.6/spec/fixtures/unit/dhcp_servers/nmcli_devices_disconnected0000664005276200011600000000025512651736735026424 0ustar jenkinsjenkinsDEVICE TYPE STATE wlan0 802-11-wireless disconnected eth0 802-3-ethernet disconnected eth1 802-3-ethernet disconnected facter-2.4.6/spec/fixtures/unit/dhcp_servers/nmcli_eth0_dhcp0000664005276200011600000000432312651736735024116 0ustar jenkinsjenkinsGENERAL.DEVICE: eth0 GENERAL.TYPE: 802-3-ethernet GENERAL.VENDOR: Realtek Semiconductor Co., Ltd. GENERAL.PRODUCT: RTL8111/8168 PCI Express Gigabit Ethernet controller GENERAL.DRIVER: r8169 GENERAL.DRIVER-VERSION: 2.3LK-NAPI GENERAL.FIRMWARE-VERSION: GENERAL.HWADDR: D4:BE:D9:34:67:68 GENERAL.STATE: 100 (connected) GENERAL.REASON: 0 (No reason given) GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.0/0000:07:00.0/net/eth0 GENERAL.IP-IFACE: eth0 GENERAL.NM-MANAGED: yes GENERAL.AUTOCONNECT: yes GENERAL.FIRMWARE-MISSING: no GENERAL.CONNECTION: /org/freedesktop/NetworkManager/ActiveConnection/9 CAPABILITIES.CARRIER-DETECT: yes CAPABILITIES.SPEED: 1000 Mb/s CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{1,2} CONNECTIONS.AVAILABLE-CONNECTIONS[1]: acafdb99-23e4-49e5-a3e6-0a00575312b5 | Office CONNECTIONS.AVAILABLE-CONNECTIONS[2]: d6aaee51-2ed8-4b05-82ac-365c9c74b44e | DHCP WIRED-PROPERTIES.CARRIER: on IP4.ADDRESS[1]: ip = 192.168.1.10, gw = 192.168.1.1 IP4.DNS[1]: 192.168.1.1 DHCP4.OPTION[1]: time_offset = 0 DHCP4.OPTION[2]: expiry = 1401991971 DHCP4.OPTION[3]: broadcast_address = 192.168.1.255 DHCP4.OPTION[4]: dhcp_message_type = 5 DHCP4.OPTION[5]: dhcp_lease_time = 9999999 DHCP4.OPTION[6]: ip_address = 192.168.1.10 DHCP4.OPTION[7]: subnet_mask = 255.255.255.0 DHCP4.OPTION[8]: routers = 192.168.1.1 DHCP4.OPTION[9]: domain_name_servers = 192.168.1.1 DHCP4.OPTION[10]: network_number = 192.168.1.0 DHCP4.OPTION[11]: default_ip_ttl = 64 DHCP4.OPTION[12]: dhcp_server_identifier = 192.168.1.1 facter-2.4.6/spec/fixtures/unit/dhcp_servers/nmcli_eth0_static0000664005276200011600000000267112651736735024473 0ustar jenkinsjenkinsGENERAL.DEVICE: eth0 GENERAL.TYPE: 802-3-ethernet GENERAL.VENDOR: Realtek Semiconductor Co., Ltd. GENERAL.PRODUCT: RTL8111/8168 PCI Express Gigabit Ethernet controller GENERAL.DRIVER: r8169 GENERAL.DRIVER-VERSION: 2.3LK-NAPI GENERAL.FIRMWARE-VERSION: GENERAL.HWADDR: D4:BE:D9:34:67:68 GENERAL.STATE: 100 (connected) GENERAL.REASON: 0 (No reason given) GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.0/0000:07:00.0/net/eth0 GENERAL.IP-IFACE: eth0 GENERAL.NM-MANAGED: yes GENERAL.AUTOCONNECT: yes GENERAL.FIRMWARE-MISSING: no GENERAL.CONNECTION: /org/freedesktop/NetworkManager/ActiveConnection/9 CAPABILITIES.CARRIER-DETECT: yes CAPABILITIES.SPEED: 1000 Mb/s CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{1,2} CONNECTIONS.AVAILABLE-CONNECTIONS[1]: acafdb99-23e4-49e5-a3e6-0a00575312b5 | Office CONNECTIONS.AVAILABLE-CONNECTIONS[2]: d6aaee51-2ed8-4b05-82ac-365c9c74b44e | DHCP WIRED-PROPERTIES.CARRIER: on IP4.ADDRESS[1]: ip = 192.168.1.10, gw = 192.168.1.1 IP4.DNS[1]: 192.168.1.1 facter-2.4.6/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_dhcp0000664005276200011600000000543512651736735024304 0ustar jenkinsjenkinsGENERAL.DEVICE: wlan0 GENERAL.TYPE: 802-11-wireless GENERAL.VENDOR: Intel Corporation GENERAL.PRODUCT: Centrino Advanced-N 6235 AGN GENERAL.DRIVER: iwlwifi GENERAL.DRIVER-VERSION: 3.11.0-12-generic GENERAL.FIRMWARE-VERSION: 18.168.6.1 GENERAL.HWADDR: C4:85:08:06:2C:55 GENERAL.STATE: 100 (connected) GENERAL.REASON: 0 (No reason given) GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.2/0000:08:00.0/net/wlan0 GENERAL.IP-IFACE: wlan0 GENERAL.NM-MANAGED: yes GENERAL.AUTOCONNECT: yes GENERAL.FIRMWARE-MISSING: no GENERAL.CONNECTION: /org/freedesktop/NetworkManager/ActiveConnection/10 CAPABILITIES.CARRIER-DETECT: no CAPABILITIES.SPEED: 13 Mb/s CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{3} CONNECTIONS.AVAILABLE-CONNECTIONS[1]: 7a82c94b-afba-498b-9a62-30ebb335b365 | Auto OptusCD3_80ac32 WIFI-PROPERTIES.WEP: yes WIFI-PROPERTIES.WPA: yes WIFI-PROPERTIES.WPA2: yes WIFI-PROPERTIES.TKIP: yes WIFI-PROPERTIES.CCMP: yes WIFI-PROPERTIES.AP: yes WIFI-PROPERTIES.ADHOC: yes AP[1].SSID: 'TestSSid' AP[1].BSSID: C8:F9:F9:BE:F1:4E AP[1].MODE: Infrastructure AP[1].FREQ: 5745 MHz AP[1].RATE: 54 MB/s AP[1].SIGNAL: 72 AP[1].SECURITY: WPA WPA2 Enterprise AP[1].ACTIVE: no IP4.ADDRESS[1]: ip = 192.168.2.10/24, gw = 192.168.2.1 IP4.DNS[1]: 192.168.2.1 DHCP4.OPTION[1]: time_offset = 0 DHCP4.OPTION[2]: expiry = 1401991971 DHCP4.OPTION[3]: broadcast_address = 192.168.0.255 DHCP4.OPTION[4]: dhcp_message_type = 5 DHCP4.OPTION[5]: dhcp_lease_time = 9999999 DHCP4.OPTION[6]: ip_address = 192.168.2.10 DHCP4.OPTION[7]: subnet_mask = 255.255.255.0 DHCP4.OPTION[8]: routers = 192.168.2.1 DHCP4.OPTION[9]: domain_name_servers = 192.168.2.1 DHCP4.OPTION[10]: network_number = 192.168.2.0 DHCP4.OPTION[11]: default_ip_ttl = 64 DHCP4.OPTION[12]: dhcp_server_identifier = 192.168.2.1 facter-2.4.6/spec/fixtures/unit/dhcp_servers/nmcli_wlan0_static0000664005276200011600000000400312651736735024643 0ustar jenkinsjenkinsGENERAL.DEVICE: wlan0 GENERAL.TYPE: 802-11-wireless GENERAL.VENDOR: Intel Corporation GENERAL.PRODUCT: Centrino Advanced-N 6235 AGN GENERAL.DRIVER: iwlwifi GENERAL.DRIVER-VERSION: 3.11.0-12-generic GENERAL.FIRMWARE-VERSION: 18.168.6.1 GENERAL.HWADDR: C4:85:08:06:2C:55 GENERAL.STATE: 100 (connected) GENERAL.REASON: 0 (No reason given) GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.2/0000:08:00.0/net/wlan0 GENERAL.IP-IFACE: wlan0 GENERAL.NM-MANAGED: yes GENERAL.AUTOCONNECT: yes GENERAL.FIRMWARE-MISSING: no GENERAL.CONNECTION: /org/freedesktop/NetworkManager/ActiveConnection/10 CAPABILITIES.CARRIER-DETECT: no CAPABILITIES.SPEED: 13 Mb/s CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{3} CONNECTIONS.AVAILABLE-CONNECTIONS[1]: 7a82c94b-afba-498b-9a62-30ebb335b365 | Auto OptusCD3_80ac32 WIFI-PROPERTIES.WEP: yes WIFI-PROPERTIES.WPA: yes WIFI-PROPERTIES.WPA2: yes WIFI-PROPERTIES.TKIP: yes WIFI-PROPERTIES.CCMP: yes WIFI-PROPERTIES.AP: yes WIFI-PROPERTIES.ADHOC: yes AP[1].SSID: 'TestSSid' AP[1].BSSID: C8:F9:F9:BE:F1:4E AP[1].MODE: Infrastructure AP[1].FREQ: 5745 MHz AP[1].RATE: 54 MB/s AP[1].SIGNAL: 72 AP[1].SECURITY: WPA WPA2 Enterprise AP[1].ACTIVE: no IP4.ADDRESS[1]: ip = 192.168.2.10/24, gw = 192.168.2.1 IP4.DNS[1]: 192.168.2.1 facter-2.4.6/spec/fixtures/unit/dhcp_servers/route0000664005276200011600000000025312651736735022232 0ustar jenkinsjenkinsIface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT eth0 00000000 0110100A 0003 0 0 0 00000000 0 0 0 eth0 0010100A 00000000 0001 0 0 1 00FCFFFF 0 0 0 facter-2.4.6/spec/fixtures/unit/dhcp_servers/route_nogw0000664005276200011600000000011112651736735023255 0ustar jenkinsjenkinsIface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT facter-2.4.6/spec/fixtures/unit/ec2/0000775005276200011600000000000012651736742017131 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/ec2/rest/0000775005276200011600000000000012651736742020106 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/ec2/rest/meta-data/0000775005276200011600000000000012651736742021743 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/ec2/rest/meta-data/root0000664005276200011600000000037012651736735022653 0ustar jenkinsjenkinsami-id ami-launch-index ami-manifest-path block-device-mapping/ hostname instance-action instance-id instance-type kernel-id local-hostname local-ipv4 mac metrics/ network/ placement/ profile public-hostname public-ipv4 public-keys/ reservation-id facter-2.4.6/spec/fixtures/unit/filesystems/0000775005276200011600000000000012651736742021027 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/filesystems/linux0000664005276200011600000000065312651736735022117 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-2.4.6/spec/fixtures/unit/gce/0000775005276200011600000000000012651736742017216 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/gce/metadata/0000775005276200011600000000000012651736742020776 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/gce/metadata/metadata.json0000664005276200011600000000621512651736735023457 0ustar jenkinsjenkins{ "instance": { "attributes": {}, "description": "", "disks": [ { "deviceName": "gce-facts", "index": 0, "mode": "READ_WRITE", "type": "PERSISTENT" } ], "hostname": "gce-facts.c.dev-sand-box.internal", "id": 18287562037867659655, "image": "projects/485161417235/images/centos6", "machineType": "projects/485161417235/machineTypes/n1-standard-1", "maintenanceEvent": "NONE", "networkInterfaces": [ { "accessConfigs": [ { "externalIp": "23.251.145.218", "type": "ONE_TO_ONE_NAT" } ], "forwardedIps": [], "ip": "10.240.193.246", "network": "projects/485161417235/networks/default" } ], "scheduling": { "automaticRestart": "TRUE", "onHostMaintenance": "MIGRATE" }, "serviceAccounts": { "485161417235-u737tauareitfc5ju1t5cbmdrasr4giv@developer.gserviceaccount.com": { "aliases": [ "default" ], "email": "485161417235-u737tauareitfc5ju1t5cbmdrasr4giv@developer.gserviceaccount.com", "scopes": [ "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.full_control", "https://www.googleapis.com/auth/userinfo.email" ] }, "default": { "aliases": [ "default" ], "email": "485161417235-u737tauareitfc5ju1t5cbmdrasr4giv@developer.gserviceaccount.com", "scopes": [ "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.full_control", "https://www.googleapis.com/auth/userinfo.email" ] } }, "tags": [], "zone": "projects/485161417235/zones/us-central1-b" }, "project": { "attributes": { "sshKeys": "justin:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKTIyNpvkUHk71q79CfiMOiY9xL9bOazvDfsCLD1UaK+g6kugMRxxiFRIB7aOajOrQl/+ZJ3Cy16f/D6zmSLTMJSIQKiJsGFyCdfkbZ6YKDSKMOpqlZCSeErpJp74X4Olg37DLqkFH2MtuoclrkheY0f87CMTGc/ICr6zDF2DoYM7yCU7y8s6FckcDs6xBUYd+phduQLLuEiUxB95neESvV0ZiD4IoJsEMOj5Y5VLqvmbozlHVu8OqVtUxNj5iIwXMGG/hROvjtZQfFRYn64xhINDt/ozbesh5ah1zn6FosGwfuYM5WJeTsUN53iiXIsDDks2Kv3bLu4fOSQ/P9LEF justin@holguinj.wifi.puppetlabs.net\nadrien:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtYeE0mv03TdEZ/1Gd6SEOkG0QCFzBH/rGqji75WJpMrr9UKti7wAN3nFBWp6ElM1pxmnzGBqJPxFfsIkjRhm89hh123KlaorJQZU5pftGXGNMUo/cd/idqu3OXTMs149TGrZAlowKdzOPIx9ndNJQW6OtKmn8yFgxXFpB6kJRccjeh0erDk9Zdv+/PZL1UWmDBlNh9exPsUV9qTclih/jI1PAbA+/8Oj8MqlxrlsTltjczPe/TUbvpw/d/12d1EIF6F3f498Y4mAwB/ERQIKb55b3NwPjQJ+RwZIRpayQ8nvhxJmAn8xtbyTF4o5ORHICbGqLpbmc52h2pUieqJqf adrien@grey" }, "numericProjectId": 485161417235, "projectId": "dev-sand-box" } } facter-2.4.6/spec/fixtures/unit/interfaces/0000775005276200011600000000000012651736742020603 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt0000664005276200011600000000204012651736735025660 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-2.4.6/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.em10000664005276200011600000000120512651736735026343 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-2.4.6/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.lo0000664005276200011600000000063212651736735026276 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-2.4.6/spec/fixtures/unit/ipaddress/0000775005276200011600000000000012651736742020436 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt0000664005276200011600000000217212651736735027330 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-2.4.6/spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt0000664005276200011600000000204012651736735025513 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-2.4.6/spec/fixtures/unit/ipaddress/ifconfig_non_english_locale.txt0000664005276200011600000000163712651736735026676 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-2.4.6/spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt0000664005276200011600000000146612651736735025044 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-2.4.6/spec/fixtures/unit/kernelrelease/0000775005276200011600000000000012651736742021301 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/kernelrelease/openbsd-5.30000664005276200011600000000025512651736735023165 0ustar jenkinsjenkinsOpenBSD 5.3 (GENERIC.MP) #2: Fri May 17 15:54:55 CEST 2013 root@binpatch-53-i386.mtier.org:/home/jasper/binpatchng/work-binpatch53-i386/src/sys/arch/i386/compile/GENERIC.MP facter-2.4.6/spec/fixtures/unit/kernelrelease/openbsd-5.3-current0000664005276200011600000000021112651736735024635 0ustar jenkinsjenkinsOpenBSD 5.3-current (GENERIC.MP) #130: Wed Jun 5 15:15:03 MDT 2013 deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP facter-2.4.6/spec/fixtures/unit/memory/0000775005276200011600000000000012651736742017770 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/memory/aix-svmon0000664005276200011600000000071312651736735021637 0ustar jenkinsjenkinsUnit: KB -------------------------------------------------------------------------------------- size inuse free pin virtual available mmode memory 32768000 9948408 22819592 2432080 4448928 27231828 Ded pg space 34078720 15000 work pers clnt other pin 1478228 0 0 953852 in use 4448928 0 5499480 facter-2.4.6/spec/fixtures/unit/memory/aix-swap_l0000664005276200011600000000006512651736735021762 0ustar jenkinsjenkinsdevice maj,min total free /dev/hd6 10, 2 512MB 508MB facter-2.4.6/spec/fixtures/unit/memory/darwin-swapinfo-multiple0000664005276200011600000000023312651736735024654 0ustar jenkinsjenkinsDevice 1K-blocks Used Avail Capacity /dev/da0p3 2048540 0 1048540 0% /dev/da0p4 3048540 0 1048540 0% facter-2.4.6/spec/fixtures/unit/memory/darwin-swapinfo-single0000664005276200011600000000015012651736735024300 0ustar jenkinsjenkinsDevice 1K-blocks Used Avail Capacity /dev/da0p3 2048540 0 1048540 0% facter-2.4.6/spec/fixtures/unit/memory/darwin-vm_stat0000664005276200011600000000112512651736735022653 0ustar jenkinsjenkinsMach Virtual Memory Statistics: (page size of 4096 bytes) Pages free: 28430. Pages active: 1152576. Pages inactive: 489054. Pages speculative: 7076. Pages wired down: 418217. "Translation faults": 1340091228. Pages copy-on-write: 16851357. Pages zero filled: 665168768. Pages reactivated: 3082708. Pageins: 13862917. Pageouts: 1384383. Object cache: 14 hits of 2619925 lookups (0% hit rate) facter-2.4.6/spec/fixtures/unit/memory/dragonfly-vmstat0000664005276200011600000000035112651736735023215 0ustar jenkinsjenkins procs memory page disks faults cpu r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id 0 0 0 33152 13940 1902120 2198 53119 11642 6544597 5460994 0 0 6148243 7087927 3484264 0 1 9 facter-2.4.6/spec/fixtures/unit/memory/freebsd-vmstat0000664005276200011600000000036212651736735022644 0ustar jenkinsjenkins procs memory page disks faults cpu r b w avm fre flt re pi po fr sr da0 cd0 in sy cs us sy id 1 0 0 207600 656640 10 0 0 0 13 0 0 0 51 164 257 0 1 99 facter-2.4.6/spec/fixtures/unit/memory/linux-proc_meminfo0000664005276200011600000000033412651736735023527 0ustar jenkinsjenkinsMemTotal: 255908 kB MemFree: 69936 kB Buffers: 15812 kB Cached: 115124 kB SwapCached: 0 kB Active: 92700 kB Inactive: 63792 kB SwapTotal: 524280 kB SwapFree: 524280 kB Dirty: 4 kB facter-2.4.6/spec/fixtures/unit/memory/openbsd-vmstat0000664005276200011600000000032012651736735022656 0ustar jenkinsjenkins procs memory page disks traps cpu r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id 0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100 facter-2.4.6/spec/fixtures/unit/memory/smartos_zone_swap_l-single0000664005276200011600000000015312651736735025263 0ustar jenkinsjenkinsswapfile dev swaplo blocks free swap - 8 100663296 68968568 facter-2.4.6/spec/fixtures/unit/memory/solaris-prtconf0000664005276200011600000000016112651736735023040 0ustar jenkinsjenkinsSystem Configuration: Sun Microsystems sun4u Memory size: 2048 Megabytes System Peripherals (Software Nodes): facter-2.4.6/spec/fixtures/unit/memory/solaris-swap_l-multiple0000664005276200011600000000026112651736735024504 0ustar jenkinsjenkinsswapfile dev swaplo blocks free /dev/swap 4294967295,4294967295 16 2097136 2097136 /dev/swap2 4294967295,4294967295 16 2097136 2097136 facter-2.4.6/spec/fixtures/unit/memory/solaris-swap_l-single0000664005276200011600000000016012651736735024130 0ustar jenkinsjenkinsswapfile dev swaplo blocks free /dev/swap 4294967295,4294967295 16 2097136 2097136 facter-2.4.6/spec/fixtures/unit/memory/solaris-vmstat0000664005276200011600000000035112651736735022704 0ustar jenkinsjenkins kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr s0 s3 -- -- in sy cs us sy id 0 0 0 1154552 476224 8 19 0 0 0 0 0 0 0 0 0 460 294 236 1 2 97 facter-2.4.6/spec/fixtures/unit/netmask/0000775005276200011600000000000012651736742020122 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/netmask/darwin_10_8_5.txt0000664005276200011600000000236512651736735023132 0ustar jenkinsjenkinslo0: flags=8049 mtu 16384 options=3 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 28:cf:e9:1a:8a:2d inet6 fe80::2acf:e9ff:fe1a:8a2d%en0 prefixlen 64 scopeid 0x5 inet 10.16.141.17 netmask 0xfffffc00 broadcast 10.16.143.255 media: autoselect status: active p2p0: flags=8843 mtu 2304 ether 0a:cf:e9:1a:8a:2d media: autoselect status: inactive vmnet1: flags=8863 mtu 1500 ether 00:50:56:c0:00:01 inet 192.168.51.1 netmask 0xffffff00 broadcast 192.168.51.255 vmnet8: flags=8863 mtu 1500 ether 00:50:56:c0:00:08 inet 172.16.138.1 netmask 0xffffff00 broadcast 172.16.138.255 en3: flags=8863 mtu 1500 options=4 ether 70:11:24:8c:33:df inet6 fe80::7211:24ff:fe8c:33df%en3 prefixlen 64 scopeid 0x7 inet 10.16.16.205 netmask 0xfffffc00 broadcast 10.16.19.255 media: autoselect (100baseTX ) status: active facter-2.4.6/spec/fixtures/unit/netmask/ifconfig_aix_7.txt0000664005276200011600000000037012651736735023540 0ustar jenkinsjenkinsen0: flags=1e080863,480 inet 10.16.45.25 netmask 0xffffff00 broadcast 10.16.45.255 tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1 facter-2.4.6/spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt0000664005276200011600000000204012651736735025177 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-2.4.6/spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt0000664005276200011600000000146612651736735024530 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-2.4.6/spec/fixtures/unit/processors/0000775005276200011600000000000012651736742020662 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/processors/os/0000775005276200011600000000000012651736742021303 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/processors/os/darwin-system-profiler0000664005276200011600000003101012651736735025651 0ustar jenkinsjenkins _SPCommandLineArguments /usr/sbin/system_profiler -nospawn -xml SPHardwareDataType -detailLevel full _SPCompletionInterval 0.012148022651672363 _SPResponseTime 0.11940205097198486 _dataType SPHardwareDataType _detailLevel -2 _items SMC_version_system 2.19f7 _name hardware_overview boot_rom_version MBP112.0138.B07 cpu_type Intel Core i7 current_processor_speed 2.3 GHz l2_cache_core 256 KB l3_cache 6 MB machine_model MacBookPro11,3 machine_name MacBook Pro number_processors 4 packages 1 physical_memory 16 GB platform_UUID 24A95B44-2444-59CF-9D9B-A42CF82590AE serial_number C02MQ15KFD57 _parentDataType SPRootDataType _properties LOM_revision _order 85 Lightshow_version _order 83 _suppressLocalization YES MMM_state _order 70 SMC_version_other _order 82 SMC_version_riser _order 81 SMC_version_system _order 80 _suppressLocalization YES apple_rom_info _order 53 boot_rom_release_date _order 52 boot_rom_vendor _order 50 boot_rom_version _order 51 bus_speed _order 45 cores_per_package _order 24 cpu_interconnect_speed _order 46 cpu_type _order 15 current_processor_speed _order 17 l2_cache _order 26 l2_cache_core _order 26 l2_cache_share _order 26 l2_cache_size _order 26 l3_cache _order 27 l3_cache_processor _order 27 l3_cache_size _order 27 machine_model _order 11 machine_name _order 10 maximum_processor_speed _order 19 minimum_processor_speed _order 18 number_cpus _order 20 number_processors _order 22 packages _order 20 physical_memory _order 40 platform_UUID _detailLevel 0 _order 98 platform_cpu_features _order 30 platform_cpu_htt _order 28 platform_cpu_vendor _order 12 platform_manufacturer _order 4 platform_product_name _order 2 platform_version _order 6 riser_serial_number _detailLevel 0 _order 92 sales_order_number _detailLevel 0 _order 95 serial_number _detailLevel 0 _order 90 volumes _detailLevel 0 _timeStamp 2014-07-09T18:43:25Z _versionInfo com.apple.SystemProfiler.SPPlatformReporter 1441 facter-2.4.6/spec/fixtures/unit/selinux/0000775005276200011600000000000012651736742020147 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/selinux/selinux_sestatus0000664005276200011600000000030312651736735023512 0ustar jenkinsjenkinsSELinux status: enabled SELinuxfs mount: /selinux Current Mode: permissive Mode from config file: permissive Policy version: 16 Policy from config file: targeted facter-2.4.6/spec/fixtures/unit/selinux/selinux_sestatus20000664005276200011600000000042012651736735023574 0ustar jenkinsjenkinsSELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: default Current mode: enforcing Mode from config file: permissive Policy MLS status: enabled Policy deny_unknown status: denied Max kernel policy version: 29 facter-2.4.6/spec/fixtures/unit/util/0000775005276200011600000000000012651736742017435 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/dhcp_servers/0000775005276200011600000000000012651736742022124 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/dhcp_servers/route0000664005276200011600000000025312651736735023207 0ustar jenkinsjenkinsIface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT eth0 00000000 0110100A 0003 0 0 0 00000000 0 0 0 eth0 0010100A 00000000 0001 0 0 1 00FCFFFF 0 0 0 facter-2.4.6/spec/fixtures/unit/util/dhcp_servers/route_nogw0000664005276200011600000000011112651736735024232 0ustar jenkinsjenkinsIface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT facter-2.4.6/spec/fixtures/unit/util/ec2/0000775005276200011600000000000012651736742020106 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/ec2/centos-arp-ec2.out0000664005276200011600000000006512651736735023364 0ustar jenkinsjenkins? (10.240.93.1) at FE:FF:FF:FF:FF:FF [ether] on eth0 facter-2.4.6/spec/fixtures/unit/util/ec2/linux-arp-ec2.out0000664005276200011600000000006512651736735023230 0ustar jenkinsjenkins? (10.240.93.1) at fe:ff:ff:ff:ff:ff [ether] on eth0 facter-2.4.6/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out0000664005276200011600000000041212651736735024022 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-2.4.6/spec/fixtures/unit/util/ec2/solaris8_arp_a_not_ec2.out0000664005276200011600000000065612651736735025167 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-2.4.6/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out0000664005276200011600000000037612651736735025173 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-2.4.6/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out0000664005276200011600000000074312651736735023724 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-2.4.6/spec/fixtures/unit/util/ip/0000775005276200011600000000000012651736742020045 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig0000664005276200011600000000117212651736735024404 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-2.4.6/spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig0000664005276200011600000000302412651736735024033 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-2.4.6/spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces0000664005276200011600000000070012651736735031120 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-2.4.6/spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface0000664005276200011600000000042712651736735026506 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-2.4.6/spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig0000664005276200011600000000343712651736735024734 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan00000664005276200011600000000016312651736735024177 0ustar jenkinsjenkinslan0: flags=843 inet 192.168.3.10 netmask ffffff00 broadcast 192.168.3.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan10000664005276200011600000000015412651736735024200 0ustar jenkinsjenkinslan1: flags=843 inet 10.1.1.6 netmask ffffff00 broadcast 10.1.1.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lo00000664005276200011600000000012612651736735024036 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1111_lanscan0000664005276200011600000000060112651736735023115 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1111_netstat_in0000664005276200011600000000047412651736735023656 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan00000664005276200011600000000016212651736735026105 0ustar jenkinsjenkinslan0: flags=843 inet 192.168.3.9 netmask ffffff00 broadcast 192.168.3.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan10000664005276200011600000000015312651736735026106 0ustar jenkinsjenkinslan1: flags=842 inet 10.10.0.5 netmask ffffff00 broadcast 10.10.0.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lo00000664005276200011600000000012612651736735025745 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_asterisk_lanscan0000664005276200011600000000062312651736735025030 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_asterisk_netstat_in0000664005276200011600000000047312651736735025564 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan00000664005276200011600000000017312651736735024202 0ustar jenkinsjenkinslan0: flags=1843 inet 192.168.30.152 netmask ffffff00 broadcast 192.168.30.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan10000664005276200011600000000016412651736735024203 0ustar jenkinsjenkinslan1: flags=1843 inet 10.1.54.36 netmask ffffff00 broadcast 10.1.54.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lo00000664005276200011600000000012612651736735024040 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_lanscan0000664005276200011600000000047612651736735023131 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_netstat_in0000664005276200011600000000047712651736735023663 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan10000664005276200011600000000017212651736735026533 0ustar jenkinsjenkinslan1: flags=1843 inet 192.168.30.32 netmask ffffff00 broadcast 192.168.30.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan40000664005276200011600000000017212651736735026536 0ustar jenkinsjenkinslan4: flags=1843 inet 192.168.32.75 netmask ffffff00 broadcast 192.168.32.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4_10000664005276200011600000000017312651736735026757 0ustar jenkinsjenkinslan4:1: flags=1843 inet 192.168.1.197 netmask ffffff00 broadcast 192.168.1.255 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lo00000664005276200011600000000012612651736735026371 0ustar jenkinsjenkinslo0: flags=849 inet 127.0.0.1 netmask ff000000 facter-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_lanscan0000664005276200011600000000131712651736735025455 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-2.4.6/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_netstat_in0000664005276200011600000000073712651736735026213 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-2.4.6/spec/fixtures/unit/util/ip/linux_2_6_35_proc_net_bonding_bond00000664005276200011600000000066312651736735026566 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-2.4.6/spec/fixtures/unit/util/ip/linux_get_single_interface_eth00000664005276200011600000000102312651736735026265 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-2.4.6/spec/fixtures/unit/util/ip/linux_get_single_interface_ib00000664005276200011600000000100012651736735026072 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-2.4.6/spec/fixtures/unit/util/ip/linux_get_single_interface_lo0000664005276200011600000000062512651736735026046 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-2.4.6/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface0000664005276200011600000000164712651736735030251 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-2.4.6/spec/fixtures/unit/util/ip/linux_ifconfig_ib00000664005276200011600000000100012651736735023516 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-2.4.6/spec/fixtures/unit/util/ip/solaris_ifconfig_all_with_multiple_interfaces0000664005276200011600000000074312651736735031317 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-2.4.6/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface0000664005276200011600000000027212651736735026674 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-2.4.6/spec/fixtures/unit/util/ip/windows_netsh_all_interfaces0000664005276200011600000000124112651736735025716 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-2.4.6/spec/fixtures/unit/util/ip/windows_netsh_single_interface0000664005276200011600000000057212651736735026252 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-2.4.6/spec/fixtures/unit/util/ip/windows_netsh_single_interface60000664005276200011600000000115212651736735026333 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-2.4.6/spec/fixtures/unit/util/manufacturer/0000775005276200011600000000000012651736742022131 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/manufacturer/freebsd_dmidecode0000664005276200011600000000163112651736735025466 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-2.4.6/spec/fixtures/unit/util/manufacturer/intel_linux_dmidecode0000664005276200011600000003467512651736735026424 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-2.4.6/spec/fixtures/unit/util/manufacturer/linux_dmidecode_with_spaces0000664005276200011600000000451112651736735027604 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-2.4.6/spec/fixtures/unit/util/manufacturer/opensolaris_smbios0000664005276200011600000000157612651736735026001 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-2.4.6/spec/fixtures/unit/util/manufacturer/smartos_smbios0000664005276200011600000002763312651736735025135 0ustar jenkinsjenkinsID SIZE TYPE 0 63 SMB_TYPE_BIOS (BIOS information) Vendor: Phoenix Technologies Ltd. Version String: V1.23D Release Date: 06/11/2007 Address Segment: 0xe3b4 ROM Size: 524288 bytes Image Size: 115904 bytes Characteristics: 0x7fc8de80 SMB_BIOSFL_PCI (PCI is supported) SMB_BIOSFL_PLUGNPLAY (Plug and Play is supported) SMB_BIOSFL_APM (APM is supported) SMB_BIOSFL_FLASH (BIOS is Flash Upgradeable) SMB_BIOSFL_SHADOW (BIOS shadowing is allowed) SMB_BIOSFL_ESCD (ESCD support is available) SMB_BIOSFL_CDBOOT (Boot from CD is supported) SMB_BIOSFL_EDD (EDD Spec is supported) SMB_BIOSFL_525_360K (int 0x13 5.25" 360K floppy) SMB_BIOSFL_525_12M (int 0x13 5.25" 1.2M floppy) SMB_BIOSFL_35_720K (int 0x13 3.5" 720K floppy) SMB_BIOSFL_35_288M (int 0x13 3.5" 2.88M floppy) SMB_BIOSFL_I5_PRINT (int 0x5 print screen svcs) SMB_BIOSFL_I9_KBD (int 0x9 8042 keyboard svcs) SMB_BIOSFL_I14_SER (int 0x14 serial svcs) SMB_BIOSFL_I17_PRINTER (int 0x17 printer svcs) SMB_BIOSFL_I10_CGA (int 0x10 CGA svcs) Characteristics Extension Byte 1: 0x13 SMB_BIOSXB1_ACPI (ACPI is supported) SMB_BIOSXB1_USBL (USB legacy is supported) SMB_BIOSXB1_LS120 (LS-120 boot is supported) Characteristics Extension Byte 2: 0x0 ID SIZE TYPE 1 52 SMB_TYPE_SYSTEM (system information) Manufacturer: RIOWORKS Product: HDAMA Version: Serial Number: 0123456789 UUID: 00000000-0000-0000-0000-000000000000 Wake-Up Event: 0x6 (power switch) SKU Number: Family: ID SIZE TYPE 2 37 SMB_TYPE_BASEBOARD (base board) Manufacturer: RIOWORKS Product: HDAMA-I Version: Serial Number: 0123456789 Chassis: 0 Flags: 0x0 Board Type: 0x0 ID SIZE TYPE 3 37 SMB_TYPE_CHASSIS (system enclosure or chassis) Manufacturer: RIOWORKS Version: N/A Serial Number: N/A Asset Tag: N/A OEM Data: 0x1234 Lock Present: N Chassis Type: 0x7 (tower) Boot-Up State: 0x2 (unknown) Power Supply State: 0x2 (unknown) Thermal State: 0x2 (unknown) Chassis Height: 0u Power Cords: 0 Element Records: 0 ID SIZE TYPE 4 68 SMB_TYPE_PROCESSOR (processor) Manufacturer: AMD Version: AMD Location Tag: Socket 940 Family: 132 (Opteron) CPUID: 0x178bfbff00020f12 Type: 3 (central processor) Socket Upgrade: 6 (none) Socket Status: Populated Processor Status: 1 (enabled) Supported Voltages: 1.6V External Clock Speed: Unknown Maximum Speed: 3000MHz Current Speed: 2200MHz L1 Cache: 6 L2 Cache: 7 L3 Cache: None ID SIZE TYPE 5 67 SMB_TYPE_PROCESSOR (processor) Manufacturer: AMD Version: AMD Location Tag: Socket 940 Family: 132 (Opteron) CPUID: 0x178bfbff00020f12 Type: 3 (central processor) Socket Upgrade: 6 (none) Socket Status: Populated Processor Status: 1 (enabled) Supported Voltages: 1.6V External Clock Speed: Unknown Maximum Speed: 3000MHz Current Speed: 2200MHz L1 Cache: None L2 Cache: None L3 Cache: None ID SIZE TYPE 6 27 SMB_TYPE_CACHE (processor cache) Location Tag: L1 Cache Level: 1 Maximum Installed Size: 131072 bytes Installed Size: 131072 bytes Speed: Unknown Supported SRAM Types: 0x58 SMB_CAT_BURST (burst) SMB_CAT_PBURST (pipeline burst) SMB_CAT_ASYNC (asynchronous) Current SRAM Type: 0x40 (asynchronous) Error Correction Type: 2 (unknown) Logical Cache Type: 2 (unknown) Associativity: 2 (unknown) Mode: 1 (write-back) Location: 0 (internal) Flags: 0x1 SMB_CAF_ENABLED (enabled at boot time) ID SIZE TYPE 7 27 SMB_TYPE_CACHE (processor cache) Location Tag: L2 Cache Level: 2 Maximum Installed Size: 1048576 bytes Installed Size: 2097152 bytes Speed: Unknown Supported SRAM Types: 0x38 SMB_CAT_BURST (burst) SMB_CAT_PBURST (pipeline burst) SMB_CAT_SYNC (synchronous) Current SRAM Type: 0x20 (synchronous) Error Correction Type: 2 (unknown) Logical Cache Type: 5 (unified) Associativity: 2 (unknown) Mode: 0 (write-through) Location: 0 (internal) Flags: 0x1 SMB_CAF_ENABLED (enabled at boot time) ID SIZE TYPE 8 25 SMB_TYPE_SLOT (upgradeable system slot) Location Tag: PCI-X Slot 1 Reference Designator: PCI-X Slot 1 Slot ID: 0x0 Type: 0x10 (AGP 2X) Width: 0x5 (32 bit) Usage: 0x2 (unknown) Length: 0x4 (long length) Slot Characteristics 1: 0x4 SMB_SLCH1_33V (provides 3.3V) Slot Characteristics 2: 0x1 SMB_SLCH2_PME (slot supports PME# signal) Segment Group: 0 Bus Number: 0 Device/Function Number: 0 ID SIZE TYPE 9 25 SMB_TYPE_SLOT (upgradeable system slot) Location Tag: PCI-X Slot 2 Reference Designator: PCI-X Slot 2 Slot ID: 0x1 Type: 0x6 (PCI) Width: 0x5 (32 bit) Usage: 0x4 (in use) Length: 0x4 (long length) Slot Characteristics 1: 0x4 SMB_SLCH1_33V (provides 3.3V) Slot Characteristics 2: 0x1 SMB_SLCH2_PME (slot supports PME# signal) Segment Group: 0 Bus Number: 0 Device/Function Number: 0 ID SIZE TYPE 10 25 SMB_TYPE_SLOT (upgradeable system slot) Location Tag: PCI-X Slot 3 Reference Designator: PCI-X Slot 3 Slot ID: 0x2 Type: 0x6 (PCI) Width: 0x5 (32 bit) Usage: 0x3 (available) Length: 0x4 (long length) Slot Characteristics 1: 0x4 SMB_SLCH1_33V (provides 3.3V) Slot Characteristics 2: 0x1 SMB_SLCH2_PME (slot supports PME# signal) Segment Group: 0 Bus Number: 0 Device/Function Number: 0 ID SIZE TYPE 11 25 SMB_TYPE_SLOT (upgradeable system slot) Location Tag: PCI-X Slot 4 Reference Designator: PCI-X Slot 4 Slot ID: 0x3 Type: 0x6 (PCI) Width: 0x5 (32 bit) Usage: 0x3 (available) Length: 0x4 (long length) Slot Characteristics 1: 0x4 SMB_SLCH1_33V (provides 3.3V) Slot Characteristics 2: 0x1 SMB_SLCH2_PME (slot supports PME# signal) Segment Group: 0 Bus Number: 0 Device/Function Number: 0 ID SIZE TYPE 12 23 SMB_TYPE_SLOT (upgradeable system slot) Location Tag: PCI Slot 5 Reference Designator: PCI Slot 5 Slot ID: 0x4 Type: 0x6 (PCI) Width: 0x5 (32 bit) Usage: 0x3 (available) Length: 0x4 (long length) Slot Characteristics 1: 0x4 SMB_SLCH1_33V (provides 3.3V) Slot Characteristics 2: 0x1 SMB_SLCH2_PME (slot supports PME# signal) Segment Group: 0 Bus Number: 0 Device/Function Number: 0 ID SIZE TYPE 13 23 SMB_TYPE_SLOT (upgradeable system slot) Location Tag: PCI Slot 6 Reference Designator: PCI Slot 6 Slot ID: 0x5 Type: 0x6 (PCI) Width: 0x5 (32 bit) Usage: 0x3 (available) Length: 0x4 (long length) Slot Characteristics 1: 0x4 SMB_SLCH1_33V (provides 3.3V) Slot Characteristics 2: 0x1 SMB_SLCH2_PME (slot supports PME# signal) Segment Group: 0 Bus Number: 0 Device/Function Number: 0 ID SIZE TYPE 14 29 SMB_TYPE_SLOT (upgradeable system slot) Location Tag: PCI-X Riser Slot Reference Designator: PCI-X Riser Slot Slot ID: 0x2 Type: 0x12 (PCI-X) Width: 0x6 (64 bit) Usage: 0x3 (available) Length: 0x4 (long length) Slot Characteristics 1: 0x6 SMB_SLCH1_5V (provides 5.0V) SMB_SLCH1_33V (provides 3.3V) Slot Characteristics 2: 0x1 SMB_SLCH2_PME (slot supports PME# signal) Segment Group: 0 Bus Number: 0 Device/Function Number: 0 ID SIZE TYPE 15 34 SMB_TYPE_OEMSTR (OEM string table) 0 0 ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ID SIZE TYPE 16 29 SMB_TYPE_EVENTLOG (system event log) Log Area Size: 16 bytes Header Offset: 0 Data Offset: 16 Data Access Method: 4 (GP Non-Volatile API Access) Log Flags: 0x1 SMB_EVFL_VALID (log area valid) Log Header Format: 1 (DMTF log header type 1) Update Token: 0x40 Data Access Address: 0x0 Type Descriptors: 0: Log Type 0x8, Data Type 0x4 1: Log Type 0x1, Data Type 0x2 2: Log Type 0x2, Data Type 0x2 ID SIZE TYPE 17 15 SMB_TYPE_MEMARRAY (physical memory array) Location: 3 (system board or motherboard) Use: 3 (system memory) ECC: 5 (single-bit ECC) Number of Slots/Sockets: 3 Memory Error Data: Not Supported Max Capacity: 34359738368 bytes ID SIZE TYPE 18 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S0 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 1 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S0 Bank Locator: Bank 0 ID SIZE TYPE 19 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S1 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 1 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S1 Bank Locator: Bank 0 ID SIZE TYPE 20 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S2 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 2 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S2 Bank Locator: Bank 1 ID SIZE TYPE 21 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S3 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 2 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S3 Bank Locator: Bank 1 ID SIZE TYPE 22 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S4 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 5 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S4 Bank Locator: Bank 2 ID SIZE TYPE 23 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S5 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 5 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S5 Bank Locator: Bank 2 ID SIZE TYPE 24 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S6 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 6 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S6 Bank Locator: Bank 3 ID SIZE TYPE 25 36 SMB_TYPE_MEMDEVICE (memory device) Location Tag: S7 Physical Memory Array: 17 Memory Error Data: None Total Width: 128 bits Data Width: 64 bits Size: 1073741824 bytes Form Factor: 9 (DIMM) Set: 6 Memory Type: 3 (DRAM) Flags: 0x80 SMB_MDF_SYNC (synchronous) Speed: Unknown Device Locator: S7 Bank Locator: Bank 3 ID SIZE TYPE 26 15 SMB_TYPE_MEMARRAYMAP (memory array mapped address) Physical Memory Array: 17 Devices per Row: 2 Physical Address: 0x0 Size: 8589934592 bytes ID SIZE TYPE 27 19 SMB_TYPE_MEMDEVICEMAP (memory device mapped address) Memory Device: 18 Memory Array Mapped Address: 26 Physical Address: 0x0 Size: 1073741824 bytes Partition Row Position: 1 Interleave Position: 0 Interleave Data Depth: 1 ID SIZE TYPE 28 19 SMB_TYPE_MEMDEVICEMAP (memory device mapped address) Memory Device: 19 Memory Array Mapped Address: 26 Physical Address: 0x40000000 Size: 1073741824 bytes Partition Row Position: 1 Interleave Position: 0 Interleave Data Depth: 1 ID SIZE TYPE 29 19 SMB_TYPE_MEMDEVICEMAP (memory device mapped address) Memory Device: 20 Memory Array Mapped Address: 26 Physical Address: 0x80000000 Size: 1073741824 bytes Partition Row Position: 1 Interleave Position: 0 Interleave Data Depth: 1 ID SIZE TYPE 30 20 SMB_TYPE_BOOT (system boot status) Boot Status Code: 0xc Boot Data (9 bytes): offset: 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 0: 01020304 05060708 09 ......... facter-2.4.6/spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag0000664005276200011600000000314012651736735027545 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-2.4.6/spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag0000664005276200011600000001472612651736735026112 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-2.4.6/spec/fixtures/unit/util/operatingsystem/0000775005276200011600000000000012651736742022672 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/operatingsystem/coreos.txt0000664005276200011600000000031012651736735024721 0ustar jenkinsjenkinsNAME=CoreOS ID=coreos VERSION=575.0.0 VERSION_ID=575.0.0 BUILD_ID= PRETTY_NAME="CoreOS 575.0.0" ANSI_COLOR="1;32" HOME_URL="https://coreos.com/" BUG_REPORT_URL="https://github.com/coreos/bugs/issues" facter-2.4.6/spec/fixtures/unit/util/operatingsystem/cumuluslinux.txt0000664005276200011600000000040712651736735026213 0ustar jenkinsjenkinsNAME="Cumulus Linux" VERSION_ID=1.5.2 VERSION="1.5.2-28283a7-201311181623-final" PRETTY_NAME="Cumulus Linux" ID=cumulus-linux ID_LIKE=debian CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:1.5.2-28283a7-201311181623-final HOME_URL="http://www.cumulusnetworks.com/" facter-2.4.6/spec/fixtures/unit/util/operatingsystem/redhat-7.txt0000664005276200011600000000063112651736735025050 0ustar jenkinsjenkinsNAME="Red Hat Enterprise Linux Everything" VERSION="7.0 (Maipo)" ID="rhel" VERSION_ID="7.0" PRETTY_NAME="Red Hat Enterprise Linux Everything 7.0 (Maipo)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:redhat:enterprise_linux:7.0:beta:everything" REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7" REDHAT_BUGZILLA_PRODUCT_VERSION=7.0 REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" REDHAT_SUPPORT_PRODUCT_VERSION=7.0 facter-2.4.6/spec/fixtures/unit/util/operatingsystem/sabayon.txt0000664005276200011600000000027412651736735025074 0ustar jenkinsjenkinsNAME=Sabayon ID=sabayon PRETTY_NAME="Sabayon/Linux" ANSI_COLOR="1;32" HOME_URL="http://www.sabayon.org/" SUPPORT_URL="http://forum.sabayon.org/" BUG_REPORT_URL="https://bugs.sabayon.org/" facter-2.4.6/spec/fixtures/unit/util/operatingsystem/wheezy.txt0000664005276200011600000000037212651736735024752 0ustar jenkinsjenkinsPRETTY_NAME="Debian GNU/Linux 7 (wheezy)" NAME="Debian GNU/Linux" VERSION_ID="7" VERSION="7 (wheezy)" ID=debian ANSI_COLOR="1;31" HOME_URL="http://www.debian.org/" SUPPORT_URL="http://www.debian.org/support/" BUG_REPORT_URL="http://bugs.debian.org/" facter-2.4.6/spec/fixtures/unit/util/partitions/0000775005276200011600000000000012651736742021631 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/partitions/partitions/0000775005276200011600000000000012651736742024025 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/partitions/partitions/mount0000664005276200011600000000067212651736735025121 0ustar jenkinsjenkinsproc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/cgroup type tmpfs (rw) udev on /dev type devtmpfs (rw,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) /dev/sda1 on /home type ext4 (rw) /dev/sdb2 on / type ext4 (rw,errors=remount-ro) /dev/sdc3 on /var type ext4 (rw,errors=remount-ro) facter-2.4.6/spec/fixtures/unit/util/processor/0000775005276200011600000000000012651736742021454 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/processor/solaris-i86pc0000664005276200011600000000251412651736735024006 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-2.4.6/spec/fixtures/unit/util/processor/solaris-sun4u0000664005276200011600000001674612651736735024147 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-2.4.6/spec/fixtures/unit/util/processor/x86-pentium20000664005276200011600000000152512651736735023572 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-2.4.6/spec/fixtures/unit/util/uptime/0000775005276200011600000000000012651736742020740 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/uptime/kstat_boot_time0000664005276200011600000000005312651736735024052 0ustar jenkinsjenkinsunix:0:system_misc:boot_time 1236919980 facter-2.4.6/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin0000664005276200011600000000007012651736735026470 0ustar jenkinsjenkins{ sec = 1320011547, usec = 0 } Sun Oct 30 21:52:27 2011 facter-2.4.6/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd0000664005276200011600000000001312651736735026633 0ustar jenkinsjenkins1323465106 facter-2.4.6/spec/fixtures/unit/util/uptime/ubuntu_proc_uptime0000664005276200011600000000002712651736735024614 0ustar jenkinsjenkins5097686.63 40756306.43 facter-2.4.6/spec/fixtures/unit/util/virtual/0000775005276200011600000000000012651736742021123 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/virtual/invalid_unicode_dmi_entries0000664005276200011600000000011212651736735026560 0ustar jenkinsjenkinsÚÆˆóLö¼ qœ þ—„innotek GmbHVirtualBox1.20Virtual Machinefacter-2.4.6/spec/fixtures/unit/util/virtual/solaris10_proc_self_status10000664005276200011600000000216012651736735026404 0ustar jenkinsjenkins j"d"j"d"Ìh à Ø]ÁK,Z TSØ]ÂK,`*æþÃCC¢*æþÄðøþEÅñþ¬ðEÅñþ;‚¬ðC?ÿÿ;C€facter-2.4.6/spec/fixtures/unit/util/vlans/0000775005276200011600000000000012651736742020560 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/vlans/centos-5-no-vlans0000664005276200011600000000010712651736735023673 0ustar jenkinsjenkinsVLAN Dev name | VLAN ID Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD facter-2.4.6/spec/fixtures/unit/util/vlans/linux_vlan_config0000664005276200011600000000027312651736735024213 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-2.4.6/spec/fixtures/unit/util/xendomains/0000775005276200011600000000000012651736742021602 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/util/xendomains/xendomains0000664005276200011600000000047512651736735023702 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-2.4.6/spec/fixtures/unit/virtual/0000775005276200011600000000000012651736742020146 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt0000664005276200011600000000005212651736735025310 0ustar jenkinsjenkinsGoogleGooglefacter-2.4.6/spec/fixtures/unit/zfs_version/0000775005276200011600000000000012651736742021027 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/zfs_version/freebsd_8.20000664005276200011600000000073012651736735022755 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-2.4.6/spec/fixtures/unit/zfs_version/freebsd_9.00000664005276200011600000000066112651736735022757 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-2.4.6/spec/fixtures/unit/zfs_version/linux-fuse_0.6.90000664005276200011600000000073112651736735023606 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-2.4.6/spec/fixtures/unit/zfs_version/solaris_100000664005276200011600000000054612651736735022735 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-2.4.6/spec/fixtures/unit/zfs_version/solaris_110000664005276200011600000000064312651736735022734 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-2.4.6/spec/fixtures/unit/zfs_version/zfs_new0000664005276200011600000000516012651736735022431 0ustar jenkinsjenkinsusage: zfs command args ... where 'command' is one of the following: create [-p] [-o property=value] ... create [-ps] [-b blocksize] [-o property=value] ... -V destroy [-rRf] destroy [-rRd] snapshot [-r] [-o property=value] ... rollback [-rRf] clone [-p] [-o property=value] ... promote rename rename -p rename -r list [-rH][-d max] [-o property[,...]] [-t type[,...]] [-s property] ... [-S property] ... [filesystem|volume|snapshot] ... set ... get [-rHp] [-d max] [-o "all" | field[,...]] [-s source[,...]] <"all" | property[,...]> [filesystem|volume|snapshot] ... inherit [-rS] ... upgrade [-v] upgrade [-r] [-V version] <-a | filesystem ...> userspace [-hniHp] [-o field[,...]] [-sS field] ... [-t type[,...]] groupspace [-hniHpU] [-o field[,...]] [-sS field] ... [-t type[,...]] mount mount [-vO] [-o opts] <-a | filesystem> unmount [-f] <-a | filesystem|mountpoint> share <-a | filesystem> unshare <-a | filesystem|mountpoint> send [-RDp] [-[iI] snapshot] receive [-vnFu] receive [-vnFu] [-d | -e] allow allow [-ldug] <"everyone"|user|group>[,...] [,...] allow [-ld] -e [,...] allow -c [,...] allow -s @setname [,...] unallow [-rldug] <"everyone"|user|group>[,...] [[,...]] unallow [-rld] -e [[,...]] unallow [-r] -c [[,...]] unallow [-r] -s @setname [[,...]] hold [-r] ... holds [-r] ... release [-r] ... Each dataset is of the form: pool/[dataset/]*dataset[@name] For the property list, run: zfs set|get For the delegated permission list, run: zfs allow|unallow facter-2.4.6/spec/fixtures/unit/zfs_version/zfs_old0000664005276200011600000000266012651736735022420 0ustar jenkinsjenkinsusage: zfs command args ... where 'command' is one of the following: create [[-o property=value] ... ] create [-s] [-b blocksize] [[-o property=value] ...] -V destroy [-rRf] snapshot [-r] rollback [-rRf] clone promote rename list [-rH] [-o property[,property]...] [-t type[,type]...] [-s property [-s property]...] [-S property [-S property]...] [filesystem|volume|snapshot] ... set ... get [-rHp] [-o field[,field]...] [-s source[,source]...] [filesystem|volume|snapshot] ... inherit [-r] ... mount mount [-o opts] [-O] -a mount [-o opts] [-O] unmount [-f] -a unmount [-f] share -a share unshare [-f] -a unshare [-f] send [-i ] receive [-vnF] receive [-vnF] -d Each dataset is of the form: pool/[dataset/]*dataset[@name] For the property list, run: zfs set|get facter-2.4.6/spec/fixtures/unit/zfs_version/zfsonlinux_0.6.10000664005276200011600000000065612651736735023724 0ustar jenkinsjenkinsThe following filesystem versions are supported: VER DESCRIPTION --- -------------------------------------------------------- 1 Initial ZFS filesystem version 2 Enhanced directory entries 3 Case insensitive and filesystem user 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-2.4.6/spec/fixtures/unit/zpool_version/0000775005276200011600000000000012651736742021370 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/unit/zpool_version/freebsd_8.20000664005276200011600000000144512651736735023322 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-2.4.6/spec/fixtures/unit/zpool_version/freebsd_9.00000664005276200011600000000214612651736735023320 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-2.4.6/spec/fixtures/unit/zpool_version/linux-fuse_0.6.90000664005276200011600000000177012651736735024153 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-2.4.6/spec/fixtures/unit/zpool_version/solaris_100000664005276200011600000000165112651736735023274 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-2.4.6/spec/fixtures/unit/zpool_version/solaris_110000664005276200011600000000240112651736735023267 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-2.4.6/spec/fixtures/unit/zpool_version/zfsonlinux_0.6.10000664005276200011600000000275712651736735024271 0ustar jenkinsjenkinsThis system supports ZFS pool feature flags. The following features are supported: FEAT DESCRIPTION ------------------------------------------------------------- async_destroy (read-only compatible) Destroy filesystems asynchronously. empty_bpobj (read-only compatible) Snapshots use less space. lz4_compress LZ4 compression algorithm support. The following legacy versions are also 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-2.4.6/spec/fixtures/virtual/0000775005276200011600000000000012651736742017167 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/virtual/proc_1_cgroup/0000775005276200011600000000000012651736742021731 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/virtual/proc_1_cgroup/in_a_container0000664005276200011600000000131312651736735024624 0ustar jenkinsjenkins9:hugetlb:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 8:perf_event:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 7:blkio:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 6:freezer:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 5:devices:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 4:memory:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 3:cpuacct:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 2:cpu:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be 1:cpuset:/lxc/e411045bbbc61eca5d3af7eb0764c30833606f51d20c176f406afbdb47bb04be facter-2.4.6/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container0000664005276200011600000000035112651736735026154 0ustar jenkinsjenkins9:perf_event:/ 8:blkio:/ 7:freezer:/ 6:devices:/docker/0e3c605ac1470c776c34a8eff362a0c816bcaac78559a43955173bd786281b7f 5:memory:/ 4:cpuacct:/ 3:cpu:/docker/0e3c605ac1470c776c34a8eff362a0c816bcaac78559a43955173bd786281b7f 2:cpuset:/ facter-2.4.6/spec/fixtures/virtual/proc_1_cgroup/in_a_docker_container_with_systemd_slices0000664005276200011600000000136712651736735032331 0ustar jenkinsjenkins10:hugetlb:/ 9:perf_event:/ 8:blkio:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope 7:net_cls:/ 6:freezer:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope 5:devices:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope 4:memory:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope 3:cpuacct,cpu:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope 2:cpuset:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope 1:name=systemd:/system.slice/docker-8255e18aa44c5809a33db5f324a4b34e3a73b246394e4070cff752cd84d79a6d.scope facter-2.4.6/spec/fixtures/virtual/proc_1_cgroup/not_in_a_container0000664005276200011600000000014712651736735025510 0ustar jenkinsjenkins9:hugetlb:/ 8:perf_event:/ 7:blkio:/ 6:freezer:/ 5:devices:/ 4:memory:/ 3:cpuacct:/ 2:cpu:/ 1:cpuset:/ facter-2.4.6/spec/fixtures/virtual/proc_self_status/0000775005276200011600000000000012651736742022546 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/virtual/proc_self_status/vserver_2_1/0000775005276200011600000000000012651736742024703 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/virtual/proc_self_status/vserver_2_1/guest0000664005276200011600000000137112651736735025761 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-2.4.6/spec/fixtures/virtual/proc_self_status/vserver_2_1/host0000664005276200011600000000132412651736735025605 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-2.4.6/spec/fixtures/virtual/proc_self_status/vserver_2_3/0000775005276200011600000000000012651736742024705 5ustar jenkinsjenkinsfacter-2.4.6/spec/fixtures/virtual/proc_self_status/vserver_2_3/guest0000664005276200011600000000146712651736735025771 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-2.4.6/spec/fixtures/virtual/proc_self_status/vserver_2_3/host0000664005276200011600000000147312651736735025614 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-2.4.6/spec/integration/0000775005276200011600000000000012651736742016153 5ustar jenkinsjenkinsfacter-2.4.6/spec/integration/facter_spec.rb0000775005276200011600000000146312651736735020767 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 facter-2.4.6/spec/lib/0000775005276200011600000000000012651736742014376 5ustar jenkinsjenkinsfacter-2.4.6/spec/lib/facter_spec/0000775005276200011600000000000012651736742016654 5ustar jenkinsjenkinsfacter-2.4.6/spec/lib/facter_spec/cpuinfo.rb0000664005276200011600000000046512651736735020653 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-2.4.6/spec/lib/facter_spec/windows_network.rb0000664005276200011600000000242412651736735022450 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-2.4.6/spec/puppetlabs_spec/0000775005276200011600000000000012651736742017021 5ustar jenkinsjenkinsfacter-2.4.6/spec/puppetlabs_spec/files.rb0000775005276200011600000000240012651736735020451 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-2.4.6/spec/puppetlabs_spec/fixtures.rb0000775005276200011600000000324112651736735021224 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-2.4.6/spec/puppetlabs_spec/matchers.rb0000664005276200011600000000377012651736735021165 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-2.4.6/spec/puppetlabs_spec/verbose.rb0000775005276200011600000000031712651736735021021 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-2.4.6/spec/puppetlabs_spec_helper.rb0000664005276200011600000000172612651736735020715 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-2.4.6/spec/schema/0000775005276200011600000000000012651736742015070 5ustar jenkinsjenkinsfacter-2.4.6/spec/schema/validate_facter_schema.rb0000664005276200011600000000104712651736735022056 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/util/config' if !Facter::Util::Config.is_windows? require 'json' require 'json-schema' describe 'facter.json schema' do it 'should be valid' do # Read in both the json meta-schema and the facter schema JSON_META_SCHEMA = JSON.parse(File.read('schema/json-meta-schema.json')) FACTER_SCHEMA = JSON.parse(File.read('schema/facter.json')) # Validate that the facter schema itself is valid json JSON::Validator.validate!(JSON_META_SCHEMA, FACTER_SCHEMA) end end end facter-2.4.6/spec/shared_contexts/0000775005276200011600000000000012651736742017025 5ustar jenkinsjenkinsfacter-2.4.6/spec/shared_contexts/platform.rb0000664005276200011600000000301012651736735021172 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-2.4.6/spec/shared_formats/0000775005276200011600000000000012651736742016631 5ustar jenkinsjenkinsfacter-2.4.6/spec/shared_formats/parses.rb0000664005276200011600000000015012651736735020451 0ustar jenkinsjenkinsRSpec.configure do |config| config.alias_it_should_behave_like_to :example_behavior_for, "parses" end facter-2.4.6/spec/spec_helper.rb0000664005276200011600000000454112651736735016454 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? && RUBY_VERSION =~ /^1\./ 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-2.4.6/spec/unit/0000775005276200011600000000000012651736742014607 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/application_spec.rb0000664005276200011600000000620012651736735020451 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].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 it "enables tracing when given --trace" do Facter.trace(false) Facter::Application.parse(['--trace']) Facter.should be_trace Facter.trace(false) 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 ['-h', '--help'].each do |option| it "issues a deprecation message for `--puppet`" do Facter::Application.stubs(:exit).with(0) expect do Facter::Application.parse([option]) end.to have_printed('Deprecated: use `puppet facts` instead') 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 after(:all) do Facter.debugging(false) Facter.timing(false) Facter.trace(false) end end describe "formatting facts" do before do Facter.stubs(:to_hash) Facter.stubs(:value) Facter::Application.stubs(:puts) end it "delegates YAML formatting" do Facter::Util::Formatter.expects(:format_yaml) Facter::Application.stubs(:exit).with(0) Facter::Application.run(['--yaml']) end it "delegates JSON formatting", :if => Facter.json? do Facter::Util::Formatter.expects(:format_json) Facter::Application.stubs(:exit).with(0) Facter::Application.run(['--json']) end it "delegates plaintext formatting" do Facter::Util::Formatter.expects(:format_plaintext) Facter::Application.stubs(:exit).with(0) Facter::Application.run(['--plaintext']) end it "defaults to plaintext" do Facter::Util::Formatter.expects(:format_plaintext) Facter::Application.stubs(:exit).with(0) Facter::Application.run([]) end end end facter-2.4.6/spec/unit/architecture_spec.rb0000775005276200011600000000355712651736735020647 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-2.4.6/spec/unit/blockdevices_spec.rb0000664005276200011600000001033212651736735020604 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-2.4.6/spec/unit/core/0000775005276200011600000000000012651736742015537 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/core/aggregate_spec.rb0000664005276200011600000000675312651736735021041 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/core/aggregate' describe Facter::Core::Aggregate do let(:fact) { stub('stub_fact', :name => 'stub_fact') } subject { obj = described_class.new('aggregated', fact) } it "can be resolved" do expect(subject).to be_a_kind_of Facter::Core::Resolvable end it "can be confined and weighted" do expect(subject).to be_a_kind_of Facter::Core::Suitable end describe "setting options" do it "can set the timeout" do subject.set_options(:timeout => 314) expect(subject.limit).to eq 314 end it "can set the weight" do subject.set_options(:weight => 27) expect(subject.weight).to eq 27 end it "can set the name" do subject.set_options(:name => 'something') expect(subject.name).to eq 'something' end it "fails on unhandled options" do expect do subject.set_options(:foo => 'bar') end.to raise_error(ArgumentError, /Invalid aggregate options .*foo/) end end describe "declaring chunks" do it "requires that an chunk is given a block" do expect { subject.chunk(:fail) }.to raise_error(ArgumentError, /requires a block/) end it "allows an chunk to have a list of requirements" do subject.chunk(:data, :require => [:other]) { } expect(subject.deps[:data]).to eq [:other] end it "converts a single chunk requirement to an array" do subject.chunk(:data, :require => :other) { } expect(subject.deps[:data]).to eq [:other] end it "raises an error when an unhandled option is passed" do expect { subject.chunk(:data, :before => [:other]) { } }.to raise_error(ArgumentError, /Unexpected options.*#chunk: .*before/) end end describe "handling interactions between chunks" do it "generates a warning when there is a dependency cycle in chunks" do subject.chunk(:first, :require => [:second]) { } subject.chunk(:second, :require => [:first]) { } Facter.expects(:warn) do |msg| expect(msg).to match /dependency cycles: .*[:first, :second]/ end subject.value end it "passes all requested chunk results to the depending chunk" do subject.chunk(:first) { ['foo'] } subject.chunk(:second, :require => [:first]) do |first| [first[0] + ' bar'] end output = subject.value expect(output).to include 'foo' expect(output).to include 'foo bar' end it "clones and freezes chunk results passed to other chunks" do subject.chunk(:first) { 'foo' } subject.chunk(:second, :require => [:first]) do |first| expect(first).to be_frozen end subject.aggregate do |chunks| chunks.values.each do |chunk| expect(chunk).to be_frozen end end end end describe "aggregating chunks" do it "passes all chunk results as a hash to the aggregate block" do subject.chunk(:data) { 'data chunk' } subject.chunk(:datum) { 'datum chunk' } subject.aggregate do |chunks| expect(chunks).to eq(:data => 'data chunk', :datum => 'datum chunk') end subject.value end it "uses the result of the aggregate block as the value" do subject.aggregate { "who needs chunks anyways" } expect(subject.value).to eq "who needs chunks anyways" end end describe "evaluating" do it "evaluates the block in the context of the aggregate" do subject.expects(:has_weight).with(5) subject.evaluate { has_weight(5) } end end end facter-2.4.6/spec/unit/core/directed_graph_spec.rb0000664005276200011600000000405112651736735022044 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/core/directed_graph' describe Facter::Core::DirectedGraph do subject(:graph) { described_class.new } describe "detecting cycles" do it "is acyclic if the graph is empty" do expect(graph).to be_acyclic end it "is acyclic if the graph has no edges" do graph[:one] = [] graph[:two] = [] expect(graph).to be_acyclic end it "is acyclic if a vertex has an edge to itself" do graph[:one] = [:one] expect(graph).to be_acyclic end it "is acyclic if there are no loops in the graph" do graph[:one] = [:two, :three] graph[:two] = [:four] graph[:three] = [:four] graph[:four] = [] expect(graph).to be_acyclic end it "is cyclic if there is a loop in the graph" do graph[:one] = [:two] graph[:two] = [:one] expect(graph).to_not be_acyclic end it "can return the cycles in the graph" do graph[:one] = [:two] graph[:two] = [:one] graph[:three] = [:four] graph[:four] = [:three] first_cycle = graph.cycles.find { |cycle| cycle.include? :one } second_cycle = graph.cycles.find { |cycle| cycle.include? :three } expect(first_cycle).to include :two expect(second_cycle).to include :four end end describe "sorting" do it "returns the vertices in topologically sorted order" do graph[:one] = [:two, :three] graph[:two] = [:three] graph[:three] = [] expect(graph.tsort).to eq [:three, :two, :one] end it "raises an error if there is a cycle in the graph" do graph[:one] = [:two] graph[:two] = [:one] expect { graph.tsort }.to raise_error(Facter::Core::DirectedGraph::CycleError, /found the following cycles:/) end it "raises an error if there is an edge to a non-existent vertex" do graph[:one] = [:two, :three] graph[:two] = [:three] expect { graph.tsort }.to raise_error(Facter::Core::DirectedGraph::MissingVertex, /missing elements.*three/) end end end facter-2.4.6/spec/unit/core/execution/0000775005276200011600000000000012651736742017542 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/core/execution/base_spec.rb0000664005276200011600000001031612651736735022016 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/core/execution' describe Facter::Core::Execution::Base do describe "#with_env" do it "should execute the caller's block with the specified env vars" do test_env = { 'LANG' => 'C', 'LC_ALL' => 'C', 'FOO' => 'BAR' } subject.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 subject.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" } subject.with_env new_env do ENV[@sentinel_var].should == "bar" return end end handy_method() ENV[@sentinel_var].should == "foo" end end describe "#execute" do it "switches LANG and LC_ALL to C when executing the command" do subject.expects(:with_env).with('LC_ALL' => 'C', 'LANG' => 'C') subject.execute('foo') end it "expands the command before running it" do subject.stubs(:`).returns '' subject.expects(:expand_command).with('foo').returns '/bin/foo' subject.execute('foo') end describe "and the command is not present" do it "raises an error when the :on_fail behavior is :raise" do subject.expects(:expand_command).with('foo').returns nil expect { subject.execute('foo') }.to raise_error(Facter::Core::Execution::ExecutionFailure) end it "returns the given value when :on_fail is set to a value" do subject.expects(:expand_command).with('foo').returns nil expect(subject.execute('foo', :on_fail => nil)).to be_nil end end describe "when command execution fails" do before do subject.expects(:`).with("/bin/foo").raises "kaboom!" subject.expects(:expand_command).with('foo').returns '/bin/foo' end it "raises an error when the :on_fail behavior is :raise" do expect { subject.execute('foo') }.to raise_error(Facter::Core::Execution::ExecutionFailure) end it "returns the given value when :on_fail is set to a value" do expect(subject.execute('foo', :on_fail => nil)).to be_nil end end it "launches a thread to wait on children if the command was interrupted" do subject.expects(:`).with("/bin/foo").raises "kaboom!" subject.expects(:expand_command).with('foo').returns '/bin/foo' Facter.stubs(:warn) Thread.expects(:new).yields Process.expects(:waitall).once subject.execute("foo", :on_fail => nil) end it "returns the output of the command" do subject.expects(:`).with("/bin/foo").returns 'hi' subject.expects(:expand_command).with('foo').returns '/bin/foo' expect(subject.execute("foo")).to eq 'hi' end it "strips off trailing newlines" do subject.expects(:`).with("/bin/foo").returns "hi\n" subject.expects(:expand_command).with('foo').returns '/bin/foo' expect(subject.execute("foo")).to eq 'hi' end end end facter-2.4.6/spec/unit/core/execution/posix_spec.rb0000664005276200011600000000721212651736735022247 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/util/config' describe Facter::Core::Execution::Posix, :unless => Facter::Util::Config.is_windows? do describe "#search_paths" do it "should use the PATH environment variable plus /sbin and /usr/sbin on unix" do ENV.expects(:[]).with('PATH').returns "/bin:/usr/bin" subject.search_paths.should == %w{/bin /usr/bin /sbin /usr/sbin} end end describe "#which" do before :each do subject.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(:file?).with('/opt/foo').returns true File.expects(:executable?).with('/opt/foo').returns true subject.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 subject.which('/opt/foo').should be_nil end it "should return nil if the binary is not a file" do File.expects(:file?).with('/opt/foo').returns false File.expects(:executable?).with('/opt/foo').returns true subject.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(:file?).with('/bin/foo').never File.expects(:executable?).with('/bin/foo').returns false File.expects(:file?).with('/sbin/foo').returns true File.expects(:executable?).with('/sbin/foo').returns true File.expects(:file?).with('/usr/sbin/foo').never File.expects(:executable?).with('/usr/sbin/foo').never subject.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 subject.which('foo').should be_nil end end end describe "#expand_command" do it "should expand binary" do subject.expects(:which).with('foo').returns '/bin/foo' subject.expand_command('foo -a | stuff >> /dev/null').should == '/bin/foo -a | stuff >> /dev/null' end it "should expand double quoted binary" do subject.expects(:which).with('/tmp/my foo').returns '/tmp/my foo' subject.expand_command(%q{"/tmp/my foo" bar}).should == %q{'/tmp/my foo' bar} end it "should expand single quoted binary" do subject.expects(:which).with('my foo').returns '/home/bob/my path/my foo' subject.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 subject.expects(:which).with('foo.sh').returns '/home/bob/my tools/foo.sh' subject.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 subject.expects(:which).with('foo').returns nil subject.expand_command('foo -a | stuff >> /dev/null').should be_nil end end describe "#absolute_path?" 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 subject.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 subject.should_not be_absolute_path(path) end end end end facter-2.4.6/spec/unit/core/execution/windows_spec.rb0000664005276200011600000001042312651736735022575 0ustar jenkinsjenkinsrequire 'spec_helper' describe Facter::Core::Execution::Windows, :as_platform => :windows do describe "#search_paths" do it "should use the PATH environment variable to determine locations" do ENV.expects(:[]).with('PATH').returns 'C:\Windows;C:\Windows\System32' subject.search_paths.should == %w{C:\Windows C:\Windows\System32} end end describe "#which" do before :each do subject.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 subject.which('C:\Tools\foo.exe').should == 'C:\Tools\foo.exe' subject.which('\\\\remote\dir\foo.exe').should == '\\\\remote\dir\foo.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 subject.which('C:\Tools\foo.exe').should be_nil subject.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 subject.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 subject.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 subject.which('foo.exe').should be_nil end end end describe "#expand_command" do it "should expand binary" do subject.expects(:which).with('cmd').returns 'C:\Windows\System32\cmd' subject.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 subject.expects(:which).with('my foo').returns 'C:\My Tools\my foo.exe' subject.expand_command('"my foo" /a /b').should == '"C:\My Tools\my foo.exe" /a /b' end it "should not expand single quoted binary" do subject.expects(:which).with('\'C:\My').returns nil subject.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 subject.expects(:which).with('foo').returns 'C:\My Tools\foo.exe' subject.expand_command('foo /a /b').should == '"C:\My Tools\foo.exe" /a /b' end it "should return nil if not found" do subject.expects(:which).with('foo').returns nil subject.expand_command('foo /a | stuff >> NUL').should be_nil end end describe "#absolute_path?" 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 subject.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 subject.should_not be_absolute_path(path) end end end end facter-2.4.6/spec/unit/core/execution_spec.rb0000664005276200011600000000224512651736735021106 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/core/execution' describe Facter::Core::Execution do subject { described_class} let(:impl) { described_class.impl } it "delegates #search_paths to the implementation" do impl.expects(:search_paths) subject.search_paths end it "delegates #which to the implementation" do impl.expects(:which).with('waffles') subject.which('waffles') end it "delegates #absolute_path? to the implementation" do impl.expects(:absolute_path?).with('waffles', nil) subject.absolute_path?('waffles') end it "delegates #absolute_path? with an optional platform to the implementation" do impl.expects(:absolute_path?).with('waffles', :windows) subject.absolute_path?('waffles', :windows) end it "delegates #expand_command to the implementation" do impl.expects(:expand_command).with('waffles') subject.expand_command('waffles') end it "delegates #exec to #execute" do impl.expects(:execute).with('waffles', {:on_fail => nil}) subject.exec('waffles') end it "delegates #execute to the implementation" do impl.expects(:execute).with('waffles', {}) subject.execute('waffles') end end facter-2.4.6/spec/unit/core/logging_spec.rb0000664005276200011600000001344312651736735020533 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/core/logging' describe Facter::Core::Logging do subject { described_class } after(:all) do subject.debugging(false) subject.timing(false) subject.on_message end describe "emitting debug messages" do it "doesn't log a message when debugging is disabled" do subject.debugging(false) subject.expects(:puts).never subject.debug("foo") end describe "and debugging is enabled" do before { subject.debugging(true) } it "emits a warning when called with nil" do subject.expects(:warn).with { |msg| expect(msg).to match /invalid message nil:NilClass/ } subject.debug(nil) end it "emits a warning when called with an empty string" do subject.expects(:warn).with { |msg| expect(msg).to match /invalid message "":String/ } subject.debug("") end it "prints the message when logging is enabled" do subject.expects(:puts).with { |msg| expect(msg).to match /foo/ } subject.debug("foo") end end end describe "when warning" do it "emits a warning when given a string" do subject.debugging(true) Kernel.expects(:warn).with('foo') subject.warn('foo') end it "emits a warning regardless of log level" do subject.debugging(false) Kernel.expects(:warn).with "foo" subject.warn "foo" end it "emits a warning if nil is passed" do Kernel.expects(:warn).with { |msg| expect(msg).to match /invalid message nil:NilClass/ } subject.warn(nil) end it "emits a warning if an empty string is passed" do Kernel.expects(:warn).with { |msg| expect(msg).to match /invalid message "":String/ } subject.warn('') end end describe "when warning once" do it "only logs a given warning string once" do subject.expects(:warn).with('foo').once subject.warnonce('foo') subject.warnonce('foo') end end describe "when setting the debugging mode" do it "is enabled when the given value is true" do subject.debugging(true) expect(subject.debugging?).to be_true end it "is disabled when the given value is false" do subject.debugging(false) expect(subject.debugging?).to be_false end it "is disabled when the given value is nil" do subject.debugging(nil) expect(subject.debugging?).to be_false end end describe "when setting the timing mode" do it "is enabled when the given value is true" do subject.timing(true) expect(subject.timing?).to be_true end it "is disabled when the given value is false" do subject.timing(false) expect(subject.timing?).to be_false end it "is disabled when the given value is nil" do subject.timing(nil) expect(subject.timing?).to be_false end end describe 'without a logging callback' do before :each do subject.timing(true) subject.debugging(true) subject.on_message end it 'calls puts for debug' do subject.expects(:puts).with(subject::GREEN + 'foo' + subject::RESET).once subject.debug('foo') end it 'calls puts for debugonce' do subject.expects(:puts).with(subject::GREEN + 'foo' + subject::RESET).once subject.debugonce('foo') subject.debugonce('foo') end it 'calls Kernel.warn for warn' do Kernel.expects(:warn).with('foo').once subject.warn('foo') end it 'calls Kernel.warn for warnonce' do Kernel.expects(:warn).with('foo').once subject.warnonce('foo') subject.warnonce('foo') end it 'calls $stderr.puts for timing' do $stderr.expects(:puts).with(subject::GREEN + 'foo' + subject::RESET).once subject.show_time('foo') end end describe 'with a logging callback' do before :each do subject.debugging(true) subject.timing(true) subject.on_message end def log_message(level, message) called = false subject.on_message do |lvl, msg| called = true expect(lvl).to eq(level) expect(msg).to eq(message) end case level when :debug Facter.debug(message) when :warn Facter.warn(message) when :info Facter.show_time(message) else raise 'unexpected logging level' end subject.on_message expect(called).to be_true end def log_message_once(level, message) calls = 0 subject.on_message do |lvl, msg| expect(lvl).to eq(level) expect(msg).to eq(message) calls += 1 end case level when :debug Facter.debugonce(message) Facter.debugonce(message) when :warn Facter.warnonce(message) Facter.warnonce(message) else raise 'unexpected logging level' end expect(calls).to eq(1) end it 'does not call puts for debug or debugonce' do subject.on_message {} subject.expects(:puts).never subject.debug('debug message') subject.debugonce('debug once message') end it 'passes debug messages to callback' do log_message(:debug, 'debug message') log_message_once(:debug, 'debug once message') end it 'does not call Kernel.warn for warn or warnonce' do subject.on_message {} Kernel.expects(:warn).never subject.warn('warn message') subject.warnonce('warn once message') end it 'passes warning messages to callback' do log_message(:warn, 'warn message') log_message_once(:warn, 'warn once message') end it 'does not call $stderr.puts for show_time' do subject.on_message {} $stderr.expects(:puts).never subject.show_time('debug message') end it 'passes info messages to callback' do log_message(:info, 'timing message') end end end facter-2.4.6/spec/unit/core/resolvable_spec.rb0000664005276200011600000000422412651736735021240 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/core/resolvable' describe Facter::Core::Resolvable do class ResolvableClass def initialize(name) @name = name @fact = Facter::Util::Fact.new("stub fact") end attr_accessor :name, :resolve_value attr_reader :fact include Facter::Core::Resolvable end subject { ResolvableClass.new('resolvable') } it "has a default timeout of 0 seconds" do expect(subject.limit).to eq 0 end it "can specify a custom timeout" do subject.timeout = 10 expect(subject.limit).to eq 10 end describe "generating a value" do it "returns the results of #resolve_value" do subject.resolve_value = 'stuff' expect(subject.value).to eq 'stuff' end it "normalizes the resolved value" do Facter::Util::Normalization.expects(:normalize).returns 'stuff' subject.resolve_value = 'stuff' expect(subject.value).to eq('stuff') end it "logs a warning if an exception was raised" do subject.expects(:resolve_value).raises RuntimeError, "kaboom!" Facter.expects(:warn).with(regexp_matches(/Could not retrieve .*: kaboom!/)) expect(subject.value).to eq nil end end describe "timing out" do it "uses #limit instead of #timeout to determine the timeout period" do subject.expects(:timeout).never subject.expects(:limit).returns 25 Timeout.expects(:timeout).with(25) subject.value end it "returns nil if the timeout was reached" do Facter.expects(:warn).with(regexp_matches(/Timed out after 0\.1 seconds while resolving/)) Timeout.expects(:timeout).raises Timeout::Error subject.timeout = 0.1 expect(subject.value).to be_nil end end describe 'callbacks when flushing facts' do class FlushFakeError < StandardError; 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 end facter-2.4.6/spec/unit/core/suitable_spec.rb0000664005276200011600000000555012651736735020715 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/core/suitable' describe Facter::Core::Suitable do class SuitableClass def initialize @confines = [] end attr_reader :confines include Facter::Core::Suitable end subject { SuitableClass.new } describe "confining on facts" do it "can add confines with a fact and a single value" do subject.confine :kernel => 'Linux' end it "creates a Facter::Util::Confine object for the confine call" do subject.confine :kernel => 'Linux' conf = subject.confines.first expect(conf).to be_a_kind_of Facter::Util::Confine expect(conf.fact).to eq :kernel expect(conf.values).to eq ['Linux'] end end describe "confining on blocks" do it "can add a single fact with a block parameter" do subject.confine(:one) { true } end it "creates a Util::Confine instance for the provided fact with block parameter" do block = lambda { true } Facter::Util::Confine.expects(:new).with("one") subject.confine("one", &block) end it "should accept a single block parameter" do subject.confine() { true } end it "should create a Util::Confine instance for the provided block parameter" do block = lambda { true } Facter::Util::Confine.expects(:new) subject.confine(&block) end end describe "determining weight" do it "is zero if no confines are set" do expect(subject.weight).to eq 0 end it "defaults to the number of confines" do subject.confine :kernel => 'Linux' expect(subject.weight).to eq 1 end it "can be explicitly set" do subject.has_weight 10 expect(subject.weight).to eq 10 end it "prefers an explicit weight over the number of confines" do subject.confine :kernel => 'Linux' subject.has_weight 11 expect(subject.weight).to eq 11 end end describe "determining suitability" do it "is true if all confines for the object evaluate to true" do subject.confine :kernel => 'Linux' subject.confine :operatingsystem => 'Redhat' subject.confines.each { |confine| confine.stubs(:true?).returns true } expect(subject).to be_suitable end it "is false if any confines for the object evaluate to false" do subject.confine :kernel => 'Linux' subject.confine :operatingsystem => 'Redhat' subject.confines.first.stubs(:true?).returns true subject.confines.first.stubs(:true?).returns false expect(subject).to_not be_suitable end it "recalculates suitability on every invocation" do subject.confine :kernel => 'Linux' subject.confines.first.stubs(:true?).returns false expect(subject).to_not be_suitable subject.confines.first.unstub(:true?) subject.confines.first.stubs(:true?).returns true expect(subject).to be_suitable end end end facter-2.4.6/spec/unit/dhcp_servers_spec.rb0000664005276200011600000002454312651736735020647 0ustar jenkinsjenkinsrequire 'spec_helper' describe "DHCP server facts" do describe "on Linux OS's" do before :each do Facter.fact(:kernel).stubs(:value).returns 'Linux' Facter::Util::FileRead.stubs(:read).with('/proc/net/route').returns(my_fixture_read('route')) end describe "with nmcli version <= 0.9.8 available" do before :each do Facter::Core::Execution.stubs(:which).with('nmcli').returns('/usr/bin/nmcli') Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns('nmcli tool, version 0.9.8.0') end describe "with a main interface configured with DHCP" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_dhcp")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE nm 2>/dev/null').returns("connected\n") end it "should produce a dhcp_servers fact that includes values for 'system' as well as each dhcp enabled interface" do Facter.fact(:dhcp_servers).value.should == { 'system' => '192.168.1.1', 'eth0' => '192.168.1.1', 'wlan0' => '192.168.2.1' } end end describe "with a main interface NOT configured with DHCP" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_static")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE nm 2>/dev/null').returns("connected\n") end it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do Facter.fact(:dhcp_servers).value.should == {'wlan0' => '192.168.2.1' } end end describe "with no default gateway" do before :each do Facter::Util::FileRead.stubs(:read).with('/proc/net/route').returns(my_fixture_read('route_nogw')) Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_dhcp")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE nm 2>/dev/null').returns("connected\n") end it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do Facter.fact(:dhcp_servers).value.should == {'eth0' => '192.168.1.1', 'wlan0' => '192.168.2.1' } end end describe "with no DHCP enabled interfaces" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_static")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_static")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE nm 2>/dev/null').returns("connected\n") end it "should not produce a dhcp_servers fact" do Facter.fact(:dhcp_servers).value.should be_nil end end describe "with no CONNECTED devices" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices_disconnected")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE nm 2>/dev/null').returns("disconnected\n") end it "should not produce a dhcp_servers fact" do Facter.fact(:dhcp_servers).value.should be_nil end end end describe "with nmcli version >= 0.9.9 available" do before :each do Facter::Core::Execution.stubs(:which).with('nmcli').returns('/usr/bin/nmcli') Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns('nmcli tool, version 0.9.9.0-20.git20131003.fc20') end describe "with a main interface configured with DHCP" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_dhcp")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE g 2>/dev/null').returns("connected\n") end it "should produce a dhcp_servers fact that includes values for 'system' as well as each dhcp enabled interface" do Facter.fact(:dhcp_servers).value.should == { 'system' => '192.168.1.1', 'eth0' => '192.168.1.1', 'wlan0' => '192.168.2.1' } end end describe "with a main interface NOT configured with DHCP" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_static")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE g 2>/dev/null').returns("connected\n") end it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do Facter.fact(:dhcp_servers).value.should == {'wlan0' => '192.168.2.1' } end end describe "with no default gateway" do before :each do Facter::Util::FileRead.stubs(:read).with('/proc/net/route').returns(my_fixture_read('route_nogw')) Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_dhcp")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE g 2>/dev/null').returns("connected\n") end it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do Facter.fact(:dhcp_servers).value.should == {'eth0' => '192.168.1.1', 'wlan0' => '192.168.2.1' } end end describe "with no DHCP enabled interfaces" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_static")) Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_static")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE g 2>/dev/null').returns("connected\n") end it "should not produce a dhcp_servers fact" do Facter.fact(:dhcp_servers).value.should be_nil end end describe "with no CONNECTED devices" do before :each do Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices_disconnected")) Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE g 2>/dev/null').returns("disconnected\n") end it "should not produce a dhcp_servers fact" do Facter.fact(:dhcp_servers).value.should be_nil end end end describe 'without NetworkManager running' do before :each do Facter::Core::Execution.stubs(:which).with('nmcli').returns('/usr/bin/nmcli') end describe 'with nmcli version >= 0.9.9 available' do before :each do Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE g 2>/dev/null').returns("unknown\n") Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns('nmcli tool, version 0.9.9.0') end it 'should not produce a dhcp_servers fact' do Facter.fact(:dhcp_servers).value.should be_nil end end describe 'with nmcli version <= 0.9.8 available' do before :each do Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE nm 2>/dev/null').returns("unknown\n") Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns('nmcli tool, version 0.9.7.0') end it 'should not produce a dhcp_servers fact' do Facter.fact(:dhcp_servers).value.should be_nil end end describe 'with nmcli version >= 0.9.9 available but printing an error to STDERR' do before :each do Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE g 2>/dev/null').returns("\n") Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns('nmcli tool, version 0.9.9.0') end it 'should not produce a dhcp_servers fact' do Facter.fact(:dhcp_servers).value.should be_nil end end describe 'with nmcli version <= 0.9.8 available but printing an error to STDERR' do before :each do Facter::Core::Execution.stubs(:exec).with('nmcli -t -f STATE nm 2>/dev/null').returns("\n") Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns('nmcli tool, version 0.9.7.0') end it 'should not produce a dhcp_servers fact' do Facter.fact(:dhcp_servers).value.should be_nil end end end describe "without nmcli available" do before :each do Facter::Core::Execution.stubs(:which).with('nmcli').returns(nil) end it "should not produce a dhcp_server fact" do Facter.fact(:dhcp_servers).value.should be_nil end end end end facter-2.4.6/spec/unit/domain_spec.rb0000775005276200011600000002264112651736735017427 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::Core::Execution.stubs(:exec).with(hostname_command).returns(value) end def the_dnsdomainname_is(value) Facter::Core::Execution.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::Core::Execution.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::Core::Execution.stubs(:exec).with("hostname -f 2> /dev/null").returns(scenario[:hostname]) Facter::Core::Execution.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-2.4.6/spec/unit/ec2/0000775005276200011600000000000012651736742015260 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/ec2/rest_spec.rb0000664005276200011600000001337512651736735017607 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/ec2/rest' shared_examples_for "an ec2 rest querier" do describe "determining if the uri is reachable" do it "retries if the connection times out" do subject.stubs(:open).returns(stub(:read => nil)) Timeout.expects(:timeout).with(0.2).twice.raises(Timeout::Error).returns(true) expect(subject).to be_reachable end it "retries if the connection is reset" do subject.expects(:open).twice.raises(Errno::ECONNREFUSED).returns(StringIO.new("woo")) expect(subject).to be_reachable end it "is false if the given uri returns a 404" do subject.expects(:open).with(anything, :proxy => nil).once.raises(OpenURI::HTTPError.new("404 Not Found", StringIO.new("woo"))) expect(subject).to_not be_reachable end it "is false if the connection always times out" do Timeout.expects(:timeout).with(0.2).times(3).raises(Timeout::Error) expect(subject).to_not be_reachable end end end describe Facter::EC2::Metadata do subject { described_class.new('http://0.0.0.0/latest/meta-data/') } let(:response) { StringIO.new } describe "fetching a metadata endpoint" do it "splits the body into an array" do response.string = my_fixture_read("meta-data/root") subject.stubs(:open).with("http://0.0.0.0/latest/meta-data/", {:proxy => nil}).returns response output = subject.fetch_endpoint('') expect(output).to eq %w[ ami-id ami-launch-index ami-manifest-path block-device-mapping/ hostname instance-action instance-id instance-type kernel-id local-hostname local-ipv4 mac metrics/ network/ placement/ profile public-hostname public-ipv4 public-keys/ reservation-id ] end it "reformats keys that are array indices" do response.string = "0=adrien@grey/" subject.stubs(:open).with("http://0.0.0.0/latest/meta-data/public-keys/", {:proxy => nil}).returns response output = subject.fetch_endpoint("public-keys/") expect(output).to eq %w[0/] end it "returns nil if the endpoint returns a 404" do Facter.expects(:log_exception).never subject.stubs(:open).with("http://0.0.0.0/latest/meta-data/public-keys/1/", {:proxy => nil}).raises OpenURI::HTTPError.new("404 Not Found", response) output = subject.fetch_endpoint('public-keys/1/') expect(output).to be_nil end it "logs an error if the endpoint raises a non-404 HTTPError" do Facter.expects(:log_exception).with(instance_of(OpenURI::HTTPError), anything) subject.stubs(:open).with("http://0.0.0.0/latest/meta-data/", {:proxy => nil}).raises OpenURI::HTTPError.new("418 I'm a Teapot", response) output = subject.fetch_endpoint("") expect(output).to be_nil end it "logs an error if the endpoint raises a connection error" do Facter.expects(:log_exception).with(instance_of(Errno::ECONNREFUSED), anything) subject.stubs(:open).with("http://0.0.0.0/latest/meta-data/", {:proxy => nil}).raises Errno::ECONNREFUSED output = subject.fetch_endpoint('') expect(output).to be_nil end end describe "recursively fetching the EC2 metadata API" do it "queries the given endpoint for metadata keys" do subject.expects(:fetch_endpoint).with("").returns([]) subject.fetch end it "fetches the value for a simple metadata key" do subject.expects(:fetch_endpoint).with("").returns(['indexthing']) subject.expects(:fetch_endpoint).with("indexthing").returns(['first', 'second']) output = subject.fetch expect(output).to eq({'indexthing' => ['first', 'second']}) end it "unwraps metadata values that are in single element arrays" do subject.expects(:fetch_endpoint).with("").returns(['ami-id']) subject.expects(:fetch_endpoint).with("ami-id").returns(['i-12x']) output = subject.fetch expect(output).to eq({'ami-id' => 'i-12x'}) end it "recursively queries an endpoint if the key ends with '/'" do subject.expects(:fetch_endpoint).with("").returns(['metrics/']) subject.expects(:fetch_endpoint).with("metrics/").returns(['vhostmd']) subject.expects(:fetch_endpoint).with("metrics/vhostmd").returns(['woo']) output = subject.fetch expect(output).to eq({'metrics' => {'vhostmd' => 'woo'}}) end end it 'filters out IAM security credentials' do subject.expects(:fetch_endpoint).with('').returns(['iam/']) subject.expects(:fetch_endpoint).with('iam/').returns(['foo', 'security-credentials/', 'bar/']) subject.expects(:fetch_endpoint).with('iam/foo').returns(['baz']) subject.expects(:fetch_endpoint).with('iam/bar/').returns(['baz']) subject.expects(:fetch_endpoint).with('iam/bar/baz').returns(['foo']) output = subject.fetch expect(output).to eq({ 'iam' => { 'foo' => 'baz', 'bar' => { 'baz' => 'foo' } } }) end it_behaves_like "an ec2 rest querier" end describe Facter::EC2::Userdata do subject { described_class.new('http://0.0.0.0/latest/user-data/') } let(:response) { StringIO.new } describe "reaching the userdata" do it "queries the userdata URI" do subject.expects(:open).with('http://0.0.0.0/latest/user-data/').returns(response) subject.fetch end it "returns the result of the query without modification" do response.string = "clooouuuuud" subject.expects(:open).with('http://0.0.0.0/latest/user-data/').returns(response) expect(subject.fetch).to eq "clooouuuuud" end it "is nil if the URI returned a 404" do subject.expects(:open).with('http://0.0.0.0/latest/user-data/').once.raises(OpenURI::HTTPError.new("404 Not Found", StringIO.new("woo"))) expect(subject.fetch).to be_nil end end it_behaves_like "an ec2 rest querier" end facter-2.4.6/spec/unit/ec2_spec.rb0000775005276200011600000001033112651736735016622 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/ec2/rest' describe "ec2_metadata" do let(:querier) { stub('EC2 metadata querier') } before do Facter::EC2::Metadata.stubs(:new).returns querier # Prevent flattened facts from forcing evaluation of the ec2 metadata fact Facter.stubs(:value).with(:ec2_metadata) Facter.collection.internal_loader.load(:ec2) Facter.unstub(:value) end subject { Facter.fact(:ec2_metadata).resolution(:rest) } it "is unsuitable if the virtual fact is not xen,xenu or kvm" do querier.stubs(:reachable?).returns false Facter.fact(:virtual).stubs(:value).returns("Not kvm","Not xen","Not xenu") expect(subject).to_not be_suitable end it "is unsuitable if ec2 endpoint is not reachable" do Facter.fact(:virtual).stubs(:value).returns("xen","kvm") querier.stubs(:reachable?).returns false expect(subject).to_not be_suitable end describe "when the ec2 endpoint is reachable" do before do querier.stubs(:reachable?).returns true end it "is suitable if the virtual fact is xen" do Facter.fact(:virtual).stubs(:value).returns "xen" subject.suitable? expect(subject).to be_suitable end it "is suitable if the virtual fact is kvm" do Facter.fact(:virtual).stubs(:value).returns "kvm" subject.suitable? expect(subject).to be_suitable end it "is suitable if the virtual fact is xenu" do Facter.fact(:virtual).stubs(:value).returns "xenu" expect(subject).to be_suitable end end it "resolves the value by recursively querying the rest endpoint" do querier.expects(:fetch).returns({"hello" => "world"}) expect(subject.value).to eq({"hello" => "world"}) end end describe "ec2_userdata" do let(:querier) { stub('EC2 metadata querier') } before do Facter::EC2::Userdata.stubs(:new).returns querier # Prevent flattened facts from forcing evaluation of the ec2 metadata fact Facter.stubs(:value).with(:ec2_metadata) Facter.collection.internal_loader.load(:ec2) Facter.unstub(:value) end subject { Facter.fact(:ec2_userdata).resolution(:rest) } it "is unsuitable if the virtual fact is not xen,xenu or kvm" do querier.stubs(:reachable?).returns(true) Facter.fact(:virtual).stubs(:value).returns("Not kvm","Not xen","Not xenu") expect(subject).to_not be_suitable end it "is unsuitable if ec2 endpoint is not reachable" do Facter.fact(:virtual).stubs(:value).returns("xen","kvm") querier.stubs(:reachable?).returns false expect(subject).to_not be_suitable end describe "when the ec2 endpoint is reachable" do before do querier.stubs(:reachable?).returns true end it "is suitable if the virtual fact is xen" do Facter.fact(:virtual).stubs(:value).returns "xen" expect(subject).to be_suitable end it "is suitable if the virtual fact is kvm" do Facter.fact(:virtual).stubs(:value).returns "kvm" expect(subject).to be_suitable end it "is suitable if the virtual fact is xenu" do Facter.fact(:virtual).stubs(:value).returns "xenu" expect(subject).to be_suitable end end it "resolves the value by fetching the rest endpoint" do querier.expects(:fetch).returns "user data!" expect(subject.value).to eq "user data!" end end describe "flattened versions of ec2 facts" do # These facts are tricky to test because they are dynamic facts, and they are # generated from a fact that is defined in the same file. In order to pull # this off we need to define the ec2_metadata fact ahead of time so that we # can stub the value, and then manually load the correct files. it "unpacks the ec2_metadata fact" do Facter.define_fact(:ec2_metadata).stubs(:value).returns({"hello" => "world"}) Facter.collection.internal_loader.load(:ec2) expect(Facter.value("ec2_hello")).to eq "world" end it "does not set any flat ec2 facts if the ec2_metadata fact is nil" do Facter.define_fact(:ec2_metadata).stubs(:value) Facter.define_fact(:ec2_userdata).stubs(:value).returns(nil) Facter.collection.internal_loader.load(:ec2) all_facts = Facter.collection.to_hash ec2_facts = all_facts.keys.select { |k| k =~ /^ec2_/ } expect(ec2_facts).to be_empty end end facter-2.4.6/spec/unit/facter_spec.rb0000775005276200011600000000561612651736735017427 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe Facter do it "caches the collection" do Facter.collection.should equal(Facter.collection) end describe "methods on the collection" do it "delegates the :flush method to the collection" do Facter.collection.expects(:flush) Facter.flush end it "delegates the :fact method to the collection" do Facter.collection.expects(:fact).with("afact") Facter.fact("afact") end it "delegates the :list method to the collection" do Facter.collection.expects(:list) Facter.list end it "loads all facts when listing" do Facter.collection.expects(:load_all) Facter.list end it "delegates the :to_hash method to the collection" do Facter.collection.expects(:to_hash) Facter.to_hash end it "loads all facts when calling :to_hash" do Facter.collection.expects(:load_all) Facter.collection.stubs(:to_hash) Facter.to_hash end it "delegates the :value method to the collection" do Facter.collection.expects(:value).with("myvaluefact") Facter.value("myvaluefact") end it "delegates the :each method to the collection" do Facter.collection.expects(:each) Facter.each end it "delegates the :add method to the collection" do Facter.collection.expects(:add).with("factname", {}) Facter.add("factname") end it "delegates the :define_fact method to the collection" do Facter.collection.expects(:define_fact).with("factname", {}) Facter.define_fact("factname") end it "loads all facts when calling :each" do Facter.collection.expects(:load_all) Facter.collection.stubs(:each) Facter.each end end it "yields 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 registering directories to search" do after { Facter.reset_search_path! } it "allows registration of a directory" do Facter.search "/my/dir" end it "allows registration of multiple directories" do Facter.search "/my/dir", "/other/dir" end it "returns all registered directories when asked" do Facter.search "/my/dir", "/other/dir" Facter.search_path.should == %w{/my/dir /other/dir} end end describe "when registering directories to search for external facts" do it "allows registration of a directory" do Facter.search_external ["/my/dir"] end it "allows registration of multiple directories" do Facter.search_external ["/my/dir", "/other/dir"] end it "returns all registered directories when asked" do Facter.search_external ["/my/dir", "/other/dir"] Facter.search_external_path.should include("/my/dir", "/other/dir") end end end facter-2.4.6/spec/unit/filesystems_spec.rb0000664005276200011600000000265412651736735020526 0ustar jenkinsjenkins#! /usr/bin/env ruby 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::Core::Execution.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-2.4.6/spec/unit/fqdn_spec.rb0000664005276200011600000000076212651736735017105 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "fqdn fact" do it "should concatenate hostname and domain" do Facter.fact(:hostname).stubs(:value).returns("foo") Facter.fact(:domain).stubs(:value).returns("bar") Facter.fact(:fqdn).value.should == "foo.bar" end it "should return hostname when domain is nil" do Facter.fact(:hostname).stubs(:value).returns("foo") Facter.fact(:domain).stubs(:value).returns(nil) Facter.fact(:fqdn).value.should == "foo" end end facter-2.4.6/spec/unit/gce/0000775005276200011600000000000012651736742015345 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/gce/metadata_spec.rb0000664005276200011600000000350112651736735020465 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/gce/metadata' describe Facter::GCE::Metadata, :if => Facter.json? do describe "contacting the metadata server" do it "retries the request when a connection error is thrown" do subject.stubs(:open).returns(stub(:read => '{"hello": "world"}')) seq = sequence('open-uri seq') Timeout.expects(:timeout).with(0.05).twice.in_sequence(seq).raises(Timeout::Error) Timeout.expects(:timeout).with(0.05).once.in_sequence(seq).yields expect(subject.fetch).to eq({'hello' => 'world'}) end it "logs the exception when all retries failed" do Timeout.expects(:timeout).with(0.05).times(3).raises(Timeout::Error) Facter.expects(:log_exception).with(instance_of(Timeout::Error), instance_of(String)) expect(subject.fetch).to be_nil end end describe "parsing the metadata response" do let(:body) { my_fixture_read('metadata.json') } before do subject.stubs(:open).returns(stub(:read => body)) end it "transforms hash values with the 'image' key" do expect(subject.fetch['instance']['image']).to eq 'centos6' end it "transforms hash values with the 'machineType' key" do expect(subject.fetch['instance']['machineType']).to eq 'n1-standard-1' end it "transforms hash values with the 'zone' key" do expect(subject.fetch['instance']['zone']).to eq 'us-central1-b' end it "transforms hash values with the 'network' key" do expect(subject.fetch['instance']['networkInterfaces'][0]['network']).to eq 'default' end it "splits up the elements of the 'sshKeys' value into an array" do expect(subject.fetch['project']['attributes']['sshKeys'][0]).to match(/justin:ssh-rsa/) expect(subject.fetch['project']['attributes']['sshKeys'][1]).to match(/adrien:ssh-rsa/) end end end facter-2.4.6/spec/unit/gce_spec.rb0000664005276200011600000000173312651736735016712 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/gce/metadata' describe "gce_metadata" do let(:querier) { stub('GCE metadata querier') } before do Facter::GCE::Metadata.stubs(:new).returns querier Facter.collection.internal_loader.load(:ec2) end subject { Facter.fact(:gce).resolution(:rest) } it "is unsuitable when the virtual type is not gce" do Facter.fact(:virtual).stubs(:value).returns 'kvm' expect(subject).to_not be_suitable end it "is unsuitable when JSON is not available" do Facter.stubs(:json?).returns false expect(subject).to_not be_suitable end it "is suitable when both the virtual type is gce and JSON is available" do Facter.fact(:virtual).stubs(:value).returns 'gce' Facter.stubs(:json?).returns true expect(subject).to be_suitable end it "resolves the fact by querying GCE metadata API" do querier.expects(:fetch).returns({'hello' => 'world'}) expect(subject.value).to eq({'hello' => 'world'}) end end facter-2.4.6/spec/unit/gid_spec.rb0000775005276200011600000000305012651736735016714 0ustar jenkinsjenkinsrequire 'spec_helper' describe "gid fact" do describe "on non-SunOS systems with id" do it "should return the current group" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Core::Execution.expects(:which).with('id').returns(true) Facter::Core::Execution.expects(:exec).once.with('id -ng').returns 'bar' Facter.fact(:gid).value.should == 'bar' end end describe "on non-SunOS systems without id" do it "is not supported" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Core::Execution.expects(:which).with('id').returns(false) Facter.fact(:gid).value.should == nil end end describe "on SunOS systems with /usr/xpg4/bin/id" do it "should return the current group" do Facter.fact(:kernel).stubs(:value).returns("SunOS") File.expects(:exist?).with('/usr/xpg4/bin/id').returns true Facter::Core::Execution.expects(:exec).with('/usr/xpg4/bin/id -ng').returns 'bar' Facter.fact(:gid).value.should == 'bar' end end describe "on SunOS systems without /usr/xpg4/bin/id" do it "is not supported" do Facter.fact(:kernel).stubs(:value).returns("SunOS") File.expects(:exist?).with('/usr/xpg4/bin/id').returns false Facter.fact(:gid).value.should == nil end end describe "on windows systems" do it "is not supported" do Facter.fact(:kernel).stubs(:value).returns("windows") Facter::Core::Execution.expects(:which).with('id').returns(true) Facter.fact(:gid).value.should == nil end end end facter-2.4.6/spec/unit/hardwareisa_spec.rb0000775005276200011600000000247412651736735020454 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::Core::Execution.stubs(:execute).with("uname -p", anything).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::Core::Execution.stubs(:execute).with("uname -p", anything).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::Core::Execution.stubs(:execute).with("uname -p", anything).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::Core::Execution.stubs(:execute).with("uname -p", anything).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::Core::Execution.stubs(:execute).with("uname -m", anything).returns("Pac-Man") Facter.fact(:hardwareisa).value.should == "Pac-Man" end end facter-2.4.6/spec/unit/hardwaremodel_spec.rb0000664005276200011600000000365012651736735020772 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.fact(:operatingsystem).stubs(:value).returns("Darwin") Facter::Core::Execution.stubs(:execute).with("uname -m", anything).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") Facter.fact(:operatingsystem).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-2.4.6/spec/unit/hostname_spec.rb0000775005276200011600000000236112651736735017773 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::Core::Execution.expects(:execute).with('hostname').at_least_once Facter.fact(:hostname).value.should be_nil end it "should use hostname as the fact if unqualified" do Facter::Core::Execution.stubs(:execute).with('hostname').returns('host1') Facter.fact(:hostname).value.should == "host1" end it "should truncate the domain name if qualified" do Facter::Core::Execution.stubs(:execute).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::Core::Execution.expects(:execute).with('/usr/sbin/scutil --get LocalHostName', anything).returns("host1") Facter.fact(:hostname).value.should == "host1" end end end facter-2.4.6/spec/unit/id_spec.rb0000775005276200011600000000161612651736735016553 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::Core::Execution.expects(:execute).once.with('whoami', anything).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.fact(:kernel).stubs(:value).returns 'SunOS' Facter::Core::Execution.expects(:execute).once.with('/usr/xpg4/bin/id -un', anything).returns 'bar' Facter.fact(:id).value.should == 'bar' end end facter-2.4.6/spec/unit/interfaces_spec.rb0000775005276200011600000000422112651736735020275 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'shared_formats/parses' require 'facter/util/ip' shared_examples_for "interface netmask and mtu from ifconfig output" do |platform, interface, netmask, mtu, fixture| it "should be correct on #{platform} for 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) Facter.fact("netmask_#{interface}".intern).value.should eq(netmask) Facter.fact("mtu_#{interface}".intern).value.should eq(mtu) 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 it "should properly format a mac address" do Facter::Util::IP.stubs(:get_interfaces).returns ["net0"] Facter::Util::IP.stubs(:get_interface_value).returns "0:12:34:56:78:90" Facter.collection.internal_loader.load(:interfaces) fact = Facter.fact("macaddress_net0".intern) fact.value.should eq("00:12:34:56:78:90") end end describe "Netmask and MTU handling on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end example_behavior_for "interface netmask and mtu from ifconfig output", "Archlinux (net-tools 1.60)", "em1", "255.255.255.0", 1500, "ifconfig_net_tools_1.60.txt" example_behavior_for "interface netmask and mtu from ifconfig output", "Archlinux (net-tools 1.60)", "lo", "255.0.0.0", 16436, "ifconfig_net_tools_1.60.txt" end facter-2.4.6/spec/unit/ipaddress6_spec.rb0000775005276200011600000001622512651736735020225 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/ip' def ifconfig_fixture(filename) File.read(fixtures('ifconfig', filename)) end describe "The IPv6 address fact" do include FacterSpec::ConfigHelper before do given_a_configuration_of(:is_windows => false) end it "should return ipaddress6 information for Darwin" do Facter::Core::Execution.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::Core::Execution.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::Core::Execution.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 with fe80 in any other octet than the first for Linux" do Facter::Core::Execution.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_and_fe80')) Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:fe80:2201" end it "should not return ipaddress6 link-local address for Linux" do Facter::Core::Execution.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_and_no_public_ipv6')) Facter.value(:ipaddress6).should be_false end it "should return ipaddress6 information for Solaris" do Facter::Core::Execution.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-2.4.6/spec/unit/ipaddress_spec.rb0000775005276200011600000000763012651736735020137 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::Core::Execution.stubs(:execute) 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-2.4.6/spec/unit/kernel_spec.rb0000664005276200011600000000116712651736735017435 0ustar jenkinsjenkins#! /usr/bin/env ruby 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::Core::Execution.stubs(:exec).with('uname -s').returns("test_kernel") Facter.fact(:kernel).value.should == 'test_kernel' end end end facter-2.4.6/spec/unit/kernelmajversion_spec.rb0000775005276200011600000000121712651736735021532 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Kernel major version fact" do context "when the kernelrelease fact contains three components" do it "returns the first two components" do Facter.fact(:kernelversion).stubs(:value).returns("12.34.56") Facter.fact(:kernelmajversion).value.should == "12.34" end end context "when the kernelrelease fact only contains two components" do it "returns the first component" do Facter.fact(:kernel).stubs(:value).returns('FreeBSD') Facter.fact(:kernelversion).stubs(:value).returns("9.2") Facter.fact(:kernelmajversion).value.should == "9" end end end facter-2.4.6/spec/unit/kernelrelease_spec.rb0000664005276200011600000000377612651736735021006 0ustar jenkinsjenkins#! /usr/bin/env ruby 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::Core::Execution.stubs(:execute).with('oslevel -s', anything).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::Core::Execution.stubs(:execute).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::Core::Execution.stubs(:execute).with('uname -r', anything).returns("test_kernel") end it "should return the kernel release" do Facter.fact(:kernelrelease).value.should == "test_kernel" end end describe 'on OpenBSD' do before do Facter.fact(:kernel).stubs(:value).returns :openbsd end it 'parses 5.3-current sysctl output' do Facter::Util::POSIX.stubs(:sysctl).with("kern.version").returns(my_fixture_read('openbsd-5.3-current')) Facter.value(:kernelrelease).should == '5.3-current' end it 'parses 5.3 sysctl output' do Facter::Util::POSIX.stubs(:sysctl).with("kern.version").returns(my_fixture_read('openbsd-5.3')) Facter.value(:kernelrelease).should == '5.3' end end end facter-2.4.6/spec/unit/kernelversion_spec.rb0000664005276200011600000000136412651736735021042 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Kernel version fact" do describe "on Solaris/Sun OS" do before do Facter.fact(:kernel).stubs(:value).returns('sunos') Facter::Core::Execution.stubs(:execute).with('uname -v', anything).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-2.4.6/spec/unit/ldom_spec.rb0000664005276200011600000000511712651736735017107 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.fact(:hardwareisa).stubs(:value).returns("sparc") Facter::Core::Execution.stubs(:which).with("virtinfo").returns 'virtinfo' Facter::Core::Execution.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 end describe "when running on non ldom hardware" do before :each do Facter.fact(:hardwareisa).stubs(:value).returns("sparc") Facter::Core::Execution.stubs(:which).with("virtinfo").returns(nil) Facter.collection.internal_loader.load(:ldom) end it "should return correct virtual" do Facter.fact(:ldom_domainrole_impl).should == nil end end describe "when running on non-sparc hardware" do before :each do Facter.fact(:hardwareisa).stubs(:value).returns("i386") Facter::Core::Execution.stubs(:which).with("virtinfo").returns 'virtinfo' end it "should not try to resolve the ldom facts" do Facter.fact(:ldom_domainrole_impl).should == nil end end end facter-2.4.6/spec/unit/lsbdistcodename_spec.rb0000775005276200011600000000211212651736735021307 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistcodename fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" }, "lsb" => { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "SomeDesc", "distrelease" => "1.2.3", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" }, } } it "should use the 'distcodename' key of the 'os' fact" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:lsbdistcodename).value.should eq "SomeCodeName" end end facter-2.4.6/spec/unit/lsbdistdescription_spec.rb0000775005276200011600000000211712651736735022064 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistdescription fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" }, "lsb" => { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "SomeDesc", "distrelease" => "1.2.3", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" }, } } it "should use the 'distdescription' key of the 'os' fact" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:lsbdistdescription).value.should eq "SomeDesc" end end facter-2.4.6/spec/unit/lsbdistid_spec.rb0000664005276200011600000000207612651736735020136 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistcodename fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" }, "lsb" => { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "SomeDesc", "distrelease" => "1.2.3", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" }, } } it "should use the 'distcodename' key of the 'os' fact" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:lsbdistid).value.should eq "SomeID" end end facter-2.4.6/spec/unit/lsbdistrelease_spec.rb0000775005276200011600000000210012651736735021151 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbdistrelease fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" }, "lsb" => { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "SomeDesc", "distrelease" => "1.2.3", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" }, } } it "should use the 'distrelease' key of the 'os' fact" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:lsbdistrelease).value.should eq "1.2.3" end end facter-2.4.6/spec/unit/lsbmajdistrelease_spec.rb0000775005276200011600000000211612651736735021650 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' describe "LSB distribution major release fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" }, "lsb" => { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "SomeDesc", "distrelease" => "1.2.3", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" }, } } it "should use the 'minordistrelease' key of the 'os' fact" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:lsbminordistrelease).value.should eq "2" end end facter-2.4.6/spec/unit/lsbminordistrelease_spec.rb0000775005276200011600000000213312651736735022224 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' describe "LSB distribution major release fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" }, "lsb" => { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "SomeDesc", "distrelease" => "1.2.3", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" }, } } it "should use the 'majdistrelease' key of the 'os' fact" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:lsbmajdistrelease).value.should eq "1" end end facter-2.4.6/spec/unit/lsbrelease_spec.rb0000775005276200011600000000207212651736735020275 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "lsbrelease fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" }, "lsb" => { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "SomeDesc", "distrelease" => "1.2.3", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" }, } } it "should use the 'distrelease' key from the 'os' fact" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:lsbrelease).value.should eq "1.2.3" end end facter-2.4.6/spec/unit/macaddress_spec.rb0000775005276200011600000000512512651736735020264 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.fact(:operatingsystem).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 describe "when run on OpenBSD with bridge(4) rules" do it "should return macaddress information" do Facter.fact(:kernel).stubs(:value).returns("OpenBSD") Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD") Facter.fact(:osfamily).stubs(:value).returns("OpenBSD") Facter::Util::IP.stubs(:get_ifconfig).returns("/sbin/ifconfig") Facter::Util::IP.stubs(:exec_ifconfig). returns(ifconfig_fixture('openbsd_bridge_rules')) proc { Facter.value(:macaddress) }.should_not raise_error Facter.value(:macaddress).should be_nil end end end facter-2.4.6/spec/unit/manufacturer_spec.rb0000664005276200011600000000755712651736735020662 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 end facter-2.4.6/spec/unit/memory_spec.rb0000775005276200011600000003355612651736735017477 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::POSIX.stubs(:sysctl).with('hw.memsize').returns('8589934592') Facter::Core::Execution.stubs(:exec).with('vm_stat').returns(my_fixture_read('darwin-vm_stat')) Facter::Util::POSIX.stubs(:sysctl).with('vm.swapusage').returns("vm.swapusage: total = 64.00M used = 1.00M free = 63.00M (encrypted)") Facter.collection.internal_loader.load(:memory) end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "64.00" end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "63.00" end it "should return whether swap is encrypted" do Facter.fact(:swapencrypted).value.should == true end it "should return the memory size in MB" do Facter.fact(:memorysize_mb).value.should == "8192.00" end it "should return the memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "138.70" end after(:each) do Facter.clear end end [ "linux", "gnu/kfreebsd", ].each do |kernel| describe "on #{kernel}" do before(:each) do Facter.clear Facter.fact(:kernel).stubs(:value).returns(kernel) meminfo_contents = my_fixture_read('linux-proc_meminfo').split("\n") File.stubs(:readlines).with("/proc/meminfo").returns(meminfo_contents) Facter.collection.internal_loader.load(:memory) end after(:each) do Facter.clear end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "249.91" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "196.16" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "511.99" end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "511.99" end end end describe "on AIX" do before (:each) do Facter.clear Facter.fact(:kernel).stubs(:value).returns("AIX") Facter::Core::Execution.stubs(:exec).with('swap -l 2>/dev/null').returns(my_fixture_read('aix-swap_l')) Facter::Core::Execution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(my_fixture_read('aix-svmon')) Facter.collection.internal_loader.load(:memory) end after(:each) do Facter.clear end describe "when not root" do before(:each) do Facter.fact(:id).stubs(:value).returns("notroot") end it "should return nil for swap size" do Facter.fact(:swapsize_mb).value.should be_nil end it "should return nil for swap free" do Facter.fact(:swapfree_mb).value.should be_nil end end describe "when root" do before(:each) do Facter.fact(:id).stubs(:value).returns("root") end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "512.00" end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "508.00" end end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "22284.76" end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "32000.00" end end describe "on OpenBSD" do before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("OpenBSD") swapusage = "total: 4080510 512-blocks allocated, 461832 used, 3618678 available" Facter::Core::Execution.stubs(:exec).with('swapctl -s').returns(swapusage) Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('openbsd-vmstat')) Facter::Util::POSIX.stubs(:sysctl).with('hw.physmem').returns('267321344') Facter::Util::POSIX.stubs(:sysctl).with('vm.swapencrypt.enable').returns('1') Facter.collection.internal_loader.load(:memory) end after :each do Facter.clear end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "1766.93" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "1992.44" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "176.79" end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "254.94" end it "should return whether swap is encrypted" do Facter.fact(:swapencrypted).value.should == true end end describe "on Solaris" do before(:each) do Facter.clear Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter::Core::Execution.stubs(:exec).with('/usr/sbin/prtconf 2>/dev/null').returns(my_fixture_read('solaris-prtconf')) Facter::Core::Execution.stubs(:exec).with('vmstat').returns(my_fixture_read('solaris-vmstat')) end after(:each) do Facter.clear end describe "when single swap exists" do before(:each) do Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-single') 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 Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('solaris-swap_l-multiple') 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::Core::Execution.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 describe "when in a SmartOS zone" do before(:each) do Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('smartos_zone_swap_l-single') Facter.collection.internal_loader.load(:memory) end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "49152.00" end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "33676.06" 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::POSIX.stubs(:sysctl).with('hw.pagesize').returns("4096") Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_size').returns("128461") Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_anon_use').returns("2635") Facter::Util::POSIX.stubs(:sysctl).with('vm.swap_cache_use').returns("0") Facter::Core::Execution.stubs(:exec).with('vmstat').returns my_fixture_read('dragonfly-vmstat') Facter::Util::POSIX.stubs(:sysctl).with("hw.physmem").returns('248512512') Facter.collection.internal_loader.load(:memory) end after :each do Facter.clear end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "491.51" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "501.80" end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "237.00" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "13.61" end end describe "on FreeBSD" do before(:each) do Facter.clear Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Core::Execution.stubs(:exec).with('vmstat -H').returns my_fixture_read('freebsd-vmstat') Facter::Util::POSIX.stubs(:sysctl).with('hw.physmem').returns '1056276480' end after(:each) do Facter.clear end describe "with no swap" do before(:each) do sample_swapinfo = 'Device 1K-blocks Used Avail Capacity' Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns sample_swapinfo Facter.collection.internal_loader.load(:memory) end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "0.00" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "0.00" end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "1007.34" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "641.25" end end describe "with one swap" do before(:each) do Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-single') Facter.collection.internal_loader.load(:memory) end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "1023.96" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "2000.53" end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "1007.34" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "641.25" end end describe "with multiple swaps" do before(:each) do Facter::Core::Execution.stubs(:exec).with('swapinfo -k').returns my_fixture_read('darwin-swapinfo-multiple') Facter.collection.internal_loader.load(:memory) end it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "2047.93" end it "should return the current swap size in MB" do Facter.fact(:swapsize_mb).value.should == "4977.62" end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "1007.34" end it "should return the current memory free in MB" do Facter.fact(:memoryfree_mb).value.should == "641.25" end end end describe "on Windows" do before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("windows") Facter.collection.internal_loader.load(:memory) require 'facter/util/wmi' end it "should return free memory in MB" do os = stubs 'os' os.stubs(:FreePhysicalMemory).returns("3415624") Facter::Util::WMI.stubs(:execquery).returns([os]) Facter.fact(:memoryfree_mb).value.should == '3335.57' end it "should return total memory in MB" do computer = stubs 'computer' computer.stubs(:TotalPhysicalMemory).returns("4193837056") Facter::Util::WMI.stubs(:execquery).returns([computer]) Facter.fact(:memorysize_mb).value.should == '3999.55' end end end facter-2.4.6/spec/unit/netmask_spec.rb0000775005276200011600000000651412651736735017623 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 AIX" do before :each do Facter.fact(:kernel).stubs(:value).returns("AIX") end example_behavior_for "netmask from ifconfig output", "AIX 7", "255.255.255.0", "ifconfig_aix_7.txt" end context "on Darwin" do before :each do Facter.fact(:kernel).stubs(:value).returns("Darwin") end example_behavior_for "netmask from ifconfig output", "Darwin 10.8.5", "255.255.252.0", "darwin_10_8_5.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-2.4.6/spec/unit/operatingsystem/0000775005276200011600000000000012651736742020044 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/operatingsystem/base_spec.rb0000664005276200011600000000513712651736735022325 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/operatingsystem/base' describe Facter::Operatingsystem::Base do subject { described_class.new } before :each do Facter.fact(:kernel).stubs(:value).returns("Nutmeg") end describe "Operating system fact" do it "should default to the kernel name" do os = subject.get_operatingsystem expect(os).to eq "Nutmeg" end end describe "Osfamily fact" do it "should default to the kernel name" do osfamily = subject.get_osfamily expect(osfamily).to eq "Nutmeg" end end describe "Operatingsystemrelease fact" do it "should return the kernel fact by default" do Facter.fact(:kernelrelease).stubs(:value).returns("1.2.3") operatingsystemrelease = subject.get_operatingsystemrelease expect(operatingsystemrelease).to eq "1.2.3" end end describe "Operatingsystemmajrelease fact" do it "should base major release on release fact if available" do subject.expects(:get_operatingsystemrelease).returns("1.2.3") operatingsystemmajrelease = subject.get_operatingsystemmajorrelease expect(operatingsystemmajrelease).to eq "1" end it "should return nil if release fact not available" do subject.expects(:get_operatingsystemrelease).returns(nil) operatingsystemmajrelease = subject.get_operatingsystemmajorrelease expect(operatingsystemmajrelease).to be_nil end end describe "Operatingsystemminorrelease" do it "should base minor release on release fact if available" do subject.expects(:get_operatingsystemrelease).returns("1.2.3") operatingsystemminorrelease = subject.get_operatingsystemminorrelease expect(operatingsystemminorrelease).to eq "2" end it "should strip off the patch release if appended with a '-'" do subject.stubs(:get_operatingsystem).returns("FreeBSD") subject.expects(:get_operatingsystemrelease).returns("10.0-RELEASE") release = subject.get_operatingsystemminorrelease expect(release).to eq "0" end it "should return nil if release fact not available" do subject.expects(:get_operatingsystemrelease).returns(nil) operatingsystemmajrelease = subject.get_operatingsystemminorrelease expect(operatingsystemmajrelease).to be_nil end end describe "Operatingsystemrelease hash" do it "should return a hash of release values" do subject.expects(:get_operatingsystemrelease).at_least_once.returns("1.2.3") release_hash = subject.get_operatingsystemrelease_hash expect(release_hash).to eq({"major" => "1", "minor" => "2", "full" => "1.2.3" }) end end end facter-2.4.6/spec/unit/operatingsystem/cumuluslinux_spec.rb0000664005276200011600000000215612651736735024166 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/operatingsystem/cumuluslinux' describe Facter::Operatingsystem::CumulusLinux do subject { described_class.new } before :all do Facter.fact(:kernel).stubs(:value).returns("Linux") end describe "Operating system fact" do it "should identify Cumulus Linux" do os = subject.get_operatingsystem expect(os).to eq "CumulusLinux" end end describe "Osfamily fact" do it "should return Debian" do osfamily = subject.get_osfamily expect(osfamily).to eq "Debian" end end describe "Operatingsystemrelease fact" do it "uses '/etc/os-release" do Facter::Util::Operatingsystem.expects(:os_release).returns({"VERSION_ID" => "1.5.0"}) release = subject.get_operatingsystemrelease expect(release).to eq "1.5.0" end end describe "Operatingsystemmajrelease fact" do it "should return the majrelease value based on its operatingsystemrelease" do subject.expects(:get_operatingsystemrelease).returns("1.5.0") release = subject.get_operatingsystemmajrelease expect(release).to eq "1" end end end facter-2.4.6/spec/unit/operatingsystem/implementation_spec.rb0000664005276200011600000000422712651736735024437 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/operatingsystem/implementation' require 'facter/operatingsystem/base' require 'facter/operatingsystem/cumuluslinux' require 'facter/operatingsystem/osreleaselinux' require 'facter/operatingsystem/linux' require 'facter/operatingsystem/sunos' require 'facter/operatingsystem/vmkernel' require 'facter/operatingsystem/windows' describe Facter::Operatingsystem do it "should return an object of type Linux for linux kernels that are not Cumulus Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Util::Operatingsystem.expects(:os_release).at_least_once.returns({'NAME' => 'Some Linux'}) object = described_class.implementation object.should be_a_kind_of(Facter::Operatingsystem::Linux) end it "should return an object of type Linux for gnu/kfreebsd kernels" do Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD") Facter::Util::Operatingsystem.expects(:os_release).at_least_once.returns({'NAME' => 'Some Linux'}) object = described_class.implementation object.should be_a_kind_of(Facter::Operatingsystem::Linux) end it "should identify Cumulus Linux when a Linux kernel is encountered" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Util::Operatingsystem.expects(:os_release).at_least_once.returns({'NAME' => 'Cumulus Linux'}) object = described_class.implementation object.should be_a_kind_of(Facter::Operatingsystem::CumulusLinux) end it "should return an object of type SunOS for SunOS kernels" do Facter.fact(:kernel).stubs(:value).returns("SunOS") object = described_class.implementation object.should be_a_kind_of(Facter::Operatingsystem::SunOS) end it "should return an object of type VMkernel for VMkernel kernels" do Facter.fact(:kernel).stubs(:value).returns("VMkernel") object = described_class.implementation object.should be_a_kind_of(Facter::Operatingsystem::VMkernel) end it "should return an object of type Base for other kernels" do Facter.fact(:kernel).stubs(:value).returns("Nutmeg") object = described_class.implementation object.should be_a_kind_of(Facter::Operatingsystem::Base) end end facter-2.4.6/spec/unit/operatingsystem/linux_spec.rb0000664005276200011600000005322112651736735022547 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/operatingsystem/linux' describe Facter::Operatingsystem::Linux do subject { described_class.new } describe "Operating system fact" do describe "On gnu/kfreebsd" do it "should return 'GNU/kFreeBSD'" do Facter.expects(:value).with(:kernel).returns("GNU/kFreeBSD") os = subject.get_operatingsystem expect(os).to eq "GNU/kFreeBSD" end end describe "When lsbdistid is available" do it "on Ubuntu should use the lsbdistid fact" do subject.expects(:get_lsbdistid).returns("Ubuntu") os = subject.get_operatingsystem expect(os).to eq "Ubuntu" end it "on LinuxMint should use the lsbdistid fact" do subject.expects(:get_lsbdistid).returns("LinuxMint") os = subject.get_operatingsystem expect(os).to eq "LinuxMint" end end describe "When lsbdistid is not available" do { "AristaEOS" => "/etc/Eos-release", "Debian" => "/etc/debian_version", "Gentoo" => "/etc/gentoo-release", "Fedora" => "/etc/fedora-release", "Mageia" => "/etc/mageia-release", "Mandriva" => "/etc/mandriva-release", "Mandrake" => "/etc/mandrake-release", "MeeGo" => "/etc/meego-release", "Archlinux" => "/etc/arch-release", "Manjarolinux"=> "/etc/manjaro-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 subject.expects(:get_lsbdistid).returns(nil) FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with(releasefile).returns true os = subject.get_operatingsystem expect(os).to eq distribution end end end describe "on distributions that rely on the contents of /etc/redhat-release" do before :each do subject.expects(:get_lsbdistid).returns(nil) end { "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)", "XCP" => "XCP release 1.6.10-61809c", }.each_pair do |operatingsystem, string| it "should be #{operatingsystem} based on /etc/redhat-release contents #{string}" do FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with("/etc/enterprise-release").returns false FileTest.expects(:exists?).with("/etc/redhat-release").returns true File.expects(:read).with("/etc/redhat-release").at_least_once.returns string os = subject.get_operatingsystem expect(os).to eq operatingsystem end end it "should be OEL if /etc/ovs-release doesn't exist" do FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with("/etc/enterprise-release").returns true FileTest.expects(:exists?).with("/etc/ovs-release").returns false os = subject.get_operatingsystem expect(os).to eq "OEL" end it "should differentiate between Scientific Linux CERN and Scientific Linux" do FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with("/etc/redhat-release").returns true FileTest.expects(:exists?).with("/etc/enterprise-release").returns false File.expects(:read).with("/etc/redhat-release").at_least_once.returns("Scientific Linux CERN SLC 5.7 (Boron)") os = subject.get_operatingsystem expect(os).to eq "SLC" end it "should default to RedHat" do FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with("/etc/redhat-release").returns true FileTest.expects(:exists?).with("/etc/enterprise-release").returns false File.expects(:read).with("/etc/redhat-release").at_least_once.returns("Mystery RedHat") os = subject.get_operatingsystem expect(os).to eq "RedHat" end describe "on Oracle variants" do it "should be OVS if /etc/ovs-release exists" do FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with("/etc/enterprise-release").returns true FileTest.expects(:exists?).with("/etc/ovs-release").returns true os = subject.get_operatingsystem expect(os).to eq "OVS" end it "should be OEL if /etc/ovs-release doesn't exist" do FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with("/etc/enterprise-release").returns true FileTest.expects(:exists?).with("/etc/ovs-release").returns false os = subject.get_operatingsystem expect(os).to eq "OEL" end end end describe "on distributions that rely on the contents of /etc/SuSE-release" do before :each do subject.expects(:get_lsbdistid).returns(nil) end { "SLES" => "SUSE LINUX Enterprise Server", "SLED" => "SUSE LINUX Enterprise Desktop", "OpenSuSE" => "openSUSE" }.each_pair do |operatingsystem, string| it "should be #{operatingsystem} based on /etc/SuSE-release contents #{string}" do FileTest.expects(:exists?).at_least_once.returns false FileTest.expects(:exists?).with("/etc/enterprise-release").returns false FileTest.expects(:exists?).with("/etc/redhat-release").returns false FileTest.expects(:exists?).with("/etc/SuSE-release").returns true File.expects(:read).with("/etc/SuSE-release").at_least_once.returns string os = subject.get_operatingsystem expect(os).to eq operatingsystem end end end end describe "Osfamily fact" do { 'Archlinux' => 'Archlinux', "Manjarolinux" => "Archlinux", 'Ubuntu' => 'Debian', 'Debian' => 'Debian', 'LinuxMint' => 'Debian', 'Gentoo' => 'Gentoo', 'Fedora' => 'RedHat', 'Amazon' => 'RedHat', 'OracleLinux' => 'RedHat', 'OVS' => 'RedHat', 'OEL' => 'RedHat', 'CentOS' => 'RedHat', 'SLC' => 'RedHat', 'Scientific' => 'RedHat', 'CloudLinux' => 'RedHat', 'PSBM' => 'RedHat', 'Ascendos' => 'RedHat', 'XenServer' => 'RedHat', 'RedHat' => 'RedHat', 'SLES' => 'Suse', 'SLED' => 'Suse', 'OpenSuSE' => 'Suse', 'SuSE' => 'Suse', 'Mageia' => 'Mandrake', 'Mandriva' => 'Mandrake', 'Mandrake' => 'Mandrake', }.each do |os,family| it "should return #{family} on operatingsystem #{os}" do subject.expects(:get_operatingsystem).returns(os) osfamily = subject.get_osfamily expect(osfamily).to eq family end end [ 'MeeGo', 'VMWareESX', 'Bluewhite64', 'Slamd64', 'Slackware', 'Alpine', 'AristaEOS', ].each do |os| it "should return the kernel fact on operatingsystem #{os}" do Facter.expects(:value).with("kernel").returns "Linux" subject.expects(:get_operatingsystem).returns(os) osfamily = subject.get_osfamily expect(osfamily).to eq "Linux" end end it "should return the kernel value on gnu/kfreebsd" do Facter.expects(:value).with("kernel").returns "gnu/kfreebsd" subject.expects(:get_operatingsystem).returns("Gnu/kfreebsd") osfamily = subject.get_osfamily expect(osfamily).to eq "gnu/kfreebsd" end end describe "Operatingsystemrelease fact" do test_cases = { "AristaEOS" => "/etc/Eos-release", "OpenWrt" => "/etc/openwrt_version", "CentOS" => "/etc/redhat-release", "RedHat" => "/etc/redhat-release", "LinuxMint" => "/etc/linuxmint/info", "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}" do it "should read #{file}" do subject.expects(:get_operatingsystem).at_least_once.returns(system) Facter::Util::FileRead.expects(:read).with(file).at_least_once release = subject.get_operatingsystemrelease end end end it "should not include trailing whitespace on Debian" do subject.expects(:get_operatingsystem).returns("Debian") Facter::Util::FileRead.expects(:read).returns("6.0.6\n") release = subject.get_operatingsystemrelease expect(release).to eq "6.0.6" end it "should run the vmware -v command in VMWareESX" do Facter.fact(:kernel).stubs(:value).returns("VMkernel") Facter.fact(:kernelrelease).stubs(:value).returns("4.1.0") subject.expects(:get_operatingsystem).returns("VMwareESX") Facter::Core::Execution.expects(:exec).with('vmware -v').returns("VMware ESX 4.1.0") release = subject.get_operatingsystemrelease expect(release).to eq "4.1.0" end it "should use the contents of /etc/alpine-release in Alpine" do subject.expects(:get_operatingsystem).returns("Alpine") File.expects(:read).with("/etc/alpine-release").returns("foo") release = subject.get_operatingsystemrelease expect(release).to eq "foo" end it "should use the contents of /etc/Eos-release in AristaEOS" do subject.expects(:get_operatingsystem).returns("AristaEOS") File.expects(:read).with("/etc/Eos-release").returns("Arista Networks EOS 4.13.7M") release = subject.get_operatingsystemrelease expect(release).to eq "4.13.7M" end it "should fall back to parsing /etc/system-release if lsb facts are not available in Amazon" do subject.expects(:get_operatingsystem).returns("Amazon") subject.expects(:get_lsbdistrelease).returns(nil) Facter::Util::FileRead.expects(:read).with('/etc/system-release').returns("Amazon Linux AMI release 2014.03") release = subject.get_operatingsystemrelease expect(release).to eq "2014.03" end it "should fall back to kernelrelease fact for gnu/kfreebsd" do Facter.fact(:kernelrelease).stubs(:value).returns("1.2.3") subject.expects(:get_operatingsystem).returns("GNU/kFreeBSD") release = subject.get_operatingsystemrelease expect(release).to eq "1.2.3" end describe "with operatingsystem reported as Ubuntu" do let(:lsbrelease) { 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=10.04\nDISTRIB_CODENAME=lucid\nDISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"'} it "Returns only the major and minor version (not patch version)" do Facter::Util::FileRead.expects(:read).with("/etc/lsb-release").returns(lsbrelease) subject.expects(:get_operatingsystem).returns("Ubuntu") release = subject.get_operatingsystemrelease expect(release).to eq "10.04" end end end describe "Operatingsystemmajrelease key" do ['Amazon' 'AristaEOS', 'CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC','CumulusLinux','CoreOS'].each do |operatingsystem| describe "on #{operatingsystem} operatingsystems" do it "should be derived from operatingsystemrelease" do subject.stubs(:get_operatingsystem).returns(operatingsystem) subject.expects(:get_operatingsystemrelease).returns("6.3") release = subject.get_operatingsystemmajorrelease expect(release).to eq "6" end end end it "should derive major release properly in Ubuntu" do subject.stubs(:get_operatingsystem).returns("Ubuntu") subject.expects(:get_operatingsystemrelease).returns("10.04") release = subject.get_operatingsystemmajorrelease expect(release).to eq "10.04" end end describe "Operatingsystem minor release key" do it "should strip off the patch release if appended with a '-'" do subject.stubs(:get_operatingsystem).returns("FreeBSD") subject.expects(:get_operatingsystemrelease).returns("10.0-RELEASE") release = subject.get_operatingsystemminorrelease expect(release).to eq "0" end end describe "Lsb facts" do let(:raw_lsb_data) { "Distributor ID:\tSomeID\nDescription:\tSome Desc\nRelease:\t14.04\nCodename:\tSomeCodeName\nLSB Version:\t1.2.3" } let(:lsb_data) { { "Distributor ID" => "SomeID", "Description" => "Some Desc", "Release" => "14.04", "Codename" => "SomeCodeName", "LSB Version" => "1.2.3" } } let(:lsb_hash) { { "distcodename" => "SomeCodeName", "distid" => "SomeID", "distdescription" => "Some Desc", "distrelease" => "14.04", "release" => "1.2.3", "majdistrelease" => "1", "minordistrelease" => "2" } } describe "collecting LSB data" do it "should properly parse the lsb_release command" do Facter::Core::Execution.expects(:exec).with('lsb_release -cidvr 2>/dev/null', anything).returns raw_lsb_data lsb_hash = subject.collect_lsb_information expect(lsb_hash).to eq lsb_data end end describe "lsbdistcodename fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do it "returns the codename" do subject.expects(:collect_lsb_information).returns lsb_data lsbdistcodename = subject.get_lsbdistcodename expect(lsbdistcodename).to eq 'SomeCodeName' end it "returns nil if lsb_release is not installed" do subject.expects(:collect_lsb_information).returns nil lsbdistcodename = subject.get_lsbdistcodename expect(lsbdistcodename).to be_nil end end end it "should return the lsbdistcodename in the lsb facts hash" do subject.expects(:get_lsb_facts_hash).returns(lsb_hash) lsbdistcodename = subject.get_lsb_facts_hash["distcodename"] expect(lsbdistcodename).to eq "SomeCodeName" end end describe "lsbdistid fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do it "returns the id" do subject.expects(:collect_lsb_information).returns lsb_data lsbdistid = subject.get_lsbdistid expect(lsbdistid).to eq 'SomeID' end it "returns nil if lsb_release is not installed" do subject.expects(:collect_lsb_information).returns nil lsbdistid = subject.get_lsbdistid expect(lsbdistid).to be_nil end end end it "should return the lsbdistid in the lsb facts hash" do subject.expects(:get_lsb_facts_hash).returns(lsb_hash) lsbdistid = subject.get_lsb_facts_hash["distid"] expect(lsbdistid).to eq "SomeID" end end describe "lsbdistdescription fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do it "returns the description" do subject.expects(:collect_lsb_information).returns lsb_data lsbdistdescription = subject.get_lsbdistdescription expect(lsbdistdescription).to eq 'Some Desc' end it "returns nil if lsb_release is not installed" do subject.expects(:collect_lsb_information).returns nil lsbdistdescription = subject.get_lsbdistdescription expect(lsbdistdescription).to be_nil end end end it "should return the lsbdistdescription in the lsb facts hash" do subject.expects(:get_lsb_facts_hash).returns(lsb_hash) lsbdistdescription = subject.get_lsb_facts_hash["distdescription"] expect(lsbdistdescription).to eq "Some Desc" end end describe "lsbrelease fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do it "returns the LSB release" do subject.expects(:collect_lsb_information).returns lsb_data lsbrelease = subject.get_lsbrelease expect(lsbrelease).to eq '1.2.3' end it "returns nil if lsb_release is not installed" do subject.expects(:collect_lsb_information).returns nil lsbrelease = subject.get_lsbrelease expect(lsbrelease).to be_nil end end end it "should return the lsbrelease in the lsb facts hash" do subject.expects(:get_lsb_facts_hash).returns(lsb_hash) lsbrelease = subject.get_lsb_facts_hash["release"] expect(lsbrelease).to eq '1.2.3' end end describe "lsbdistrelease fact" do [ "Linux", "GNU/kFreeBSD"].each do |kernel| describe "on #{kernel}" do it "should return the dist release" do subject.expects(:collect_lsb_information).returns lsb_data lsbdistrelease = subject.get_lsbdistrelease expect(lsbdistrelease).to eq '14.04' end it "should return nil if lsb_release is not installed" do subject.expects(:collect_lsb_information).returns nil lsbdistrelease = subject.get_lsbdistrelease expect(lsbdistrelease).to be_nil end end end it "should return the lsbdistrelease in the lsb facts hash" do subject.expects(:get_lsb_facts_hash).returns(lsb_hash) lsbdistrelease = subject.get_lsb_facts_hash["distrelease"] expect(lsbdistrelease).to eq '14.04' end end describe "lsbmajdistrelease fact" do it "should be derived from lsb_release" do subject.expects(:get_operatingsystem).returns("Amazon") subject.expects(:get_lsbdistrelease).returns("10.04") lsbmajdistrelease = subject.get_lsbmajdistrelease expect(lsbmajdistrelease).to eq "10" end it "should derive correctly in Ubuntu" do subject.expects(:get_operatingsystem).returns("Ubuntu") subject.expects(:get_lsbdistrelease).returns("10.04") lsbmajdistrelease = subject.get_lsbmajdistrelease expect(lsbmajdistrelease).to eq "10.04" end it "should return the lsbmajdistrelease" do subject.expects(:get_lsb_facts_hash).returns(lsb_hash) lsbmajdistrelease = subject.get_lsb_facts_hash["majdistrelease"] expect(lsbmajdistrelease).to eq "1" end end describe "lsbminordistrelease fact" do it "should be derived from lsb_release" do subject.expects(:get_operatingsystem).returns("Amazon") subject.expects(:get_lsbdistrelease).returns("10.04") lsbminordistrelease = subject.get_lsbminordistrelease expect(lsbminordistrelease).to eq "04" end it "should derive correctly in Ubuntu" do subject.expects(:get_operatingsystem).returns("Ubuntu") subject.expects(:get_lsbdistrelease).returns("10.04.02") lsbminordistrelease = subject.get_lsbminordistrelease expect(lsbminordistrelease).to eq "02" end it 'should be derived from lsbdistrelease and take Y from version X.Y' do subject.expects(:get_operatingsystem).returns("Amazon") subject.expects(:get_lsbdistrelease).returns("6.4") lsbminordistrelease = subject.get_lsbminordistrelease expect(lsbminordistrelease).to eq "4" end it 'should be derived from lsbdistrelease and take Y from version X.Y.Z' do subject.expects(:get_operatingsystem).returns("Amazon") subject.expects(:get_lsbdistrelease).returns("6.4.1") lsbminordistrelease = subject.get_lsbminordistrelease expect(lsbminordistrelease).to eq "4" end it 'should be derived from lsbdistrelease and take Y from version X.Y.Z where multiple digits exist' do subject.expects(:get_operatingsystem).returns("Amazon") subject.expects(:get_lsbdistrelease).returns("10.20.30") lsbminordistrelease = subject.get_lsbminordistrelease expect(lsbminordistrelease).to eq "20" end it 'should not be present if lsbdistrelease is only X and is missing .Y' do subject.expects(:get_operatingsystem).returns("Amazon") subject.expects(:get_lsbdistrelease).returns("6") lsbminordistrelease = subject.get_lsbminordistrelease expect(lsbminordistrelease).to be_nil end it "should return the lsbmajdistrelease" do subject.expects(:get_lsb_facts_hash).returns(lsb_hash) lsbminordistrelease = subject.get_lsb_facts_hash["minordistrelease"] expect(lsbminordistrelease).to eq "2" end end end end facter-2.4.6/spec/unit/operatingsystem/sunos_spec.rb0000664005276200011600000001473012651736735022561 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/operatingsystem/sunos' describe Facter::Operatingsystem::SunOS do subject { described_class.new } describe "Operating system fact" do it "should be Nexenta if /etc/debian_version is present" do FileTest.expects(:exists?).with("/etc/debian_version").returns true os = subject.get_operatingsystem expect(os).to eq "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 os = subject.get_operatingsystem expect(os).to eq "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::Core::Execution.expects(:exec).with('uname -v').returns(string) os = subject.get_operatingsystem expect(os).to eq distribution end end end describe "Osfamily fact" do it "should return Solaris" do osfamily = subject.get_osfamily expect(osfamily).to eq "Solaris" end end describe "Operatingsystemrelease fact" do { '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', 'Oracle Solaris 11 11/11 X86' => '11 11/11', 'Oracle Solaris 11.1 SPARC' => '11.1' }.each do |fakeinput, expected_output| it "should be able to parse a release of #{fakeinput}" do Facter::Util::FileRead.expects(:read).with("/etc/release").returns fakeinput release = subject.get_operatingsystemrelease expect(release).to eq expected_output end end context "malformed /etc/release files" do it "should fallback to the kernelrelease fact if /etc/release is empty" do Facter::Util::FileRead.expects(:read).with('/etc/release').returns("") release = subject.get_operatingsystemrelease expect(release).to eq Facter.fact(:kernelrelease).value end it "should fallback to the kernelrelease fact if /etc/release is not present" do Facter::Util::FileRead.expects(:read).with('/etc/release').returns false release = subject.get_operatingsystemrelease expect(release).to eq Facter.fact(:kernelrelease).value end it "should fallback to the kernelrelease fact if /etc/release cannot be parsed" do Facter::Util::FileRead.expects(:read).with('/etc/release').returns 'some future release string' release = subject.get_operatingsystemrelease expect(release).to eq Facter.fact(:kernelrelease).value end end end describe "Operatingsystemmajrelease fact" do before :each do Facter.fact(:kernel).stubs(:value).returns("SunOS") subject.expects(:get_operatingsystem).returns("Solaris") end it "should correctly derive from operatingsystemrelease on solaris 10" do subject.expects(:get_operatingsystemrelease).returns("10_u8") release = subject.get_operatingsystemmajorrelease expect(release).to eq "10" end it "should correctly derive from operatingsystemrelease on solaris 11 (old version scheme)" do subject.expects(:get_operatingsystemrelease).returns("11 11/11") release = subject.get_operatingsystemmajorrelease expect(release).to eq "11" end it "should correctly derive from operatingsystemrelease on solaris 11 (new version scheme)" do subject.expects(:get_operatingsystemrelease).returns("11.1") release = subject.get_operatingsystemmajorrelease expect(release).to eq "11" end end end facter-2.4.6/spec/unit/operatingsystem/vmkernel_spec.rb0000664005276200011600000000045212651736735023231 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/operatingsystem/vmkernel' describe Facter::Operatingsystem::VMkernel do subject { described_class.new } describe "Operating system fact" do it "should be ESXi" do os = subject.get_operatingsystem expect(os).to eq "ESXi" end end end facter-2.4.6/spec/unit/operatingsystem/windows_spec.rb0000664005276200011600000000664412651736735023111 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/operatingsystem/windows' describe Facter::Operatingsystem::Windows do require 'facter/util/wmi' subject { described_class.new } describe "Operatingsystemrelease fact" do before do Facter.fact(:kernel).stubs(:value).returns("windows") end { ['5.2.3790', 1] => "XP", ['6.0.6002', 1] => "Vista", ['6.0.6002', 2] => "2008", ['6.0.6002', 3] => "2008", ['6.1.7601', 1] => "7", ['6.1.7601', 2] => "2008 R2", ['6.1.7601', 3] => "2008 R2", ['6.2.9200', 1] => "8", ['6.2.9200', 2] => "2012", ['6.2.9200', 3] => "2012", ['6.3.9600', 1] => "8.1", ['6.3.9600', 2] => "2012 R2", ['6.3.9600', 3] => "2012 R2", ['6.4.9841', 1] => "10", # Kernel version for Windows 10 preview. Subject to change. }.each do |os_values, expected_output| it "should be #{expected_output} with Version #{os_values[0]} and ProductType #{os_values[1]}" do os = mock('os', :version => os_values[0], :producttype => os_values[1]) Facter::Util::WMI.expects(:execquery).returns([os]) release = subject.get_operatingsystemrelease expect(release).to eq expected_output end end { # Note: this is the kernel version for the Windows 10 technical preview, # which is subject to change. These tests cover any future Windows server # releases with a kernel version of 6.4.x, none of which have been released # as of October 2014. ['6.4.9841', 2] => "6.4.9841", ['6.4.9841', 3] => "6.4.9841", }.each do |os_values, expected_output| it "should be the kernel release for unknown future server releases" do Facter.fact(:kernelrelease).stubs(:value).returns("6.4.9841") os = mock('os', :version => os_values[0], :producttype => os_values[1]) Facter::Util::WMI.expects(:execquery).returns([os]) release = subject.get_operatingsystemrelease expect(release).to eq expected_output end end { ['5.2.3790', 2, ""] => "2003", ['5.2.3790', 2, "R2"] => "2003 R2", ['5.2.3790', 3, ""] => "2003", ['5.2.3790', 3, "R2"] => "2003 R2", }.each do |os_values, expected_output| it "should be #{expected_output} with Version #{os_values[0]} and ProductType #{os_values[1]} and OtherTypeDescription #{os_values[2]}" do os = mock('os', :version => os_values[0], :producttype => os_values[1], :othertypedescription => os_values[2]) Facter::Util::WMI.expects(:execquery).returns([os]) release = subject.get_operatingsystemrelease expect(release).to eq expected_output end end it "reports '2003' if the WMI method othertypedescription does not exist" do os = mock('os', :version => '5.2.3790', :producttype => 2) os.stubs(:othertypedescription).raises(NoMethodError) Facter::Util::WMI.expects(:execquery).returns([os]) release = subject.get_operatingsystemrelease expect(release).to eq "2003" end context "Unknown Windows version" do before :each do Facter.fact(:kernelrelease).stubs(:value).returns("X.Y.ZZZZ") end it "should be kernel version value with unknown values " do os = mock('os', :version => "X.Y.ZZZZ") Facter::Util::WMI.expects(:execquery).returns([os]) release = subject.get_operatingsystemrelease expect(release).to eq "X.Y.ZZZZ" end end end end facter-2.4.6/spec/unit/operatingsystem_spec.rb0000775005276200011600000000076412651736735021417 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Operating System fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => "1.2.3", "releasemajor" => "1", } } it "should use the 'operatingsystem' key from the 'os' fact" do Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:operatingsystem).value.should eq "SomeOS" end end facter-2.4.6/spec/unit/operatingsystemmajrelease_spec.rb0000664005276200011600000000122712651736735023440 0ustar jenkinsjenkins#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "OS Major Release fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" } } } it "should use the 'major' key of the 'release' key from the 'os' fact" do Facter.fact(:operatingsystem).stubs(:value).returns("Amazon") Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:operatingsystemmajrelease).value.should eq "1" end end facter-2.4.6/spec/unit/operatingsystemrelease_spec.rb0000775005276200011600000000112412651736735022747 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Operating System Release fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => { "major" => "1", "minor" => "2", "full" => "1.2.3" } } } it "should use the 'full' key of the 'release' key from the 'os' fact" do Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:operatingsystemrelease).value.should eq "1.2.3" end end facter-2.4.6/spec/unit/os_spec.rb0000664005276200011600000001011712651736735016571 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/operatingsystem/base' require 'facter/operatingsystem/linux' describe "os" do subject { Facter.fact("os") } let(:os) { stub 'OS object' } let(:lsb_hash) { { "distcodename" => "trusty", "distid" => "Ubuntu", "distdescription" => "Ubuntu 14.04 LTS", "distrelease" => "14.04", "release" => "14.04", "majdistrelease" => "14" } } let(:release_hash) { { "major" => 1, "minor" => 2, "patch" => 3, "full" => "1.2.3" } } describe "in Linux with lsb facts available" do before do Facter::Operatingsystem::Linux.stubs(:new).returns os end before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") os.expects(:get_operatingsystem).returns("Ubuntu") os.expects(:get_osfamily).returns("Debian") os.expects(:get_operatingsystemrelease_hash).returns(release_hash) os.expects(:has_lsb?).returns(true) os.expects(:get_lsb_facts_hash).returns(lsb_hash) end it "should include a name key with the operatingsystem name" do expect(subject.value["name"]).to eq "Ubuntu" end it "should include a family key with the osfamily name" do expect(subject.value["family"]).to eq "Debian" end it "should include a release key with the OS release" do expect(subject.value["release"]["full"]).to eq "1.2.3" end it "should include a major key with the major release" do expect(subject.value["release"]["major"]).to eq 1 end it "should include a minor key with the major release" do expect(subject.value["release"]["minor"]).to eq 2 end it "should include a patch key with the patch release" do expect(subject.value["release"]["patch"]).to eq 3 end it "should include a distid key with the distid" do expect(subject.value["lsb"]["distid"]).to eq "Ubuntu" end it "should include an distcodename key with the codename" do expect(subject.value["lsb"]["distcodename"]).to eq "trusty" end it "should include an distdescription key with the description" do expect(subject.value["lsb"]["distdescription"]).to eq "Ubuntu 14.04 LTS" end it "should include an release key with the release" do expect(subject.value["lsb"]["release"]).to eq "14.04" end it "should include an distrelease key with the release" do expect(subject.value["lsb"]["distrelease"]).to eq "14.04" end it "should include an majdistrelease key with the major release" do expect(subject.value["lsb"]["majdistrelease"]).to eq "14" end end describe "in an OS without lsb facts available" do before do Facter::Operatingsystem::Base.stubs(:new).returns os end before :each do Facter.fact(:kernel).stubs(:value).returns("Darwin") os.expects(:get_operatingsystem).returns("Darwin") os.expects(:get_osfamily).returns("Darwin") os.expects(:get_operatingsystemrelease_hash).returns(release_hash) os.expects(:has_lsb?).returns(false) end it "should include a name key with the operatingsystem name" do expect(subject.value["name"]).to eq "Darwin" end it "should include a family key with the osfamily name" do expect(subject.value["family"]).to eq "Darwin" end it "should include a release key with the OS release" do expect(subject.value["release"]["full"]).to eq "1.2.3" end it "should include a major with the major release" do expect(subject.value["release"]["major"]).to eq 1 end it "should include a minor with the minor release" do expect(subject.value["release"]["minor"]).to eq 2 end it "should include a patch with the patch release" do expect(subject.value["release"]["patch"]).to eq 3 end it "should not include an lsb key" do expect(subject.value["lsb"]).to be_nil end end end facter-2.4.6/spec/unit/osfamily_spec.rb0000664005276200011600000000074112651736735017775 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "OS Family fact" do let(:os_hash) { { "name" => "SomeOS", "family" => "SomeFamily", "release" => "1.2.3", "releasemajor" => "1", } } it "should use the 'osfamily' key of the 'os' fact" do Facter.fact("os").stubs(:value).returns(os_hash) Facter.fact(:osfamily).value.should eq "SomeFamily" end end facter-2.4.6/spec/unit/partitions_spec.rb0000664005276200011600000000563612651736735020356 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' describe "Partition facts" do describe "on unsupported platforms" do it "should not exist" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter.fact(:partitions).value.should == nil end end describe "on Linux" do before do Facter.fact(:kernel).stubs(:value).returns("Linux") end it "should return a structured fact with uuid, size, label (if available), mount point and filesytem for each partition" do partitions = { 'sda1' => { 'uuid' => '13459663-22cc-47b4-a9e6-21dea9906e03', 'size' => '1234', 'mount' => '/', 'filesystem' => 'ext4', }, 'sdb2' => { 'uuid' => '98043570-eb10-457f-9718-0b85a26e66bf', 'size' => '5678', 'label' => 'homes', 'mount' => '/home', 'filesystem' => 'xfs', }, } Facter::Util::Partitions.stubs(:list).returns(partitions.keys) partitions.each do |part,vals| Facter::Util::Partitions.stubs(:uuid).with(part).returns(vals['uuid']) Facter::Util::Partitions.stubs(:size).with(part).returns(vals['size']) Facter::Util::Partitions.stubs(:label).with(part).returns(vals['label']) Facter::Util::Partitions.stubs(:mount).with(part).returns(vals['mount']) Facter::Util::Partitions.stubs(:filesystem).with(part).returns(vals['filesystem']) end Facter.fact(:partitions).value.should == { 'sda1' => { 'uuid' => '13459663-22cc-47b4-a9e6-21dea9906e03', 'size' => '1234', 'mount' => '/', 'filesystem' => 'ext4' }, 'sdb2' => { 'uuid' => '98043570-eb10-457f-9718-0b85a26e66bf', 'size' => '5678', 'label' => 'homes', 'mount' => '/home', 'filesystem' => 'xfs' }, } end end describe "on OpenBSD" do before do Facter.fact(:kernel).stubs(:value).returns("OpenBSD") end it "should return a structured fact with size, mount point and filesystem for each partition" do partitions = { 'sd2a' => { 'size' => '1234', 'mount' => '/', 'filesystem' => 'ffs', }, 'sd2d' => { 'size' => '4321', 'mount' => '/usr', 'filesystem' => 'ffs2', }, } Facter::Util::Partitions.stubs(:list).returns(partitions.keys) partitions.each do |part,vals| Facter::Util::Partitions.stubs(:size).with(part).returns(vals['size']) Facter::Util::Partitions.stubs(:mount).with(part).returns(vals['mount']) Facter::Util::Partitions.stubs(:filesystem).with(part).returns(vals['filesystem']) end Facter.fact(:partitions).value.should == { 'sd2a' => { 'size' => '1234', 'mount' => '/', 'filesystem' => 'ffs' }, 'sd2d' => { 'size' => '4321', 'mount' => '/usr', 'filesystem' => 'ffs2' }, } end end end facter-2.4.6/spec/unit/physicalprocessorcount_spec.rb0000775005276200011600000000074412651736735023005 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Physical processor count fact" do ["linux", "windows", "sunos", "openbsd"].each do |kernel| it "should return the value of the 'physicalcount' key of the 'processors' fact on #{kernel}" do Facter.fact(:kernel).stubs(:value).returns("#{kernel}") Facter.fact("processors").stubs(:value).returns({"physicalcount" => 2, "count" => 4}) Facter.fact("physicalprocessorcount").value.should eq 2 end end end facter-2.4.6/spec/unit/processor_spec.rb0000775005276200011600000000301712651736735020173 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe "Processor facts" do describe "processorX facts" do expected_proc_list = ["Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz", "Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz"] ["aix", "hp-ux", "sunos", "linux", "gnu/kfreebsd"].each do |kernel| it "should use the 'models' key from the 'processors' fact on #{kernel}" do Facter.fact(:kernel).stubs(:value).returns("#{kernel}") Facter.fact("processors").stubs(:value).returns({"count" => 8, "physicalcount" => 4, "models" => expected_proc_list}) Facter.collection.internal_loader.load(:processor) expected_proc_list.each_with_index do |processor, i| Facter.fact("processor#{i}").value.should eq processor end end end end describe "processorcount" do it "should use the 'processorcount' key from the 'processors' fact" do Facter.fact(:kernel).stubs(:value).returns("linux") Facter.fact("processors").stubs(:value).returns({"count" => 8, "physicalcount" => 4 }) Facter.collection.internal_loader.load(:processor) Facter.fact(:processorcount).value.should eq 8 end end describe "processor" do it "should print the correct CPU Model on OpenBSD" do Facter.collection.internal_loader.load(:processor) Facter.fact(:kernel).stubs(:value).returns("OpenBSD") Facter::Util::POSIX.stubs(:sysctl).with("hw.model").returns('SomeVendor CPU 4.2GHz') Facter.fact(:processor).value.should eq "SomeVendor CPU 4.2GHz" end end end facter-2.4.6/spec/unit/processors/0000775005276200011600000000000012651736742017011 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/processors/os_spec.rb0000664005276200011600000004227012651736735021000 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/processors/os' require 'facter/util/wmi' require 'facter_spec/cpuinfo' shared_context "processor list" do let(:proc_list_array) { ["Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz", "Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz"] } end describe Facter::Processors::Linux do include FacterSpec::Cpuinfo subject { described_class.new } include_context "processor list" describe "getting the processor list" do it "should delegate to the enum_cpuinfo utility" do Facter::Util::Processor.expects(:enum_cpuinfo).once.returns(proc_list_array) list = subject.get_processor_list expect(list).to eq proc_list_array end end describe "getting the processor count" do describe "when enum_cpuinfo is available" do before :each do File.expects(:exists?).with("/proc/cpuinfo").returns(true) end it "should be 1 in SPARC fixture" do Facter.fact(:architecture).stubs(:value).returns("sparc") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("sparc")) count = subject.get_processor_count expect(count).to eq 1 end it "should be 2 in ppc64 fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("ppc64") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("ppc64")) count = subject.get_processor_count expect(count).to eq 2 end it "should be 2 in ppc64le fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("ppc64le") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("ppc64le")) count = subject.get_processor_count expect(count).to eq 2 end it "should be 2 in panda-armel fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("arm") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("panda-armel")) count = subject.get_processor_count expect(count).to eq 2 end it "should be 1 in bbg3-armel fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("arm") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("bbg3-armel")) count = subject.get_processor_count expect(count).to eq 1 end it "should be 1 in beaglexm-armel fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("arm") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("beaglexm-armel")) count = subject.get_processor_count expect(count).to eq 1 end it "should be 1 in amd64solo fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64solo")) count = subject.get_processor_count expect(count).to eq 1 end it "should be 2 in amd64dual fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64dual")) count = subject.get_processor_count expect(count).to eq 2 end it "should be 3 in amd64tri fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64tri")) count = subject.get_processor_count expect(count).to eq 3 end it "should be 4 in amd64quad fixture on Linux" do Facter.fact(:architecture).stubs(:value).returns("amd64") File.expects(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64quad")) count = subject.get_processor_count expect(count).to eq 4 end end describe "when enum_cpuinfo returns 0 processors (#2945)" do def sysfs_cpu_stubs(count) (0...count).map { |index| "/sys/devices/system/cpu/cpu#{index}" } end before :each do subject.expects(:get_processor_list).returns([]) File.expects(: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)) count = subject.get_processor_count expect(count).to eq 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)) count = subject.get_processor_count expect(count).to eq 16 end end end describe "getting the physical processor count" do def sysfs_cpu_stubs(count) (0...count).map { |index| "/sys/devices/system/cpu/cpu#{index}/topology/physical_package_id" } end describe "when /sys/devices/system/cpu is available" do before :each do File.expects(:exists?).with("/sys/devices/system/cpu").returns(true) end it "should return 1 when there is 1 CPU with 1 core" do Dir.expects(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(sysfs_cpu_stubs(1)) Facter::Core::Execution.expects(:exec).with("cat /sys/devices/system/cpu/cpu0/topology/physical_package_id").returns("0") count = subject.get_physical_processor_count expect(count).to eq 1 end it "should return 1 when there is 1 CPU with 4 cores" do Dir.expects(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(sysfs_cpu_stubs(4)) sysfs_cpu_stubs(4).each do |file| Facter::Core::Execution.expects(:exec).with("cat #{file}").returns("0") end count = subject.get_physical_processor_count expect(count).to eq 1 end it "returns 4 when there are 4 CPUs each with one core" do Dir.expects(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(sysfs_cpu_stubs(4)) sysfs_cpu_stubs(4).each_with_index do |file, i| Facter::Core::Execution.expects(:exec).with("cat #{file}").returns(i) end count = subject.get_physical_processor_count expect(count).to eq 4 end it "returns 4 when there are 4 CPUs each with two cores" do Dir.expects(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(sysfs_cpu_stubs(8)) sysfs_cpu_stubs(8).each_with_index do |file, i| Facter::Core::Execution.expects(:exec).with("cat #{file}").returns((i / 2).floor) end count = subject.get_physical_processor_count expect(count).to eq 4 end end describe "when the sysfs cpu directory is not available" do include FacterSpec::Cpuinfo before :each do File.stubs(:exists?).with("/sys/devices/system/cpu").returns false end it "returns 1 when there is 1 amd64 CPU with 2 cores" do Facter::Core::Execution.expects(:exec).with("grep 'physical.\+:' /proc/cpuinfo").returns(cpuinfo_fixture_read("amd64dual-grep")) count = subject.get_physical_processor_count expect(count).to eq 1 end it "returns 2 when there are 2 CPUs each with 1 core" do Facter::Core::Execution.expects(:exec).with("grep 'physical.\+:' /proc/cpuinfo").returns(cpuinfo_fixture_read("two_singlecore-grep")) count = subject.get_physical_processor_count expect(count).to eq 2 end it "returns 2 when there are 2 CPUS each with 2 cores" do Facter::Core::Execution.expects(:exec).with("grep 'physical.\+:' /proc/cpuinfo").returns(cpuinfo_fixture_read("two_multicore-grep")) count = subject.get_physical_processor_count expect(count).to eq 2 end it "returns 2 when there are 2 CPUs each with 12 cores" do Facter::Core::Execution.expects(:exec).with("grep 'physical.\+:' /proc/cpuinfo").returns(cpuinfo_fixture_read("amd64twentyfour-grep")) count = subject.get_physical_processor_count expect(count).to eq 2 end end end end describe Facter::Processors::Windows do subject { described_class.new } include_context "processor list" 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") end before :each do Facter.fact(:kernel).stubs(:value).returns("windows") end describe "getting the processor list" do describe "2003" do before :each do proc = stubs 'proc' proc.stubs(:Name).returns("Intel(R) Celeron(R) processor") proc.stubs(:ole_respond_to?).with(:NumberOfLogicalProcessors).returns(false) load(Array.new(2, proc)) end it "should squeeze the processor name 2 times" do 2.times do |i| subject.get_processor_list[i].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(:ole_respond_to?).with(:NumberOfLogicalProcessors).returns(true) proc.stubs(:Name).returns("Intel(R) Celeron(R) processor") load(Array.new(2, proc)) end it "should squeeze the processor name 4 times" do 4.times do |i| subject.get_processor_list[i].should == "Intel(R) Celeron(R) processor" end end end end describe "getting the processor count" do it "should use the length of its processor list" do subject.expects(:get_processor_list).returns(proc_list_array) count = subject.get_processor_count expect(count).to eq 2 end end describe "getting the physical processor count" do it "should delegate to the execquery utility" do ole = stub 'WIN32OLE' Facter::Util::WMI.expects(:execquery).with("select Name from Win32_Processor").returns(ole) ole.stubs(:Count).returns(4) count = subject.get_physical_processor_count expect(count).to eq 4 end end end describe Facter::Processors::Darwin, :unless => Facter::Util::Config.is_windows? do subject { described_class.new } include_context "processor list" before :each do Facter::Core::Execution.expects(:exec).with("/usr/sbin/system_profiler -xml SPHardwareDataType 2>/dev/null").returns(my_fixture_read("darwin-system-profiler")) subject.stubs(:query_system_profiler).returns({"number_processors" => 4, "current_processor_speed" => "2.3 GHz"}) subject.instance_variable_set :@system_hardware_data, {"number_processors" => 4, "current_processor_speed" => "2.3 GHz"} end describe "getting the processor list" do it "should delegate to the enum_cpuinfo utility" do Facter::Util::Processor.expects(:enum_cpuinfo).once.returns(proc_list_array) list = subject.get_processor_list expect(list).to eq proc_list_array end end describe "getting the processor count" do it "should delegate to the sysctl utility" do Facter::Util::POSIX.expects(:sysctl).with("hw.ncpu").once.returns("2") count = subject.get_processor_count expect(count).to eq 2 end end describe "getting the processor speed" do it "should use system_profiler" do subject.instance_variable_set :@system_hardware_data, {"number_processors" => 4, "current_processor_speed" => "2.4 GHz"} speed = subject.get_processor_speed expect(speed).to eq "2.4 GHz" end end end describe Facter::Processors::AIX do subject { described_class.new } include_context "processor list" describe "getting the processor list" do it "should delegate to the aix_processor_list utility" do Facter::Util::Processor.expects(:aix_processor_list).returns(proc_list_array) list = subject.get_processor_list expect(list).to eq proc_list_array end end describe "getting the processor count" do it "should use the length of its processor list" do subject.expects(:get_processor_list).once.returns(proc_list_array) count = subject.get_processor_count expect(count).to eq 2 end end end describe Facter::Processors::HP_UX do subject { described_class.new } include_context "processor list" describe "getting the processor list" do it "should delegate to the hpux_processor_list utility" do Facter::Util::Processor.expects(:hpux_processor_list).once.returns(proc_list_array) list = subject.get_processor_list expect(list).to eq proc_list_array end end describe "getting the processor count" do it "should use the length of its processor list" do subject.expects(:get_processor_list).once.returns(proc_list_array) count = subject.get_processor_count expect(count).to eq 2 end end end describe Facter::Processors::BSD do subject { described_class.new } include_context "processor list" describe "getting the processor list" do it "should delegate to the enum_cpuinfo utility" do Facter::Util::Processor.expects(:enum_cpuinfo).once.returns(proc_list_array) list = subject.get_processor_list expect(list).to eq proc_list_array end end describe "getting the processor count" do it "should delegate to the sysctl utility" do Facter::Util::POSIX.expects(:sysctl).with("hw.ncpu").once.returns("2") count = subject.get_processor_count expect(count).to eq 2 end end end describe Facter::Processors::OpenBSD do subject { described_class.new } include_context "processor list" describe "getting the physical processor count" do it "should delegate to the sysctl utility" do Facter::Util::POSIX.expects(:sysctl).with("hw.ncpufound").once.returns("2") count = subject.get_physical_processor_count expect(count).to eq 2 end end describe "getting the processor speed" do it "should delegate to the sysctl utility (GHz)" do Facter::Util::POSIX.expects(:sysctl).with("hw.cpuspeed").once.returns("2501") speed = subject.get_processor_speed expect(speed).to eq "2.5 GHz" end it "should delegate to the sysctl utility (MHz)" do Facter::Util::POSIX.expects(:sysctl).with("hw.cpuspeed").once.returns("123") speed = subject.get_processor_speed expect(speed).to eq "123 MHz" end end end describe Facter::Processors::SunOS do subject { described_class.new } include_context "processor list" describe "getting the processor list" do it "should delegate to the enum_kstat utility" do Facter::Util::Processor.expects(:enum_kstat).once.returns(proc_list_array) list = subject.get_processor_list expect(list).to eq proc_list_array end end describe "getting the processor count" do 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')) @fixture_psrinfo = File.read(fixtures('processorcount','solaris-psrinfo')) end describe "with version 5.7 or older" do before :each do Facter.fact(:kernelrelease).stubs(:value).returns("5.7") end it "should count processors returned from kstat" do Facter::Core::Execution.expects(:exec).with("/usr/sbin/psrinfo").never Facter::Core::Execution.expects(:exec).with("/usr/bin/kstat cpu_info").returns(@fixture_kstat_sparc) count = subject.get_processor_count expect(count).to eq 8 end it "should fall back to psrinfo if kstat returns nil" do Facter::Core::Execution.expects(:exec).with("/usr/bin/kstat cpu_info").returns(nil) Facter::Core::Execution.expects(:exec).with("/usr/sbin/psrinfo").returns(@fixture_psrinfo) count = subject.get_processor_count expect(count).to eq 24 end end describe "with version 5.8 or newer" do it "should count processors using psrinfo" do Facter.fact(:kernelrelease).stubs(:value).returns("5.8") Facter::Core::Execution.expects(:exec).with("/usr/bin/kstat cpu_info").never Facter::Core::Execution.expects(:exec).with("/usr/sbin/psrinfo").returns(@fixture_psrinfo) count = subject.get_processor_count expect(count).to eq 24 end end end describe "getting the physical processor count" do before :all do @fixture_psrinfo = File.read(fixtures('processorcount','solaris-psrinfo')) end describe "with version 5.7 or older" do it "should use psrinfo without the 'p' flag" do Facter.fact(:kernelrelease).stubs(:value).returns("5.7") Facter::Core::Execution.expects(:exec).with("/usr/sbin/psrinfo").once.returns(@fixture_psrinfo) count = subject.get_physical_processor_count expect(count).to eq 24 end end describe "with version 5.8 or newer" do it "should use psrinfo with the 'p' flag" do Facter.fact(:kernelrelease).stubs(:value).returns("5.8") Facter::Core::Execution.expects(:exec).with("/usr/sbin/psrinfo -p").once.returns("2") count = subject.get_physical_processor_count expect(count).to eq 2 end end end end facter-2.4.6/spec/unit/processors_spec.rb0000664005276200011600000001346712651736735020365 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/processors/os' require 'facter/util/processor' describe "processors" do subject { Facter.fact(:processors) } let(:os) { stub('OS Object') } let(:proc_list_array) { ["Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz", "Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz"] } shared_examples "all operating systems" do it "should include a models key with all processors" do expect(subject.value["models"]).to eq proc_list_array end it "should include a count key with the number of processors" do expect(subject.value["count"]).to eq 8 end end describe "In OSX" do before do Facter::Processors::Darwin.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("Darwin") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(nil) os.stubs(:get_processor_speed).returns("2.4 GHz") end it_behaves_like "all operating systems" it "should include a speed key with the processor speed" do expect(subject.value["speed"]).to eq "2.4 GHz" end end describe "In Linux" do before do Facter::Processors::Linux.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("Linux") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(4) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" it "should include a physicalcount key with the number of physical processors" do expect(subject.value["physicalcount"]).to eq 4 end end describe "In Windows" do before do Facter::Processors::Windows.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("windows") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(4) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" it "should include a physicalcount key with the number of physical processors" do expect(subject.value["physicalcount"]).to eq 4 end end describe "In SunOS" do before do Facter::Processors::SunOS.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("SunOS") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(4) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" it "should include a physicalcount key with the number of physical processors" do expect(subject.value["physicalcount"]).to eq 4 end end describe "In Dragonfly and FreeBSD" do before do Facter::Processors::BSD.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("FreeBSD") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(nil) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" end describe "OpenBSD" do before do Facter::Processors::OpenBSD.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("OpenBSD") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(4) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" it "should include a physicalcount key with the number of physical processors" do expect(subject.value["physicalcount"]).to eq 4 end end describe "In GNU/kFreeBSD" do before do Facter::Processors::GNU.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(nil) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" end describe "In AIX" do before do Facter::Processors::AIX.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("AIX") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(nil) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" end describe "In HP-UX" do before do Facter::Processors::HP_UX.stubs(:new).returns os end before :each do Facter.clear Facter.fact(:kernel).stubs(:value).returns("HP-UX") os.stubs(:get_processor_list).returns(proc_list_array) os.stubs(:get_processor_count).returns(8) os.stubs(:get_physical_processor_count).returns(nil) os.stubs(:get_processor_speed).returns(nil) end it_behaves_like "all operating systems" end describe "In non-supported kernels" do before do Facter.fact(:kernel).stubs(:value).returns("Foo") end it "should not resolve the processors fact" do Facter::Processors.expects(:implementation).returns(nil) expect(subject.value).to be_nil end end end facter-2.4.6/spec/unit/ps_spec.rb0000775005276200011600000000175312651736735016603 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-2.4.6/spec/unit/rackspace_spec.rb0000664005276200011600000000263112651736735020106 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' describe "rackspace facts" do describe "on Rackspace Cloud" do before :each do Facter.collection.internal_loader.load(:rackspace) end it "should set is_rsc to true" do Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/provider 2> /dev/null").returns("Rackspace") Facter.fact(:is_rsc).value.should == "true" end it "should set the region to dfw" do Facter.fact(:is_rsc).stubs(:value).returns("true") Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/region 2> /dev/null").returns("dfw") Facter.fact(:rsc_region).value.should == "dfw" end it "should get the instance id" do Facter.fact(:is_rsc).stubs(:value).returns("true") Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read name").returns("instance-75a96685-85d6-44c6-aed8-41ef0fb2cfcc") Facter.fact(:rsc_instance_id).value.should == "75a96685-85d6-44c6-aed8-41ef0fb2cfcc" end end describe "not on Rackspace Cloud" do before do Facter.collection.internal_loader.load(:rackspace) end it "shouldn't set is_rsc" do Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/provider 2> /dev/null").returns("other") Facter.fact(:is_rsc).value.should == nil end end end facter-2.4.6/spec/unit/rubyplatform_spec.rb0000664005276200011600000000025612651736735020701 0ustar jenkinsjenkinsrequire 'spec_helper' describe "ruby platform" do it "should return the ruby platform" do expect(Facter.fact(:rubyplatform).value).to eq(RUBY_PLATFORM.to_s) end end facter-2.4.6/spec/unit/selinux_spec.rb0000775005276200011600000000752312651736735017651 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 return the loaded SELinux policy" do sestatus_is(my_fixture_read("selinux_sestatus2")) Facter.fact(:selinux_config_policy).value.should == "default" end end def sestatus_is(status) Facter::Core::Execution.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::Core::Execution.expects(:exec).with("cat /proc/self/mounts").returns(lines.join("\n")) end end facter-2.4.6/spec/unit/ssh_spec.rb0000775005276200011600000001016312651736735016751 0ustar jenkinsjenkins#! /usr/bin/env ruby 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"], 'SSHED25519Key' => [ 'ssh_host_ed25519_key.pub' , 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAkxkUMKV0H7Z0KDgfMs+iKQFwJhKUDg8GImV/BwN48X', "SSHFP 4 1 216d49ff3581a42c7a2d4064f2356b375367d493\nSSHFP 4 2 95e3aa6f86bc2dcc46f1e9e5ea930c790afc0669fcf237c4d7b0c8e386ef2790"] }.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-2.4.6/spec/unit/system32_spec.rb0000664005276200011600000000133412651736735017642 0ustar jenkinsjenkinsrequire 'spec_helper' describe "system32 fact" do let(:systemroot) { 'D:\Windows' } let(:sysnative) { "#{systemroot}\\sysnative" } let(:system32) { "#{systemroot}\\system32" } before(:each) do Facter.fact(:kernel).stubs(:value).returns("windows") ENV['SYSTEMROOT'] = systemroot end describe "when running in 32-bit ruby" do it "resolves to sysnative" do File.expects(:exist?).with(sysnative).returns(true) expect(Facter.fact(:system32).value).to eq(sysnative) end end describe "when running in 64-bit ruby" do it "resolves to system32" do File.expects(:exist?).with(sysnative).returns(false) expect(Facter.fact(:system32).value).to eq(system32) end end end facter-2.4.6/spec/unit/system_uptime_spec.rb0000664005276200011600000000516112651736735021062 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/uptime' describe "system_uptime:" 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 in Linux" do Facter.fact(:kernel).stubs(:value).returns("linux") Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(seconds) Facter.fact(:system_uptime).value['uptime'].should eq expected end it "should return #{expected.inspect} for #{seconds} seconds in Windows" do Facter.fact(:kernel).stubs(:value).returns("windows") Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(seconds) Facter.fact(:system_uptime).value['uptime'].should eq 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 it "should include a key for seconds" do Facter.fact(:system_uptime).value['seconds'].should eq 60 * 60 * 24 + 23 end it "should include a key for hours" do Facter.fact(:system_uptime).value['hours'].should eq 24 end it "should include a key for days" do Facter.fact(:system_uptime).value['days'].should eq 1 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) end it "should have an 'uptime' key with value 'unknown'" do Facter.fact(:system_uptime).value['uptime'].should eq "unknown" end it "should have a 'seconds' key with value nil" do Facter.fact(:system_uptime).value['seconds'].should eq nil end it "should have a 'hours' key with value nil" do Facter.fact(:system_uptime).value['hours'].should eq nil end it "should have a 'days' key with value nil" do Facter.fact(:system_uptime).value['days'].should eq nil end end end facter-2.4.6/spec/unit/uniqueid_spec.rb0000775005276200011600000000144612651736735020003 0ustar jenkinsjenkins#!/usr/bin/env ruby require 'spec_helper' require 'facter' describe "Uniqueid fact" do it "should match hostid on Solaris" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter::Core::Execution.stubs(:execute).with("hostid", anything).returns("Larry") Facter.fact(:uniqueid).value.should == "Larry" end it "should match hostid on Linux" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Core::Execution.stubs(:execute).with("hostid", anything).returns("Curly") Facter.fact(:uniqueid).value.should == "Curly" end it "should match hostid on AIX" do Facter.fact(:kernel).stubs(:value).returns("AIX") Facter::Core::Execution.stubs(:execute).with("hostid", anything).returns("Moe") Facter.fact(:uniqueid).value.should == "Moe" end end facter-2.4.6/spec/unit/uptime_spec.rb0000775005276200011600000000571312651736735017464 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-2.4.6/spec/unit/util/0000775005276200011600000000000012651736742015564 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/util/collection_spec.rb0000775005276200011600000001606712651736735021275 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, :timeout => 1) { } end it "passes resolution specific options to the fact" do fact = Facter::Util::Fact.new(:myname) Facter::Util::Fact.expects(:new).with(:myname, {:timeout => 'myval'}).returns fact fact.expects(:add).with({:timeout => 'myval'}) collection.add(:myname, :timeout => "myval") {} end describe "and a block is provided" do it "should use the block to add a resolution to the fact" do fact = mock 'fact' fact.stubs(:extract_ldapname_option!) 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 Facter.expects(:warn).with(regexp_matches(/Unable to add resolve .* kaboom!/)) expect { collection.add('yay') do raise "kaboom!" end }.to_not raise_error expect(collection.value('yay')).to be_nil end end end describe "when only defining facts" do it "creates a new fact if no such fact exists" do fact = Facter::Util::Fact.new(:newfact) Facter::Util::Fact.expects(:new).with(:newfact, {}).returns fact expect(collection.define_fact(:newfact)).to equal fact end it "returns an existing fact if the fact has already been defined" do fact = collection.define_fact(:newfact) expect(collection.define_fact(:newfact)).to equal fact end it "passes options to newly generated facts" do Facter.stubs(:warnonce) fact = collection.define_fact(:newfact, :ldapname => 'NewFact') expect(fact.ldapname).to eq 'NewFact' end it "logs a warning if the fact could not be defined" do Facter.expects(:warn).with("Unable to add fact newfact: kaboom!") collection.define_fact(:newfact) do raise "kaboom!" 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-2.4.6/spec/unit/util/config_spec.rb0000664005276200011600000001116612651736735020377 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' describe Facter::Util::Config do include PuppetlabsSpec::Files describe "ENV['HOME'] is unset", :unless => Facter::Util::Root.root? do around do |example| Facter::Core::Execution.with_env('HOME' => nil) do example.run end end it "should not set @external_facts_dirs" do Facter::Util::Config.setup_default_ext_facts_dirs Facter::Util::Config.external_facts_dirs.should be_empty end end 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.setup_default_ext_facts_dirs Facter::Util::Config.external_facts_dirs.should == ["/opt/puppetlabs/facter/facts.d", "/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.setup_default_ext_facts_dirs 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.setup_default_ext_facts_dirs Facter::Util::Config.external_facts_dirs.should == [File.join("C:\\Documents", 'PuppetLabs', 'facter', 'facts.d')] end it "returns the old and new (AIO) paths under user's home directory when not root" do Facter::Util::Root.stubs(:root?).returns(false) Facter::Util::Config.setup_default_ext_facts_dirs Facter::Util::Config.external_facts_dirs.should == [File.expand_path(File.join("~", ".puppetlabs", "opt", "facter", "facts.d")), File.expand_path(File.join("~", ".facter", "facts.d"))] end it "includes additional values when user appends to the list" do Facter::Util::Config.setup_default_ext_facts_dirs original_values = Facter::Util::Config.external_facts_dirs.dup new_value = '/usr/share/newdir' Facter::Util::Config.external_facts_dirs << new_value Facter::Util::Config.external_facts_dirs.should == original_values + [new_value] end it "should only output new values when explicitly set" do Facter::Util::Config.setup_default_ext_facts_dirs new_value = ['/usr/share/newdir'] Facter::Util::Config.external_facts_dirs = new_value Facter::Util::Config.external_facts_dirs.should == new_value end end describe "override_binary_dir" do it "should return the default value for linux" do Facter::Util::Config.stubs(:is_windows?).returns(false) Facter::Util::Config.setup_default_override_binary_dir Facter::Util::Config.override_binary_dir.should == "/opt/puppetlabs/puppet/bin" end it "should return nil for windows" do Facter::Util::Config.stubs(:is_windows?).returns(true) Facter::Util::Config.setup_default_override_binary_dir Facter::Util::Config.override_binary_dir.should == nil end it "should output new values when explicitly set" do Facter::Util::Config.setup_default_override_binary_dir new_value = '/usr/share/newdir' Facter::Util::Config.override_binary_dir = new_value Facter::Util::Config.override_binary_dir.should == new_value end end end facter-2.4.6/spec/unit/util/confine_spec.rb0000775005276200011600000001157212651736735020557 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 it "should accept and evaluate a block argument against the fact" do @fact.expects(:value).returns 'foo' confine = Facter::Util::Confine.new :yay do |f| f === 'foo' end confine.true?.should be_true end it "should return false if the block raises a StandardError when checking a fact" do @fact.stubs(:value).returns 'foo' confine = Facter::Util::Confine.new :yay do |f| raise StandardError end confine.true?.should be_false end it "should accept and evaluate only a block argument" do Facter::Util::Confine.new { true }.true?.should be_true Facter::Util::Confine.new { false }.true?.should be_false end it "should return false if the block raises a StandardError" do Facter::Util::Confine.new { raise StandardError }.true?.should be_false end end end facter-2.4.6/spec/unit/util/dhcp_servers_spec.rb0000664005276200011600000000462512651736735021623 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/dhcp_servers' describe Facter::Util::DHCPServers do describe "retrieving the gateway device" do it "returns nil when there are no default routes" do Facter::Util::FileRead.stubs(:read).with('/proc/net/route').returns(my_fixture_read('route_nogw')) described_class.gateway_device.should be_nil end it "returns the interface associated with the first default route" do Facter::Util::FileRead.stubs(:read).with('/proc/net/route').returns(my_fixture_read('route')) described_class.gateway_device.should eq "eth0" end end describe "nmcli_version" do { 'nmcli tool, version 0.9.8.0' => [0, 9, 8, 0], 'nmcli tool, version 0.9.8.10' => [0, 9, 8, 10], 'nmcli tool, version 0.9.8.9' => [0, 9, 8, 9], 'nmcli tool, version 0.9.9.0' => [0, 9, 9, 0], 'nmcli tool, version 0.9.9.9' => [0, 9, 9, 9], 'version 0.9.9.0-20.git20131003.fc20' => [0, 9, 9, 0], 'nmcli tool, version 0.9.9' => [0, 9, 9, 0], 'nmcli tool, version 0.9' => [0, 9, 0, 0], 'nmcli tool, version 1' => [1, 0, 0, 0] }.each do |version, expected| it "should turn #{version} into the integer #{expected}" do Facter::Core::Execution.stubs(:which).with('nmcli').returns('/usr/bin/nmcli') Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns(version) result = Facter::Util::DHCPServers.nmcli_version result.is_a?(Array).should be true result.should == expected end end end describe "device_dhcp_server" do { '0.1.2.3' => false, '0.9.8.10' => false, '0.9.9.0' => true, '0.9.10.0' => true, '0.10.0.0' => true, '1.0.0.0' => true }.each do |version, uses_show| it "should use #{if uses_show then 'show' else 'list' end} for version #{version}" do command = if uses_show then 'nmcli -f all d show eth0' else 'nmcli -f all d list iface eth0' end Facter::Core::Execution.stubs(:which).with('nmcli').returns('/usr/bin/nmcli') Facter::Core::Execution.stubs(:exec).with('nmcli --version').returns "nmcli tool, version #{version}" Facter::Core::Execution.stubs(:exec).with(command).returns 'DHCP4.OPTION[1]: dhcp_server_identifier = 192.168.1.1' Facter::Util::DHCPServers.device_dhcp_server('eth0').should == '192.168.1.1' end end end end facter-2.4.6/spec/unit/util/directory_loader_spec.rb0000664005276200011600000000642712651736735022470 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 Facter.expects(:warn).with(regexp_matches(/#{ext}/)) 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 collection.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 describe "given a custom weight" do subject { Facter::Util::DirectoryLoader.new(tmpdir('directory_loader'), 10) } it "should set that weight for loaded external facts" do collection.add("f1", :value => "higher_weight_fact") { has_weight(11) } data = {"f1" => "external_fact"} write_to_file("data.yaml", YAML.dump(data)) subject.load(collection) collection.value("f1").should == "higher_weight_fact" end 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-2.4.6/spec/unit/util/ec2_spec.rb0000775005276200011600000001406212651736735017604 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/ec2' describe Facter::Util::EC2 do before do # Squelch deprecation notices Facter.stubs(:warnonce) end # 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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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-2.4.6/spec/unit/util/fact_spec.rb0000775005276200011600000001015212651736735020044 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/fact' describe Facter::Util::Fact do subject(:fact) { Facter::Util::Fact.new("yay") } let(:resolution) { Facter::Util::Resolution.new("yay", fact) } it "requires a name" do expect { Facter::Util::Fact.new }.to raise_error(ArgumentError) end it "downcases and converts the name to a symbol" do expect(Facter::Util::Fact.new("YayNess").name).to eq :yayness end it "issues a deprecation warning for use of ldapname" do Facter.expects(:warnonce).with("ldapname is deprecated and will be removed in a future version") Facter::Util::Fact.new("YayNess", :ldapname => "fooness") end describe "when adding resolution mechanisms using #add" do it "delegates to #define_resolution with an anonymous resolution" do subject.expects(:define_resolution).with(nil, {}) subject.add end end describe "looking up resolutions by name" do subject(:fact) { described_class.new('yay') } it "returns nil if no such resolution exists" do expect(fact.resolution('nope')).to be_nil end it "never returns anonymous resolutions" do fact.add() { setcode { 'anonymous' } } expect(fact.resolution(nil)).to be_nil end end describe "adding resolution mechanisms by name" do let(:res) do stub 'resolution', :name => 'named', :set_options => nil, :resolution_type => :simple end it "creates a new resolution if no such resolution exists" do Facter::Util::Resolution.expects(:new).once.with('named', fact).returns(res) fact.define_resolution('named') expect(fact.resolution('named')).to eq res end it "creates a simple resolution when the type is nil" do fact.define_resolution('named') expect(fact.resolution('named')).to be_a_kind_of Facter::Util::Resolution end it "creates a simple resolution when the type is :simple" do fact.define_resolution('named', :type => :simple) expect(fact.resolution('named')).to be_a_kind_of Facter::Util::Resolution end it "creates an aggregate resolution when the type is :aggregate" do fact.define_resolution('named', :type => :aggregate) expect(fact.resolution('named')).to be_a_kind_of Facter::Core::Aggregate end it "raises an error if there is an existing resolution with a different type" do pending "We need to stop rescuing all errors when instantiating resolutions" fact.define_resolution('named') expect { fact.define_resolution('named', :type => :aggregate) }.to raise_error(ArgumentError, /Cannot return resolution.*already defined as simple/) end it "returns existing resolutions by name" do Facter::Util::Resolution.expects(:new).once.with('named', fact).returns(res) fact.define_resolution('named') fact.define_resolution('named') expect(fact.resolution('named')).to eq res end end describe "when returning a value" do it "returns nil if there are no resolutions" do Facter::Util::Fact.new("yay").value.should be_nil end it "prefers the highest weight resolution" do fact.add { has_weight 1; setcode { "1" } } fact.add { has_weight 2; setcode { "2" } } fact.add { has_weight 0; setcode { "0" } } expect(fact.value).to eq "2" end it "returns the first value returned by a resolution" do fact.add { has_weight 1; setcode { "1" } } fact.add { has_weight 2; setcode { nil } } fact.add { has_weight 0; setcode { "0" } } expect(fact.value).to eq "1" end it "skips unsuitable resolutions" do fact.add { has_weight 1; setcode { "1" } } fact.add do def suitable?; false; end has_weight 2 setcode { 2 } end expect(fact.value).to eq "1" end end describe '#flush' do subject do Facter::Util::Fact.new(:foo) end it "invokes #flush on all resolutions" do simple = subject.add(:type => :simple) simple.expects(:flush) aggregate = subject.add(:type => :aggregate) aggregate.expects(:flush) subject.flush end end end facter-2.4.6/spec/unit/util/file_read_spec.rb0000664005276200011600000000173712651736735021047 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-2.4.6/spec/unit/util/formatter_spec.rb0000664005276200011600000000377112651736735021140 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/util/formatter' describe Facter::Util::Formatter do describe "formatting as json" do it "formats the text as json when json is available", :if => Facter.json? do JSON.expects(:pretty_generate).with({"hello" => "world"}).returns(%Q({"hello": "world"})) expect(described_class.format_json({"hello" => "world"})).to eq %Q({"hello": "world"}) end it "raises an error when JSON is not available" do Facter.stubs(:json?).returns false expect { described_class.format_json({"hello" => "world"}) }.to raise_error(/'json' library is not present/) end end describe "formatting as yaml" do it "dumps the text as YAML" do expect(described_class.format_yaml({"hello" => "world"})).to match(/hello: world/) end end describe "formatting as plaintext" do it "formats a single string value without quotes" do expect(described_class.format_plaintext({"foo" => "bar"})).to eq "bar" end it "can return false:FalseClass as a single fact value" do expect(described_class.format_plaintext({"foo" => false})).to eq "false" end it "formats a structured value with #inspect" do value = ["bar"] value.expects(:inspect).returns %Q(["bar"]) hash = {"foo" => value, "baz" => "quux"} expect(described_class.format_plaintext(hash)).to match(%Q([bar])) end it "formats multiple string values as key/value pairs" do hash = {"foo" => "bar", "baz" => "quux"} expect(described_class.format_plaintext(hash)).to match(/foo => bar/) expect(described_class.format_plaintext(hash)).to match(/baz => quux/) end it "formats multiple structured values with #inspect" do value = ["bar"] value.expects(:inspect).twice.returns %Q(["bar"]) hash = {"foo" => value, "baz" => "quux"} expect(described_class.format_plaintext(hash)).to match(/foo => \["bar"\]/) expect(described_class.format_plaintext(hash)).to match(/baz => quux/) end end end facter-2.4.6/spec/unit/util/ip/0000775005276200011600000000000012651736742016174 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/util/ip/windows_spec.rb0000664005276200011600000000517512651736735021237 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-2.4.6/spec/unit/util/ip_spec.rb0000775005276200011600000005255612651736735017555 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::Core::Execution.stubs(:exec) 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::Core::Execution.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::Core::Execution.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-2.4.6/spec/unit/util/loader_spec.rb0000775005276200011600000002174412651736735020406 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/loader' describe Facter::Util::Loader do before :each do Facter::Util::Loader.any_instance.unstub(:load_all) end def loader_from(places) env = places[:env] || {} search_path = places[:search_path] || [] loader = Facter::Util::Loader.new(env) loader.stubs(:search_path).returns search_path loader 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 let(:loader) { Facter::Util::Loader.new } # 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 let(:loader) { Facter::Util::Loader.new } it "should include the facter subdirectory of all paths in ruby LOAD_PATH" do dirs = $LOAD_PATH.collect { |d| File.expand_path('facter', d) } loader.stubs(:valid_search_path?).returns(true) File.stubs(:directory?).returns true paths = loader.search_path dirs.each do |dir| paths.should be_include(dir) end 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} loader.stubs(:valid_search_path?).returns true File.stubs(:directory?).returns false File.stubs(:directory?).with('/one').returns true File.stubs(:directory?).with('/two').returns true paths = loader.search_path paths.should be_include("/one") paths.should be_include("/two") end it "should warn on invalid search paths registered with Facter" do Facter.expects(:search_path).returns %w{/one two/three} loader.stubs(:valid_search_path?).returns false loader.stubs(:valid_search_path?).with('/one').returns true loader.stubs(:valid_search_path?).with('two/three').returns false Facter.expects(:warn).with('Excluding two/three from search path. Fact file paths must be an absolute directory').once File.stubs(:directory?).returns false File.stubs(:directory?).with('/one').returns true paths = loader.search_path paths.should be_include("/one") paths.should_not be_include("two/three") end it "should strip paths that are valid paths but not are not present" do Facter.expects(:search_path).returns %w{/one /two} loader.stubs(:valid_search_path?).returns false loader.stubs(:valid_search_path?).with('/one').returns true loader.stubs(:valid_search_path?).with('/two').returns true File.stubs(:directory?).returns false File.stubs(:directory?).with('/one').returns true File.stubs(:directory?).with('/two').returns false paths = loader.search_path paths.should be_include("/one") paths.should_not be_include('/two') end describe "and the FACTERLIB environment variable is set" do it "should include all paths in FACTERLIB" do loader = Facter::Util::Loader.new("FACTERLIB" => "/one/path#{File::PATH_SEPARATOR}/two/path") File.stubs(:directory?).returns false File.stubs(:directory?).with('/one/path').returns true File.stubs(:directory?).with('/two/path').returns true loader.stubs(:valid_search_path?).returns true paths = loader.search_path %w{/one/path /two/path}.each do |dir| paths.should be_include(dir) end end end end describe "when loading facts" do it "should load values from the matching environment variable if one is present" do loader = loader_from(:env => { "facter_testing" => "yayness" }) Facter.expects(:add).with("testing") loader.load(:testing) end it "should load any files in the search path with names matching the fact name" do loader = loader_from(:search_path => %w{/one/dir /two/dir}) loader.expects(:search_path).returns %w{/one/dir /two/dir} File.stubs(:file?).returns false File.expects(:file?).with("/one/dir/testing.rb").returns true Kernel.expects(:load).with("/one/dir/testing.rb") loader.load(:testing) end it 'should not load any ruby files from subdirectories matching the fact name in the search path' do loader = Facter::Util::Loader.new File.stubs(:file?).returns false File.expects(:file?).with("/one/dir/testing.rb").returns true Kernel.expects(:load).with("/one/dir/testing.rb") File.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) end it "should not load files that don't end in '.rb'" do loader = Facter::Util::Loader.new loader.expects(:search_path).returns %w{/one/dir} File.stubs(:file?).returns false File.expects(:file?).with("/one/dir/testing.rb").returns false File.expects(:exist?).with("/one/dir/testing").never Kernel.expects(:load).never loader.load(:testing) end end describe "when loading all facts" do let(:loader) { Facter::Util::Loader.new } before :each do loader.stubs(:search_path).returns [] File.stubs(:directory?).returns true end it "should load all files in all search paths" do loader = loader_from(:search_path => %w{/one/dir /two/dir}) Dir.expects(:glob).with('/one/dir/*.rb').returns %w{/one/dir/a.rb /one/dir/b.rb} Dir.expects(:glob).with('/two/dir/*.rb').returns %w{/two/dir/c.rb /two/dir/d.rb} %w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each do |f| File.expects(:file?).with(f).returns true Kernel.expects(:load).with(f) end loader.load_all end it "should not try to load subdirectories of search paths" do loader.expects(:search_path).returns %w{/one/dir /two/dir} # a.rb is a directory Dir.expects(:glob).with('/one/dir/*.rb').returns %w{/one/dir/a.rb /one/dir/b.rb} File.expects(:file?).with('/one/dir/a.rb').returns false File.expects(:file?).with('/one/dir/b.rb').returns true Kernel.expects(:load).with('/one/dir/b.rb') # c.rb is a directory Dir.expects(:glob).with('/two/dir/*.rb').returns %w{/two/dir/c.rb /two/dir/d.rb} File.expects(:file?).with('/two/dir/c.rb').returns false File.expects(:file?).with('/two/dir/d.rb').returns true Kernel.expects(:load).with('/two/dir/d.rb') 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(:glob).with('/one/dir/*.rb').returns %w{/one/dir/a.rb} File.expects(:file?).with('/one/dir/a.rb').returns true Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError) Facter.expects(:warn) expect { loader.load_all }.to_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 = loader_from(:env => {}) 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 loader = loader_from(:env => {}) loader.load_all loader.expects(:kernel_load).with(regexp_matches(/ec2/)).never loader.load(:ec2) end end facter-2.4.6/spec/unit/util/macaddress_spec.rb0000775005276200011600000001315612651736735021244 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.macaddress end it "should return the macaddress of the first non-loopback interface" do Facter.expects(:warn).with("Could not find a default route. Using first non-loopback interface") 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.fact(:operatingsystem).stubs(:value).returns('windows') Facter.fact(:osfamily).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-2.4.6/spec/unit/util/macosx_spec.rb0000775005276200011600000001133612651736735020426 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/config' require 'facter/util/macosx' unless Facter::Util::Config.is_windows? describe "Facter::Util::Macosx", :unless => Facter::Util::Config.is_windows? 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::Core::Execution.expects(:exec).with("/usr/sbin/system_profiler -xml foo 2>/dev/null").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 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::Core::Execution.expects(:exec).with("/usr/bin/sw_vers -productName").returns "Mac OS X" Facter::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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-2.4.6/spec/unit/util/manufacturer_spec.rb0000775005276200011600000001770112651736735021632 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::Core::Execution.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::Core::Execution.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::Core::Execution.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 "can parse smbios output that contains non-UTF8 characters" do smbios_output = my_fixture_read("smartos_smbios") Facter::Core::Execution.stubs(:exec).with('/usr/sbin/smbios 2>/dev/null').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 == "06/11/2007" 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 describe "using sysctl to look up manufacturer information" do before do Facter.fact(:kernel).stubs(:value).returns 'OpenBSD' end let(:mfg_keys) do { 'hw.vendor' => 'manufacturer', 'hw.product' => 'productname', 'hw.serialno' => 'serialnumber' } end it "creates a new fact for the each hash key" do mfg_keys.values.each do |value| Facter.expects(:add).with(value) end described_class.sysctl_find_system_info(mfg_keys) end it "uses sysctl to determine the value for that fact" do mfg_keys.keys.each do |sysctl| Facter::Util::POSIX.expects(:sysctl).with(sysctl).returns "sysctl #{sysctl}" end described_class.sysctl_find_system_info(mfg_keys) mfg_keys.invert.each_pair do |factname, value| expect(Facter.value(factname)).to eq "sysctl #{value}" end end end end facter-2.4.6/spec/unit/util/normalization_spec.rb0000664005276200011600000000754312651736735022024 0ustar jenkinsjenkins# encoding: utf-8 require 'spec_helper' require 'facter/util/normalization' describe Facter::Util::Normalization do subject { described_class } def utf16(str) if String.method_defined?(:encode) && defined?(::Encoding) str.encode(Encoding::UTF_16LE) else str end end def utf8(str) if String.method_defined?(:encode) && defined?(::Encoding) str.encode(Encoding::UTF_8) else str end end describe "validating strings" do describe "and string encoding is supported", :if => String.instance_methods.include?(:encoding) do it "accepts strings that are ASCII and match their encoding and converts them to UTF-8" do str = "ASCII".encode(Encoding::ASCII) normalized_str = subject.normalize(str) expect(normalized_str.encoding).to eq(Encoding::UTF_8) end it "accepts strings that are UTF-8 and match their encoding" do str = "let's make a ☃!".encode(Encoding::UTF_8) expect(subject.normalize(str)).to eq(str) end it "converts valid non UTF-8 strings to UTF-8" do str = "let's make a ☃!".encode(Encoding::UTF_16LE) enc = subject.normalize(str).encoding expect(enc).to eq(Encoding::UTF_8) end it "normalizes a frozen string returning a non-frozen string" do str = "factvalue".encode(Encoding::UTF_16LE).freeze normalized_str = subject.normalize(str) expect(normalized_str.encoding).to eq(Encoding::UTF_8) expect(normalized_str).to_not be_frozen end it "rejects strings that are not UTF-8 and do not match their claimed encoding" do invalid_shift_jis = "\xFF\x5C!".force_encoding(Encoding::SHIFT_JIS) expect { subject.normalize(invalid_shift_jis) }.to raise_error(Facter::Util::Normalization::NormalizationError, /String encoding Shift_JIS is not UTF-8 and could not be converted to UTF-8/) end it "rejects strings that claim to be UTF-8 encoded but aren't" do str = "\255ay!".force_encoding(Encoding::UTF_8) expect { subject.normalize(str) }.to raise_error(Facter::Util::Normalization::NormalizationError, /String.*doesn't match the reported encoding UTF-8/) end end describe "and string encoding is not supported", :unless => String.instance_methods.include?(:encoding) do it "accepts strings that are UTF-8 and match their encoding" do str = "let's make a ☃!" expect(subject.normalize(str)).to eq(str) end it "rejects strings that are not UTF-8" do str = "let's make a \255\255\255!" expect { subject.normalize(str) }.to raise_error(Facter::Util::Normalization::NormalizationError, /String .* is not valid UTF-8/) end end end describe "normalizing arrays" do it "normalizes each element in the array" do arr = [utf16('first'), utf16('second'), [utf16('third'), utf16('fourth')]] expected_arr = [utf8('first'), utf8('second'), [utf8('third'), utf8('fourth')]] expect(subject.normalize_array(arr)).to eq(expected_arr) end end describe "normalizing hashes" do it "normalizes each element in the array" do hsh = {utf16('first') => utf16('second'), utf16('third') => [utf16('fourth'), utf16('fifth')]} expected_hsh = {utf8('first') => utf8('second'), utf8('third') => [utf8('fourth'), utf8('fifth')]} expect(subject.normalize_hash(hsh)).to eq(expected_hsh) end end [1, 1.0, true, false, nil].each do |val| it "accepts #{val.inspect}:#{val.class}" do expect(subject.normalize(val)).to eq(val) end end [:sym, Object.new, Set.new].each do |val| it "rejects #{val.inspect}:#{val.class}" do expect { subject.normalize(val) }.to raise_error(Facter::Util::Normalization::NormalizationError, /Expected .*but was #{val.class}/ ) end end end facter-2.4.6/spec/unit/util/operatingsystem_spec.rb0000664005276200011600000000721212651736735022364 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/util/operatingsystem' describe Facter::Util::Operatingsystem do describe "reading the os-release file" do it "correctly parses the file on Cumulus Linux" do values = described_class.os_release(my_fixture('cumuluslinux.txt')) expect(values).to eq({ 'NAME' => "Cumulus Linux", 'VERSION_ID' => "1.5.2", 'VERSION' => "1.5.2-28283a7-201311181623-final", 'PRETTY_NAME' => "Cumulus Linux", 'ID' => "cumulus-linux", 'ID_LIKE' => "debian", 'CPE_NAME' => "cpe:/o:cumulusnetworks:cumulus_linux:1.5.2-28283a7-201311181623-final", 'HOME_URL' => "http://www.cumulusnetworks.com/", }) end it "correctly parses the file on CoreOS Linux" do values = described_class.os_release(my_fixture('coreos.txt')) expect(values).to eq({ 'NAME' => "CoreOS", 'VERSION_ID' => "575.0.0", 'VERSION' => "575.0.0", 'PRETTY_NAME' => "CoreOS 575.0.0", 'ID' => "coreos", 'HOME_URL' => "https://coreos.com/", 'BUG_REPORT_URL' => "https://github.com/coreos/bugs/issues", 'ANSI_COLOR' => "1;32", }) end it "correctly parses the file on Sabayon" do values = described_class.os_release(my_fixture('sabayon.txt')) expect(values).to eq({ "NAME" => "Sabayon", "ID" => "sabayon", "PRETTY_NAME" => "Sabayon/Linux", "ANSI_COLOR" => "1;32", "HOME_URL" => "http://www.sabayon.org/", "SUPPORT_URL" => "http://forum.sabayon.org/", "BUG_REPORT_URL" => "https://bugs.sabayon.org/", }) end it "correctly parses the file on Debian Wheezy" do values = described_class.os_release(my_fixture('wheezy.txt')) expect(values).to eq({ "PRETTY_NAME" => "Debian GNU/Linux 7 (wheezy)", "NAME" => "Debian GNU/Linux", "VERSION_ID" => "7", "VERSION" => "7 (wheezy)", "ID" => "debian", "ANSI_COLOR" => "1;31", "HOME_URL" => "http://www.debian.org/", "SUPPORT_URL" => "http://www.debian.org/support/", "BUG_REPORT_URL" => "http://bugs.debian.org/", }) end it "correctly parses the file on Debian Wheezy" do values = described_class.os_release(my_fixture('wheezy.txt')) expect(values).to eq({ "PRETTY_NAME" => "Debian GNU/Linux 7 (wheezy)", "NAME" => "Debian GNU/Linux", "VERSION_ID" => "7", "VERSION" => "7 (wheezy)", "ID" => "debian", "ANSI_COLOR" => "1;31", "HOME_URL" => "http://www.debian.org/", "SUPPORT_URL" => "http://www.debian.org/support/", "BUG_REPORT_URL" => "http://bugs.debian.org/", }) end it "correctly parses the file on RedHat 7" do values = described_class.os_release(my_fixture('redhat-7.txt')) expect(values).to eq({ "NAME" => "Red Hat Enterprise Linux Everything", "VERSION" => "7.0 (Maipo)", "ID" => "rhel", "VERSION_ID" => "7.0", "PRETTY_NAME" => "Red Hat Enterprise Linux Everything 7.0 (Maipo)", "ANSI_COLOR" => "0;31", "CPE_NAME" => "cpe:/o:redhat:enterprise_linux:7.0:beta:everything", "REDHAT_BUGZILLA_PRODUCT" => "Red Hat Enterprise Linux 7", "REDHAT_BUGZILLA_PRODUCT_VERSION" => "7.0", "REDHAT_SUPPORT_PRODUCT" => "Red Hat Enterprise Linux", "REDHAT_SUPPORT_PRODUCT_VERSION" => "7.0", }) end it "does not try to read an unreadable '/etc/os-release' file" do File.expects(:readable?).with('/some/nonexistent/file').returns false expect(described_class.os_release('/some/nonexistent/file')).to be_empty end end end facter-2.4.6/spec/unit/util/parser_spec.rb0000775005276200011600000002077312651736735020435 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::Core::Execution.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::Core::Execution.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 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, result) Facter::Util::Config.stubs(:is_windows?).returns(true) 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 Facter::Core::Execution.stubs(:exec).returns(data_in_txt) expects_to_parse_powershell(ps1, data) end describe "when executing powershell", :if => Facter::Util::Config.is_windows? do let(:sysnative_powershell) { "#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe" } let(:system32_powershell) { "#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe" } let(:sysnative_regexp) { /^\"#{Regexp.escape(sysnative_powershell)}\"/ } let(:system32_regexp) { /^\"#{Regexp.escape(system32_powershell)}\"/ } let(:powershell_regexp) { /^\"#{Regexp.escape("powershell.exe")}\"/ } it "prefers the sysnative alias to resolve 64-bit powershell on 32-bit ruby" do File.expects(:exists?).with(sysnative_powershell).returns(true) Facter::Core::Execution.expects(:exec).with(regexp_matches(sysnative_regexp)).returns(data_in_txt) expects_to_parse_powershell(ps1, data) end it "uses system32 if sysnative alias doesn't exist on 64-bit ruby" do File.expects(:exists?).with(sysnative_powershell).returns(false) File.expects(:exists?).with(system32_powershell).returns(true) Facter::Core::Execution.expects(:exec).with(regexp_matches(system32_regexp)).returns(data_in_txt) expects_to_parse_powershell(ps1, data) end it "uses 'powershell' as a last resort" do File.expects(:exists?).with(sysnative_powershell).returns(false) File.expects(:exists?).with(system32_powershell).returns(false) Facter::Core::Execution.expects(:exec).with(regexp_matches(powershell_regexp)).returns(data_in_txt) expects_to_parse_powershell(ps1, data) end 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-2.4.6/spec/unit/util/partitions/0000775005276200011600000000000012651736742017760 5ustar jenkinsjenkinsfacter-2.4.6/spec/unit/util/partitions/partitions_spec.rb0000664005276200011600000000600612651736735023517 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter' require 'facter/util/partitions/linux' describe 'Facter::Util::Partitions::Linux' do describe 'on Linux OS' do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") File.stubs(:exist?).with('/sys/block/').returns(true) File.stubs(:exist?).with("/sys/block/./device").returns(false) File.stubs(:exist?).with("/sys/block/../device").returns(false) File.stubs(:exist?).with('/dev/disk/by-uuid/').returns(true) devices = [".", "..", "sda", "sdb", "sdc"] Dir.stubs(:entries).with('/sys/block/').returns(devices) Facter::Core::Execution.stubs(:which).with('mount').returns(true) Facter::Core::Execution.stubs(:which).with('blkid').returns(true) test_parts = { 'sda1' => '13459663-22cc-47b4-a9e6-21dea9906e03', 'sdb2' => '98043570-eb10-457f-9718-0b85a26e66bf', 'sdc3' => 'a35fb506-e831-4752-9899-dff6c601214b', } Dir.stubs(:entries).with('/dev/disk/by-uuid/').returns(test_parts.values) test_parts.each do |part,uuid| device = part.match(/(\D+)/)[1] File.stubs(:exist?).with("/sys/block/#{device}/device").returns(true) File.stubs(:symlink?).with("/dev/disk/by-uuid/#{uuid}").returns(true) File.stubs(:readlink).with("/dev/disk/by-uuid/#{uuid}").returns("/dev/#{part}") Dir.stubs(:glob).with("/sys/block/#{device}/#{device}*").returns(["/sys/block/#{device}/#{part}"]) Facter::Util::Partitions::Linux.stubs(:read_size).returns('12345') Facter::Core::Execution.stubs(:exec).with("blkid /dev/#{part}").returns("/dev/#{part}: UUID=\"#{uuid}\" TYPE=\"ext4\"") end Facter::Core::Execution.stubs(:exec).with('mount').returns(my_fixture_read("mount")) end it '.list should return a list of partitions' do Facter::Util::Partitions::Linux.list.should == ['sda1', 'sdb2', 'sdc3'] end it '.uuid should return a string containing the uuid' do Facter::Util::Partitions::Linux.uuid('sda1').should == '13459663-22cc-47b4-a9e6-21dea9906e03' Facter::Util::Partitions::Linux.uuid('sdb2').should == '98043570-eb10-457f-9718-0b85a26e66bf' Facter::Util::Partitions::Linux.uuid('sdc3').should == 'a35fb506-e831-4752-9899-dff6c601214b' end it '.size should return a string containing the size' do Facter::Util::Partitions::Linux.size('sda1').should == '12345' end it '.mount should return a string containing the mount point of the partition' do Facter::Util::Partitions::Linux.mount('sda1').should == '/home' Facter::Util::Partitions::Linux.mount('sdb2').should == '/' Facter::Util::Partitions::Linux.mount('sdc3').should == '/var' end it '.filesystem should return a string containing the filesystem on the partition' do Facter::Util::Partitions::Linux.filesystem('sda1').should == 'ext4' Facter::Util::Partitions::Linux.filesystem('sdb2').should == 'ext4' Facter::Util::Partitions::Linux.filesystem('sdc3').should == 'ext4' end end end facter-2.4.6/spec/unit/util/partitions_spec.rb0000664005276200011600000000071212651736735021321 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter' require 'facter/util/partitions' describe 'Facter::Util::Partitions' do describe 'on unsupported OSs' do before :each do Facter.fact(:kernel).stubs(:value).returns("SunOS") end it 'list should return empty array' do Facter::Util::Partitions.list.should == [] end it 'available? should return false' do Facter::Util::Partitions.available?.should == false end end end facter-2.4.6/spec/unit/util/posix_spec.rb0000664005276200011600000000057212651736735020273 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/util/posix' describe Facter::Util::POSIX do describe "retrieving values via sysctl" do it "returns the result of the sysctl command" do Facter::Util::Resolution.expects(:exec).with("sysctl -n hw.pagesize 2>/dev/null").returns("somevalue") expect(described_class.sysctl("hw.pagesize")).to eq "somevalue" end end end facter-2.4.6/spec/unit/util/processor_spec.rb0000775005276200011600000002247212651736735021156 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::Core::Execution.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::Core::Execution.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 describe "on AIX" do let(:lsattr) do "type PowerPC_POWER5 Processor type False\n" end def lsdev_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 before :each do Facter.fact(:kernel).stubs(:value).returns("AIX") Facter::Util::Processor.stubs(:lsdev).returns(lsdev_examples) Facter::Util::Processor.stubs(:lsattr).returns(lsattr) end it "should create an array of processors" do Facter::Util::Processor.aix_processor_list[0].should eq "PowerPC_POWER5" Facter::Util::Processor.aix_processor_list[1].should eq "PowerPC_POWER5" Facter::Util::Processor.aix_processor_list[2].should eq "PowerPC_POWER5" end end describe "on HP-UX" do 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 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 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) end %w{ 0 1 }.each do |j| it "should find #{expected_cpu}" do Facter::Util::Processor.hpux_processor_list[j.to_i].should eq expected_cpu end end end end end describe "when machinfo is not available" do 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')) 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) end else before :each do Facter::Util::Processor.stubs(:read_sched_models).returns(nil) end end %w{ 0 1 }.each do |j| it "should find #{expected_cpu}" do Facter::Util::Processor.hpux_processor_list[j.to_i].should eq expected_cpu end end end end end end end facter-2.4.6/spec/unit/util/registry_spec.rb0000664005276200011600000000634412651736735021004 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-2.4.6/spec/unit/util/resolution_spec.rb0000775005276200011600000000645212651736735021342 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/resolution' describe Facter::Util::Resolution do include FacterSpec::ConfigHelper subject(:resolution) { described_class.new(:foo, stub_fact) } let(:stub_fact) { stub('fact', :name => :stubfact) } it "requires a name" do expect { Facter::Util::Resolution.new }.to raise_error(ArgumentError) end it "requires a fact" do expect { Facter::Util::Resolution.new('yay') }.to raise_error(ArgumentError) end it "can return its name" do expect(resolution.name).to eq :foo end it "can explicitly set a value" do resolution.value = "foo" expect(resolution.value).to eq "foo" end it "defaults to nil for code" do expect(resolution.code).to be_nil end describe "when setting the code" do before do Facter.stubs(:warnonce) end it "creates a block when given a command" do resolution.setcode "foo" expect(resolution.code).to be_a_kind_of Proc end it "stores the provided block when given a block" do block = lambda { } resolution.setcode(&block) resolution.code.should equal(block) end it "prefers a command over a block" do block = lambda { } resolution.setcode("foo", &block) expect(resolution.code).to_not eq block end it "fails if neither a string nor block has been provided" do expect { resolution.setcode }.to raise_error(ArgumentError) end end describe "when returning the value" do it "returns any value that has been provided" do resolution.value = "foo" expect(resolution.value).to eq "foo" end describe "and setcode has not been called" do it "returns nil" do expect(resolution.value).to be_nil end end describe "and the code is a string" do it "returns the result of executing the code" do resolution.setcode "/bin/foo" Facter::Core::Execution.expects(:execute).once.with("/bin/foo", anything).returns "yup" expect(resolution.value).to eq "yup" end end describe "and the code is a block" do it "returns the value returned by the block" do resolution.setcode { "yayness" } expect(resolution.value).to eq "yayness" end end end describe "setting options" do it "can set the value" do resolution.set_options(:value => 'something') expect(resolution.value).to eq 'something' end it "can set the timeout" do resolution.set_options(:timeout => 314) expect(resolution.limit).to eq 314 end it "can set the weight" do resolution.set_options(:weight => 27) expect(resolution.weight).to eq 27 end it "fails on unhandled options" do expect do resolution.set_options(:foo => 'bar') end.to raise_error(ArgumentError, /Invalid resolution options.*foo/) end end describe "evaluating" do it "evaluates the block in the context of the given resolution" do subject.expects(:has_weight).with(5) subject.evaluate { has_weight(5) } end it "raises a warning if the resolution is evaluated twice" do Facter.expects(:warn).with do |msg| expect(msg).to match /Already evaluated foo at.*reevaluating anyways/ end subject.evaluate { } subject.evaluate { } end end end facter-2.4.6/spec/unit/util/solaris_zones_spec.rb0000664005276200011600000000756412651736735022033 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::Core::Execution.expects(:execute).with(subject.zoneadm_cmd, {:on_fail => nil}).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::Core::Execution.expects(:execute).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::Core::Execution.expects(:execute).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::Core::Execution.stubs(:execute). with(subject.zoneadm_cmd, {:on_fail => nil}). 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::Core::Execution.stubs(:execute).returns(zone_list2) Facter.flush end end facter-2.4.6/spec/unit/util/uptime_spec.rb0000775005276200011600000002134212651736735020435 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/uptime' require 'facter/util/posix' 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 Facter::Util::POSIX.stubs(:sysctl).returns(my_fixture_read("sysctl_kern_boottime_openbsd")) Time.stubs(:now).returns Time.utc(2011,12,9,22,11,46) # 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 Facter::Util::POSIX.stubs(:sysctl).returns(my_fixture_read("sysctl_kern_boottime_darwin")) Time.stubs(:now).returns Time.utc(2011,10,30,22,52,27) # 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. # The coreutils package can be installed in Solaris, which brings in a GNU version of uptime. The output # from this binary differs in that is is missing the comma after "day(s)" # Some versions of uptime in Solaris may also include a '-' character in the minutes field. # 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], ['10:27am up 1 day 7:26, 1 user, load average: 0.00, 0.00, 0.00', 1*24*60*60 + 7*60*60 + 26*60], ['22:45pm up 0:-6, 1 user, load average: 0.00, 0.00, 0.00', 6*60], ['22:45pm up 1 day 0:-6, 1 user, load average: 0.00, 0.00, 0.00', 1*24*60*60 + 6*60] ] test_cases.each do |uptime, expected| it "should return #{expected} for #{uptime}" do Facter::Core::Execution.stubs(:execute).with('uptime 2>/dev/null', {:on_fail => nil}).returns(uptime) Facter.fact(:uptime_seconds).value.should == expected end end describe "nor is 'uptime' command" do before :each do Facter::Core::Execution.stubs(:execute).with('uptime 2>/dev/null', {:on_fail => nil}).returns(nil) 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-2.4.6/spec/unit/util/values_spec.rb0000664005276200011600000001233612651736735020431 0ustar jenkinsjenkinsrequire 'spec_helper' require 'facter/util/values' describe Facter::Util::Values do describe 'deep_freeze' do it "it dups and freezes strings" do input = "hi" output = described_class.deep_freeze(input) expect(input).to_not be_frozen expect(output).to be_frozen end it "freezes arrays and each element in the array" do input = %w[one two three] output = described_class.deep_freeze(input) input.each { |entry| expect(entry).to_not be_frozen } output.each { |entry| expect(entry).to be_frozen } expect(input).to_not be_frozen expect(output).to be_frozen end it "freezes hashes and each key and value in the hash" do input = {'one' => 'two', 'three' => 'four'} output = described_class.deep_freeze(input) input.each_pair do |key, val| # Ruby freezes all string keys, so these will always be frozen expect(key).to be_frozen expect(val).to_not be_frozen end output.each_pair do |key, val| expect(key).to be_frozen expect(val).to be_frozen end expect(input).to_not be_frozen expect(output).to be_frozen end it "raises an error when given a structure that cannot be deeply frozen" do expect { described_class.deep_freeze(Set.new) }.to raise_error(Facter::Util::Values::DeepFreezeError, /Cannot deep freeze.*Set/) end end describe 'deep_merge' do it "non-destructively concatenates arrays" do first = %w[foo bar] second = %w[baz quux] expect(described_class.deep_merge(first, second)).to eq %w[foo bar baz quux] expect(first).to eq %w[foo bar] expect(second).to eq %w[baz quux] end it "returns the left value if the right value is nil" do expect(described_class.deep_merge("left", nil)).to eq "left" end it "returns the right value if the left value is nil" do expect(described_class.deep_merge(nil, "right")).to eq "right" end it "returns nil if both values are nil" do expect(described_class.deep_merge(nil, nil)).to be_nil end describe "with hashes" do it "merges when keys do not overlap" do first = {:foo => 'bar'} second = {:baz => 'quux'} expect(described_class.deep_merge(first, second)).to eq(:foo => 'bar', :baz => 'quux') expect(first).to eq(:foo => 'bar') expect(second).to eq(:baz => 'quux') end it "concatenates arrays when both keys are arrays" do first = {:foo => %w[bar]} second = {:foo => %w[baz quux]} expect(described_class.deep_merge(first, second)).to eq(:foo => %w[bar baz quux]) expect(first).to eq(:foo => %w[bar]) expect(second).to eq(:foo => %w[baz quux]) end it "merges hashes when both keys are hashes" do first = {:foo => {:pb => 'lead', :ag => 'silver'}} second = {:foo => {:au => 'gold', :na => 'sodium'}} expect(described_class.deep_merge(first, second)).to eq( :foo => { :pb => 'lead', :ag => 'silver', :au => 'gold', :na => 'sodium' } ) end it "prints the data structure path if an error is raised" do first = {:foo => {:bar => {:baz => {:quux => true}}}} second = {:foo => {:bar => {:baz => {:quux => false}}}} expect { described_class.deep_merge(first, second) }.to raise_error(Facter::Util::Values::DeepMergeError, /Cannot merge .*at .*foo.*bar.*baz.*quux/) end end describe "with unmergable scalar values" do [ [true, false], [1, 2], ['up', 'down'] ].each do |(left, right)| it "raises an error when merging #{left}:#{left.class} and #{right}:#{right.class}" do expect { described_class.deep_merge(left, right) }.to raise_error(Facter::Util::Values::DeepMergeError, /Cannot merge #{left.inspect}:#{left.class} and #{right.inspect}:#{right.class}/) end end end end describe "flatten_structure" do it "converts a string to a hash containing that string" do input = "foo" output = described_class.flatten_structure("path", input) expect(output).to eq({"path" => "foo"}) end it "converts an array to a hash with the array elements with indexes" do input = ["foo"] output = described_class.flatten_structure("path", input) expect(output).to eq({"path_0" => "foo"}) end it "prefixes a non-nested hash with the given path" do input = {"foo" => "bar"} output = described_class.flatten_structure("path", input) expect(output).to eq({"path_foo" => "bar"}) end it "flattens elements till it reaches the first non-flattenable structure" do input = { "first" => "second", "arr" => ["zero", "one"], "nested_array" => [ "hash" => "string", ], "top" => {"middle" => ['bottom']}, } output = described_class.flatten_structure("path", input) expect(output).to eq({ "path_first" => "second", "path_arr_0" => "zero", "path_arr_1" => "one", "path_nested_array_0_hash" => "string", "path_top_middle_0" => "bottom" }) end end end facter-2.4.6/spec/unit/util/virtual_spec.rb0000775005276200011600000003563512651736735020632 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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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 it "detects GCE if the DMI product name is Google" do File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name").returns("Google") expect(Facter::Util::Virtual.gce?).to be_true end it "does not detect GCE if the DMI product name is not Google" do File.stubs(:read).with("/sys/devices/virtual/dmi/id/product_name").returns('') expect(Facter::Util::Virtual.gce?).to be_false 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::POSIX.stubs(:sysctl).with("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::POSIX.stubs(:sysctl).with("hw.model").returns('QEMU Virtual CPU version (cpu64-rhel6) ("AuthenticAMD" 686-class, 512KB L2 cache)') Facter::Util::Virtual.should be_kvm end it "should detect kvm on SunOS" do FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false) Facter.fact(:kernel).stubs(:value).returns("SunOS") FileTest.stubs(:exists?).with("/usr/sbin/prtconf").returns(true) Facter::Core::Execution.stubs(:exec).with("/usr/sbin/prtconf -v").returns("Qemu virtual machine") Facter::Util::Virtual.should be_kvm end it "should identify FreeBSD jail when in jail" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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, override_location| before(:each) do Facter.fact(:kernel).stubs(:value).returns(kernel) if override_location Facter::Core::Execution.expects(:which).with(File.join(Facter::Util::Config.override_binary_dir, "virt-what")).returns(path) else Facter::Core::Execution.expects(:which).with(File.join(Facter::Util::Config.override_binary_dir, "virt-what")).returns(nil) Facter::Core::Execution.expects(:which).with("virt-what").returns(path) end Facter::Core::Execution.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 describe "override binary dir doesn't exist" do it_should_behave_like "virt-what", "linux", "/usr/bin/virt-what", "/dev/null", true it_should_behave_like "virt-what", "linux", "/usr/bin/virt-what", "/dev/null", false 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::Core::Execution.expects(:which).with(File.join(Facter::Util::Config.override_binary_dir, "virt-what")).returns(nil) Facter::Core::Execution.expects(:which).with('virt-what').returns "/usr/bin/virt-what" Facter::Core::Execution.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 end context "on unix" do it_should_behave_like "virt-what", "unix", "/usr/bin/virt-what", "/dev/null", true it_should_behave_like "virt-what", "unix", "/usr/bin/virt-what", "/dev/null", false end context "on windows" do it_should_behave_like "virt-what", "windows", 'c:\windows\system32\virt-what', "NUL", false end describe '.lxc?' do subject do Facter::Util::Virtual.lxc? end fixture_path = fixtures('virtual', 'proc_1_cgroup') context '/proc/1/cgroup has at least one hierarchy rooted in /lxc/' do before :each do fakepath = Pathname.new(File.join(fixture_path, 'in_a_container')) Pathname.stubs(:new).with('/proc/1/cgroup').returns(fakepath) end it 'is true' do subject.should be_true end end context '/proc/1/cgroup has no hierarchies rooted in /lxc/' do before :each do fakepath = Pathname.new(File.join(fixture_path, 'not_in_a_container')) Pathname.stubs(:new).with('/proc/1/cgroup').returns(fakepath) end it 'is false' do subject.should be_false end end end describe '.docker?' do subject do Facter::Util::Virtual.docker? end fixture_path = fixtures('virtual', 'proc_1_cgroup') context '/proc/1/cgroup has at least one hierarchy rooted in /docker/' do before :each do fakepath = Pathname.new(File.join(fixture_path, 'in_a_docker_container')) Pathname.stubs(:new).with('/proc/1/cgroup').returns(fakepath) end it 'is true' do subject.should be_true end end context '/proc/1/cgroup has at least one hierarchy with docker underneath a systemd slice parent' do before :each do fakepath = Pathname.new(File.join(fixture_path, 'in_a_docker_container_with_systemd_slices')) Pathname.stubs(:new).with('/proc/1/cgroup').returns(fakepath) end it 'is true' do subject.should be_true end end context '/proc/1/cgroup has no hierarchies rooted in /docker/' do before :each do fakepath = Pathname.new(File.join(fixture_path, 'not_in_a_container')) Pathname.stubs(:new).with('/proc/1/cgroup').returns(fakepath) end it 'is false' do subject.should be_false end end end end facter-2.4.6/spec/unit/util/vlans_spec.rb0000775005276200011600000000267712651736735020267 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/vlans' describe Facter::Util::Vlans do let(:vlan_file) { "/proc/net/vlan/config" } describe "reading the vlan configuration" do it "uses the contents of /proc/net/vlan/config" do File.expects(:exist?).with(vlan_file).returns true File.expects(:readable?).with(vlan_file).returns true File.expects(:read).with(vlan_file).returns "vlan contents here" expect(Facter::Util::Vlans.get_vlan_config).to eq "vlan contents here" end it "returns nil when /proc/net/vlan/config is absent" do File.expects(:exist?).with(vlan_file).returns false expect(Facter::Util::Vlans.get_vlan_config).to be_nil end end describe "parsing the vlan configuration" do let(:vlan_content) { my_fixture_read("linux_vlan_config") } it "returns a list of vlans on Linux when vlans are configured" do Facter::Util::Vlans.stubs(:get_vlan_config).returns(vlan_content) expect(Facter::Util::Vlans.get_vlans()).to eq %{400,300,200,100} end it "returns nil when no vlans are configured" do Facter::Util::Vlans.stubs(:get_vlan_config).returns(nil) expect(Facter::Util::Vlans.get_vlans()).to be_nil end it "returns nil when only the vlan header is returned" do Facter::Util::Vlans.stubs(:get_vlan_config).returns(my_fixture_read("centos-5-no-vlans")) expect(Facter::Util::Vlans.get_vlans()).to be_nil end end end facter-2.4.6/spec/unit/util/wmi_spec.rb0000775005276200011600000000106612651736735017727 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-2.4.6/spec/unit/util/xendomains_spec.rb0000775005276200011600000000764712651736735021313 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/xendomains' describe Facter::Util::Xendomains do let(:xen0_domains) { my_fixture_read("xendomains") } describe "when the xen-toolstack command is present" do before do File.expects(:file?).with('/usr/lib/xen-common/bin/xen-toolstack').returns true end describe "and the xen-toolstack returns xl" do before do Facter::Util::Resolution.stubs(:exec).with('/usr/lib/xen-common/bin/xen-toolstack').returns('/usr/sbin/xl') end it "lists the domains running on Xen0 with the 'xl' command" do Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains) Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} end end describe "and the xen-toolstack returns xm" do before do Facter::Util::Resolution.stubs(:exec).with('/usr/lib/xen-common/bin/xen-toolstack').returns('/usr/sbin/xm') end it "lists the domains running on Xen0 with the 'xm' command" do Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains) Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} end end describe "and the xen-toolstack returns nil" do before do Facter::Util::Resolution.stubs(:exec).with('/usr/lib/xen-common/bin/xen-toolstack').returns(nil) end it "returns nil" do Facter::Util::Xendomains.get_domains.should == nil end end end describe "when the xen-toolstack command is not present" do before do File.expects(:file?).with('/usr/lib/xen-common/bin/xen-toolstack').returns false end describe "and the xl command is present" do before do Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns('/usr/sbin/xl') end describe "and the xm command is not present" do before do Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil) Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never end it "lists the domains running on Xen0 with the 'xl' command" do Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains) Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} end end describe "and the xm command is also present" do before do Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/bin/xm') Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never end it "prefers xl over xm" do Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains) Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} end end end describe "when xl is not present" do before do Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil) Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').never end describe "and the xm command is present" do before do Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/sbin/xm') end it "lists the domains running on Xen0 with the 'xm' command" do Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains) Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} end end end describe "neither xl or xm are present" do it "returns nil" do Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil) Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil) Facter::Util::Xendomains.get_domains.should == nil end end end end facter-2.4.6/spec/unit/version_spec.rb0000664005276200011600000000177212651736735017644 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-2.4.6/spec/unit/virtual_spec.rb0000775005276200011600000006142712651736735017653 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter/util/virtual' require 'facter/util/macosx' unless Facter::Util::Config.is_windows? describe "Virtual fact" do before(:each) do Facter::Util::Virtual.stubs(:docker?).returns(false) Facter::Util::Virtual.stubs(:lxc?).returns(false) 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(:gce?).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.fact(:operatingsystem).stubs(:value).returns("Solaris") 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 LDoms on Solaris when an ldom" do ldom_fixture = File.read(fixtures('ldom', 'ldom_v1')) Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter.fact(:operatingsystem).stubs(:value).returns("Solaris") Facter.fact(:hardwareisa).stubs(:value).returns("sparc") Facter::Core::Execution.stubs(:which).with("virtinfo").returns 'virtinfo' Facter::Core::Execution.stubs(:which).with("vmware").returns nil Facter::Core::Execution.stubs(:exec).with("virtinfo -ap").returns(ldom_fixture) Facter.collection.internal_loader.load(:ldom) Facter.fact(:virtual).value.should == "LDoms" 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.fact(:operatingsystem).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", :unless => Facter::Util::Config.is_windows? do before do Facter.fact(:kernel).stubs(:value).returns("Darwin") end it "should be parallels with Parallels ethernet vendor id" do Facter::Util::Macosx.stubs(:profiler_data).returns({ "spethernet_subsystem-vendor-id" => "0x1ab8" }) Facter.fact(:virtual).value.should == "parallels" end it "should be virtualbox with VirtualBox boot rom name" do Facter::Util::Macosx.stubs(:profiler_data).returns({ "boot_rom_version" => "VirtualBox" }) Facter.fact(:virtual).value.should == "virtualbox" end it "should be vmware with VMware machine model" do Facter::Util::Macosx.stubs(:profiler_data).returns({ "machine_model" => "VMware7,1" }) Facter.fact(:virtual).value.should == "vmware" end end describe "on FreeBSD" do before(:each) do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter.fact(:operatingsystem).stubs(:value).returns("FreeBSD") end it "should be kvm with virtio device pciconf -lv 2>/dev/null" do Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n security.jail.jailed').returns('0') Facter::Util::Virtual.stubs(:lspci).returns("virtio_pci4@pci0:0:8:0: class=0x020000 card=0x00011af4 chip=0x10001af4 rev=0x00 hdr=0x00") Facter.fact(:virtual).value.should == "kvm" end it "should be bochs with Bochs vendor name from dmidecode" do Facter::Core::Execution.stubs(:exec).with('/sbin/sysctl -n security.jail.jailed').returns('0') Facter::Core::Execution.stubs(:exec).with('pciconf -lv 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Manufacturer: Bochs") Facter.fact(:virtual).value.should == "bochs" end end describe "on Linux" do before(:each) do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:operatingsystem).stubs(:value).returns("Linux") Facter::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.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 xenu with xvda1 device in /dev" 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(false) FileTest.expects(:exists?).with("/dev/xvda1").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::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Product Name: oVirt Node") Facter.fact(:virtual).value.should == "ovirt" end it "should be kvm with KVM Node manufacturer name from dmidecode" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Manufacturer: QEMU") Facter.fact(:virtual).value.should == "kvm" end it "is gce based on DMI info" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter::Util::Virtual.stubs(:gce?).returns(true) Facter.fact(:virtual).value.should == "gce" end it "should be hyperv with Microsoft vendor name from lspci 2>/dev/null" do Facter::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine") Facter.fact(:virtual).value.should == "hyperv" end it "should be kvm with virtio device lspci 2>/dev/null" do Facter::Util::Virtual.expects(:lspci).returns("00:03.0 Ethernet controller: Red Hat, Inc Virtio network device") Facter.fact(:virtual).value.should == "kvm" end context "In a Linux Container (LXC)" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end it 'is "lxc" when Facter::Util::Virtual.lxc? is true' do Facter::Util::Virtual.stubs(:lxc?).returns(true) Facter.fact(:virtual).value.should == 'lxc' end end context "In a Docker Container (docker)" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") end it 'is "docker" when Facter::Util::Virtual.docker? is true' do Facter::Util::Virtual.stubs(:docker?).returns(true) Facter.fact(:virtual).value.should == 'docker' end 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::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns("garbage\ninformation\n") Facter::Core::Execution.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::Core::Execution.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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('prtdiag 2>/dev/null').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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('prtdiag 2>/dev/null').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::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('prtdiag 2>/dev/null').returns("System Configuration: innotek GmbH VirtualBox") Facter.fact(:virtual).value.should == "virtualbox" end end describe "on OpenBSD" do before do Facter::Core::Execution.stubs(:exec).with("vmware -v").returns false Facter.fact(:kernel).stubs(:value).returns("OpenBSD") Facter.fact(:hardwaremodel).stubs(:value).returns(nil) Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil) Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil) end it "should be parallels with Parallels product name from sysctl" do Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("Parallels Virtual Platform") Facter.fact(:virtual).value.should == "parallels" end it "should be vmware with VMware product name from sysctl" do Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("VMware Virtual Platform") Facter.fact(:virtual).value.should == "vmware" end it "should be virtualbox with VirtualBox product name from sysctl" do Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("VirtualBox") Facter.fact(:virtual).value.should == "virtualbox" end it "should be xenhvm with Xen HVM product name from sysctl" do Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("HVM domU") Facter.fact(:virtual).value.should == "xenhvm" end it "should be ovirt with oVirt Node product name from sysctl" do Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("oVirt Node") Facter.fact(:virtual).value.should == "ovirt" end it "should be kvm with KVM product name from sysctl" do Facter::Util::POSIX.stubs(:sysctl).with('hw.product').returns("KVM") Facter.fact(:virtual).value.should == "kvm" 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 it "should be true when running on gce" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("gce") Facter.fact(:is_virtual).value.should == true end it "should be true when running in LXC" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("lxc") Facter.fact(:is_virtual).value.should == true end it "should be true when running in docker" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("docker") Facter.fact(:is_virtual).value.should == true end it "should be true when running in bochs" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("bochs") Facter.fact(:is_virtual).value.should == true end end facter-2.4.6/spec/unit/zfs_version_spec.rb0000664005276200011600000000752712651736735020532 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::Core::Execution.stubs(:which).with("zfs").returns("/usr/bin/zfs") end it "should return nil on old versions of Solaris 10" do Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_old')) Facter.fact(:zfs_version).value.should == nil end it "should return correct version on Solaris 10" do Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new')) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new')) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new')) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new')) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new')) Facter::Core::Execution.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 correct version on Linux with zfsonlinux" do Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new')) Facter::Core::Execution.stubs(:exec).with("zfs upgrade -v").returns(my_fixture_read('zfsonlinux_0.6.1')) Facter.fact(:zfs_version).value.should == "5" end it "should return nil if zfs command is not available" do Facter::Core::Execution.stubs(:which).with("zfs").returns(nil) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").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::Core::Execution.stubs(:which).with("zfs").returns(nil,nil,"/usr/bin/zfs") Facter::Core::Execution.stubs(:exec).with("zfs -? 2> /dev/null").returns(my_fixture_read('zfs_new')) Facter::Core::Execution.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-2.4.6/spec/unit/zonename_spec.rb0000664005276200011600000000051712651736735017767 0ustar jenkinsjenkins#! /usr/bin/env ruby require 'spec_helper' require 'facter' describe "zonename fact" do it "should return global zone" do Facter.fact(:kernel).stubs(:value).returns("SunOS") Facter::Core::Execution.stubs(:execute).with("zonename", anything).returns('global') Facter.fact(:zonename).value.should == "global" end end facter-2.4.6/spec/unit/zones_spec.rb0000664005276200011600000000307212651736735017310 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::Core::Execution.stubs(:execute).with('/usr/sbin/zoneadm list -cp', {:on_fail => nil}).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-2.4.6/spec/unit/zpool_version_spec.rb0000664005276200011600000000572112651736735021065 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::Core::Execution.stubs(:which).with("zpool").returns("/usr/bin/zpool") end it "should return correct version on Solaris 10" do Facter::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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::Core::Execution.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 correct version on Linux with zfsonlinux" do Facter::Core::Execution.stubs(:exec).with("zpool upgrade -v").returns(my_fixture_read('zfsonlinux_0.6.1')) Facter.fact(:zpool_version).value.should == "28" end it "should return nil if zpool is not available" do Facter::Core::Execution.stubs(:which).with("zpool").returns(nil) Facter::Core::Execution.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::Core::Execution.stubs(:exec).with("zpool upgrade -v").returns('') 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::Core::Execution.stubs(:which). with("zpool"). returns(nil,nil,"/usr/bin/zpool") Facter::Core::Execution.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-2.4.6/spec/watchr.rb0000775005276200011600000000533612651736735015461 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