canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.98k stars 880 forks source link

mask2cidr error with integer value - argument of type 'int' is not iterable #2862

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1684349

Launchpad details
affected_projects = ['cloud-init (Ubuntu)', 'cloud-init (Ubuntu Xenial)', 'cloud-init (Ubuntu Yakkety)', 'cloud-init (Ubuntu Zesty)']
assignee = akaris
assignee_name = Andreas Karis
date_closed = 2017-09-23T02:31:10.266682+00:00
date_created = 2017-04-20T04:23:31.742980+00:00
date_fix_committed = 2017-05-26T18:49:27.370764+00:00
date_fix_released = 2017-09-23T02:31:10.266682+00:00
id = 1684349
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1684349
milestone = None
owner = akaris
owner_name = Andreas Karis
private = False
status = fix_released
submitter = akaris
submitter_name = Andreas Karis
tags = ['verification-done-xenial', 'verification-done-yakkety', 'verification-done-zesty']
duplicates = []

Launchpad user Andreas Karis(akaris) wrote on 2017-04-20T04:23:31.742980+00:00

=== Begin SRU Template === [Impact] On Openstack instances, when rendering sysconfig output, cloud-init would stacktrace due to a TypeError. This affects runtime only when rendering sysconfig networking, which is what is used on CentOS and RedHat systems.

[Test Case] The basic idea below is:  a.) launch an instance with proposed version of cloud-init.  b.) inside instance, get cloud-init's network rendering tool from trunk  c.) run the rendering tool against a config that failed before.  d.) check rendered netplan config to verify it has the correct format.      The failed output would have 'addresses' with a format like:      172.19.1.34/255.255.255.0      The expected output would be 'cidr' format:      172.19.1.34/24

launch an instance.

$ release=xenial $ ref=$release-proposed $ lxc-proposed-snapshot --proposed --publish $release $ref $ lxc launch $ref $name $ lxc exec $name

get render tool

% wget https://git.launchpad.net/~cloud-init-dev/cloud-init/plain/tools/net-convert.py -O net-convert.py

write the network_data.json

% cat > simple-ipv6.yaml <<EOF version: 1 config:   - type: physical     name: eth0     subnets:      - type: static        address: "2000:192:168::5"        netmask: 64        routes:         - netmask: 0           gateway: "2000:192:168::1"           network: "::" EOF

run the converter

% ./net-convert.py --network-data=simple-ipv6.yaml \      --kind=yaml --output-kind=eni --directory=out.d

check the output

% cat out.d/etc/network/interfaces auto lo iface lo inet loopback

auto eth0 iface eth0 inet6 static     address 2000:192:168::5     netmask 64     post-up route add -A inet6 default gw 2000:192:168::1 || true     pre-down route del -A inet6 default gw 2000:192:168::1 || true

show the cloud-init versions

% dpkg-query --show cloud-init ...

[Regression Potential] The fix here was just to make a common networking method accept a string input as intended rather than only an integer.

The common code changes could shake out other failures in the networking path.

[Other Info] Upstream commit at   https://git.launchpad.net/cloud-init/commit/?id=16a7302f6a

lxc-proposed-snapshot is   https://git.launchpad.net/~smoser/cloud-init/+git/sru-info/tree/bin/lxc-proposed-snapshot It publishes an image to lxd with proposed enabled and cloud-init upgraded. === End SRU Template ===

mask2cidr error with integer value - argument of type 'int' is not iterable

def mask2cidr(mask):
    if ':' in str(mask):
        return ipv6mask2cidr(mask)
    elif '.' in mask:
        return ipv4mask2cidr(mask)
    else:
        return mask

