Merge pull request #58 from smasc/fix_autoconnect

Fix handling of autoconnect parameter
This commit is contained in:
Till Maas 2018-06-11 15:36:15 +02:00 committed by GitHub
commit 70d3e9e96c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 0 deletions

View file

@ -1302,6 +1302,8 @@ class IfcfgUtil:
if connection['autoconnect']:
ifcfg['ONBOOT'] = 'yes'
else:
ifcfg['ONBOOT'] = 'no'
ifcfg['DEVICE'] = connection['interface_name']

View file

@ -347,6 +347,71 @@ class TestValidator(unittest.TestCase):
},
],
)
self.do_connections_validate(
[
{
'name': '5',
'state': 'up',
'type': 'ethernet',
'autoconnect': False,
'parent': None,
'ip': {
'gateway6': None,
'gateway4': None,
'route_metric4': None,
'auto6': True,
'dhcp4': True,
'address': [],
'route_append_only': False,
'rule_append_only': False,
'route': [],
'dns': [],
'dns_search': [],
'route_metric6': None,
'dhcp4_send_hostname': None,
},
'ethernet': {
'autoneg': None,
'duplex': None,
'speed': 0,
},
'mac': None,
'mtu': None,
'zone': None,
'master': None,
'ignore_errors': None,
'interface_name': None,
'check_iface_exists': True,
'force_state_change': None,
'slave_type': None,
'wait': None,
},
],
[
{ 'name': '5',
'state': 'up',
'type': 'ethernet',
'autoconnect': 'no',
},
],
initscripts_dict_expected = [
{
'ifcfg': {
'BOOTPROTO': 'dhcp',
'IPV6INIT': 'yes',
'IPV6_AUTOCONF': 'yes',
'NM_CONTROLLED': 'no',
'ONBOOT': 'no',
'TYPE': 'Ethernet',
},
'keys': None,
'route': None,
'route6': None,
'rule': None,
'rule6': None,
},
],
)
self.do_connections_check_invalid([ { 'name': 'a', 'autoconnect': True }])