mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Adding Unit Tests and Fixing debian_eth.jinja
Had to undo the replace all underscores with dashes in the debian_eth template as that messes up accept_ra which needs to be an underscore to work. Added a Unittest as "eth20" for testing accept_ra and autoconf 1 in IPv6 interfaces.
This commit is contained in:
parent
7580b45fa9
commit
c3f7c4caeb
2 changed files with 34 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
|||
'pre_down_cmds': 'pre-down',
|
||||
'post_down_cmds': 'post-down',
|
||||
'master': 'bond-master',
|
||||
'accept_ra': 'accept_ra',
|
||||
} -%}
|
||||
{% set concat_opts = ['dns_nameservers'] -%}
|
||||
{% set valid_opts = [
|
||||
|
@ -16,14 +17,14 @@
|
|||
'vendor', 'client', 'bootfile', 'server', 'mode', 'endpoint', 'dstaddr', 'local', 'ttl', 'mtu',
|
||||
'provider', 'unit', 'options', 'master', 'dns_nameservers', 'wireless_mode', 'wpa_ap_scan',
|
||||
'wpa_conf', 'wpa_driver', 'wpa_group', 'wpa_key_mgmt', 'wpa_pairwise', 'wpa_proto', 'wpa_psk',
|
||||
'wpa_roam', 'wpa_ssid',
|
||||
'wpa_roam', 'wpa_ssid', 'accept_ra'
|
||||
] -%}
|
||||
{% if data.enabled %}auto {{ name }}
|
||||
{% endif %}{% if data.hotplug %}allow-hotplug {{ name }}
|
||||
{% endif %}{% for inet in ['inet', 'inet6'] -%}
|
||||
{% if data.data[inet] and data.data[inet].addrfam == inet %}{% set interface = data.data[inet] -%}
|
||||
{% if interface.proto and interface.addrfam %}iface {{name}} {{interface.addrfam}} {{interface.proto}}
|
||||
{% for opt in valid_opts %}{% set debopt = optmap.get(opt, opt).replace('_', '-') -%}
|
||||
{% for opt in valid_opts %}{% set debopt = optmap.get(opt, opt.replace('_', '-')) -%}
|
||||
{% set val = interface.get(opt, False) %}{% if val -%}
|
||||
{% if opt in concat_opts and val is iterable %} {{ debopt }} {{ val|join(' ') }}
|
||||
{% elif val is string or val is number %} {{ debopt }} {{ val }}
|
||||
|
|
|
@ -779,6 +779,37 @@ test_interfaces = [
|
|||
' address 2001:db8:dead:c0::3/64\n',
|
||||
' gateway 2001:db8:dead:c0::1\n',
|
||||
'\n']},
|
||||
|
||||
# IPv6-only; static with autoconf and accept_ra forced
|
||||
{'iface_name': 'eth20', 'iface_type': 'eth', 'enabled': True,
|
||||
'build_interface': {
|
||||
'ipv6proto': 'static',
|
||||
'ipv6ipaddr': '2001:db8:dead:beef::3/64',
|
||||
'ipv6gateway': '2001:db8:dead:beef::1',
|
||||
'enable_ipv6': True,
|
||||
'autoconf': 1,
|
||||
'accept_ra': 2,
|
||||
'noifupdown': True,
|
||||
},
|
||||
'get_interface': odict([('eth20', odict([('enabled', True), ('data', odict([
|
||||
('inet6', odict([
|
||||
('addrfam', 'inet6'),
|
||||
('proto', 'static'),
|
||||
('filename', None),
|
||||
('autoconf', 1),
|
||||
('address', '2001:db8:dead:beef::3/64'),
|
||||
('gateway', '2001:db8:dead:beef::1'),
|
||||
('accept_ra', 2),
|
||||
])),
|
||||
]))]))]),
|
||||
'return': [
|
||||
'auto eth20\n',
|
||||
'iface eth20 inet6 static\n',
|
||||
' autoconf 1\n',
|
||||
' address 2001:db8:dead:beef::3/64\n',
|
||||
' gateway 2001:db8:dead:beef::1\n',
|
||||
' accept_ra 2\n',
|
||||
'\n']},
|
||||
]
|
||||
# fmt: on
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue