register_cli_opts() does not work after register_opts()

Bug #1363808 reported by Baohua Yang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Incomplete
Undecided
Unassigned
oslo-config (Ubuntu)
Invalid
Undecided
Baohua Yang

Bug Description

The following code will not register the common_opts as cli options, unless we put register_cli_opts() ahead of register_opts()

==================
import sys
from oslo.config import cfg

if __name__ == "__main__":
    common_opts = [ cfg.StrOpt('bind_host', default='0.0.0.0', help='IP address to listen on'), cfg.IntOpt('bind_port', default=9292, help='Port number to listen on') ]

    CONF = cfg.CONF
    CONF.register_opts(common_opts)
    CONF.register_cli_opts(common_opts)

    CONF(args=sys.argv[1:])
===================

I think the usage order should not affect the registration.

Baohua Yang (yangbaohua)
Changed in oslo-config (Ubuntu):
assignee: nobody → Baohua Yang (yangbaohua)
status: New → Confirmed
status: Confirmed → Fix Committed
Baohua Yang (yangbaohua)
Changed in oslo-config (Ubuntu):
status: Fix Committed → Confirmed
Baohua Yang (yangbaohua)
Changed in oslo-config (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

I'm not sure this is really a bug. Command line options must all be registered before the command line arguments are parsed. File-only options can be registered at any point while the program is running.

Revision history for this message
Baohua Yang (yangbaohua) wrote :

To Doug Hellmann (doug-hellmann):
    Thanks for the comments, doug!
    Yes, the file-only options can be registered at any point. However, if it's registered before the cmd options, it will disable the following cmd option registration. This is inconvenient and not necessary to have the limit.
    So I suggest we trace the option owner and register correctly based on their categories.
    Thanks!

Revision history for this message
Ben Nemec (bnemec) wrote :

Why was oslo-incubator added to this bug? It doesn't exist anymore, and I don't believe any of the relevant code here ever lived in incubator anyway.

Changed in oslo-incubator:
status: New → Incomplete
Revision history for this message
Baohua Yang (yangbaohua) wrote :

invalid after lots of change.

Changed in oslo-config (Ubuntu):
status: In Progress → Invalid
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.