Class: Kanrisuru::Remote::Os
- Inherits:
-
Object
- Object
- Kanrisuru::Remote::Os
- Defined in:
- lib/kanrisuru/remote/os.rb
Instance Attribute Summary collapse
-
#operating_system ⇒ Object
readonly
Returns the value of attribute operating_system.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
-
#release ⇒ Object
readonly
Returns the value of attribute release.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(host) ⇒ Os
constructor
A new instance of Os.
- #kernel ⇒ Object
- #linux? ⇒ Boolean
- #uname(opts = {}) ⇒ Object
Constructor Details
#initialize(host) ⇒ Os
Returns a new instance of Os.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kanrisuru/remote/os.rb', line 8 def initialize(host) Kanrisuru.logger.info('Gathering OS details') @host = host @kernel_name = uname(kernel_name: true) case @kernel_name when 'Linux' initialize_linux end end |
Instance Attribute Details
#operating_system ⇒ Object (readonly)
Returns the value of attribute operating_system.
6 7 8 |
# File 'lib/kanrisuru/remote/os.rb', line 6 def @operating_system end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
6 7 8 |
# File 'lib/kanrisuru/remote/os.rb', line 6 def processor @processor end |
#release ⇒ Object (readonly)
Returns the value of attribute release.
6 7 8 |
# File 'lib/kanrisuru/remote/os.rb', line 6 def release @release end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/kanrisuru/remote/os.rb', line 6 def version @version end |
Instance Method Details
#kernel ⇒ Object
20 21 22 |
# File 'lib/kanrisuru/remote/os.rb', line 20 def kernel @kernel_name end |
#linux? ⇒ Boolean
24 25 26 |
# File 'lib/kanrisuru/remote/os.rb', line 24 def linux? kernel == 'Linux' end |
#uname(opts = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kanrisuru/remote/os.rb', line 28 def uname(opts = {}) command = Kanrisuru::Command.new('uname') if opts[:all] command.append_flag('-a', opts[:all]) else command.append_flag('-s', opts[:kernel_name]) command.append_flag('-n', opts[:node_name]) command.append_flag('-r', opts[:kernel_release]) command.append_flag('-v', opts[:kernel_version]) command.append_flag('-m', opts[:machine]) command.append_flag('-p', opts[:processor]) command.append_flag('-i', opts[:hardware_platform]) command.append_flag('-o', opts[:operating_system]) end @host.execute(command) return unless command.success? if opts.keys.length > 1 || opts[:all] command.to_a else command.to_s end end |