Commit 984c0f33 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Adapted for Fedora-26 idempotency

parent 3f895c42
......@@ -83,6 +83,7 @@ def generate_ifcfgv4(tree, interface, search, nameservers):
if a in n:
netmask = n.netmask
network = n.network
prefixlen = n.prefixlen
broadcast = n.broadcast
gateway = s.gateway[0]
if interface_is_static(interface):
......@@ -101,10 +102,13 @@ def generate_ifcfgv4(tree, interface, search, nameservers):
if ip.gateway[0]: gateway = ip.gateway[0]
if ip.search[0]: search.update(ip.search[0].split())
config.append('IPADDR%s=%s' % (index, a))
if prefixlen:
config.append('PREFIX%s=%s' % (index, prefixlen))
pass
if netmask:
config.append('NETMASK%s=%s' % (index, netmask))
pass
if gateway:
if gateway and index == '':
config.append('GATEWAY%s=%s' % (index, gateway))
pass
if network:
......@@ -118,6 +122,9 @@ def generate_ifcfgv4(tree, interface, search, nameservers):
if interface.defroute[0]:
config.append('DEFROUTE=%s' % interface.defroute[0])
pass
else:
config.append('DEFROUTE=yes')
pass
return config
......@@ -177,8 +184,7 @@ def generate_ifcfgv6(tree, interface, search, nameservers):
pass
pass
if len(address) > 1:
config.append('IPV6ADDR_SECONDARIES="%s"' %
' '.join(address[1:]))
config.append('IPV6ADDR_SECONDARIES=%s' % ' '.join(address[1:]))
pass
pass
return config
......@@ -204,7 +210,7 @@ def generate_ifcfg(tree, interface):
# Remove duplicate nameservers
nameservers = reduce(lambda r,v: v in r and r or r + [v],
nameservers, [])
config.extend(indexed_assign('DNS', nameservers, 1))
config.extend(indexed_assign('DNS', nameservers[0:10], 1))
if search:
def reverse_order(a, b):
a_v = list(reversed(a.split('.')))
......@@ -212,7 +218,12 @@ def generate_ifcfg(tree, interface):
return cmp(a_v, b_v)
tmp = sorted(search, cmp=reverse_order)
config.append('SEARCH="%s"' % (' '.join(tmp)))
config.append('DOMAIN="%s"' % (' '.join(tmp)))
pass
config.append('PROXY_METHOD=none')
config.append('BROWSER_ONLY=no')
config.append('IPV4_FAILURE_FATAL=no')
return '\n'.join(config) + '\n'
......@@ -225,7 +236,7 @@ def generate(tree, host):
if i.bridge[0]:
config = '# Generated by %s\n' % (' '.join(sys.argv))
config += 'DEVICE=%s\n' % i.bridge[0]
config += 'NAME="%s"\n' % i.bridge[0]
config += 'NAME=%s\n' % i.bridge[0]
config += 'ONBOOT=yes\n'
config += 'TYPE=Bridge\n'
config += 'STP=off\n'
......@@ -235,7 +246,7 @@ def generate(tree, host):
config = '# Generated by %s\n' % (' '.join(sys.argv))
config += 'DEVICE=%s\n' % device_name
config += 'NAME="%s"\n' % device_name
config += 'NAME=%s\n' % device_name
config += 'HWADDR=%s\n' % i.ethernet[0].upper()
config += 'ONBOOT=yes\n'
config += 'TYPE=Ethernet\n'
......@@ -246,7 +257,7 @@ def generate(tree, host):
elif i.ethernet[0]:
config = '# Generated by %s\n' % (' '.join(sys.argv))
config += 'DEVICE=%s\n' % device_name
config += 'NAME="%s"\n' % device_name
config += 'NAME=%s\n' % device_name
config += 'HWADDR=%s\n' % i.ethernet[0].upper()
config += 'ONBOOT=yes\n'
config += 'TYPE=Ethernet\n'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment