diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-10-15 01:40:25 +0100 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-11-04 21:37:39 +0000 |
| commit | efede80046e0504dc8a68ab5447f97b05c02dd7a (patch) | |
| tree | 91d38f5b23a25efc321b6df8e038444e07347bad /nova | |
| parent | dd086638b8c6e43f275fc45b3fc7df2de90bb2c2 (diff) | |
| download | nova-efede80046e0504dc8a68ab5447f97b05c02dd7a.tar.gz nova-efede80046e0504dc8a68ab5447f97b05c02dd7a.tar.xz nova-efede80046e0504dc8a68ab5447f97b05c02dd7a.zip | |
Move parse_args to nova.config
The flags module will eventually be removed and this is a first step
towards that.
Change-Id: I729b08900e53e2ae6db10633dcff3be59720fa6f
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/config.py | 29 | ||||
| -rw-r--r-- | nova/flags.py | 7 | ||||
| -rw-r--r-- | nova/test.py | 3 | ||||
| -rw-r--r-- | nova/tests/test_flags.py | 7 |
4 files changed, 35 insertions, 11 deletions
diff --git a/nova/config.py b/nova/config.py new file mode 100644 index 000000000..608a3ee53 --- /dev/null +++ b/nova/config.py @@ -0,0 +1,29 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# Copyright 2012 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from nova.openstack.common import cfg + +CONF = cfg.CONF + + +def parse_args(argv, default_config_files=None): + CONF.disable_interspersed_args() + return argv[:1] + CONF(argv[1:], + project='nova', + default_config_files=default_config_files) diff --git a/nova/flags.py b/nova/flags.py index 7d09915a5..a27674472 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -36,13 +36,6 @@ from nova.openstack.common import cfg FLAGS = cfg.CONF -def parse_args(argv, default_config_files=None): - FLAGS.disable_interspersed_args() - return argv[:1] + FLAGS(argv[1:], - project='nova', - default_config_files=default_config_files) - - class UnrecognizedFlag(Exception): pass diff --git a/nova/test.py b/nova/test.py index 911ad1390..cd82d74e2 100644 --- a/nova/test.py +++ b/nova/test.py @@ -32,6 +32,7 @@ import nose.plugins.skip import stubout import testtools +from nova import config from nova import flags from nova.openstack.common import cfg from nova.openstack.common import log as logging @@ -68,7 +69,7 @@ class TestCase(testtools.TestCase): super(TestCase, self).setUp() fake_flags.set_defaults(FLAGS) - flags.parse_args([], default_config_files=[]) + config.parse_args([], default_config_files=[]) # NOTE(vish): We need a better method for creating fixtures for tests # now that we have some required db setup for the system diff --git a/nova/tests/test_flags.py b/nova/tests/test_flags.py index 973d54a1f..15dec56b9 100644 --- a/nova/tests/test_flags.py +++ b/nova/tests/test_flags.py @@ -17,6 +17,7 @@ # License for the specific language governing permissions and limitations # under the License. +from nova import config from nova import flags from nova.openstack.common import cfg from nova import test @@ -44,7 +45,7 @@ class FlagsTestCase(test.TestCase): self.assert_('runtime_answer' not in FLAGS) argv = ['flags_test', 'extra_arg', '--runtime_answer=60'] - args = flags.parse_args(argv, default_config_files=[]) + args = config.parse_args(argv, default_config_files=[]) self.assertEqual(len(args), 3) self.assertEqual(argv, args) @@ -60,7 +61,7 @@ class FlagsTestCase(test.TestCase): default='val', help='desc')) argv = ['flags_test', '--duplicate_answer=60', 'extra_arg'] - args = flags.parse_args(argv, default_config_files=[]) + args = config.parse_args(argv, default_config_files=[]) self.assert_('duplicate_answer' not in FLAGS) self.assert_(FLAGS.duplicate_answer_long, 60) @@ -68,7 +69,7 @@ class FlagsTestCase(test.TestCase): FLAGS.clear() FLAGS.register_cli_opt(cfg.IntOpt('duplicate_answer', default=60, help='desc')) - args = flags.parse_args(argv, default_config_files=[]) + args = config.parse_args(argv, default_config_files=[]) self.assertEqual(FLAGS.duplicate_answer, 60) self.assertEqual(FLAGS.duplicate_answer_long, 'val') |
