Class: Construqt::HostId

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/hostid.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#interfacesObject

Returns the value of attribute interfaces.



4
5
6
# File 'lib/construqt/hostid.rb', line 4

def interfaces
  @interfaces
end

Class Method Details

.create(&block) ⇒ Object



5
6
7
8
9
10
# File 'lib/construqt/hostid.rb', line 5

def self.create(&block)
  a = HostId.new()
  a.interfaces=[]
  block.call(a)
  return a
end

Instance Method Details

#first_ipv4Object



36
37
38
39
40
# File 'lib/construqt/hostid.rb', line 36

def first_ipv4
  ret = first_ipv4!
  throw "first_ipv4 failed #{self.interfaces.first.host.name}" unless ret
  ret
end

#first_ipv4!Object



27
28
29
30
31
32
33
34
# File 'lib/construqt/hostid.rb', line 27

def first_ipv4!
  self.interfaces.each do |i|
    next unless i.address
    return i.address if i.address.first_ipv4
  end

  nil
end

#first_ipv6Object



21
22
23
24
25
# File 'lib/construqt/hostid.rb', line 21

def first_ipv6
  ret = first_ipv6!
  throw "first_ipv6 failed #{self.interfaces.first.host.name}" unless ret
  ret
end

#first_ipv6!Object



12
13
14
15
16
17
18
19
# File 'lib/construqt/hostid.rb', line 12

def first_ipv6!
  self.interfaces.each do |i|
    next unless i.address
    return i.address if i.address.first_ipv6
  end

  nil
end