Class: Pec::Coordinate::UserData::Nic

Inherits:
Object
  • Object
show all
Extended by:
Pec::Core
Defined in:
lib/pec/coordinate/user_data/nic.rb,
lib/pec/coordinate/user_data/nic/rhel.rb,
lib/pec/coordinate/user_data/nic/ubuntu.rb

Defined Under Namespace

Classes: Base, Rhel, Ubuntu

Instance Attribute Summary

Attributes included from Pec::Core

#kind

Class Method Summary collapse

Methods included from Pec::Core

build

Class Method Details

.build(host, attribute) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pec/coordinate/user_data/nic.rb', line 10

def build(host, attribute)
  _nic = Pec::Coordinate::UserData::Nic.constants.reject {|c|c.to_s.downcase == "base"}.find do |c|
    host.os_type && Object.const_get("Pec::Coordinate::UserData::Nic::#{c}").os_type.include?(host.os_type)
  end

  nic = if _nic
    Object.const_get("Pec::Coordinate::UserData::Nic::#{_nic}")
  else
    Pec::Coordinate::UserData::Nic::Rhel
  end

  attribute.deep_merge(
    {
      user_data: {
        "write_files" => nic.gen_user_data(host.networks, ports(attribute))
      }
    }
  )
end

.port_ids(attribute) ⇒ Object



36
37
38
# File 'lib/pec/coordinate/user_data/nic.rb', line 36

def port_ids(attribute)
  attribute[:networks].map {|n|n[:port]}
end

.ports(attribute) ⇒ Object



30
31
32
33
34
# File 'lib/pec/coordinate/user_data/nic.rb', line 30

def ports(attribute)
  port_ids(attribute).map do |id|
    Yao::Port.get(id)
  end
end