Class: MCMD::MpcManager
- Inherits:
-
Object
- Object
- MCMD::MpcManager
- Defined in:
- lib/nysol/mparallelmanager.rb
Instance Attribute Summary collapse
-
#localIP ⇒ Object
readonly
Returns the value of attribute localIP.
Instance Method Summary collapse
- #each ⇒ Object
- #getIP(no) ⇒ Object
- #getPWD(no) ⇒ Object
- #getPWDbyIP(ip) ⇒ Object
- #getUID(no) ⇒ Object
- #getUIDbyIP(ip) ⇒ Object
- #has_IP?(ip) ⇒ Boolean
-
#initialize(fn = "/etc/pclist") ⇒ MpcManager
constructor
A new instance of MpcManager.
- #pcCount ⇒ Object
Constructor Details
#initialize(fn = "/etc/pclist") ⇒ MpcManager
Returns a new instance of MpcManager.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nysol/mparallelmanager.rb', line 24 def initialize(fn="/etc/pclist") @localIP = MCMD::SysInfo.getMyIP @pcIP = [] @pcUID = [] @pcPWD = [] @ip2No = {} File.open(fn){|fp| while lin = fp.gets do next if lin =~ /^#/ lins = lin.chomp.split @pcIP << lins[1] @pcUID << lins[0] @pcPWD << lins[2] @ip2No[lins[1]] = @pcIP.size-1 end } end |
Instance Attribute Details
#localIP ⇒ Object (readonly)
Returns the value of attribute localIP.
74 75 76 |
# File 'lib/nysol/mparallelmanager.rb', line 74 def localIP @localIP end |
Instance Method Details
#each ⇒ Object
41 42 43 44 45 |
# File 'lib/nysol/mparallelmanager.rb', line 41 def each (0...@pcIP.size).each{|i| yield @pcIP[i],@pcUID[i],@pcPWD[i] } end |
#getIP(no) ⇒ Object
51 52 53 |
# File 'lib/nysol/mparallelmanager.rb', line 51 def getIP(no) return @pcIP[no] end |
#getPWD(no) ⇒ Object
57 58 59 |
# File 'lib/nysol/mparallelmanager.rb', line 57 def getPWD(no) return @pcPWD[no] end |
#getPWDbyIP(ip) ⇒ Object
68 69 70 71 |
# File 'lib/nysol/mparallelmanager.rb', line 68 def getPWDbyIP(ip) return nil unless @ip2No.has_key?(ip) return getPWD(@ip2No[ip]) end |
#getUID(no) ⇒ Object
54 55 56 |
# File 'lib/nysol/mparallelmanager.rb', line 54 def getUID(no) return @pcUID[no] end |
#getUIDbyIP(ip) ⇒ Object
64 65 66 67 |
# File 'lib/nysol/mparallelmanager.rb', line 64 def getUIDbyIP(ip) return nil unless @ip2No.has_key?(ip) return getUID(@ip2No[ip]) end |
#has_IP?(ip) ⇒ Boolean
60 61 62 |
# File 'lib/nysol/mparallelmanager.rb', line 60 def has_IP?(ip) return @ip2No.has_key?(ip) end |
#pcCount ⇒ Object
48 49 50 |
# File 'lib/nysol/mparallelmanager.rb', line 48 def pcCount return @pcIP.size end |