cloud-init mishandles dhcp6 subnets in network_data.json

Bug #1734739 reported by Ryan McCabe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Invalid
Undecided
Unassigned

Bug Description

It looks like there's a typo in the helpers/openstack.py network_data.json parser.

With a config like:

{
  "links" : [ {
    "name" : "test",
    "id" : "test",
    "type" : "vif"
  } ],
  "networks" : [ {
    "netmask" : "255.255.255.0",
    "link" : "test",
    "id" : "test",
    "ip_address" : "192.168.122.201",
    "type" : "ipv4",
    "gateway" : "192.168.122.1"
  }, {
    "link" : "test",
    "id" : "test",
    "type" : "dhcp6"
  } ]
}

the resulting network state object is

Internal State
!!python/object:cloudinit.net.network_state.NetworkState
_network_state:
    dns:
        nameservers: []
        search: []
    interfaces:
        !!python/unicode 'test':
            address: null
            gateway: null
            inet: inet
            mac_address: null
            mode: manual
            mtu: null
            name: !!python/unicode 'test'
            subnets:
            - address: !!python/unicode '192.168.122.201'
                !!python/unicode 'gateway': !!python/unicode '192.168.122.1'
                ipv4: true
                !!python/unicode 'netmask': !!python/unicode '255.255.255.0'
                !!python/unicode 'type': static
            - !!python/unicode 'type': dhcp4
            type: physical
    routes: []
_version: 1

When it should be

Internal State
!!python/object:cloudinit.net.network_state.NetworkState
_network_state:
    dns:
        nameservers: []
        search: []
    interfaces:
        !!python/unicode 'test':
            address: null
            gateway: null
            inet: inet
            mac_address: null
            mode: manual
            mtu: null
            name: !!python/unicode 'test'
            subnets:
            - address: !!python/unicode '192.168.122.201'
                !!python/unicode 'gateway': !!python/unicode '192.168.122.1'
                ipv4: true
                !!python/unicode 'netmask': !!python/unicode '255.255.255.0'
                !!python/unicode 'type': static
            - !!python/unicode 'type': dhcp6
            type: physical
    routes: []
_version: 1

It looks like this is caused by an error on line 570 of helpers/openstack.py where the test used is:

t = 'dhcp6' if network['type'].startswith('ipv6') else 'dhcp4'

which will always result in 'dhcp4' since the network type is 'dhcp6'

it looks like changing the test to

t = 'dhcp6' if network['type'].endswith('6') else 'dhcp4'

fixes things.

Revision history for this message
Ryan McCabe (rmccabe) wrote :

ovirt will change to match openstack, so that no changes are needed.

Changed in cloud-init:
status: New → Invalid
Revision history for this message
Scott Moser (smoser) wrote :

Just for historic purposes,
Ryan's response here was due to my comment on his merge proposal that sayd:

I'm somewhat disappointed that this passed unit tests.

There are real-ish world examples at bug 1514082
of things like:
        {
            "id": "network0",
            "link": "tap54d10236-5d",
            "network_id": "a5d1181f-bedd-40a5-8b4a-5574b74dba61",
            "type": "ipv4_dhcp"
        },

Did openstack *change* the 'type' value for dhcp from
  ipv4_dhcp or ipv6_dhcp
to
  dhcp4 or dhcp6 ?

like you show in your bug?

Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.