12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/pec/configure/user_data.rb', line 12
def make_port_content(config, ports)
config.networks.map do |ether|
port_content = {}
port_content["name"] = ether.name unless ether.options.key?('name')
port_content["device"] = ether.name unless ether.options.key?('device')
port_content["type"] = 'Ethernet' unless ether.options.key?('type')
port_content["onboot"] = "yes" unless ether.options.key?('onboot')
_path = "/etc/sysconfig/network-scripts/ifcfg-#{ether.name}" unless ether.options.key?('path')
port = ports.find {|p| p.name == ether.name}
if port
port_content["netmask"] = port.netmask
port_content["hwaddr"] = port.mac_address
port_content["ipaddr"] = port.ip_address
end
port_content.merge!(ether.options)
{
'content' => port_content.map {|k,v| "#{k.upcase}=#{v}"}.join("\n"),
'owner' => "root:root",
'path' => _path,
'permissions' => "0644"
}
end
end
|