import os
import yaml
import subprocess
+import socket
+import fcntl
+import struct
#
# Parse parameters
except yaml.YAMLError as exc:
print(exc)
+
+def get_ip_address(ifname):
+ """Get local IP"""
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ return socket.inet_ntoa(fcntl.ioctl(
+ s.fileno(),
+ 0x8915, # SIOCGIFADDR
+ struct.pack('256s', bytes(ifname.encode('utf-8')[:15]))
+ )[20:24])
+
+
+#
+# Config import
+#
+
#
# Config import
#
# Add some OS environment variables
config['os'] = {'home': HOME,
'user': USER,
- }
+ 'brAdmIP': get_ip_address(config['opnfv']['spaces_dict']
+ ['admin']['bridge'])}
# Prepare interface-enable, more easy to do it here
ifnamelist = set()