diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2011-11-28 14:38:35 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2011-12-08 22:44:29 +0000 |
| commit | 51ff598cc8621855e1dbf106d1d68e40ffb865c7 (patch) | |
| tree | 1753a1232514caf090b157b67d03cc27d8210841 /nova/tests | |
| parent | 6916c0aed933d200fa8bda02f04d26ef61db1410 (diff) | |
Port nova.flags to cfg
This modifies nova.flags to emulate gflags using the new cfg module
instead of optparse.
One side effect of this is that nova now has a --config-file argument
which allows a .ini style config file to be used instead of a gflags
style file.
Downstream packagers may choose to switch to using this new config
file by default, or stick with the gflags style file for now. We may,
in time, choose to deprecate --flagfile.
Obviously, this change is just a stepping stone towards having Nova use
the cfg API throughout the codebase. Next steps might include:
- Adding a DEFINE_opt() function and starting to convert all the
option definitions to the cfg.Opt schema types
- Passing a ConfigOpts instance around rather than referring to the
global flags.FLAGS variable
- Adding a default .ini style config file with the default values
commented out and an explanation of each option. This could
potentially be autogenerated from the option schemas in the code.
- Making use of option groups to organize options
- In time, deprecating --flagfile
- In time, also deprecating most of the options as CLI options and
only allowing them to be set via config files
There are two hacks in the current code where we directly access the
OptionParser instance which is technically just a private implementation
detail of the ConfigOpts class:
- We need to use optparse's disable_interspersed_args(). I think it's
needed for nova-manage
- We still need the gross hack for handling unknown CLI args. We
should either make sure they are registered at startup, or just wait
until we make them unavailable via the CLI before removing the hack.
This would also allow us to remove the gross hack to allow CLI opts
to be registered after the CLI args have been parsed.
One final note - the cfg module doesn't have support yet for multistr
opts where values are spread across the command line and config files.
This isn't a regression as it still works fine with the CLI and
--flagfile, and it should be straightforward to support later.
Change-Id: I173b99ffd645b8ac5babd68e5c2ed521b98ec2ca
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_service.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/nova/tests/test_service.py b/nova/tests/test_service.py index 760b150be..0e9ffda35 100644 --- a/nova/tests/test_service.py +++ b/nova/tests/test_service.py @@ -35,6 +35,10 @@ from nova.compute import manager as compute_manager flags.DEFINE_string("fake_manager", "nova.tests.test_service.FakeManager", "Manager for testing") +flags.DEFINE_string("test_service_listen", None, + "Host to bind test service to") +flags.DEFINE_integer("test_service_listen_port", 0, + "Port number to bind test service to") class FakeManager(manager.Manager): |
