Module: TORQUE

Defined in:
lib/torque_rm/qsub.rb,
lib/torque_rm/qdel.rb,
lib/torque_rm/qstat.rb,
lib/torque_rm/common.rb

Overview

require ‘ostruct’

Defined Under Namespace

Modules: Qdel Classes: Qstat, Qsub

Constant Summary collapse

@@username =
Etc.getlogin
@@qcommands_path =
'/usr/bin'
@@master =
Rye::Box.new("localhost")
@@conf =
{}

Class Method Summary collapse

Class Method Details

.hostObject

Get the host name/ip of the local/remote server user as submitter/interface to PBS



66
67
68
# File 'lib/torque_rm/common.rb', line 66

def self.host
	self.server.host
end

.hostnameObject

Get the hostname, this may require an internet connection and fully qualified name



71
72
73
# File 'lib/torque_rm/common.rb', line 71

def self.hostname
	self.server.hostname
end

.load_config(file = nil) ⇒ Object

Load configuration, default from file in user home with name .toruqe_rm.yaml



55
56
57
58
# File 'lib/torque_rm/common.rb', line 55

def self.load_config(file=nil)
	self.read_config File.expand_path(file.nil? ? "~/.torque_rm.yaml" : file)
	self
end

.pathObject



36
37
38
# File 'lib/torque_rm/common.rb', line 36

def self.path
	self.qcommands_path
end

.qcommands_pathObject



32
33
34
# File 'lib/torque_rm/common.rb', line 32

def self.qcommands_path
	@@qcommands_path
end

.qcommands_path=(path) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/torque_rm/common.rb', line 24

def self.qcommands_path=(path)
	@@qcommands_path = path
	%w(qstat qsub qdel).each do |command|
	  Rye::Cmd.remove_command command if Rye::Cmd.can? command
	  Rye::Cmd.add_command command, File.join(qcommands_path, command)
	end
end

.read_config(file) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/torque_rm/common.rb', line 40

def self.read_config(file)
	if File.exists?(file)
	  conf = YAML::load( File.open( file) )
    @@conf = conf.dup
    @@conf.delete(:hostname)
    @@conf.delete(:path)
	  self.qcommands_path = conf[:path]
  	self.username = conf[:user] unless conf[:user].nil?
    # self.port = conf[:port] unless conf[:port].nil?
    # self.password = conf[:password] unless conf[:password].nil?
	  self.server = conf[:hostname]
end
end

.save_config(file = nil) ⇒ Object

Save configuration, default in user home with name .toruqe_rm.yaml



61
62
63
# File 'lib/torque_rm/common.rb', line 61

def self.save_config(file=nil)
	File.write File.expand_path(file.nil? ? "~/.torque_rm.yaml" : file), {hostname: @@master.host, path: @@qcommands_path, user: @@username}.to_yaml
end

.serverObject



15
16
17
# File 'lib/torque_rm/common.rb', line 15

def self.server
	@@master
end

.server=(hostname) ⇒ Object



9
10
11
12
13
# File 'lib/torque_rm/common.rb', line 9

def self.server=(hostname)
	if hostname
		@@master = Rye::Box.new(hostname, @@conf)
	end
end

.username=(username) ⇒ Object



19
20
21
# File 'lib/torque_rm/common.rb', line 19

def self.username=(username)
	@@username = username
end