Eric Windisch <eric@cloudscaling.com>
Ewan Mellor <ewan.mellor@citrix.com>
François Charlier <francois.charlier@enovance.com>
+Ghe Rivero <ghe@debian.org>
Isaku Yamahata <yamahata@valinux.co.jp>
Jason Koelker <jason@koelker.net>
Jesse Andrews <anotherjesse@gmail.com>
LOG = logging.getLogger('cinder.all')
if __name__ == '__main__':
- utils.default_flagfile()
+ utils.default_cfgfile()
flags.FLAGS(sys.argv)
logging.setup()
utils.monkey_patch()
from cinder import utils
if __name__ == '__main__':
- utils.default_flagfile()
+ utils.default_cfgfile()
flags.FLAGS(sys.argv)
logging.setup()
utils.monkey_patch()
def main():
"""Parse options and call the appropriate class/method."""
- flagfile = utils.default_flagfile()
+ cfgfile = utils.default_cfgfile()
- if flagfile and not os.access(flagfile, os.R_OK):
- st = os.stat(flagfile)
- print "Could not read %s. Re-running with sudo" % flagfile
+ if cfgfile and not os.access(cfgfile, os.R_OK):
+ st = os.stat(cfgfile)
+ print "Could not read %s. Re-running with sudo" % cfgfile
try:
os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv)
except Exception:
from cinder import utils
if __name__ == '__main__':
- utils.default_flagfile()
+ utils.default_cfgfile()
flags.FLAGS(sys.argv)
logging.setup()
utils.monkey_patch()
from cinder import utils
if __name__ == '__main__':
- utils.default_flagfile()
+ utils.default_cfgfile()
flags.FLAGS(sys.argv)
logging.setup()
utils.monkey_patch()
x.queue_delete(q)
if __name__ == '__main__':
- utils.default_flagfile()
+ utils.default_cfgfile()
args = flags.FLAGS(sys.argv)
logging.setup()
rpc.register_opts(flags.FLAGS)
import socket
import sys
-from cinder.compat import flagfile
from cinder.openstack.common import cfg
self.disable_interspersed_args()
def __call__(self, argv):
- with flagfile.handle_flagfiles_managed(argv[1:]) as args:
- return argv[:1] + super(CinderConfigOpts, self).__call__(args)
+ return argv[:1] + super(CinderConfigOpts, self).__call__(argv[1:])
FLAGS = CinderConfigOpts()
self.reset_flags()
self.assertEqual(FLAGS.flags_unittest, 'foo')
- def test_flagfile(self):
- opts = [
- cfg.StrOpt('string', default='default', help='desc'),
- cfg.IntOpt('int', default=1, help='desc'),
- cfg.BoolOpt('false', default=False, help='desc'),
- cfg.BoolOpt('true', default=True, help='desc'),
- cfg.MultiStrOpt('multi', default=['blaa'], help='desc'),
- ]
-
- self.FLAGS.register_opts(opts)
-
- (fd, path) = tempfile.mkstemp(prefix='cinder', suffix='.flags')
-
- try:
- os.write(fd, '--string=foo\n--int=2\n--false\n--notrue\n')
- os.write(fd, '--multi=bar\n')
- os.close(fd)
-
- self.FLAGS(['flags_test', '--flagfile=' + path])
-
- self.assertEqual(self.FLAGS.string, 'foo')
- self.assertEqual(self.FLAGS.int, 2)
- self.assertEqual(self.FLAGS.false, True)
- self.assertEqual(self.FLAGS.true, False)
- self.assertEqual(self.FLAGS.multi, ['bar'])
-
- # Re-parse to test multistring isn't append multiple times
- self.FLAGS(['flags_test', '--flagfile=' + path])
- self.assertEqual(self.FLAGS.multi, ['bar'])
- finally:
- os.remove(path)
-
def test_defaults(self):
self.FLAGS.register_opt(cfg.StrOpt('foo', default='bar', help='desc'))
self.assertEqual(self.FLAGS.foo, 'bar')
return os.path.abspath(cinder.__file__).split('cinder/__init__.py')[0]
-def default_flagfile(filename='cinder.conf', args=None):
+def default_cfgfile(filename='cinder.conf', args=None):
if args is None:
args = sys.argv
for arg in args:
- if arg.find('flagfile') != -1:
- return arg[arg.index('flagfile') + len('flagfile') + 1:]
+ if arg.find('config-file') != -1:
+ return arg[arg.index('config-file') + len('config-file') + 1:]
else:
if not os.path.isabs(filename):
# turn relative filename into an absolute path
if not os.path.exists(filename):
filename = '/etc/cinder/cinder.conf'
if os.path.exists(filename):
- flagfile = '--flagfile=%s' % filename
- args.insert(1, flagfile)
+ cfgfile = '--config-file=%s' % filename
+ args.insert(1, cfgfile)
return filename