New Question
0

cloudbase-init does not support more than 1 NIC

asked 2014-11-14 11:06:57 +0300

Hoang gravatar image

updated 2014-11-14 11:29:35 +0300

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!

edit retag flag offensive close merge delete

4 answers

Sort by » oldest newest most voted
0

answered 2018-10-30 20:44:57 +0300

jeking3 gravatar image

The original file isn't there any more, and the common networkconfig.py appears to support multiple NICs identified by MAC.

edit flag offensive delete link more
0

answered 2016-03-06 20:20:49 +0300

tictoc gravatar image

Has this been resolved in newer release or is it still WIP?

edit flag offensive delete link more

Comments

The static networking code has been improved already since a few months, supporting multiple nics and a better matching between nics and metadata configuration.

alexpilotti gravatar imagealexpilotti ( 2016-03-08 10:41:46 +0300 )edit
0

answered 2014-11-14 17:02:04 +0300

Hoang gravatar image

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)

edit flag offensive delete link more
0

answered 2014-11-14 12:07:43 +0300

alexpilotti gravatar image

We worked on a pull request: https://github.com/cloudbase/cloudbas... but the original submitter didn't follow up on the latest reviews, so this is still WiP.

Most of the OpenStack use cases involve DHCP, but this feature is still on the TODO list.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-14 11:06:57 +0300

Seen: 1,095 times

Last updated: Oct 30 '18