Class: Moab::Scheduler
- Inherits:
-
Object
- Object
- Moab::Scheduler
- Defined in:
- lib/moab/scheduler.rb
Overview
Object used for simplified communication with a moab scheduler server
Instance Attribute Summary collapse
-
#bin ⇒ Pathname
readonly
The path to the Moab client installation binaries.
-
#host ⇒ String
readonly
The host of the Moab scheduler server.
-
#lib ⇒ Pathname
readonly
The path to the Moab client installation libraries.
-
#moabhomedir ⇒ Pathname
readonly
The path to the Moab home dir.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
The comparison operator.
-
#call(cmd, *args, env: {}) ⇒ Nokogiri::Document
Call a binary command from the moab client installation.
-
#eql?(other) ⇒ Boolean
Check whether objects are identical to each other.
-
#hash ⇒ Fixnum
Generate a hash value for this object.
-
#initialize(host:, lib: "", bin: "", moabhomedir: ENV['MOABHOMEDIR']) ⇒ Scheduler
constructor
A new instance of Scheduler.
-
#to_h ⇒ Hash
Convert object to hash.
Constructor Details
#initialize(host:, lib: "", bin: "", moabhomedir: ENV['MOABHOMEDIR']) ⇒ Scheduler
Returns a new instance of Scheduler.
35 36 37 38 39 40 |
# File 'lib/moab/scheduler.rb', line 35 def initialize(host:, lib: "", bin: "", moabhomedir: ENV['MOABHOMEDIR']) @host = host.to_s @lib = Pathname.new(lib.to_s) @bin = Pathname.new(bin.to_s) @moabhomedir = Pathname.new(moabhomedir.to_s) end |
Instance Attribute Details
#bin ⇒ Pathname (readonly)
The path to the Moab client installation binaries
23 24 25 |
# File 'lib/moab/scheduler.rb', line 23 def bin @bin end |
#host ⇒ String (readonly)
The host of the Moab scheduler server
11 12 13 |
# File 'lib/moab/scheduler.rb', line 11 def host @host end |
#lib ⇒ Pathname (readonly)
The path to the Moab client installation libraries
17 18 19 |
# File 'lib/moab/scheduler.rb', line 17 def lib @lib end |
#moabhomedir ⇒ Pathname (readonly)
The path to the Moab home dir
29 30 31 |
# File 'lib/moab/scheduler.rb', line 29 def moabhomedir @moabhomedir end |
Instance Method Details
#==(other) ⇒ Boolean
The comparison operator
51 52 53 |
# File 'lib/moab/scheduler.rb', line 51 def ==(other) to_h == other.to_h end |
#call(cmd, *args, env: {}) ⇒ Nokogiri::Document
Call a binary command from the moab client installation
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/moab/scheduler.rb', line 75 def call(cmd, *args, env: {}) cmd = bin.join(cmd.to_s).to_s args = ["--host=#{@host}", "--xml"] + args.map(&:to_s) env = { "LD_LIBRARY_PATH" => "#{lib}:#{ENV['LD_LIBRARY_PATH']}", "MOABHOMEDIR" => "#{moabhomedir}" }.merge(env.to_h) o, e, s = Open3.capture3(env, cmd, *args) s.success? ? Nokogiri::XML(o) : raise(CommandFailed, e) rescue Errno::ENOENT => e raise InvalidCommand, e. end |
#eql?(other) ⇒ Boolean
Check whether objects are identical to each other
58 59 60 |
# File 'lib/moab/scheduler.rb', line 58 def eql?(other) self.class == other.class && self == other end |
#hash ⇒ Fixnum
Generate a hash value for this object
64 65 66 |
# File 'lib/moab/scheduler.rb', line 64 def hash [self.class, to_h].hash end |
#to_h ⇒ Hash
Convert object to hash
44 45 46 |
# File 'lib/moab/scheduler.rb', line 44 def to_h {host: host, lib: lib, bin: bin, moabhomedir: moabhomedir} end |