Module: Ohai::Mixin::OS
Instance Method Summary collapse
-
#collect_os ⇒ String
Using ruby configuration determine the OS we’re running on.
- #collect_os_local ⇒ Object private
-
#collect_os_target ⇒ Object
private
This should exactly preserve the semantics of collect_os_local below, which is authoritative for the API and must adhere to pre-existing ohai semantics and not follow inspec’s notion of os/family/hierarchy.
- #nonruby_target? ⇒ Boolean private
Instance Method Details
#collect_os ⇒ String
Using ruby configuration determine the OS we’re running on
30 31 32 33 34 35 36 |
# File 'lib/ohai/mixin/os.rb', line 30 def collect_os if target_mode? collect_os_target else collect_os_local end end |
#collect_os_local ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/ohai/mixin/os.rb', line 95 def collect_os_local case ::RbConfig::CONFIG["host_os"] when /aix(.+)$/ "aix" when /darwin(.+)$/ "darwin" when /linux/ "linux" when /freebsd(.+)$/ "freebsd" when /openbsd(.+)$/ "openbsd" when /netbsd(.*)$/ "netbsd" when /dragonfly(.*)$/ "dragonflybsd" when /solaris2/ "solaris2" when /mswin|mingw|windows/ # After long discussion in IRC the "powers that be" have come to a consensus # that no Windows platform exists that was not based on the # Windows_NT kernel, so we herby decree that "windows" will refer to all # platforms built upon the Windows_NT kernel and have access to win32 or win64 # subsystems. "windows" else ::RbConfig::CONFIG["host_os"] end end |
#collect_os_target ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should exactly preserve the semantics of collect_os_local below, which is authoritative for the API and must adhere to pre-existing ohai semantics and not follow inspec’s notion of os/family/hierarchy.
Right or wrong the ohai ‘os` variable has matched the ruby `host_os` definition for the past 10+ years, preceding inspec/train’s definitions and this is the documented correct API of these methods. Mismatches between the ruby notion and the train version will be fixed as bugfixes in these methods and may not be considered semver violating even though they make break downstream consumers. Please ensure that both methods produce the same results if you are on a platform which supports running ruby (train is considered authoritative for any “OS” which cannot run ruby – server consoles, REST APIs, etc…)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ohai/mixin/os.rb', line 51 def collect_os_target case when transport_connection.os.aix? "aix" when transport_connection.os.darwin? "darwin" when transport_connection.os.linux? "linux" when transport_connection.os.family == "freebsd" "freebsd" when transport_connection.os.family == "openbsd" "openbsd" when transport_connection.os.family == "netbsd" "netbsd" when transport_connection.os.family == "dragonflybsd" "dragonflybsd" when transport_connection.os.solaris? "solaris2" when transport_connection.os.windows? "windows" # # The purpose of the next two lines is that anything which runs Unix is presumed to be able to run ruby, and # if it was not caught above, we MUST translate whatever train uses as the 'os' into the proper ruby host_os # string. If it is not unix and not caught above we assume it is something like a REST API which cannot run # ruby. If these assumptions are incorrect then it is a bug, which should be submitted to fix it, and the # values should not be relied upon until that bug is fixed. The train os is NEVER considered authoritative # for any target which can run ruby. # when transport_connection.os.unix? raise "Target mode unsupported on this Unix-like host, please update the collect_os_target case statement with the correct ruby host_os value." else # now we have something like an IPMI console that isn't Unix-like or Windows, presumably cannot run ruby, and # so we just trust the train O/S information. transport_connection.os.name end end |
#nonruby_target? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
90 91 92 |
# File 'lib/ohai/mixin/os.rb', line 90 def nonruby_target? transport_connection && !transport_connection.os.unix? && !transport_connection.os.windows? end |