subnet: --enable-dhcp=False/True syntax is not accepted since 2.3.5

Bug #1401555 reported by Ihar Hrachyshka
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-neutronclient
Fix Released
High
Ihar Hrachyshka

Bug Description

Here is what users get when trying the old syntax for --enable-dhcp that was valid for 2.3.4 in 2.3.5+ versions:

b469d63876a24af5ebf public 172.24.4.224/28' returned 2: usage: neutron subnet-create [-h] [-f {shell,table}] [-c COLUMN]
                             [--variable VARIABLE] [--prefix PREFIX]
                             [--request-format {json,xml}]
                             [--tenant-id TENANT_ID] [--name NAME]
                             [--gateway GATEWAY_IP] [--no-gateway]
                             [--allocation-pool start=IP_ADDR,end=IP_ADDR]
                             [--host-route destination=CIDR,nexthop=IP_ADDR]
                             [--dns-nameserver DNS_NAMESERVER]
                             [--disable-dhcp] [--enable-dhcp]
                             [--ipv6-ra-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]
                             [--ipv6-address-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]
                             [--ip-version {4,6}]
                             NETWORK CIDR
neutron subnet-create: error: argument --enable-dhcp: ignored explicit argument u'False'

This is due to the following commit: https://review.openstack.org/#/c/96199/

For backwards compatibility reasons, we need to support both new and old versions of the argument.

Changed in python-neutronclient:
assignee: nobody → Ihar Hrachyshka (ihar-hrachyshka)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/141063

Changed in python-neutronclient:
status: New → In Progress
summary: - --enable-dhcp=False/True syntax is not accepted as of 2.3.5
+ --enable-dhcp=False/True syntax is not accepted since 2.3.5
summary: - --enable-dhcp=False/True syntax is not accepted since 2.3.5
+ subnet: --enable-dhcp=False/True syntax is not accepted since 2.3.5
Kyle Mestery (mestery)
Changed in python-neutronclient:
milestone: none → 2.3.10
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-neutronclient (master)

Reviewed: https://review.openstack.org/141063
Committed: https://git.openstack.org/cgit/openstack/python-neutronclient/commit/?id=fea8706c22438af5666bc249f86aa5facf97564d
Submitter: Jenkins
Branch: master

commit fea8706c22438af5666bc249f86aa5facf97564d
Author: Ihar Hrachyshka <email address hidden>
Date: Thu Dec 11 12:42:39 2014 +0100

    subnet: allow --enable-dhcp=False/True syntax, again

    Till neutronclient 2.3.4, we allowed the following syntax to enable or
    disable DHCP: --enable-dhcp=False or --enable-dhcp=True. Since
    I52d05ec2284b6910a33df4a5cb7dc3888737acb6 was merged, it's not the case
    anymore.

    Client libraries should be backwards compatible.

    The change that introduced the regression cannot be reverted. First,
    because it's correct in essence and fixed a valid bug in neutron client
    CLI, and second (and more importantly), we don't want to break backwards
    compatibility for users that currently use 2.3.5+ version that already
    included the new style of the argument.

    So we need to support both new and old styles for setting the attribute.

    It's sad, but argparse module that we use to parse CLI arguments does
    not allow to distinguish between '--enable-dhcp=smth' and '--enable-dhcp
    smth' variants of the argument. This limitation means that an argument
    with nargs=argparse.OPTIONAL that would be useful to cover both styles
    with single entry would consume the next argument from the command line
    if it's present and does not seem to be another option argument defined
    for the parser. Meaning, it would break some cases, f.e. when
    --enable-dhcp is passed right before subnet name. In that specific case,
    the argument would consume the name as the value of the argument and
    break the client.

    That's why for this specific fix, we're forced to use
    --enable-dhcp=False and --enable-dhcp=True as argument *names*. It's
    ugly as hell, so let's hide that mess from users by suppressing help
    entries for new arguments.

    PS: And Oh Lord the Mighty, thank you for only two possible values for
    boolean attributes!)

    Closes-Bug: #1401555
    Change-Id: Ib374d1cc499e4f1e5242f1b438bc65512c109e40

Changed in python-neutronclient:
status: In Progress → Fix Committed
Akihiro Motoki (amotoki)
Changed in python-neutronclient:
status: Fix Committed → Fix Released
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.