cloudbase-init does not support more than 1 NIC
Hi,
we get this problem since a week, so we digged into the cloudbase-init code and landed at networkconfig.py ... [cloudbaseinit/plugins/windows/networkconfig.py]
content_path = network_config['content_path']
content_name = content_path.rsplit('/', 1)[-1]
debian_network_conf = service.get_content(content_name)
LOG.debug('network config content:\n%s' % debian_network_conf)
# TODO (alexpilotti): implement a proper grammar
m = re.search(r'iface eth0 inet static\s+'
r'address\s+(?P<address>[ˆ\s]+)\s+'
r'netmask\s+(?P<netmask>[ˆ\s]+)\s+'
r'broadcast\s+(?P<broadcast>[ˆ\s]+)\s+'
r'gateway\s+(?P<gateway>[ˆ\s]+)\s+'
r'dns\-nameservers\s+(?P<dnsnameservers>[ˆ\r\n]+)\s+',
debian_network_conf)
if not m:
raise Exception("network_config format not recognized")
address = m.group('address')
netmask = m.group('netmask')
broadcast = m.group('broadcast')
gateway = m.group('gateway')
dnsnameservers = m.group('dnsnameservers').strip().split(' ')
osutils = osutils_factory.get_os_utils()
network_adapter_name = CONF.network_adapter
if not network_adapter_name:
# Get the first available one
available_adapters = osutils.get_network_adapters()
if not len(available_adapters):
raise Exception("No network adapter available")
network_adapter_name = available_adapters[0]
LOG.info('Configuring network adapter: \'%s\'' % network_adapter_name)
reboot_required = osutils.set_static_network_config(
network_adapter_name, address, netmask, broadcast,
gateway, dnsnameservers)
... By bootstraping, nova injected a configuration data into this deployed VM like this
auto lo iface lo inet loopback
auto eth0 iface eth0 inet static address 172.16.x.x netmask 255.255.255.0 broadcast 172.16.x.x gateway 172.16.x.x dns-nameservers 172.16.x.x
auto eth1 iface eth1 inet static address 192.168.x.x netmask 255.255.255.0 broadcast 192.168.x.x gateway 192.168.x.x
So, as you can see, the eth1 is not in the eyes of cloudbase-init, so the IP is not set for eth1, cloudbase-init will take per default an IP in range 169.254.x.x for the second NIC via DHCP.
- Could networkconfig plugin be changed in a better way so that it can handle 2 NICs or general several NICs
- In getnetworkadapters() method, a SQL statement is invoked. Why is the first net adapter in the return list chosen for assigning the IP?
Thanks in advance for your help!