class Moab::Scheduler
Object used for simplified communication with a moab scheduler server
Attributes
The host of the Moab
scheduler server @example OSC's Oakley scheduler server
my_conn.host #=> "oak-batch.osc.edu"
@return [String] the scheduler server host
The path to the Moab
home dir @example
my_conn.moabhomedir.to_s #=> "/var/spool/batch/moab"
@return [Pathname] path to moab home dir
Public Class Methods
@param host [#to_s] the moab scheduler server @param lib [#to_s] path to moab installation libraries @param bin [#to_s] path to moab installation binaries @param moabhomedir [#to_s] path to moab home dir
# 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
Public Instance Methods
The comparison operator @param other [#to_h] object to compare against @return [Boolean] whether objects are equivalent
# File lib/moab/scheduler.rb, line 51 def ==(other) to_h == other.to_h end
Call a binary command from the moab client installation @param cmd [#to_s] command run from command line @param *args [Array<#to_s>] any number of arguments for command @param env [#to_h] environment to run command under @return [Nokogiri::Document] the xml output from command @raise [CommandFailed] if command exits with nonzero exit code @raise [InvalidCommand] if command does not exist
# 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.message end
Check whether objects are identical to each other @param other [#to_h] object to compare against @return [Boolean] whether objects are identical
# File lib/moab/scheduler.rb, line 58 def eql?(other) self.class == other.class && self == other end
Generate a hash value for this object @return [Fixnum] hash value of object
# File lib/moab/scheduler.rb, line 64 def hash [self.class, to_h].hash end
Convert object to hash @return [Hash] the hash describing this object
# File lib/moab/scheduler.rb, line 44 def to_h {host: host, lib: lib, bin: bin, moabhomedir: moabhomedir} end