Add openvpn TUN and TAP interfaces support, change type to Virtual and remove mac address #132

Merged
cyrinux merged 3 commits from tun_tap_support into master 2020-06-14 18:18:14 +02:00
Showing only changes of commit 6a3522138f - Show all commits

View file

@ -80,10 +80,6 @@ class Network(object):
ip_addr.pop(i) ip_addr.pop(i)
mac = open('/sys/class/net/{}/address'.format(interface), 'r').read().strip() mac = open('/sys/class/net/{}/address'.format(interface), 'r').read().strip()
# Loopback lo
if mac == '00:00:00:00:00:00':
mac = None
vlan = None vlan = None
if len(interface.split('.')) > 1: if len(interface.split('.')) > 1:
vlan = int(interface.split('.')[1]) vlan = int(interface.split('.')[1])
@ -102,7 +98,7 @@ class Network(object):
nic = { nic = {
'name': interface, 'name': interface,
'mac': mac, 'mac': mac if mac != '00:00:00:00:00:00' else None,
'ip': [ 'ip': [
'{}/{}'.format( '{}/{}'.format(
x['addr'], x['addr'],
@ -255,15 +251,13 @@ class Network(object):
params = { params = {
'name': nic['name'], 'name': nic['name'],
'mac_address': nic['mac'],
'type': type, 'type': type,
'mgmt_only': mgmt, 'mgmt_only': mgmt,
**self.custom_arg, **self.custom_arg,
} }
# Remove mac for virtual interface if not nic.get('virtual', False):
if nic.get('virtual', False): params['mac_address'] = nic['mac']
del params['mac_address']
interface = self.nb_net.interfaces.create(**params) interface = self.nb_net.interfaces.create(**params)