module: fix default value for dhcp4_send_hostname

We should not set "dhcp4_send_hostname" unless it is explicitly
present in the configuration. That is because initscripts don't
support this parameter and issue a warning.
This commit is contained in:
Thomas Haller 2017-03-02 16:36:19 +01:00
parent cd2030cde6
commit d88e79ac8c
2 changed files with 2 additions and 4 deletions

View file

@ -619,9 +619,7 @@ class ArgValidator_DictIP(ArgValidatorDict):
result['dhcp4'] = result['dhcp4_send_hostname'] is not None or not any([a for a in result['address'] if a['is_v4']])
if result['auto6'] is None:
result['auto6'] = not any([a for a in result['address'] if not a['is_v4']])
if result['dhcp4_send_hostname'] is None:
result['dhcp4_send_hostname'] = False
else:
if result['dhcp4_send_hostname'] is not None:
if not result['dhcp4']:
raise ValidationError(name, '"dhcp4_send_hostname" is only valid if "dhcp4" is enabled')
return result

View file

@ -272,7 +272,7 @@ class TestValidator(unittest.TestCase):
'dns_search': [ 'aa', 'bb' ],
'route_metric6': None,
'ip_is_present': True,
'dhcp4_send_hostname': False,
'dhcp4_send_hostname': None,
},
'mac': None,
'master': None,