Class: Pec::Handler::UserData::Nic

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

Defined Under Namespace

Classes: Base, Rhel, Ubuntu

Instance Attribute Summary

Attributes included from Core

#kind

Class Method Summary collapse

Methods included from Core

build, post_build, recover

Class Method Details

.port_ids(attribute) ⇒ Object



35
36
37
# File 'lib/pec/handler/user_data/nic.rb', line 35

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

.ports(attribute) ⇒ Object



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

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

.post_build(config, attribute) ⇒ Object



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

def post_build(config, attribute)
  nic = if config.os_type
    os = Pec::Handler::UserData::Nic.constants.find do |c|
      Object.const_get("Pec::Handler::UserData::Nic::#{c}").os_type.include?(config.os_type)
    end
    Object.const_get("Pec::Handler::UserData::Nic::#{os}")
  else
    Pec::Handler::UserData::Nic::Rhel
  end

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