summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-03-05 16:54:57 -0800
committerVishvananda Ishaya <vishvananda@gmail.com>2012-03-05 17:27:44 -0800
commit9627c88d688fd276d82c06bb7d11aefecce5e7d4 (patch)
tree4ed9895badeab947c76bcae024ec26bd23c23a29
parent43b52f7bd224209771245d987c3ff0f2506803ec (diff)
downloadnova-9627c88d688fd276d82c06bb7d11aefecce5e7d4.tar.gz
nova-9627c88d688fd276d82c06bb7d11aefecce5e7d4.tar.xz
nova-9627c88d688fd276d82c06bb7d11aefecce5e7d4.zip
Allows new style config to be used for --flagfile
* includes tests * fixes bug 947549 Change-Id: Ibf319ea75a2d6156c5d8f1112cd58a33e5a98fe0
-rw-r--r--nova/compat/flagfile.py4
-rw-r--r--nova/tests/test_compat_flagfile.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/nova/compat/flagfile.py b/nova/compat/flagfile.py
index 02d571cbf..3b5845c3d 100644
--- a/nova/compat/flagfile.py
+++ b/nova/compat/flagfile.py
@@ -97,6 +97,10 @@ def _read_flagfile(arg, next_arg, tempdir=None):
args = _read_lines(flagfile)
+ if args and not args[0].startswith('--'):
+ # This is a config file, not a flagfile, so return it.
+ return ['--config-file=' + flagfile] + argp[1:]
+
#
# We're recursing here to convert any --flagfile arguments
# read from this flagfile into --config-file arguments
diff --git a/nova/tests/test_compat_flagfile.py b/nova/tests/test_compat_flagfile.py
index 8ad9f8c75..d1af9c4b4 100644
--- a/nova/tests/test_compat_flagfile.py
+++ b/nova/tests/test_compat_flagfile.py
@@ -18,7 +18,6 @@ import contextlib
import os
import shutil
import StringIO
-import stubout
import textwrap
import tempfile
import unittest
@@ -150,9 +149,15 @@ class CompatFlagfileTestCase(test.TestCase):
self._do_test_flagfile('--noverbose', 'verbose=false\n')
def test_flagfile_comments(self):
- self._do_test_flagfile('--bar=foo\n#foo\n--foo=bar\n//bar',
+ self._do_test_flagfile(' \n\n#foo\n--bar=foo\n--foo=bar\n//bar',
'bar=foo\nfoo=bar\n')
+ def test_flagfile_is_config(self):
+ self.files['foo.flags'] = '\n\n#foo\n//bar\n[DEFAULT]\nbar=foo'
+ before = ['--flagfile=foo.flags']
+ after = flagfile.handle_flagfiles(before, tempdir=self.tempdir)
+ self.assertEquals(after, ['--config-file=foo.flags'])
+
def test_flagfile_nested(self):
self.files['bar.flags'] = '--foo=bar'