Handle undefined type attribute

This fixes this exception (issue #40):

 [WARNING]: exception: Traceback (most recent call last):   File
"/tmp/ansible_FfjjGk/ansible_module_network_connections.py", line 2812, in <module>     cmd.run()   File
"/tmp/ansible_FfjjGk/ansible_module_network_connections.py", line 2398, in run     self.run_prepare()   File
"/tmp/ansible_FfjjGk/ansible_module_network_connections.py", line 2653, in run_prepare     if connection['type'] in [
'macvlan' ]: KeyError: 'type'
This commit is contained in:
Till Maas 2018-05-18 23:47:47 +02:00
parent 0fc1b5bbb5
commit dd24f020a9

View file

@ -2673,7 +2673,7 @@ class Cmd_initscripts(Cmd):
def run_prepare(self):
Cmd.run_prepare(self)
for idx, connection in enumerate(self.connections):
if connection['type'] in [ 'macvlan' ]:
if connection.get('type') in [ 'macvlan' ]:
self.log_fatal(idx, 'unsupported type %s for initscripts provider' % (connection['type']))
def check_name(self, idx, name = None):