Class: Cute::TakTuk::Hostlist Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cute/taktuk.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Generates a taktuk CLI compatible host list

Instance Method Summary collapse

Constructor Details

#initialize(hostlist) ⇒ Hostlist

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Hostlist.



240
241
242
# File 'lib/cute/taktuk.rb', line 240

def initialize(hostlist)
  @hostlist=hostlist
end

Instance Method Details

#exclude(node) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



248
249
250
# File 'lib/cute/taktuk.rb', line 248

def exclude(node)
  @hostlist.remove(node) if @hostlist.is_a?(Array)
end

#freeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



244
245
246
# File 'lib/cute/taktuk.rb', line 244

def free
  @hostlist = nil
end

#to_aObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



266
267
268
269
270
271
272
273
# File 'lib/cute/taktuk.rb', line 266

def to_a
  if @hostlist.is_a?(Array)
    @hostlist
  elsif @hostlist.is_a?(String)
    raise "Hostfile does not exist" unless File.exist?(@hostlist)
    File.read(@hostlist).split("\n").uniq
  end
end

#to_cmdObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/cute/taktuk.rb', line 252

def to_cmd
  ret = []
  if @hostlist.is_a?(Array)
    @hostlist.each do |host|
      ret << '-m'
      ret << host
    end
  elsif @hostlist.is_a?(String)
    ret << '-f'
    ret << @hostlist
  end
  ret
end