Using netmask in ip_address of allowed_address_pairs will cause error

Bug #1518657 reported by Samuel Chen
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
New
Undecided
carl

Bug Description

Liberty heat-engine:

heat_template_version: 2014-10-16
description: ''

resources:
    'node:server':
        type: 'OS::Nova::Server'
        properties:
            name: test-vm
            availability_zone: zone1
            image: cirros-0.3.4-x86_64
            flavor: m1.tiny
            #key_name: ieccf
            networks:
              -
                  port:
                      get_resource: 'port'

    'port':
        type: 'OS::Neutron::Port'
        properties:
            name: myport
            network: OAM120
            allowed_address_pairs:
                -
                    ip_address: 192.168.120.0/24

Above template will fail with below error:
ERROR: Property error: : resources.port.properties.allowed_address_pairs[0].ip_address: : Error validating value '192.168.120.0/24': Invalid IP address

I think the error is ip_address used wrong constraint.

[root@liberty-controller heat]# diff ./engine/resources/openstack/neutron/port.py.orig ./engine/resources/openstack/neutron/port.py
195c195
< constraints.CustomConstraint('ip_addr')
---
> constraints.CustomConstraint('net_cidr')

carl (gsl0610)
Changed in heat:
assignee: nobody → carl (gsl0610)
Revision history for this message
carl (gsl0610) wrote :

The definition of ip_address:

ip_address

IP address desired in the subnet for this port.

String value expected.

Can be updated without replacement.

Value must be of type ip_addr

Revision history for this message
carl (gsl0610) wrote :

    def test_validate_ip_address(self):
        ip_addr = '1.1.1.1'
        msg = attributes._validate_ip_address(ip_addr)
        self.assertIsNone(msg)

        ip_addr = '1111.1.1.1'
        msg = attributes._validate_ip_address(ip_addr)
        self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg)

        # Depending on platform to run UTs, this case might or might not be
        # an equivalent to test_validate_ip_address_bsd.
        ip_addr = '1' * 59
        msg = attributes._validate_ip_address(ip_addr)
        self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg)

        ip_addr = '1.1.1.1 has whitespace'
        msg = attributes._validate_ip_address(ip_addr)
        self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg)

        ip_addr = '111.1.1.1\twhitespace'
        msg = attributes._validate_ip_address(ip_addr)
        self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg)

        ip_addr = '111.1.1.1\nwhitespace'
        msg = attributes._validate_ip_address(ip_addr)
        self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg)

        for ws in string.whitespace:
            ip_addr = '%s111.1.1.1' % ws
            msg = attributes._validate_ip_address(ip_addr)
            self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg)

        for ws in string.whitespace:
            ip_addr = '111.1.1.1%s' % ws
            msg = attributes._validate_ip_address(ip_addr)
            self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg)

Revision history for this message
Samuel Chen (samuel.chen) wrote :

But I saw template definition. the ip_address can be net_cidr.

http://docs.openstack.org/developer/heat/template_guide/openstack.html#OS::Neutron::Port
ip_address

IP address to allow through this port.

String value expected.

Updates cause replacement.

Value must be of type net_cidr

Rico Lin (rico-lin)
Changed in heat:
milestone: none → no-priority-tag-bugs
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.