facter 2.0.1.rc1-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/COMMITTERS.md +194 -0
- data/CONTRIBUTING.md +65 -0
- data/Gemfile +43 -0
- data/LICENSE +15 -0
- data/README.md +33 -0
- data/Rakefile +79 -0
- data/bin/facter +16 -0
- data/etc/facter.conf +5 -0
- data/ext/build_defaults.yaml +24 -0
- data/ext/debian/changelog.erb +59 -0
- data/ext/debian/compat +1 -0
- data/ext/debian/control +14 -0
- data/ext/debian/copyright +19 -0
- data/ext/debian/docs +1 -0
- data/ext/debian/lintian-overrides +0 -0
- data/ext/debian/rules +10 -0
- data/ext/debian/source/format +1 -0
- data/ext/facter-diff +74 -0
- data/ext/ips/facter.p5m.erb +10 -0
- data/ext/ips/rules +7 -0
- data/ext/ips/transforms +18 -0
- data/ext/osx/file_mapping.yaml +27 -0
- data/ext/osx/preflight.erb +33 -0
- data/ext/osx/prototype.plist.erb +38 -0
- data/ext/project_data.yaml +33 -0
- data/ext/redhat/facter.spec.erb +220 -0
- data/ext/solaris/pkginfo +7 -0
- data/install.rb +380 -0
- data/lib/facter.rb +262 -0
- data/lib/facter/Cfkey.rb +42 -0
- data/lib/facter/application.rb +204 -0
- data/lib/facter/architecture.rb +50 -0
- data/lib/facter/augeasversion.rb +28 -0
- data/lib/facter/blockdevices.rb +105 -0
- data/lib/facter/core/aggregate.rb +220 -0
- data/lib/facter/core/directed_graph.rb +46 -0
- data/lib/facter/core/execution.rb +100 -0
- data/lib/facter/core/execution/base.rb +73 -0
- data/lib/facter/core/execution/posix.rb +50 -0
- data/lib/facter/core/execution/windows.rb +57 -0
- data/lib/facter/core/logging.rb +169 -0
- data/lib/facter/core/resolvable.rb +94 -0
- data/lib/facter/core/suitable.rb +117 -0
- data/lib/facter/domain.rb +99 -0
- data/lib/facter/ec2.rb +37 -0
- data/lib/facter/facterversion.rb +15 -0
- data/lib/facter/filesystems.rb +38 -0
- data/lib/facter/fqdn.rb +22 -0
- data/lib/facter/hardwareisa.rb +20 -0
- data/lib/facter/hardwaremodel.rb +67 -0
- data/lib/facter/hostname.rb +33 -0
- data/lib/facter/id.rb +21 -0
- data/lib/facter/interfaces.rb +46 -0
- data/lib/facter/ipaddress.rb +171 -0
- data/lib/facter/ipaddress6.rb +82 -0
- data/lib/facter/iphostnumber.rb +29 -0
- data/lib/facter/kernel.rb +22 -0
- data/lib/facter/kernelmajversion.rb +15 -0
- data/lib/facter/kernelrelease.rb +42 -0
- data/lib/facter/kernelversion.rb +22 -0
- data/lib/facter/ldom.rb +47 -0
- data/lib/facter/lsbdistcodename.rb +18 -0
- data/lib/facter/lsbdistdescription.rb +21 -0
- data/lib/facter/lsbdistid.rb +18 -0
- data/lib/facter/lsbdistrelease.rb +18 -0
- data/lib/facter/lsbmajdistrelease.rb +27 -0
- data/lib/facter/lsbrelease.rb +18 -0
- data/lib/facter/macaddress.rb +97 -0
- data/lib/facter/macosx.rb +56 -0
- data/lib/facter/manufacturer.rb +68 -0
- data/lib/facter/memory.rb +162 -0
- data/lib/facter/netmask.rb +42 -0
- data/lib/facter/network.rb +20 -0
- data/lib/facter/operatingsystem.rb +121 -0
- data/lib/facter/operatingsystemmajrelease.rb +33 -0
- data/lib/facter/operatingsystemrelease.rb +226 -0
- data/lib/facter/osfamily.rb +35 -0
- data/lib/facter/path.rb +14 -0
- data/lib/facter/physicalprocessorcount.rb +84 -0
- data/lib/facter/processor.rb +183 -0
- data/lib/facter/ps.rb +30 -0
- data/lib/facter/puppetversion.rb +20 -0
- data/lib/facter/rubysitedir.rb +12 -0
- data/lib/facter/rubyversion.rb +12 -0
- data/lib/facter/selinux.rb +99 -0
- data/lib/facter/ssh.rb +72 -0
- data/lib/facter/timezone.rb +14 -0
- data/lib/facter/uniqueid.rb +4 -0
- data/lib/facter/uptime.rb +34 -0
- data/lib/facter/uptime_days.rb +15 -0
- data/lib/facter/uptime_hours.rb +15 -0
- data/lib/facter/uptime_seconds.rb +24 -0
- data/lib/facter/util/architecture.rb +19 -0
- data/lib/facter/util/collection.rb +161 -0
- data/lib/facter/util/composite_loader.rb +12 -0
- data/lib/facter/util/config.rb +61 -0
- data/lib/facter/util/confine.rb +66 -0
- data/lib/facter/util/directory_loader.rb +83 -0
- data/lib/facter/util/ec2.rb +101 -0
- data/lib/facter/util/fact.rb +204 -0
- data/lib/facter/util/file_read.rb +37 -0
- data/lib/facter/util/formatter.rb +38 -0
- data/lib/facter/util/ip.rb +285 -0
- data/lib/facter/util/ip/windows.rb +215 -0
- data/lib/facter/util/loader.rb +146 -0
- data/lib/facter/util/macaddress.rb +43 -0
- data/lib/facter/util/macosx.rb +73 -0
- data/lib/facter/util/manufacturer.rb +104 -0
- data/lib/facter/util/memory.rb +228 -0
- data/lib/facter/util/monkey_patches.rb +8 -0
- data/lib/facter/util/netmask.rb +40 -0
- data/lib/facter/util/normalization.rb +94 -0
- data/lib/facter/util/nothing_loader.rb +12 -0
- data/lib/facter/util/parser.rb +158 -0
- data/lib/facter/util/plist.rb +24 -0
- data/lib/facter/util/plist/generator.rb +228 -0
- data/lib/facter/util/plist/parser.rb +226 -0
- data/lib/facter/util/processor.rb +291 -0
- data/lib/facter/util/registry.rb +11 -0
- data/lib/facter/util/resolution.rb +152 -0
- data/lib/facter/util/solaris_zones.rb +158 -0
- data/lib/facter/util/unix_root.rb +5 -0
- data/lib/facter/util/uptime.rb +81 -0
- data/lib/facter/util/values.rb +80 -0
- data/lib/facter/util/virtual.rb +151 -0
- data/lib/facter/util/vlans.rb +24 -0
- data/lib/facter/util/windows_root.rb +37 -0
- data/lib/facter/util/wmi.rb +16 -0
- data/lib/facter/util/xendomains.rb +10 -0
- data/lib/facter/version.rb +86 -0
- data/lib/facter/virtual.rb +262 -0
- data/lib/facter/vlans.rb +17 -0
- data/lib/facter/xendomains.rb +20 -0
- data/lib/facter/zfs_version.rb +10 -0
- data/lib/facter/zonename.rb +6 -0
- data/lib/facter/zones.rb +17 -0
- data/lib/facter/zpool_version.rb +10 -0
- data/spec/fixtures/cpuinfo/amd64dual +57 -0
- data/spec/fixtures/cpuinfo/amd64quad +79 -0
- data/spec/fixtures/cpuinfo/amd64solo +23 -0
- data/spec/fixtures/cpuinfo/amd64tri +86 -0
- data/spec/fixtures/cpuinfo/amd64twentyfour +600 -0
- data/spec/fixtures/cpuinfo/bbg3-armel +12 -0
- data/spec/fixtures/cpuinfo/beaglexm-armel +12 -0
- data/spec/fixtures/cpuinfo/panda-armel +17 -0
- data/spec/fixtures/cpuinfo/ppc64 +19 -0
- data/spec/fixtures/cpuinfo/sparc +10 -0
- data/spec/fixtures/hpux/machinfo/hppa-rp4440 +26 -0
- data/spec/fixtures/hpux/machinfo/ia64-rx2620 +49 -0
- data/spec/fixtures/hpux/machinfo/ia64-rx6600 +26 -0
- data/spec/fixtures/hpux/machinfo/ia64-rx8640 +53 -0
- data/spec/fixtures/hpux/machinfo/superdome-server-SD32B +53 -0
- data/spec/fixtures/hpux/machinfo/superdome2-16s +31 -0
- data/spec/fixtures/hpux/sched.models +174 -0
- data/spec/fixtures/hpux/unistd.h +1534 -0
- data/spec/fixtures/ifconfig/bsd_ifconfig_all_with_multiple_interfaces +18 -0
- data/spec/fixtures/ifconfig/centos_5_5 +17 -0
- data/spec/fixtures/ifconfig/centos_5_5_eth0 +8 -0
- data/spec/fixtures/ifconfig/darwin_10_3_0 +26 -0
- data/spec/fixtures/ifconfig/darwin_10_3_0_en0 +6 -0
- data/spec/fixtures/ifconfig/darwin_10_6_4 +28 -0
- data/spec/fixtures/ifconfig/darwin_10_6_4_en1 +6 -0
- data/spec/fixtures/ifconfig/darwin_10_6_6_dualstack +8 -0
- data/spec/fixtures/ifconfig/darwin_10_6_6_dualstack_en1 +7 -0
- data/spec/fixtures/ifconfig/darwin_9_8_0 +26 -0
- data/spec/fixtures/ifconfig/darwin_9_8_0_en0 +6 -0
- data/spec/fixtures/ifconfig/darwin_ifconfig_all_with_multiple_interfaces +23 -0
- data/spec/fixtures/ifconfig/fedora_10 +36 -0
- data/spec/fixtures/ifconfig/fedora_10_eth0 +9 -0
- data/spec/fixtures/ifconfig/fedora_13 +18 -0
- data/spec/fixtures/ifconfig/fedora_13_eth0 +9 -0
- data/spec/fixtures/ifconfig/fedora_8 +38 -0
- data/spec/fixtures/ifconfig/fedora_8_eth0 +9 -0
- data/spec/fixtures/ifconfig/freebsd_6_0 +12 -0
- data/spec/fixtures/ifconfig/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt +16 -0
- data/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces +19 -0
- data/spec/fixtures/ifconfig/linux_ifconfig_no_addr +19 -0
- data/spec/fixtures/ifconfig/linux_ifconfig_no_mac +8 -0
- data/spec/fixtures/ifconfig/linux_ifconfig_venet +24 -0
- data/spec/fixtures/ifconfig/open_solaris_10 +12 -0
- data/spec/fixtures/ifconfig/open_solaris_b132 +20 -0
- data/spec/fixtures/ifconfig/sunos_ifconfig_all_with_multiple_interfaces +10 -0
- data/spec/fixtures/ifconfig/ubuntu_7_04 +38 -0
- data/spec/fixtures/ifconfig/ubuntu_7_04_eth0 +9 -0
- data/spec/fixtures/ldom/ldom_v1 +6 -0
- data/spec/fixtures/netstat/centos_5_5 +5 -0
- data/spec/fixtures/netstat/darwin_10_3_0 +35 -0
- data/spec/fixtures/netstat/darwin_10_6_4 +29 -0
- data/spec/fixtures/netstat/darwin_10_6_6_dualstack +34 -0
- data/spec/fixtures/netstat/darwin_9_8_0 +28 -0
- data/spec/fixtures/netstat/fedora_10 +7 -0
- data/spec/fixtures/netstat/open_solaris_10 +16 -0
- data/spec/fixtures/netstat/open_solaris_b132 +17 -0
- data/spec/fixtures/netstat/ubuntu_7_04 +7 -0
- data/spec/fixtures/processorcount/solaris-psrinfo +24 -0
- data/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info +1216 -0
- data/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info +225 -0
- data/spec/fixtures/unit/filesystems/linux +28 -0
- data/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.em1 +10 -0
- data/spec/fixtures/unit/interfaces/ifconfig_net_tools_1.60.txt.lo +8 -0
- data/spec/fixtures/unit/ipaddress/ifconfig_multiple_127_addresses.txt +20 -0
- data/spec/fixtures/unit/ipaddress/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/unit/ipaddress/ifconfig_non_english_locale.txt +18 -0
- data/spec/fixtures/unit/ipaddress/ifconfig_ubuntu_1204.txt +16 -0
- data/spec/fixtures/unit/netmask/darwin_10_8_5.txt +30 -0
- data/spec/fixtures/unit/netmask/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/unit/netmask/ifconfig_ubuntu_1204.txt +16 -0
- data/spec/fixtures/unit/selinux/selinux_sestatus +6 -0
- data/spec/fixtures/unit/util/ec2/centos-arp-ec2.out +1 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-ec2.out +1 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out +5 -0
- data/spec/fixtures/unit/util/ec2/solaris8_arp_a_not_ec2.out +7 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out +6 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out +10 -0
- data/spec/fixtures/unit/util/ip/6.0-STABLE_FreeBSD_ifconfig +12 -0
- data/spec/fixtures/unit/util/ip/Mac_OS_X_10.5.5_ifconfig +26 -0
- data/spec/fixtures/unit/util/ip/darwin_ifconfig_all_with_multiple_interfaces +10 -0
- data/spec/fixtures/unit/util/ip/darwin_ifconfig_single_interface +6 -0
- data/spec/fixtures/unit/util/ip/debian_kfreebsd_ifconfig +40 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_lanscan +5 -0
- data/spec/fixtures/unit/util/ip/hpux_1111_netstat_in +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_lanscan +5 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_asterisk_netstat_in +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_lanscan +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_netstat_in +4 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lan4_1 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_ifconfig_lo0 +2 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_lanscan +9 -0
- data/spec/fixtures/unit/util/ip/hpux_1131_nic_bonding_netstat_in +6 -0
- data/spec/fixtures/unit/util/ip/linux_2_6_35_proc_net_bonding_bond0 +19 -0
- data/spec/fixtures/unit/util/ip/linux_get_single_interface_eth0 +10 -0
- data/spec/fixtures/unit/util/ip/linux_get_single_interface_ib0 +8 -0
- data/spec/fixtures/unit/util/ip/linux_get_single_interface_lo +9 -0
- data/spec/fixtures/unit/util/ip/linux_ifconfig_all_with_single_interface +18 -0
- data/spec/fixtures/unit/util/ip/linux_ifconfig_ib0 +8 -0
- data/spec/fixtures/unit/util/ip/solaris_ifconfig_all_with_multiple_interfaces +8 -0
- data/spec/fixtures/unit/util/ip/solaris_ifconfig_single_interface +3 -0
- data/spec/fixtures/unit/util/ip/windows_netsh_all_interfaces +12 -0
- data/spec/fixtures/unit/util/ip/windows_netsh_single_interface +7 -0
- data/spec/fixtures/unit/util/ip/windows_netsh_single_interface6 +18 -0
- data/spec/fixtures/unit/util/loader/nosuchfact.rb +1 -0
- data/spec/fixtures/unit/util/manufacturer/freebsd_dmidecode +42 -0
- data/spec/fixtures/unit/util/manufacturer/intel_linux_dmidecode +549 -0
- data/spec/fixtures/unit/util/manufacturer/linux_dmidecode_with_spaces +60 -0
- data/spec/fixtures/unit/util/manufacturer/opensolaris_smbios +33 -0
- data/spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag +33 -0
- data/spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag +136 -0
- data/spec/fixtures/unit/util/processor/solaris-i86pc +28 -0
- data/spec/fixtures/unit/util/processor/solaris-sun4u +151 -0
- data/spec/fixtures/unit/util/processor/x86-pentium2 +41 -0
- data/spec/fixtures/unit/util/uptime/kstat_boot_time +1 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin +1 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd +1 -0
- data/spec/fixtures/unit/util/uptime/ubuntu_proc_uptime +1 -0
- data/spec/fixtures/unit/util/virtual/invalid_unicode_dmi_entries +0 -0
- data/spec/fixtures/unit/util/virtual/solaris10_proc_self_status1 +0 -0
- data/spec/fixtures/unit/util/vlans/linux_vlan_config +6 -0
- data/spec/fixtures/unit/util/xendomains/xendomains +4 -0
- data/spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt +0 -0
- data/spec/fixtures/unit/zfs_version/freebsd_8.2 +14 -0
- data/spec/fixtures/unit/zfs_version/freebsd_9.0 +13 -0
- data/spec/fixtures/unit/zfs_version/linux-fuse_0.6.9 +14 -0
- data/spec/fixtures/unit/zfs_version/solaris_10 +10 -0
- data/spec/fixtures/unit/zfs_version/solaris_11 +12 -0
- data/spec/fixtures/unit/zpool_version/freebsd_8.2 +26 -0
- data/spec/fixtures/unit/zpool_version/freebsd_9.0 +38 -0
- data/spec/fixtures/unit/zpool_version/linux-fuse_0.6.9 +35 -0
- data/spec/fixtures/unit/zpool_version/solaris_10 +31 -0
- data/spec/fixtures/unit/zpool_version/solaris_11 +43 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_1/guest +37 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_1/host +36 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_3/guest +39 -0
- data/spec/fixtures/virtual/proc_self_status/vserver_2_3/host +39 -0
- data/spec/integration/facter_spec.rb +39 -0
- data/spec/lib/facter_spec/cpuinfo.rb +15 -0
- data/spec/lib/facter_spec/windows_network.rb +64 -0
- data/spec/puppetlabs_spec/files.rb +57 -0
- data/spec/puppetlabs_spec/fixtures.rb +49 -0
- data/spec/puppetlabs_spec/matchers.rb +87 -0
- data/spec/puppetlabs_spec/verbose.rb +9 -0
- data/spec/puppetlabs_spec_helper.rb +26 -0
- data/spec/shared_contexts/platform.rb +55 -0
- data/spec/shared_formats/parses.rb +3 -0
- data/spec/spec_helper.rb +75 -0
- data/spec/unit/application_spec.rb +101 -0
- data/spec/unit/architecture_spec.rb +63 -0
- data/spec/unit/blockdevices_spec.rb +109 -0
- data/spec/unit/core/aggregate_spec.rb +125 -0
- data/spec/unit/core/directed_graph_spec.rb +79 -0
- data/spec/unit/core/execution/base_spec.rb +119 -0
- data/spec/unit/core/execution/posix_spec.rb +86 -0
- data/spec/unit/core/execution/windows_spec.rb +106 -0
- data/spec/unit/core/execution_spec.rb +37 -0
- data/spec/unit/core/logging_spec.rb +104 -0
- data/spec/unit/core/resolvable_spec.rb +81 -0
- data/spec/unit/core/suitable_spec.rb +96 -0
- data/spec/unit/domain_spec.rb +310 -0
- data/spec/unit/ec2_spec.rb +187 -0
- data/spec/unit/facter_spec.rb +108 -0
- data/spec/unit/filesystems_spec.rb +50 -0
- data/spec/unit/hardwareisa_spec.rb +41 -0
- data/spec/unit/hardwaremodel_spec.rb +56 -0
- data/spec/unit/hostname_spec.rb +40 -0
- data/spec/unit/id_spec.rb +29 -0
- data/spec/unit/interfaces_spec.rb +57 -0
- data/spec/unit/ipaddress6_spec.rb +161 -0
- data/spec/unit/ipaddress_spec.rb +114 -0
- data/spec/unit/kernel_spec.rb +24 -0
- data/spec/unit/kernelmajversion_spec.rb +17 -0
- data/spec/unit/kernelrelease_spec.rb +53 -0
- data/spec/unit/kernelversion_spec.rb +32 -0
- data/spec/unit/ldom_spec.rb +74 -0
- data/spec/unit/lsbdistcodename_spec.rb +25 -0
- data/spec/unit/lsbdistdescription_spec.rb +25 -0
- data/spec/unit/lsbdistid_spec.rb +25 -0
- data/spec/unit/lsbdistrelease_spec.rb +25 -0
- data/spec/unit/lsbmajdistrelease_spec.rb +13 -0
- data/spec/unit/lsbrelease_spec.rb +25 -0
- data/spec/unit/macaddress_spec.rb +61 -0
- data/spec/unit/manufacturer_spec.rb +115 -0
- data/spec/unit/memory_spec.rb +539 -0
- data/spec/unit/netmask_spec.rb +95 -0
- data/spec/unit/operatingsystem_spec.rb +141 -0
- data/spec/unit/operatingsystemmajrelease_spec.rb +16 -0
- data/spec/unit/operatingsystemrelease_spec.rb +226 -0
- data/spec/unit/physicalprocessorcount_spec.rb +76 -0
- data/spec/unit/processor_spec.rb +393 -0
- data/spec/unit/ps_spec.rb +42 -0
- data/spec/unit/selinux_spec.rb +114 -0
- data/spec/unit/ssh_spec.rb +77 -0
- data/spec/unit/uniqueid_spec.rb +27 -0
- data/spec/unit/uptime_spec.rb +110 -0
- data/spec/unit/util/collection_spec.rb +258 -0
- data/spec/unit/util/config_spec.rb +84 -0
- data/spec/unit/util/confine_spec.rb +148 -0
- data/spec/unit/util/directory_loader_spec.rb +88 -0
- data/spec/unit/util/ec2_spec.rb +180 -0
- data/spec/unit/util/fact_spec.rb +142 -0
- data/spec/unit/util/file_read_spec.rb +29 -0
- data/spec/unit/util/ip/windows_spec.rb +80 -0
- data/spec/unit/util/ip_spec.rb +463 -0
- data/spec/unit/util/loader_spec.rb +286 -0
- data/spec/unit/util/macaddress_spec.rb +141 -0
- data/spec/unit/util/macosx_spec.rb +113 -0
- data/spec/unit/util/manufacturer_spec.rb +179 -0
- data/spec/unit/util/normalization_spec.rb +113 -0
- data/spec/unit/util/parser_spec.rb +200 -0
- data/spec/unit/util/processor_spec.rb +92 -0
- data/spec/unit/util/registry_spec.rb +76 -0
- data/spec/unit/util/resolution_spec.rb +129 -0
- data/spec/unit/util/solaris_zones_spec.rb +127 -0
- data/spec/unit/util/uptime_spec.rb +126 -0
- data/spec/unit/util/values_spec.rb +131 -0
- data/spec/unit/util/virtual_spec.rb +294 -0
- data/spec/unit/util/vlans_spec.rb +12 -0
- data/spec/unit/util/wmi_spec.rb +19 -0
- data/spec/unit/util/xendomains_spec.rb +21 -0
- data/spec/unit/version_spec.rb +42 -0
- data/spec/unit/virtual_spec.rb +470 -0
- data/spec/unit/zfs_version_spec.rb +75 -0
- data/spec/unit/zonename_spec.rb +14 -0
- data/spec/unit/zones_spec.rb +55 -0
- data/spec/unit/zpool_version_spec.rb +75 -0
- data/spec/watchr.rb +125 -0
- metadata +674 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'set'
|
2
|
+
require 'tsort'
|
3
|
+
|
4
|
+
module Facter
|
5
|
+
module Core
|
6
|
+
class DirectedGraph < Hash
|
7
|
+
include TSort
|
8
|
+
|
9
|
+
def acyclic?
|
10
|
+
cycles.empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
def cycles
|
14
|
+
cycles = []
|
15
|
+
each_strongly_connected_component do |component|
|
16
|
+
cycles << component if component.size > 1
|
17
|
+
end
|
18
|
+
cycles
|
19
|
+
end
|
20
|
+
|
21
|
+
alias tsort_each_node each_key
|
22
|
+
|
23
|
+
def tsort_each_child(node)
|
24
|
+
fetch(node, []).each do |child|
|
25
|
+
yield child
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def tsort
|
30
|
+
missing = Set.new(self.values.flatten) - Set.new(self.keys)
|
31
|
+
|
32
|
+
if not missing.empty?
|
33
|
+
raise MissingVertex, "Cannot sort elements; cannot depend on missing elements #{missing.to_a}"
|
34
|
+
end
|
35
|
+
|
36
|
+
super
|
37
|
+
|
38
|
+
rescue TSort::Cyclic
|
39
|
+
raise CycleError, "Cannot sort elements; found the following cycles: #{cycles.inspect}"
|
40
|
+
end
|
41
|
+
|
42
|
+
class CycleError < StandardError; end
|
43
|
+
class MissingVertex < StandardError; end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'facter/util/config'
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module Core
|
5
|
+
module Execution
|
6
|
+
|
7
|
+
require 'facter/core/execution/base'
|
8
|
+
require 'facter/core/execution/windows'
|
9
|
+
require 'facter/core/execution/posix'
|
10
|
+
|
11
|
+
@@impl = if Facter::Util::Config.is_windows?
|
12
|
+
Facter::Core::Execution::Windows.new
|
13
|
+
else
|
14
|
+
Facter::Core::Execution::Posix.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.impl
|
18
|
+
@@impl
|
19
|
+
end
|
20
|
+
|
21
|
+
module_function
|
22
|
+
|
23
|
+
# Returns the locations to be searched when looking for a binary. This
|
24
|
+
# is currently determined by the +PATH+ environment variable plus
|
25
|
+
# `/sbin` and `/usr/sbin` when run on unix
|
26
|
+
#
|
27
|
+
# @return [Array<String>] the paths to be searched for binaries
|
28
|
+
# @api private
|
29
|
+
def search_paths
|
30
|
+
@@impl.search_paths
|
31
|
+
end
|
32
|
+
|
33
|
+
# Determines the full path to a binary. If the supplied filename does not
|
34
|
+
# already describe an absolute path then different locations (determined
|
35
|
+
# by {search_paths}) will be searched for a match.
|
36
|
+
#
|
37
|
+
# Returns nil if no matching executable can be found otherwise returns
|
38
|
+
# the expanded pathname.
|
39
|
+
#
|
40
|
+
# @param bin [String] the executable to locate
|
41
|
+
# @return [String,nil] the full path to the executable or nil if not
|
42
|
+
# found
|
43
|
+
#
|
44
|
+
# @api public
|
45
|
+
def which(bin)
|
46
|
+
@@impl.which(bin)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Determine in a platform-specific way whether a path is absolute. This
|
50
|
+
# defaults to the local platform if none is specified.
|
51
|
+
#
|
52
|
+
# @param path [String] the path to check
|
53
|
+
# @param platform [:posix,:windows,nil] the platform logic to use
|
54
|
+
def absolute_path?(path, platform = nil)
|
55
|
+
@@impl.absolute_path?(path, platform)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Given a command line, this returns the command line with the
|
59
|
+
# executable written as an absolute path. If the executable contains
|
60
|
+
# spaces, it has be put in double quotes to be properly recognized.
|
61
|
+
#
|
62
|
+
# @param command [String] the command line
|
63
|
+
#
|
64
|
+
# @return [String, nil] the command line with the executable's path
|
65
|
+
# expanded, or nil if the executable cannot be found.
|
66
|
+
def expand_command(command)
|
67
|
+
@@impl.expand_command(command)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Overrides environment variables within a block of code. The
|
71
|
+
# specified values will be set for the duration of the block, after
|
72
|
+
# which the original values (if any) will be restored.
|
73
|
+
#
|
74
|
+
# @overload with_env(values, { || ... })
|
75
|
+
#
|
76
|
+
# @param values [Hash<String=>String>] A hash of the environment
|
77
|
+
# variables to override
|
78
|
+
#
|
79
|
+
# @return [void]
|
80
|
+
#
|
81
|
+
# @api public
|
82
|
+
def with_env(values, &block)
|
83
|
+
@@impl.with_env(values, &block)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Executes a program and return the output of that program.
|
87
|
+
#
|
88
|
+
# Returns nil if the program can't be found, or if there is a problem
|
89
|
+
# executing the code.
|
90
|
+
#
|
91
|
+
# @param code [String] the program to run
|
92
|
+
# @return [String] the output of the program or the empty string on error
|
93
|
+
#
|
94
|
+
# @api public
|
95
|
+
def exec(command)
|
96
|
+
@@impl.exec(command)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class Facter::Core::Execution::Base
|
2
|
+
|
3
|
+
def with_env(values)
|
4
|
+
old = {}
|
5
|
+
values.each do |var, value|
|
6
|
+
# save the old value if it exists
|
7
|
+
if old_val = ENV[var]
|
8
|
+
old[var] = old_val
|
9
|
+
end
|
10
|
+
# set the new (temporary) value for the environment variable
|
11
|
+
ENV[var] = value
|
12
|
+
end
|
13
|
+
# execute the caller's block, capture the return value
|
14
|
+
rv = yield
|
15
|
+
# use an ensure block to make absolutely sure we restore the variables
|
16
|
+
ensure
|
17
|
+
# restore the old values
|
18
|
+
values.each do |var, value|
|
19
|
+
if old.include?(var)
|
20
|
+
ENV[var] = old[var]
|
21
|
+
else
|
22
|
+
# if there was no old value, delete the key from the current environment variables hash
|
23
|
+
ENV.delete(var)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
# return the captured return value
|
27
|
+
rv
|
28
|
+
end
|
29
|
+
|
30
|
+
def exec(code)
|
31
|
+
|
32
|
+
## Set LANG to force i18n to C for the duration of this exec; this ensures that any code that parses the
|
33
|
+
## output of the command can expect it to be in a consistent / predictable format / locale
|
34
|
+
with_env "LANG" => "C" do
|
35
|
+
|
36
|
+
if expanded_code = expand_command(code)
|
37
|
+
# if we can find the binary, we'll run the command with the expanded path to the binary
|
38
|
+
code = expanded_code
|
39
|
+
else
|
40
|
+
return ''
|
41
|
+
end
|
42
|
+
|
43
|
+
out = ''
|
44
|
+
|
45
|
+
begin
|
46
|
+
wait_for_child = true
|
47
|
+
out = %x{#{code}}.chomp
|
48
|
+
wait_for_child = false
|
49
|
+
rescue => detail
|
50
|
+
Facter.warn(detail.message)
|
51
|
+
return ''
|
52
|
+
ensure
|
53
|
+
if wait_for_child
|
54
|
+
# We need to ensure that if this code exits early then any spawned
|
55
|
+
# children will be reaped. Process execution is frequently
|
56
|
+
# terminated using Timeout.timeout but since the timeout isn't in
|
57
|
+
# this scope we can't rescue the raised exception. The best that
|
58
|
+
# we can do is determine if the child has exited, and if it hasn't
|
59
|
+
# then we need to spawn a thread to wait for the child.
|
60
|
+
#
|
61
|
+
# Due to the limitations of Ruby 1.8 there aren't good ways to
|
62
|
+
# asynchronously run a command and grab the PID of that command
|
63
|
+
# using the standard library. The best we can do is blindly wait
|
64
|
+
# on all processes and hope for the best. This issue is described
|
65
|
+
# at https://tickets.puppetlabs.com/browse/FACT-150
|
66
|
+
Thread.new { Process.waitall }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
out
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Facter::Core::Execution::Posix < Facter::Core::Execution::Base
|
2
|
+
|
3
|
+
DEFAULT_SEARCH_PATHS = ['/sbin', '/usr/sbin']
|
4
|
+
|
5
|
+
def search_paths
|
6
|
+
# Make sure facter is usable even for non-root users. Most commands
|
7
|
+
# in /sbin (like ifconfig) can be run as non privileged users as
|
8
|
+
# long as they do not modify anything - which we do not do with facter
|
9
|
+
ENV['PATH'].split(File::PATH_SEPARATOR) + DEFAULT_SEARCH_PATHS
|
10
|
+
end
|
11
|
+
|
12
|
+
def which(bin)
|
13
|
+
if absolute_path?(bin)
|
14
|
+
return bin if File.executable?(bin)
|
15
|
+
else
|
16
|
+
search_paths.each do |dir|
|
17
|
+
dest = File.join(dir, bin)
|
18
|
+
return dest if File.executable?(dest)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
ABSOLUTE_PATH_REGEX = %r{^/}
|
25
|
+
|
26
|
+
def absolute_path?(path)
|
27
|
+
!! (path =~ ABSOLUTE_PATH_REGEX)
|
28
|
+
end
|
29
|
+
|
30
|
+
DOUBLE_QUOTED_COMMAND = /^"(.+?)"(?:\s+(.*))?/
|
31
|
+
SINGLE_QUOTED_COMMAND = /^'(.+?)'(?:\s+(.*))?/
|
32
|
+
|
33
|
+
def expand_command(command)
|
34
|
+
exe = nil
|
35
|
+
args = nil
|
36
|
+
|
37
|
+
if (match = (command.match(DOUBLE_QUOTED_COMMAND) || command.match(SINGLE_QUOTED_COMMAND)))
|
38
|
+
exe, args = match.captures
|
39
|
+
else
|
40
|
+
exe, args = command.split(/ /,2)
|
41
|
+
end
|
42
|
+
|
43
|
+
if exe and (expanded = which(exe))
|
44
|
+
expanded = "'#{expanded}'" if expanded.match(/\s/)
|
45
|
+
expanded << " #{args}" if args
|
46
|
+
|
47
|
+
return expanded
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Facter::Core::Execution::Windows < Facter::Core::Execution::Base
|
2
|
+
|
3
|
+
def search_paths
|
4
|
+
ENV['PATH'].split(File::PATH_SEPARATOR)
|
5
|
+
end
|
6
|
+
|
7
|
+
DEFAULT_COMMAND_EXTENSIONS = %w[.COM .EXE .BAT .CMD]
|
8
|
+
|
9
|
+
def which(bin)
|
10
|
+
if absolute_path?(bin)
|
11
|
+
return bin if File.executable?(bin)
|
12
|
+
else
|
13
|
+
search_paths.each do |dir|
|
14
|
+
dest = File.join(dir, bin)
|
15
|
+
dest.gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
|
16
|
+
if File.extname(dest).empty?
|
17
|
+
exts = ENV['PATHEXT']
|
18
|
+
exts = exts ? exts.split(File::PATH_SEPARATOR) : DEFAULT_COMMAND_EXTENSIONS
|
19
|
+
exts.each do |ext|
|
20
|
+
destext = dest + ext
|
21
|
+
return destext if File.executable?(destext)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
return dest if File.executable?(dest)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
slash = '[\\\\/]'
|
31
|
+
name = '[^\\\\/]+'
|
32
|
+
ABSOLUTE_PATH_REGEX = %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i
|
33
|
+
|
34
|
+
def absolute_path?(path)
|
35
|
+
!! (path =~ ABSOLUTE_PATH_REGEX)
|
36
|
+
end
|
37
|
+
|
38
|
+
DOUBLE_QUOTED_COMMAND = /^"(.+?)"(?:\s+(.*))?/
|
39
|
+
|
40
|
+
def expand_command(command)
|
41
|
+
exe = nil
|
42
|
+
args = nil
|
43
|
+
|
44
|
+
if (match = command.match(DOUBLE_QUOTED_COMMAND))
|
45
|
+
exe, args = match.captures
|
46
|
+
else
|
47
|
+
exe, args = command.split(/ /,2)
|
48
|
+
end
|
49
|
+
|
50
|
+
if exe and (expanded = which(exe))
|
51
|
+
expanded = "\"#{expanded}\"" if expanded.match(/\s+/)
|
52
|
+
expanded << " #{args}" if args
|
53
|
+
|
54
|
+
return expanded
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'facter'
|
2
|
+
|
3
|
+
module Facter::Core::Logging
|
4
|
+
|
5
|
+
extend self
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
GREEN = "[0;32m"
|
9
|
+
# @api private
|
10
|
+
RESET = "[0m"
|
11
|
+
|
12
|
+
# @api private
|
13
|
+
@@debug = false
|
14
|
+
# @api private
|
15
|
+
@@timing = false
|
16
|
+
# @api private
|
17
|
+
@@trace = false
|
18
|
+
|
19
|
+
# @api private
|
20
|
+
@@warn_messages = {}
|
21
|
+
# @api private
|
22
|
+
@@debug_messages = {}
|
23
|
+
|
24
|
+
# Prints a debug message if debugging is turned on
|
25
|
+
#
|
26
|
+
# @param msg [String] the debug message
|
27
|
+
# @return [void]
|
28
|
+
def debug(msg)
|
29
|
+
if self.debugging?
|
30
|
+
if msg.nil? or msg.empty?
|
31
|
+
invoker = caller[0].slice(/.*:\d+/)
|
32
|
+
self.warn "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}"
|
33
|
+
else
|
34
|
+
puts GREEN + msg + RESET
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Prints a debug message only once.
|
40
|
+
#
|
41
|
+
# @note Uniqueness is based on the string, not the specific location
|
42
|
+
# of the method call.
|
43
|
+
#
|
44
|
+
# @param msg [String] the debug message
|
45
|
+
# @return [void]
|
46
|
+
def debugonce(msg)
|
47
|
+
if msg and not msg.empty? and @@debug_messages[msg].nil?
|
48
|
+
@@debug_messages[msg] = true
|
49
|
+
debug(msg)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Prints a warning message. The message is only printed if debugging
|
54
|
+
# is enabled.
|
55
|
+
#
|
56
|
+
# @param msg [String] the warning message to be printed
|
57
|
+
#
|
58
|
+
# @return [void]
|
59
|
+
def warn(msg)
|
60
|
+
if msg.nil? or msg.empty?
|
61
|
+
invoker = caller[0].slice(/.*:\d+/)
|
62
|
+
Kernel.warn "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}"
|
63
|
+
else
|
64
|
+
Kernel.warn msg
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Prints a warning message only once per process. Each unique string
|
69
|
+
# is printed once.
|
70
|
+
#
|
71
|
+
# @note Unlike {warn} the message will be printed even if debugging is
|
72
|
+
# not turned on. This behavior is likely to change and should not be
|
73
|
+
# relied on.
|
74
|
+
#
|
75
|
+
# @param msg [String] the warning message to be printed
|
76
|
+
#
|
77
|
+
# @return [void]
|
78
|
+
def warnonce(msg)
|
79
|
+
if @@warn_messages[msg].nil?
|
80
|
+
self.warn(msg)
|
81
|
+
@@warn_messages[msg] = true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def log_exception(exception, message = :default)
|
86
|
+
self.warn(format_exception(exception, message, @@trace))
|
87
|
+
end
|
88
|
+
|
89
|
+
def format_exception(exception, message, trace)
|
90
|
+
arr = []
|
91
|
+
|
92
|
+
if message == :default
|
93
|
+
arr << exception.message
|
94
|
+
elsif message
|
95
|
+
arr << message
|
96
|
+
end
|
97
|
+
|
98
|
+
if trace
|
99
|
+
arr.concat(exception.backtrace)
|
100
|
+
end
|
101
|
+
|
102
|
+
arr.flatten.join("\n")
|
103
|
+
end
|
104
|
+
|
105
|
+
# Print an exception message, and optionally a backtrace if trace is set
|
106
|
+
|
107
|
+
# Print timing information
|
108
|
+
#
|
109
|
+
# @param string [String] the time to print
|
110
|
+
# @return [void]
|
111
|
+
#
|
112
|
+
# @api private
|
113
|
+
def show_time(string)
|
114
|
+
$stderr.puts "#{GREEN}#{string}#{RESET}" if string and self.timing?
|
115
|
+
end
|
116
|
+
|
117
|
+
# Enable or disable logging of debug messages
|
118
|
+
#
|
119
|
+
# @param bool [true, false]
|
120
|
+
# @return [void]
|
121
|
+
#
|
122
|
+
# @api private
|
123
|
+
def debugging(bool)
|
124
|
+
@@debug = bool
|
125
|
+
end
|
126
|
+
|
127
|
+
# Is debugging enabled?
|
128
|
+
#
|
129
|
+
# @return [true, false]
|
130
|
+
#
|
131
|
+
# @api private
|
132
|
+
def debugging?
|
133
|
+
@@debug
|
134
|
+
end
|
135
|
+
|
136
|
+
# Enable or disable logging of timing information
|
137
|
+
#
|
138
|
+
# @param bool [true, false]
|
139
|
+
# @return [void]
|
140
|
+
#
|
141
|
+
# @api private
|
142
|
+
def timing(bool)
|
143
|
+
@@timing = bool
|
144
|
+
end
|
145
|
+
|
146
|
+
# Returns whether timing output is turned on
|
147
|
+
#
|
148
|
+
# @api private
|
149
|
+
def timing?
|
150
|
+
@@timing
|
151
|
+
end
|
152
|
+
|
153
|
+
def trace(bool)
|
154
|
+
@@trace = bool
|
155
|
+
end
|
156
|
+
|
157
|
+
def trace?
|
158
|
+
@@trace
|
159
|
+
end
|
160
|
+
|
161
|
+
# Clears the seen state of warning messages. See {warnonce}.
|
162
|
+
#
|
163
|
+
# @return [void]
|
164
|
+
#
|
165
|
+
# @api private
|
166
|
+
def clear_messages
|
167
|
+
@@warn_messages.clear
|
168
|
+
end
|
169
|
+
end
|