]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove old flagfile support
authorGhe Rivero <ghe@debian.org>
Mon, 16 Jul 2012 19:31:51 +0000 (20:31 +0100)
committerMark McLoughlin <markmc@redhat.com>
Mon, 16 Jul 2012 20:52:59 +0000 (21:52 +0100)
Cherry-picks 7e3e9b8 from Nova.

Change-Id: Id5a0ffabf7c6eab0bbda1b130a39a6581b26e350

Authors
bin/cinder-all
bin/cinder-api
bin/cinder-manage
bin/cinder-scheduler
bin/cinder-volume
bin/clear_rabbit_queues
cinder/flags.py
cinder/tests/test_flags.py
cinder/utils.py

diff --git a/Authors b/Authors
index 310e6bd7e11ca88a6931523d3be93430e4d29382..24eb71e78f10a9641d63e57a518f30375ca16c43 100644 (file)
--- a/Authors
+++ b/Authors
@@ -15,6 +15,7 @@ Eric Day <eday@oddments.org>
 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>
index 8bec9bbb39b8c84358078e1ef90a2002ab875010..4ea8104f30fce3f16976f8b40d471947a7d45cea 100755 (executable)
@@ -49,7 +49,7 @@ from cinder import utils
 LOG = logging.getLogger('cinder.all')
 
 if __name__ == '__main__':
-    utils.default_flagfile()
+    utils.default_cfgfile()
     flags.FLAGS(sys.argv)
     logging.setup()
     utils.monkey_patch()
index ba28b1a445dbcadc7ad92884858d891418b44496..be8a138d0327fddf3d12f03cf625ed54e27bf966 100755 (executable)
@@ -38,7 +38,7 @@ from cinder import service
 from cinder import utils
 
 if __name__ == '__main__':
-    utils.default_flagfile()
+    utils.default_cfgfile()
     flags.FLAGS(sys.argv)
     logging.setup()
     utils.monkey_patch()
index 0cc6d82c89239da332b8145242e7ce51a0da5003..078a405a22163e91cf2f351da3ca643f3bfc3d63 100755 (executable)
@@ -546,11 +546,11 @@ def methods_of(obj):
 
 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:
index f423bef63e96ab4eedb6b5d50ead3f7c170aaaea..716d04b6980e466537291f92a5668f534b5fbe3d 100755 (executable)
@@ -42,7 +42,7 @@ from cinder import service
 from cinder import utils
 
 if __name__ == '__main__':
-    utils.default_flagfile()
+    utils.default_cfgfile()
     flags.FLAGS(sys.argv)
     logging.setup()
     utils.monkey_patch()
index 53aa635a6fad8b7f171a1422d2a3490f7a5fb7a7..346cf86305f07e19d78b7b5c0d20446689e0220c 100755 (executable)
@@ -40,7 +40,7 @@ from cinder import service
 from cinder import utils
 
 if __name__ == '__main__':
-    utils.default_flagfile()
+    utils.default_cfgfile()
     flags.FLAGS(sys.argv)
     logging.setup()
     utils.monkey_patch()
index d652d6e14c7d46b92c8c812d7c4bacaf41c65c0d..a942fca6c8b0792f0e70ad9cb3bf710304f53e26 100755 (executable)
@@ -71,7 +71,7 @@ def delete_queues(queues):
         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)
index e3178cb3183ee80e33b08dea549273e14c9c0c28..dd532896f406c37668ffa99529ff6280a99ef7ca 100644 (file)
@@ -30,7 +30,6 @@ import os
 import socket
 import sys
 
-from cinder.compat import flagfile
 from cinder.openstack.common import cfg
 
 
@@ -43,8 +42,7 @@ class CinderConfigOpts(cfg.CommonConfigOpts):
         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()
index e94c3484ed203518d30f39f7283da40c2f7dbe8c..704966c8156d2cd6a13fa97c6d6bdc4796a418d8 100644 (file)
@@ -99,38 +99,6 @@ class FlagsTestCase(test.TestCase):
         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')
index f80fb143183c939534e77c5fdd9ae354fc83bdcf..8102722da1d2d630f5c06e662a5ab556965d561c 100644 (file)
@@ -307,12 +307,12 @@ def cinderdir():
     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
@@ -323,8 +323,8 @@ def default_flagfile(filename='cinder.conf', args=None):
             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