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

Inherits:
Base
  • Object
show all
Defined in:
lib/pec/handler/user_data/nic/rhel.rb

Constant Summary

Constants inherited from Base

Base::CONFIG, Base::NAME

Class Method Summary collapse

Methods inherited from Base

gen_user_data, safe_merge

Class Method Details

.default_path(port) ⇒ Object



23
24
25
# File 'lib/pec/handler/user_data/nic/rhel.rb', line 23

def default_path(port)
  "/etc/sysconfig/network-scripts/ifcfg-#{port.name}"
end

.ifcfg_config(network, port) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pec/handler/user_data/nic/rhel.rb', line 6

def ifcfg_config(network, port)
  base = {
    "name"      => port.name,
    "device"    => port.name,
    "type"      => 'Ethernet',
    "onboot"    => 'yes',
    "hwaddr"    => port.mac_address
  }
  base.merge!(
    {
      "netmask" => IP.new(network[CONFIG]['ip_address']).netmask.to_s,
      "ipaddr"  => port.fixed_ips.first['ip_address']
    }
  ) if network[CONFIG]['bootproto'] == "static"
  safe_merge(base, network).map {|k,v| "#{k.upcase}=#{v}"}.join("\n")
end