Fix interface method change (#38996)

This commit is contained in:
Olivier Bourdon 2018-04-19 11:05:39 +02:00 committed by ansibot
parent e2aa1155ba
commit 87a07e81a9

View file

@ -302,6 +302,14 @@ def setInterfaceOption(module, lines, iface, option, raw_value, state):
def addOptionAfterLine(option, value, iface, lines, last_line_dict, iface_options):
# Changing method of interface is not an addition
if option == 'method':
for ln in lines:
if ln.get('line_type', '') == 'iface':
ln['line'] = re.sub(ln.get('params', {}).get('method', '') + '$', value, ln.get('line'))
ln['params']['method'] = value
return lines
last_line = last_line_dict['line']
prefix_start = last_line.find(last_line.split()[0])
suffix_start = last_line.rfind(last_line.split()[-1]) + len(last_line.split()[-1])