Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 1 | {%- set macaddress = item.key -%} |
| 2 | {%- set device = item.value -%} |
Vamsi Savaram | 13de6ca | 2019-08-07 09:09:42 +0000 | [diff] [blame] | 3 | {%- for selected_net_name, selected_net in idf.net_config.items() if node.interfaces[selected_net.interface].mac_address == macaddress -%} |
Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 4 | {%- set selected_inf = node.interfaces[selected_net.interface] -%} |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 5 | {%- set ifname = device if selected_inf.vlan == 'native' else device + '.' + selected_inf.vlan -%} |
Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 6 | |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 7 | auto {{ ifname }} |
Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 8 | {% if selected_inf.address == "dhcp" %} |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 9 | iface {{ ifname }} inet dhcp |
Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 10 | {% if selected_net.gateway is defined %} |
| 11 | up route add default gateway {{ selected_net.gateway | ipaddr('address') }} |
Wenqing Gu | c05952c | 2019-03-05 15:36:44 +0100 | [diff] [blame] | 12 | {% endif %} |
Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 13 | {% elif selected_inf.address == "manual" %} |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 14 | iface {{ ifname }} inet manual |
Wenqing Gu | a6e4f65 | 2019-03-04 06:37:40 -0800 | [diff] [blame] | 15 | {% else %} |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 16 | iface {{ ifname }} inet static |
Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 17 | address {{ selected_inf.address | ipaddr('address') }} |
| 18 | netmask {{ (selected_net.network + "/" + (selected_net.mask | string)) | ipaddr('netmask') }} |
| 19 | {% if selected_net.gateway is defined %} |
| 20 | gateway {{ selected_net.gateway | ipaddr('address') }} |
Wenqing Gu | c05952c | 2019-03-05 15:36:44 +0100 | [diff] [blame] | 21 | {% endif %} |
Fatih Degirmenci | becbba0 | 2019-02-25 00:37:19 +0000 | [diff] [blame] | 22 | {% endif %} |
Wenqing Gu | 8d933be | 2019-04-10 15:14:32 +0200 | [diff] [blame] | 23 | |
Vamsi Savaram | 13de6ca | 2019-08-07 09:09:42 +0000 | [diff] [blame] | 24 | {%- endfor -%} |