1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Wed, 4 May 2016 18:31:09 +0200
3 Subject: [PATCH] deploy/reap.py: Dump extra interfaces information.
5 Since on AArch64, Ubuntu local mirror lacks arm64 packages (see [1]),
6 Fuel master requires internet connectivity during deploy, and hence
7 a way to setup such a public (extra) interface automatically.
9 Previous commit "transplant: Generate extra interfaces config file"
10 introduced support for passing this information via DEA (override),
11 which may define a IFCGF_<interface> section in its 'fuel:'
12 section, containing the necessary keys to produce a ifcfg-<interface>
13 file, like in this example:
19 netmask: 255.255.255.0
22 In order for Network Manager to use the newly added interfaces
23 for outgoing traffic and honor their GATEWAY setting (e.g. if we just
24 added one public interface), the default route on admin iface (most of
25 the time called eth0) is disabled when extra interfaces are present.
27 FIXME: Only supports lowercase interface names, but so does Fuel,
28 see related bug report [2].
30 [1] https://jira.opnfv.org/browse/ARMBAND-35
31 [2] https://jira.opnfv.org/browse/FUEL-136
33 Signed-off-by: Alexandu Avadanii <alexandru.avadanii@enea.com>
34 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
36 deploy/reap.py | 34 ++++++++++++++++++++++++++++++++++
37 1 file changed, 34 insertions(+)
39 diff --git a/deploy/reap.py b/deploy/reap.py
40 index bf64d40..6feaf17 100755
43 @@ -15,6 +15,8 @@ import yaml
52 @@ -245,6 +247,38 @@ class Reap(object):
53 if key not in ['ipaddress', 'netmask',
54 'dhcp_pool_start', 'dhcp_pool_end']:
55 del fuel['ADMIN_NETWORK'][key]
57 + ## FIXME(armband): Factor in support for adding public/other interfaces.
58 + ## TODO: Following block expects interface name(s) to be lowercase only
59 + interfaces_list = exec_cmd('ip -o -4 a | grep -e "e[nt][hopsx].*"')
60 + for interface in re.split('\n', interfaces_list):
61 + # Sample output line from above cmd:
62 + # 3: eth1 inet 10.0.2.10/24 scope global eth1 valid_lft forever ...
63 + ifcfg = re.split(r'\s+', interface)
64 + ifcfg_name = ifcfg[1]
65 + ifcfg_ipaddr = ifcfg[3]
67 + # Filter out admin interface (device name is not known, match IP)
68 + current_network = netaddr.IPNetwork(ifcfg_ipaddr)
69 + if str(current_network.ip) == fuel['ADMIN_NETWORK']['ipaddress']:
72 + # Read ifcfg-* network interface config file, write IFCFG_<IFNAME>
73 + ifcfg_sec = 'IFCFG_%s' % ifcfg_name.upper()
74 + fuel[ifcfg_sec] = {}
76 + ifcfg_f = ('/etc/sysconfig/network-scripts/ifcfg-%s' % ifcfg_name)
77 + with open(ifcfg_f) as f:
79 + (key, val) = line.split('=')
80 + ifcfg_data[key.lower()] = val.rstrip()
82 + # Keep only needed info (e.g. filter-out type=Ethernet).
83 + fuel[ifcfg_sec]['ipaddress'] = ifcfg_data['ipaddr']
84 + fuel[ifcfg_sec]['device'] = ifcfg_data['device']
85 + fuel[ifcfg_sec]['netmask'] = str(current_network.netmask)
86 + fuel[ifcfg_sec]['gateway'] = ifcfg_data['gateway']
88 self.write_yaml(self.dea_file, {'fuel': fuel})
90 def reap_network_settings(self):