Class: Hostlist

Inherits:
Object
  • Object
show all
Defined in:
lib/mofa/hostlist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#concrete_targetObject

Returns the value of attribute concrete_target.



7
8
9
# File 'lib/mofa/hostlist.rb', line 7

def concrete_target
  @concrete_target
end

#listObject

Returns the value of attribute list.



6
7
8
# File 'lib/mofa/hostlist.rb', line 6

def list
  @list
end

Class Method Details

.create(concrete_target) ⇒ Object



9
10
11
12
13
# File 'lib/mofa/hostlist.rb', line 9

def self.create(concrete_target)
  hl = Hostlist.new
  hl.concrete_target = concrete_target
  hl
end

.get_role(hostname) ⇒ Object



19
20
21
# File 'lib/mofa/hostlist.rb', line 19

def self.get_role(hostname)
  Hostlist::get_shortname(hostname).gsub(/\d+$/, '')
end

.get_shortname(hostname) ⇒ Object



15
16
17
# File 'lib/mofa/hostlist.rb', line 15

def self.get_shortname(hostname)
  hostname.gsub(/\..*$/, '')
end

Instance Method Details

#filter_by_runlist_map(runlist_map) ⇒ Object



32
33
34
# File 'lib/mofa/hostlist.rb', line 32

def filter_by_runlist_map(runlist_map)
  @list.select! { |hostname| runlist_map.mp.key?(hostname) }
end

#retrieveObject



23
24
25
# File 'lib/mofa/hostlist.rb', line 23

def retrieve
  @list = [@concrete_target]
end

#up?Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/mofa/hostlist.rb', line 27

def up?
  p = Net::Ping::TCP.new(@service_host, 'http')
  p.ping?
end