Move parse_args to nova.config
The flags module will eventually be removed and this is a first step towards that. Change-Id: I729b08900e53e2ae6db10633dcff3be59720fa6f
This commit is contained in:
@@ -40,6 +40,7 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.objectstore import s3server
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -51,7 +52,7 @@ from nova.vnc import xvp_proxy
|
||||
LOG = logging.getLogger('nova.all')
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
launcher = service.ProcessLauncher()
|
||||
|
@@ -36,13 +36,14 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
launcher = service.ProcessLauncher()
|
||||
|
@@ -32,13 +32,14 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
server = service.WSGIService('ec2')
|
||||
|
@@ -32,13 +32,14 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
server = service.WSGIService('metadata')
|
||||
|
@@ -32,13 +32,14 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
server = service.WSGIService('osapi_compute')
|
||||
|
@@ -32,13 +32,14 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
|
||||
sys.path.insert(0, POSSIBLE_TOPDIR)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
FLAGS = flags.FLAGS
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
|
@@ -42,6 +42,7 @@ gettext.install('nova', unicode=1)
|
||||
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -69,7 +70,7 @@ def delete_queues(queues):
|
||||
x.queue_delete(q)
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = flags.parse_args(sys.argv)
|
||||
args = config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
delete_queues(args[1:])
|
||||
if FLAGS.delete_exchange:
|
||||
|
@@ -34,13 +34,14 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
|
||||
sys.path.insert(0, POSSIBLE_TOPDIR)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
FLAGS = flags.FLAGS
|
||||
logging.setup('nova')
|
||||
utils.monkey_patch()
|
||||
|
@@ -33,12 +33,13 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
FLAGS = flags.FLAGS
|
||||
logging.setup("nova")
|
||||
server = service.Service.create(binary='nova-console',
|
||||
|
@@ -32,13 +32,14 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
||||
|
||||
|
||||
from nova.consoleauth import manager
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
FLAGS = flags.FLAGS
|
||||
logging.setup("nova")
|
||||
server = service.Service.create(binary='nova-consoleauth',
|
||||
|
@@ -37,6 +37,7 @@ gettext.install('nova', unicode=1)
|
||||
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.network import linux_net
|
||||
from nova.network import rpcapi as network_rpcapi
|
||||
@@ -94,7 +95,7 @@ def init_leases(network_id):
|
||||
def main():
|
||||
"""Parse environment and arguments and call the approproate action."""
|
||||
flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile)
|
||||
argv = flags.parse_args(sys.argv, default_config_files=[flagfile])
|
||||
argv = config.parse_args(sys.argv, default_config_files=[flagfile])
|
||||
logging.setup("nova")
|
||||
|
||||
if int(os.environ.get('TESTING', '0')):
|
||||
|
@@ -73,6 +73,7 @@ gettext.install('nova', unicode=1)
|
||||
from nova.api.ec2 import ec2utils
|
||||
from nova.compute import instance_types
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova import config
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova.db import migration
|
||||
@@ -1220,7 +1221,7 @@ def main():
|
||||
"""Parse options and call the appropriate class/method."""
|
||||
|
||||
try:
|
||||
argv = flags.parse_args(sys.argv)
|
||||
argv = config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
except cfg.ConfigFilesNotFoundError:
|
||||
cfgfile = FLAGS.config_file[-1] if FLAGS.config_file else None
|
||||
|
@@ -34,13 +34,14 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
FLAGS = flags.FLAGS
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
|
@@ -28,6 +28,7 @@ import sys
|
||||
|
||||
import websockify
|
||||
|
||||
from nova import config
|
||||
from nova.consoleauth import rpcapi as consoleauth_rpcapi
|
||||
from nova import context
|
||||
from nova import flags
|
||||
@@ -133,7 +134,7 @@ if __name__ == '__main__':
|
||||
parser.error("SSL only and %s not found" % FLAGS.cert)
|
||||
|
||||
# Setup flags
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
|
||||
# Check to see if novnc html/js/css files are present
|
||||
if not os.path.exists(FLAGS.web):
|
||||
|
@@ -34,6 +34,7 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.objectstore import s3server
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -42,7 +43,7 @@ from nova import utils
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
server = s3server.get_wsgi_server()
|
||||
|
@@ -32,6 +32,7 @@ POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
|
||||
sys.path.insert(0, POSSIBLE_TOPDIR)
|
||||
|
||||
from nova import config
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -45,7 +46,7 @@ FLAGS.register_opts(impl_zmq.zmq_opts)
|
||||
|
||||
|
||||
def main():
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
|
||||
|
@@ -36,13 +36,14 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
||||
|
||||
gettext.install('nova', unicode=1)
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
FLAGS = flags.FLAGS
|
||||
logging.setup("nova")
|
||||
utils.monkey_patch()
|
||||
|
@@ -31,6 +31,7 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
|
||||
from nova import config
|
||||
from nova import flags
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import rpc
|
||||
@@ -40,7 +41,7 @@ from nova.vnc import xvp_proxy
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
if __name__ == "__main__":
|
||||
flags.parse_args(sys.argv)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup("nova")
|
||||
|
||||
wsgi_server = xvp_proxy.get_wsgi_server()
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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')
|
||||
|
||||
|
Reference in New Issue
Block a user