class Pec::Handler::UserData::Nic

Public Class Methods

port_ids(attribute) click to toggle source
# File lib/pec/handler/user_data/nic.rb, line 35
def port_ids(attribute)
  attribute[:networks].map {|n|n[:port]}
end
ports(attribute) click to toggle source
# 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) click to toggle source
# 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