Commandline parsing can't handle --end value for usage/usage-list

Bug #1778536 reported by Ian Kumlien on 2018-06-25
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Medium
Takashi NATSUME

Bug Description

Imagine trying to do:
nova usage-list --start 2017-01-01 --end 2018-01-01
nova usage --tenant <project-uuid> --start 2017-01-01 --end 2018-01-01

And realizing that --end is expanded to --endpoint-override...

Example:
nova usage-list --start 2017-01-01 --end 2018-01-01
ERROR (UnknownConnectionError): Unexpected exception for 2018-01-01/2018-01-01: Invalid URL '2018-01-01/2018-01-01': No schema supplied. Perhaps you meant http://2018-01-01/2018-01-01?

This is due to how you use argparser, you should register all or handle it via namespaces

It could be reproduced in version 10.3.0.

Changed in python-novaclient:
status: New → Confirmed
importance: Undecided → Medium

The cause is the prefix matching of ArgumentParser.

https://docs.python.org/3.6/library/argparse.html#argument-abbreviations-prefix-matching

IMO, there are 2 ways to fix it.

1. Set 'allow_abbrev' to False

  But it is supported since python 3.5.
  It will not be fixed in python2.7.

  https://docs.python.org/3.6/library/argparse.html#allow-abbrev

2. rename '--endpoint-override' to '--os-endpoint-override'

Ian Kumlien (pomac) wrote :

Couldn't it be done with namespaces? or so - else i agree with solution 2 since it will work with 2.7 as well and afair it's still a target for openstack

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

Changed in python-novaclient:
assignee: nobody → Takashi NATSUME (natsume-takashi)
status: Confirmed → In Progress

Reviewed: https://review.openstack.org/580991
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=2e6ef0c45a6ada10440eb0ce87df74bf7070c1e4
Submitter: Zuul
Branch: master

commit 2e6ef0c45a6ada10440eb0ce87df74bf7070c1e4
Author: Takashi NATSUME <email address hidden>
Date: Mon Jul 9 18:40:41 2018 +0900

    Rename --endpoint-override to --os-endpoint-override

    The ``--endpoint-override`` command line argument has been deprecated.
    It is renamed to ``--os-endpoint-override`` to avoid misinterpreting
    command line arguments.
    It defaults to the ``OS_ENDPOINT_OVERRIDE`` environment variable.

    The deprecated ``--bypass-url`` command line argument has been removed.

    Change-Id: Ic8a6559cd62d46b837fa9c04b482a46ceba829db
    Closes-Bug: #1778536

Changed in python-novaclient:
status: In Progress → Fix Released

This issue was fixed in the openstack/python-novaclient 11.0.0 release.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers