New Question
1

SOLVED - static networking configuration with cloudbase-init fails

asked 2014-09-30 17:37:29 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Ciao Alex,

grazie mille per il tuo lavoro!

static network conf with cloudbase-init fails for me, the logs shows "network_config format not recognized".

I'm providing a config via a selfmade configV2 drive and I wonder in which format I am supposed to provide debian_network_conf (cloudbaseinit/plugins/windows/networkconfig.py)

right now it's a multiline string:

iface eth0 inet static
  address 192.168.1.90
  broadcast 192.168.1.255
  netmask 255.255.255.0
  gateway 192.168.1.254
  dns-nameserver 8.8.8.8

Put otherwise: How is this supposed to work? Did it ever?

# 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)

Grazie mille ancora! Florian

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
1

answered 2014-10-01 06:43:58 +0200

avladu gravatar image

updated 2014-10-01 06:45:46 +0200

Hello,

The config should be provided in this form:

iface eth0 inet static
  address 10.0.1.8
  netmask 255.255.255.0
  broadcast 10.0.1.255
  gateway 10.0.1.1
  dns-nameservers 8.8.8.8
  #here must be an empty line

The differences between your config and the one I have given are:

  1. The order: netmask before broadcast
  2. "dns-nameservers" instead of "dns-nameserver"
  3. Due to a quirk on Python 2.7.3, there needs to be a newline after the dns-nameservers (\n). On 2.7.6, it works with/without a newline.

This way, if the config files are mapped correctly, the regexp should work,

I hope it helps.

edit flag offensive delete link more

Comments

Hi avladu, thanks for your help. Please see my own answer, I am not allowed to post it as comment to your answer (too many characters) Thanks, Florian

fke gravatar imagefke ( 2014-10-01 10:26:57 +0200 )edit

So all is good?

avladu gravatar imageavladu ( 2014-10-01 18:36:52 +0200 )edit
0

answered 2014-10-01 10:25:06 +0200

fke gravatar image

updated 2014-10-01 11:13:50 +0200

UPDATE / solved

Hi avladu,

thanks. You putted me in the right direction! I was missing "s" at the end of dns-nameserver. So this is info is evaluated properly:

cat << EOF > ./seed/openstack/content/network
iface eth0 inet static
  address 192.168.1.90
  netmask 255.255.255.0
  broadcast 192.168.1.255
  gateway 192.168.1.254
  dns-nameservers 8.8.8.8

EOF

Bye, Florian

old anwer

Hi avladu,

thanks for your help. I did as advised. Still the same error. Even worse, I can't get it to work even completely isolated:

$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> debian_network_conf="""
... iface eth0 inet static
...   address 192.168.1.90
...   netmask 255.255.255.0
...   broadcast 192.168.1.255
...   gateway 192.168.1.254
...   dns-nameserver 8.8.8.8
... 
... """
>>> 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)
>>> 
>>>

whereas, without concatenating the regexp I can get matches

>>> re.search(r'iface eth0 inet static\s+',debian_network_conf)  
<_sre.SRE_Match object at 0x10ce798b8>
>>> re.search(r'address\s+(?P<address>[^\s]+)\s+',debian_network_conf)                            
<_sre.SRE_Match object at 0x10ce78990>

So, what am I doing wrong?

Thanks in advance, Florian

edit flag offensive delete link more
0

answered 2015-01-06 13:51:04 +0200

alexpilotti gravatar image

Hi Florian,

We completely refactored how the static network plugin works, overcoming the simple regex searches that we were originally doing.

Please let me know if this works for you.

Grazie!

Alessandro

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-09-30 17:37:29 +0200

Seen: 2,302 times

Last updated: Jan 06 '15