New Question

Hoang's profile - activity

2016-03-06 20:18:03 +0300 received badge  Famous Question (source)
2014-11-24 18:09:13 +0300 received badge  Notable Question (source)
2014-11-17 13:54:43 +0300 received badge  Popular Question (source)
2014-11-14 17:02:04 +0300 answered a question cloudbase-init does not support more than 1 NIC

Hi Alessandro,

many thanks for your quick response! Are there any chances that cloudbase will take this feature into the next version fast? If not, can you show me how can I do a patch for this? (a complete msi installation with the new feature)

2014-11-14 11:13:06 +0300 received badge  Editor (source)
2014-11-14 11:06:57 +0300 asked a question 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.

  1. Could networkconfig plugin be changed in a better way so that it can handle 2 NICs or general several NICs
  2. 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!