Add tunnel linux (#18118)

* Refactor the type selection of network device under linux

* Add the tunnel type to the type of net interface under Linux
pull/18387/merge
Michael Scherer 8 years ago committed by Brian Coca
parent df145df962
commit 150ea49d8a

@ -2263,6 +2263,12 @@ class LinuxNetwork(Network):
- ipv4_address and ipv6_address: the first non-local address for each family. - ipv4_address and ipv6_address: the first non-local address for each family.
""" """
platform = 'Linux' platform = 'Linux'
INTERFACE_TYPE = {
'1': 'ether',
'512': 'ppp',
'772': 'loopback',
'65534': 'tunnel',
}
def populate(self): def populate(self):
ip_path = self.module.get_bin_path('ip') ip_path = self.module.get_bin_path('ip')
@ -2336,12 +2342,7 @@ class LinuxNetwork(Network):
interfaces[device]['module'] = os.path.basename(os.path.realpath(os.path.join(path, 'device', 'driver', 'module'))) interfaces[device]['module'] = os.path.basename(os.path.realpath(os.path.join(path, 'device', 'driver', 'module')))
if os.path.exists(os.path.join(path, 'type')): if os.path.exists(os.path.join(path, 'type')):
_type = get_file_content(os.path.join(path, 'type')) _type = get_file_content(os.path.join(path, 'type'))
if _type == '1': interfaces[device]['type'] = self.INTERFACE_TYPE.get(_type, 'unknown')
interfaces[device]['type'] = 'ether'
elif _type == '512':
interfaces[device]['type'] = 'ppp'
elif _type == '772':
interfaces[device]['type'] = 'loopback'
if os.path.exists(os.path.join(path, 'bridge')): if os.path.exists(os.path.join(path, 'bridge')):
interfaces[device]['type'] = 'bridge' interfaces[device]['type'] = 'bridge'
interfaces[device]['interfaces'] = [ os.path.basename(b) for b in glob.glob(os.path.join(path, 'brif', '*')) ] interfaces[device]['interfaces'] = [ os.path.basename(b) for b in glob.glob(os.path.join(path, 'brif', '*')) ]

Loading…
Cancel
Save