is not type safe. It tries to take into account that this can be a prefix (so it does not contain ':' not '.' and then return mask. The problem is that if mask is an integer, then this returns:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 513, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 269, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 641, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/__init__.py", line 150, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 59, in _write_network_config
    ns = parse_net_config_data(netconfig)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 32, in parse_net_config_data
    nsi.parse_config(skip_broken=skip_broken)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 205, in parse_config
    handler(self, command)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 78, in decorator
    return func(self, command, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 239, in handle_physical
    subnet['netmask'] = mask2cidr(subnet['netmask'])
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 441, in mask2cidr
    elif '.' in mask:

Made a modification to the code to troubleshoot this:

       # convert subnet ipv6 netmask to cidr as needed
        subnets = command.get('subnets')
        print subnets
        if subnets:
            for subnet in subnets:
                if subnet['type'] == 'static':
                    if 'netmask' in subnet and ':' in subnet['address']:
                        subnet['netmask'] = mask2cidr(subnet['netmask'])
                        for route in subnet.get('routes', []):
                            if 'netmask' in route:
                                route['netmask'] = mask2cidr(route['netmask'])

This error can be hit on RHEL when running the following 2x (don't know why 2x):

 rm -Rf /var/lib/cloud/data/* ; cloud-init --force init

On the second run, this will be returned:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 513, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 269, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 641, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/__init__.py", line 150, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 59, in _write_network_config
    ns = parse_net_config_data(netconfig)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 32, in parse_net_config_data
    nsi.parse_config(skip_broken=skip_broken)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 205, in parse_config
    handler(self, command)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 78, in decorator
    return func(self, command, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 239, in handle_physical
    subnet['netmask'] = mask2cidr(subnet['netmask'])
  File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 441, in mask2cidr
    elif '.' in mask:
TypeError: argument of type 'int' is not iterable
------------------------------------------------------------
[{u'routes': [{u'netmask': u'0.0.0.0', u'network': u'0.0.0.0', u'gateway': u'192.168.0.1'}], u'netmask': u'255.255.255.0', u'type': 'static', 'ipv4': True, 'address': u'192.168.0.11'}, {u'routes': [{u'netmask': 0, u'network': u'::', u'gateway': u'2000:192:168::1'}], u'netmask': 64, 'ipv6': True, u'type': 'static', 'address': u'2000:192:168::4'}]

not the u'netmask': 64 integer

This can be fixed by changing the code to:

def mask2cidr(mask):
    if ':' in str(mask):
        return ipv6mask2cidr(mask)
    elif '.' in str(mask):
        return ipv4mask2cidr(mask)
    else:
        return mask
ubuntu-server-builder commented 1 year ago

Launchpad user Andreas Karis(akaris) wrote on 2017-04-21T21:01:07.517635+00:00

With the above modification of 'print subnets', I ran this twice:

[root@rhel2 ~]# vi /usr/lib/python2.7/site-packages/cloudinit/net/network_state.py [root@rhel2 ~]# rm -Rf /var/lib/cloud/data/ ; cloud-init --force init Cloud-init v. 0.7.9 running 'init' at Fri, 21 Apr 2017 20:59:09 +0000. Up 101437.95 seconds. ci-info: +++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++ ci-info: +---------+------+--------------+---------------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +---------+------+--------------+---------------+-------+-------------------+ ci-info: | eth0:0: | True | 192.168.0.11 | 255.255.255.0 | . | fa:16:3e:cc:06:c3 | ci-info: | eth1: | True | . | . | . | fa:16:3e:8a:1f:f4 | ci-info: | eth1: | True | . | . | d | fa:16:3e:8a:1f:f4 | ci-info: | eth2: | True | . | . | . | fa:16:3e:78:c2:39 | ci-info: | eth2: | True | . | . | d | fa:16:3e:78:c2:39 | ci-info: | eth0: | True | . | . | . | fa:16:3e:cc:06:c3 | ci-info: | eth0: | True | . | . | d | fa:16:3e:cc:06:c3 | ci-info: | eth3: | True | . | . | . | fa:16:3e:3b:76:55 | ci-info: | eth3: | True | . | . | d | fa:16:3e:3b:76:55 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | eth2:0: | True | 10.0.0.106 | 255.255.255.0 | . | fa:16:3e:78:c2:39 | ci-info: +---------+------+--------------+---------------+-------+-------------------+ ci-info: ++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++ ci-info: +-------+-------------+------------+---------------+-----------+-------+ ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags | ci-info: +-------+-------------+------------+---------------+-----------+-------+ ci-info: | 0 | 0.0.0.0 | 10.0.0.250 | 0.0.0.0 | eth2 | UG | ci-info: | 1 | 10.0.0.0 | 0.0.0.0 | 255.255.255.0 | eth2 | U | ci-info: | 2 | 192.168.0.0 | 0.0.0.0 | 255.255.255.0 | eth0 | U | ci-info: +-------+-------------+------------+---------------+-----------+-------+ [{u'routes': [{u'netmask': u'0.0.0.0', u'network': u'0.0.0.0', u'gateway': u'192.168.0.1'}], u'netmask': u'255.255.255.0', u'type': 'static', 'ipv4': True, 'address': u'192.168.0.11'}, {u'routes': [{u'netmask': u'::', u'network': u'::', u'gateway': u'2000:192:168::1'}], u'netmask': u'ffff:ffff:ffff:ffff::', 'address': u'2000:192:168::5', u'type': 'static', 'ipv6': True}] [{u'routes': [{u'netmask': u'::', u'network': u'::', u'gateway': u'2000:172:20::1'}], u'netmask': u'ffff:ffff:ffff:ffff::', 'address': u'2000:172:20::4', u'type': 'static', 'ipv6': True}] [{u'routes': [{u'netmask': u'0.0.0.0', u'network': u'0.0.0.0', u'gateway': u'10.0.0.250'}], u'netmask': u'255.255.255.0', u'type': 'static', 'ipv4': True, 'address': u'10.0.0.106'}, {u'routes': [{u'netmask': u'::', u'network': u'::', u'gateway': u'2000:10::250'}], u'netmask': u'ffff:ffff:ffff:ffff::', 'address': u'2000:10::1', u'type': 'static', 'ipv6': True}] [{u'type': 'dhcp4'}, {u'routes': [{u'netmask': u'::', u'network': u'::', u'gateway': u'2000:10::250'}], u'netmask': u'ffff:ffff:ffff:ffff::', 'address': u'2000:123::2', u'type': 'static', 'ipv6': True}] [root@rhel2 ~]# rm -Rf /var/lib/cloud/data/ ; cloud-init --force init Cloud-init v. 0.7.9 running 'init' at Fri, 21 Apr 2017 20:59:34 +0000. Up 101463.22 seconds. ci-info: +++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++ ci-info: +---------+------+--------------+---------------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +---------+------+--------------+---------------+-------+-------------------+ ci-info: | eth0:0: | True | 192.168.0.11 | 255.255.255.0 | . | fa:16:3e:cc:06:c3 | ci-info: | eth1: | True | . | . | . | fa:16:3e:8a:1f:f4 | ci-info: | eth1: | True | . | . | d | fa:16:3e:8a:1f:f4 | ci-info: | eth2: | True | . | . | . | fa:16:3e:78:c2:39 | ci-info: | eth2: | True | . | . | d | fa:16:3e:78:c2:39 | ci-info: | eth0: | True | . | . | . | fa:16:3e:cc:06:c3 | ci-info: | eth0: | True | . | . | d | fa:16:3e:cc:06:c3 | ci-info: | eth3: | True | . | . | . | fa:16:3e:3b:76:55 | ci-info: | eth3: | True | . | . | d | fa:16:3e:3b:76:55 | ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | eth2:0: | True | 10.0.0.106 | 255.255.255.0 | . | fa:16:3e:78:c2:39 | ci-info: +---------+------+--------------+---------------+-------+-------------------+ ci-info: ++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++ ci-info: +-------+-------------+------------+---------------+-----------+-------+ ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags | ci-info: +-------+-------------+------------+---------------+-----------+-------+ ci-info: | 0 | 0.0.0.0 | 10.0.0.250 | 0.0.0.0 | eth2 | UG | ci-info: | 1 | 10.0.0.0 | 0.0.0.0 | 255.255.255.0 | eth2 | U | ci-info: | 2 | 192.168.0.0 | 0.0.0.0 | 255.255.255.0 | eth0 | U | ci-info: +-------+-------------+------------+---------------+-----------+-------+ 2017-04-21 16:59:34,937 - util.py[WARNING]: failed stage init failed run of stage init

Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 513, in status_wrapper ret = functor(name, args) File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 269, in main_init init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL)) File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 641, in apply_network_config return self.distro.apply_network_config(netcfg, bring_up=bring_up) File "/usr/lib/python2.7/site-packages/cloudinit/distros/init.py", line 150, in apply_network_config dev_names = self._write_network_config(netconfig) File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 59, in _write_network_config ns = parse_net_config_data(netconfig) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 32, in parse_net_config_data nsi.parse_config(skip_broken=skip_broken) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 205, in parse_config handler(self, command) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 78, in decorator return func(self, command, *args, **kwargs) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 239, in handle_physical subnet['netmask'] = mask2cidr(subnet['netmask']) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 439, in mask2cidr if ':' in mask: TypeError: argument of type 'int' is not iterable

[{u'routes': [{u'netmask': u'0.0.0.0', u'network': u'0.0.0.0', u'gateway': u'192.168.0.1'}], u'netmask': u'255.255.255.0', u'type': 'static', 'ipv4': True, 'address': u'192.168.0.11'}, {u'routes': [{u'netmask': 0, u'network': u'::', u'gateway': u'2000:192:168::1'}], u'netmask': 64, 'ipv6': True, u'type': 'static', 'address': u'2000:192:168::5'}] [root@rhel2 ~]#

Note that the netmask changed: u'ffff:ffff:ffff:ffff::', 'address': u'2000:192:168::5' vs u'netmask': 64, 'ipv6': True, u'type': 'static', 'address': u'2000:192:168::5'

ubuntu-server-builder commented 1 year ago

Launchpad user Andreas Karis(akaris) wrote on 2017-05-18T16:20:43.151614+00:00

Here is how to trigger this bug:

Enable config drive IPv4/IPv6 address injection

On the compute nodes and controllers, configure

crudini --set /etc/nova/nova.conf DEFAULT injected_network_template /usr/lib/python2.7/site-packages/nova/virt/interfaces.template
crudini --set /etc/nova/nova.conf DEFAULT flat_injected true
crudini --set /etc/nova/nova.conf DEFAULT force_config_drive true
crudini --set /etc/nova/nova.conf DEFAULT config_drive_cdrom True
crudini --set /etc/nova/nova.conf DEFAULT debug true
crudini --set /etc/nova/nova.conf DEFAULT use_ipv6 true
crudini --set /etc/nova/nova.conf os_vif_linux_bridge use_ipv6 true
crudini --set /etc/nova/nova.conf libvirt inject_partition -1

Restart all OpenStack services on computes and controllers:

systemctl list-units | grep nova | awk '{print $1}' | xargs -I {} systemctl restart {}

Use a recent version of cloud-init within the instances

sudo yumdownloader cloud-init pyserial python-jinja2 python-babel python-markupsafe pytz
for i in *.rpm;do virt-customize -a rhel.qcow2 --upload $i:/root/$i ; done        
virt-customize -a rhel.qcow2 -v --run-command 'yum -y localinstall /root/*.rpm'
source overcloudrc

Set password for console login

virt-customize -a rhel.qcow2 --root-password password:Redhat01

Create glance image

glance image-create --name rhel-cloud-init --file rhel.qcow2 --container-format bare --disk-format qcow2 --progress

Open all security groups and add keypair

nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
nova secgroup-add-rule default tcp 1 65535 0.0.0.0/0
nova secgroup-add-rule default udp 1 65535 0.0.0.0/0
nova secgroup-add-rule default icmp -1 -1 ::/0
nova secgroup-add-rule default tcp 1 65535 ::/0
nova secgroup-add-rule default udp 1 65535 ::/0
nova keypair-add --pub-key ~/.ssh/id_rsa.pub id_rsa

Configure networks without DHCP

Make sure that none of the subnets has DHCP enabled!

# access network
neutron net-create provider1 --provider:network_type vlan --provider:physical_network $PROVIDER_PHYSICAL_NETWORK --provider:segmentation_id $PROVIDER_SEGMENTATION_ID --shared --router:external
neutron subnet-create --gateway 10.0.0.1 --allocation-pool start=10.0.0.100,end=10.0.0.150 --dns-nameserver 8.8.8.8 --name provider1-subnet provider1 10.0.0.0/24
neutron subnet-update provider1-subnet --disable-dhcp

# test networks
neutron net-create private-no-dhcp-1
neutron net-delete private-no-dhcp-1
neutron net-create private-no-dhcp-1
neutron net-create private-no-dhcp-2
neutron net-create private-no-dhcp-3
neutron subnet-create --disable-dhcp private-no-dhcp-1 192.168.100.0/24
neutron subnet-create --disable-dhcp private-no-dhcp-1 192.168.101.0/24
neutron subnet-create --disable-dhcp private-no-dhcp-1 192.168.102.0/24
neutron subnet-create --disable-dhcp private-no-dhcp-2 192.168.200.0/24
neutron subnet-create --disable-dhcp --ip-version 6  private-no-dhcp-2 2000:192:168:200::/64
neutron subnet-create --disable-dhcp --ip-version 6  private-no-dhcp-2 2000:192:168:201::/64
neutron subnet-create --disable-dhcp --ip-version 6 --gateway 2000:192:168:202::1  private-no-dhcp-3 2000:192:168:202::/64 
neutron subnet-create --disable-dhcp --ip-version 6 --gateway 2000:192:168:203::1  private-no-dhcp-3 2000:192:168:203::/64 
neutron subnet-create --disable-dhcp --ip-version 6 --gateway 2000:192:168:204::1  private-no-dhcp-3 2000:192:168:204::/64 
[stack@undercloud-1 ~]$ neutron net-list
+--------------------------------------+-------------------+------------------------------------------------------------+
| id                                   | name              | subnets                                                    |
+--------------------------------------+-------------------+------------------------------------------------------------+
| 05e253ca-1878-43a3-854e-287ccc160d4f | private-no-dhcp-2 | c06c0013-3eb8-42cf-a3ab-535bda78c084 2000:192:168:201::/64 |
|                                      |                   | 75c0768c-7359-4abd-96cc-e3ef8003b08f 192.168.200.0/24      |
|                                      |                   | bd1d4188-22fb-495b-943c-866baccf20d0 2000:192:168:200::/64 |
| 622f4b76-1891-46b8-a08a-639076377d7e | private-no-dhcp-3 | f815a0b9-6618-41fe-895d-a8de32b237cd 2000:192:168:204::/64 |
|                                      |                   | f1738838-bb98-41f1-8142-fa3f020adc29 2000:192:168:202::/64 |
|                                      |                   | c49858db-91fb-4b34-b086-846d2a6df5d5 2000:192:168:203::/64 |
| 6dd84bd5-4da0-4a55-ad66-9b101b82e44d | provider1         | fce9d8c6-ef86-40df-85c8-8a0075eb613d 10.0.0.0/24           |
| 9945b557-e7e9-4bdd-a310-e133e95b0c1c | private-no-dhcp-1 | 3713f49a-d866-4bfd-9050-c423dd575215 192.168.100.0/24      |
|                                      |                   | ad4897e0-adb2-40f3-aac3-556862672672 192.168.102.0/24      |
|                                      |                   | 1f32c95f-8d59-47d9-8672-4362e1b57c20 192.168.101.0/24      |
| deeef632-a41d-4341-a4f1-5a18511cce97 | private           | 61110018-b0c6-4a9e-9511-86175f55dcce 192.168.0.0/24        |
|                                      |                   | b8ff9d8a-6fad-4379-83d4-9a7fb9b0c1d9 2000:192:168:1::/64   |
+--------------------------------------+-------------------+------------------------------------------------------------+

Boot test instance

nova boot --nic net-id=$NETID --nic net-id=$NETID2 --image rhel-cloud-init --flavor m1.small --key-name id_rsa rhel-cloud-init-test

Apply master or branch of cloud-init

RHEL 7

Go to root directory of cloud-init clone and create an archive, then copy the archive to undercloud

tar -czf cloudinit.0.7.9.patch.tar.gz cloudinit/
scp cloudinit.0.7.9.patch.tar.gz root@10.12.208.113:/home/stack/.

On undercloud, run:

sudo chown stack. cloudinit.0.7.9.patch.tar.gz 
sudo yumdownloader python-oauthlib
sudo yumdownloader python-crypto
cp rhel.qcow2 rhel.patch.qcow2
for i in python-oauthlib* python-crypto*; do virt-customize -a rhel.patch.qcow2 --upload $i:/root/$i; done
virt-customize -a rhel.patch.qcow2 -v --run-command 'yum localinstall -y /root/*.rpm'
for i in cloudinit.0.7.9.patch.tar.gz ; do virt-customize -a rhel.patch.qcow2 --upload $i:/root/$i; done
virt-customize -a rhel.patch.qcow2 -v --run-command 'rm -Rf /usr/lib/python2.7/site-packages/cloudinit ; tar -xzf /root/cloudinit.0.7.9.patch.tar.gz  -C /usr/lib/python2.7/site-packages/'
glance image-create --name rhel-cloud-init-patch --file rhel.patch.qcow2 --container-format bare --disk-format qcow2 --progress

Boot an instance

NETID1=6dd84bd5-4da0-4a55-ad66-9b101b82e44d
NETID2=9945b557-e7e9-4bdd-a310-e133e95b0c1c
NETID3=05e253ca-1878-43a3-854e-287ccc160d4f
NETID4=622f4b76-1891-46b8-a08a-639076377d7e
nova boot --nic net-id=$NETID1 --nic net-id=$NETID2 --nic net-id=$NETID3 --nic net-id=$NETID4 --image rhel-cloud-init-patch --flavor m1.small --key-name id_rsa rhel-cloud-init-patch-test

Note how neutron does not translate this correctly:

[stack@undercloud-1 ~]$ nova show rhel-cloud-init-patch-test
(...)
| private-no-dhcp-1 network            | 192.168.101.7                                                |
| private-no-dhcp-2 network            | 192.168.200.2, 2000:192:168:201::7                           |
| private-no-dhcp-3 network            | 2000:192:168:204::7                                          |

Verification on the instance:

mount /dev/sr0 /mnt
cat /mnt/openstack/latest/network_data.json | python -m json.tool
(...)
"networks": [
        {
            "id": "network0",
            "ip_address": "10.0.0.106",
            "link": "tapf7ec043c-b1",
            "netmask": "255.255.255.0",
            "network_id": "6dd84bd5-4da0-4a55-ad66-9b101b82e44d",
            "routes": [
                {
                    "gateway": "10.0.0.1",
                    "netmask": "0.0.0.0",
                    "network": "0.0.0.0"
                }
            ],
            "type": "ipv4"
        },
        {
            "id": "network1",
            "ip_address": "192.168.101.7",
            "link": "tap71bedd6b-2e",
            "netmask": "255.255.255.0",
            "network_id": "9945b557-e7e9-4bdd-a310-e133e95b0c1c",
            "routes": [
                {
                    "gateway": "192.168.101.1",
                    "netmask": "0.0.0.0",
                    "network": "0.0.0.0"
                }
            ],
            "type": "ipv4"
        },
        {
            "id": "network2",
            "ip_address": "192.168.200.2",
            "link": "tap08ce6a9a-1f",
            "netmask": "255.255.255.0",
            "network_id": "05e253ca-1878-43a3-854e-287ccc160d4f",
            "routes": [
                {
                    "gateway": "192.168.200.1",
                    "netmask": "0.0.0.0",
                    "network": "0.0.0.0"
                }
            ],
            "type": "ipv4"
        },
        {
            "id": "network3",
            "ip_address": "2000:192:168:201::7",
            "link": "tap08ce6a9a-1f",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network_id": "05e253ca-1878-43a3-854e-287ccc160d4f",
            "routes": [
                {
                    "gateway": "2000:192:168:201::1",
                    "netmask": "::",
                    "network": "::"
                }
            ],
            "type": "ipv6"
        },
        {
            "id": "network4",
            "ip_address": "2000:192:168:204::7",
            "link": "tapf2d2a0e3-73",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network_id": "622f4b76-1891-46b8-a08a-639076377d7e",
            "routes": [
                {
                    "gateway": "2000:192:168:204::1",
                    "netmask": "::",
                    "network": "::"
                }
            ],
            "type": "ipv6"
        }
(...)

Force rerun of cloud-init:

[root@rhel-cloud-init-patch-test network-scripts]# rm -Rf /var/lib/cloud/data/* ; cloud-init --force init Cloud-init v. 0.7.9 running 'init' at Thu, 18 May 2017 16:19:44 +0000. Up 839.21 seconds. ci-info: +++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++ ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . | ci-info: | lo: | True | . | . | d | . | ci-info: | eth1: | True | 192.168.101.7 | 255.255.255.0 | . | fa:16:3e:1e:97:ad | ci-info: | eth1: | True | . | . | d | fa:16:3e:1e:97:ad | ci-info: | eth2: | True | 192.168.200.2 | 255.255.255.0 | . | fa:16:3e:a3:bc:ef | ci-info: | eth2: | True | . | . | d | fa:16:3e:a3:bc:ef | ci-info: | eth0: | True | 10.0.0.106 | 255.255.255.0 | . | fa:16:3e:46:24:4f | ci-info: | eth0: | True | . | . | d | fa:16:3e:46:24:4f | ci-info: | eth3: | True | . | . | . | fa:16:3e:70:41:a3 | ci-info: | eth3: | True | . | . | d | fa:16:3e:70:41:a3 | ci-info: +--------+------+---------------+---------------+-------+-------------------+ ci-info: +++++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++++ ci-info: +-------+---------------+---------------+---------------+-----------+-------+ ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags | ci-info: +-------+---------------+---------------+---------------+-----------+-------+ ci-info: | 0 | 0.0.0.0 | 192.168.200.1 | 0.0.0.0 | eth2 | UG | ci-info: | 1 | 10.0.0.0 | 0.0.0.0 | 255.255.255.0 | eth0 | U | ci-info: | 2 | 169.254.0.0 | 0.0.0.0 | 255.255.0.0 | eth0 | U | ci-info: | 3 | 169.254.0.0 | 0.0.0.0 | 255.255.0.0 | eth1 | U | ci-info: | 4 | 169.254.0.0 | 0.0.0.0 | 255.255.0.0 | eth2 | U | ci-info: | 5 | 169.254.0.0 | 0.0.0.0 | 255.255.0.0 | eth3 | U | ci-info: | 6 | 192.168.101.0 | 0.0.0.0 | 255.255.255.0 | eth1 | U | ci-info: | 7 | 192.168.200.0 | 0.0.0.0 | 255.255.255.0 | eth2 | U | ci-info: +-------+---------------+---------------+---------------+-----------+-------+ 2017-05-18 12:19:44,917 - util.py[WARNING]: failed stage init failed run of stage init

Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 648, in status_wrapper ret = functor(name, args) File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 365, in main_init init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL)) File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 649, in apply_network_config return self.distro.apply_network_config(netcfg, bring_up=bring_up) File "/usr/lib/python2.7/site-packages/cloudinit/distros/init.py", line 166, in apply_network_config dev_names = self._write_network_config(netconfig) File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 56, in _write_network_config return self._supported_write_network_config(netconfig) File "/usr/lib/python2.7/site-packages/cloudinit/distros/init.py", line 82, in _supported_write_network_config renderer.render_network_config(network_config=network_config) File "/usr/lib/python2.7/site-packages/cloudinit/net/renderer.py", line 47, in render_network_config network_state=parse_net_config_data(network_config), target=target) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 42, in parse_net_config_data nsi.parse_config(skip_broken=skip_broken) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 225, in parse_config self.parse_config_v1(skip_broken=skip_broken) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 240, in parse_config_v1 handler(self, command) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 89, in decorator return func(self, command, *args, **kwargs) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 299, in handle_physical subnet['netmask'] = mask2cidr(subnet['netmask']) File "/usr/lib/python2.7/site-packages/cloudinit/net/network_state.py", line 737, in mask2cidr if ':' in mask: TypeError: argument of type 'int' is not iterable

[root@rhel-cloud-init-patch-test network-scripts]#

ubuntu-server-builder commented 1 year ago

Launchpad user Scott Moser(smoser) wrote on 2017-05-26T18:35:50.217254+00:00

Heres a simple recreate using net-convert.py

$ cat simple-ipv6.yaml version: 1 config:

$ PYTHONPATH=$PWD ./tools/net-convert.py --network-data=simple-ipv6.yaml \ --kind=yaml --output-kind=eni --directory=out.d ... Traceback (most recent call last): File "./tools/net-convert.py", line 82, in main() ... subnet['netmask'] = mask2cidr(subnet['netmask']) File "/home/smoser-public/src/cloud-init/cloud-init/cloudinit/net/network_state.py", line 737, in mask2cidr if ':' in mask: TypeError: argument of type 'int' is not iterable

ubuntu-server-builder commented 1 year ago

Launchpad user Brian Murray(brian-murray) wrote on 2017-06-13T18:05:00.212108+00:00

Hello Andreas, or anyone else affected,

Accepted cloud-init into zesty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-init/0.7.9-153-g16a7302f-0ubuntu1~17.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

ubuntu-server-builder commented 1 year ago

Launchpad user Brian Murray(brian-murray) wrote on 2017-06-13T18:53:34.127541+00:00

Hello Andreas, or anyone else affected,

Accepted cloud-init into yakkety-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-init/0.7.9-153-g16a7302f-0ubuntu1~16.10.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

ubuntu-server-builder commented 1 year ago

Launchpad user Brian Murray(brian-murray) wrote on 2017-06-13T19:07:06.008442+00:00

Hello Andreas, or anyone else affected,

Accepted cloud-init into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-init/0.7.9-153-g16a7302f-0ubuntu1~16.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

ubuntu-server-builder commented 1 year ago

Launchpad user Chad Smith(chad.smith) wrote on 2017-06-13T21:41:37.943824+00:00

Validated xenial yakkety and zesty

xenial START -------------- Input YAML config:

Internal State !!python/object:cloudinit.net.network_state.NetworkState _network_state: dns: nameservers: [] search: [] interfaces: eth0: address: null gateway: null inet: inet mac_address: null mode: manual mtu: null name: eth0 subnets:

Generated intefaces START ---- auto lo iface lo inet loopback

auto eth0 iface eth0 inet6 static address 2000:192:168::5 netmask 64 post-up route add -A inet6 default gw 2000:192:168::1 || true pre-down route del -A inet6 default gw 2000:192:168::1 || true Generated intefaces END ---- Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==============-============-============-================================= ii cloud-init 0.7.9-153-g1 all Init scripts for cloud instances xenial DONE -------------- yakkety START -------------- Input YAML config:

Internal State !!python/object:cloudinit.net.network_state.NetworkState _network_state: dns: nameservers: [] search: [] interfaces: eth0: address: null gateway: null inet: inet mac_address: null mode: manual mtu: null name: eth0 subnets:

Generated intefaces START ---- auto lo iface lo inet loopback

auto eth0 iface eth0 inet6 static address 2000:192:168::5 netmask 64 post-up route add -A inet6 default gw 2000:192:168::1 || true pre-down route del -A inet6 default gw 2000:192:168::1 || true Generated intefaces END ---- Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==============-============-============-================================= ii cloud-init 0.7.9-153-g1 all Init scripts for cloud instances yakkety DONE -------------- zesty START -------------- Input YAML config:

Internal State !!python/object:cloudinit.net.network_state.NetworkState _network_state: dns: nameservers: [] search: [] interfaces: eth0: address: null gateway: null inet: inet mac_address: null mode: manual mtu: null name: eth0 subnets:

Generated intefaces START ---- auto lo iface lo inet loopback

auto eth0 iface eth0 inet6 static address 2000:192:168::5 netmask 64 post-up route add -A inet6 default gw 2000:192:168::1 || true pre-down route del -A inet6 default gw 2000:192:168::1 || true Generated intefaces END ---- Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==============-============-============-================================= ii cloud-init 0.7.9-153-g1 all Init scripts for cloud instances zesty DONE --------------

ubuntu-server-builder commented 1 year ago

Launchpad user Launchpad Janitor(janitor) wrote on 2017-06-27T15:51:34.880334+00:00

This bug was fixed in the package cloud-init - 0.7.9-153-g16a7302f-0ubuntu1~17.04.1


cloud-init (0.7.9-153-g16a7302f-0ubuntu1~17.04.1) zesty-proposed; urgency=medium

ubuntu-server-builder commented 1 year ago

Launchpad user Steve Langasek(vorlon) wrote on 2017-06-27T15:52:13.653732+00:00

The verification of the Stable Release Update for cloud-init has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

ubuntu-server-builder commented 1 year ago

Launchpad user Launchpad Janitor(janitor) wrote on 2017-06-27T15:54:02.062609+00:00

This bug was fixed in the package cloud-init - 0.7.9-153-g16a7302f-0ubuntu1~16.10.1


cloud-init (0.7.9-153-g16a7302f-0ubuntu1~16.10.1) yakkety-proposed; urgency=medium

ubuntu-server-builder commented 1 year ago

Launchpad user Launchpad Janitor(janitor) wrote on 2017-06-27T15:54:45.867129+00:00

This bug was fixed in the package cloud-init - 0.7.9-153-g16a7302f-0ubuntu1~16.04.1


cloud-init (0.7.9-153-g16a7302f-0ubuntu1~16.04.1) xenial-proposed; urgency=medium

ubuntu-server-builder commented 1 year ago

Launchpad user Scott Moser(smoser) wrote on 2017-09-23T02:31:12.584401+00:00

This bug is believed to be fixed in cloud-init in 17.1. If this is still a problem for you, please make a comment and set the state back to New

Thank you.