summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/conf/README9
-rw-r--r--tools/conf/extract_opts.py59
-rwxr-xr-xtools/conf/generate_sample.sh10
-rwxr-xr-xtools/hacking.py9
-rw-r--r--tools/pip-requires2
-rw-r--r--tools/test-requires1
6 files changed, 65 insertions, 25 deletions
diff --git a/tools/conf/README b/tools/conf/README
new file mode 100644
index 0000000000..a76efb2a75
--- /dev/null
+++ b/tools/conf/README
@@ -0,0 +1,9 @@
+This tool is used to generate etc/nova/nova.conf.sample
+
+Run it from the top-level working directory i.e.
+
+ $> ./tools/conf/generate_sample.sh
+
+Watch out for warnings about modules like libvirt, qpid and zmq not
+being found - these warnings are significant because they result
+in options not appearing in the generated config file.
diff --git a/tools/conf/extract_opts.py b/tools/conf/extract_opts.py
index 44ae2b000f..e518a00090 100644
--- a/tools/conf/extract_opts.py
+++ b/tools/conf/extract_opts.py
@@ -20,6 +20,7 @@
import os
import re
+import socket
import sys
import textwrap
@@ -41,17 +42,19 @@ OPTION_REGEX = re.compile(r"(%s)" % "|".join([STROPT, BOOLOPT, INTOPT,
OPTION_HELP_INDENT = "####"
PY_EXT = ".py"
-BASEDIR = os.path.abspath(os.path.dirname(__file__) + "../../")
+BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))
WORDWRAP_WIDTH = 60
def main(srcfiles):
print '\n'.join(['#' * 20, '# nova.conf sample #', '#' * 20,
'', '[DEFAULT]', ''])
+ _list_opts(cfg.CommonConfigOpts,
+ cfg.__name__ + ':' + cfg.CommonConfigOpts.__name__)
mods_by_pkg = dict()
for filepath in srcfiles:
- pkg_name = filepath.split(os.sep)[3]
- mod_str = '.'.join(['.'.join(filepath.split(os.sep)[2:-1]),
+ pkg_name = filepath.split(os.sep)[1]
+ mod_str = '.'.join(['.'.join(filepath.split(os.sep)[:-1]),
os.path.basename(filepath).split('.')[0]])
mods_by_pkg.setdefault(pkg_name, list()).append(mod_str)
# NOTE(lzyeval): place top level modules before packages
@@ -69,8 +72,6 @@ def main(srcfiles):
def _print_module(mod_str):
- global OPTION_COUNT
- opts = list()
mod_obj = None
if mod_str.endswith('.__init__'):
mod_str = mod_str[:mod_str.rfind(".")]
@@ -83,28 +84,54 @@ def _print_module(mod_str):
return
except Exception, e:
return
- for attr_str in dir(mod_obj):
- attr_obj = getattr(mod_obj, attr_str)
+ _list_opts(mod_obj, mod_str)
+
+
+def _list_opts(obj, name):
+ opts = list()
+ for attr_str in dir(obj):
+ attr_obj = getattr(obj, attr_str)
if isinstance(attr_obj, cfg.Opt):
opts.append(attr_obj)
elif (isinstance(attr_obj, list) and
all(map(lambda x: isinstance(x, cfg.Opt), attr_obj))):
opts.extend(attr_obj)
- # NOTE(lzyeval): return if module has no options
if not opts:
return
+ global OPTION_COUNT
OPTION_COUNT += len(opts)
- print '######## defined in %s ########\n' % mod_str
+ print '######## defined in %s ########\n' % name
for opt in opts:
_print_opt(opt)
print
-def _convert_abspath(s):
- """Set up a reasonably sensible default for pybasedir."""
- if not s.startswith(BASEDIR):
- return s
- return s.replace(BASEDIR, '/usr/lib/python/site-packages')
+def _get_my_ip():
+ try:
+ csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ csock.connect(('8.8.8.8', 80))
+ (addr, port) = csock.getsockname()
+ csock.close()
+ return addr
+ except socket.error:
+ return None
+
+
+MY_IP = _get_my_ip()
+HOST = socket.gethostname()
+
+
+def _sanitize_default(s):
+ """Set up a reasonably sensible default for pybasedir, my_ip and host."""
+ if s.startswith(BASEDIR):
+ return s.replace(BASEDIR, '/usr/lib/python/site-packages')
+ elif s == MY_IP:
+ return '10.0.0.1'
+ elif s == HOST:
+ return 'nova'
+ elif s.strip() != s:
+ return '"%s"' % s
+ return s
def _wrap(msg, indent):
@@ -114,7 +141,7 @@ def _wrap(msg, indent):
def _print_opt(opt):
- opt_name, opt_default, opt_help = opt.name, opt.default, opt.help
+ opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help
if not opt_help:
sys.stderr.write('WARNING: "%s" is missing help string.\n' % opt_name)
opt_type = None
@@ -128,7 +155,7 @@ def _print_opt(opt):
print '# %s=<None>' % opt_name
elif opt_type == STROPT:
assert(isinstance(opt_default, basestring))
- print '# %s=%s' % (opt_name, _convert_abspath(opt_default))
+ print '# %s=%s' % (opt_name, _sanitize_default(opt_default))
elif opt_type == BOOLOPT:
assert(isinstance(opt_default, bool))
print '# %s=%s' % (opt_name, str(opt_default).lower())
diff --git a/tools/conf/generate_sample.sh b/tools/conf/generate_sample.sh
index 2a6b17aa45..25462caa28 100755
--- a/tools/conf/generate_sample.sh
+++ b/tools/conf/generate_sample.sh
@@ -16,10 +16,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-pushd $(cd $(dirname "$0") && pwd) >/dev/null
-find ../../nova -type f -name "*.py" ! -path "../../nova/tests/*" -exec \
- grep -l "Opt(" {} \; | sort -u | xargs python extract_opts.py > \
- ../../etc/nova/nova.conf.sample
+FILES=$(find nova -type f -name "*.py" ! -path "nova/tests/*" -exec \
+ grep -l "Opt(" {} \; | sort -u)
-popd >/dev/null
+PYTHONPATH=./:${PYTHONPATH} \
+ python $(dirname "$0")/extract_opts.py ${FILES} > \
+ etc/nova/nova.conf.sample
diff --git a/tools/hacking.py b/tools/hacking.py
index 88d0747942..096cf77862 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -436,7 +436,7 @@ def once_git_check_commit_title():
"""
#Get title of most recent commit
- subp = subprocess.Popen(['git', 'log', '--pretty=%s', '-1'],
+ subp = subprocess.Popen(['git', 'log', '--no-merges', '--pretty=%s', '-1'],
stdout=subprocess.PIPE)
title = subp.communicate()[0]
if subp.returncode:
@@ -450,20 +450,24 @@ def once_git_check_commit_title():
'([Bb]lue[Pp]rint|[Bb][Pp])[\s\#:]*([A-Za-z0-9\\-]+)')
GIT_REGEX = re.compile(git_keywords)
+ error = False
#NOTE(jogo) if match regex but over 3 words, acceptable title
if GIT_REGEX.search(title) is not None and len(title.split()) <= 3:
print ("N801: git commit title ('%s') should provide an accurate "
"description of the change, not just a reference to a bug "
"or blueprint" % title.strip())
+ error = True
if len(title.decode('utf-8')) > 72:
print ("N802: git commit title ('%s') should be under 50 chars"
% title.strip())
+ error = True
+ return error
if __name__ == "__main__":
#include nova path
sys.path.append(os.getcwd())
#Run once tests (not per line)
- once_git_check_commit_title()
+ once_error = once_git_check_commit_title()
#NOVA error codes start with an N
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
add_nova()
@@ -473,6 +477,7 @@ if __name__ == "__main__":
pep8.input_dir = input_dir
try:
pep8._main()
+ sys.exit(once_error)
finally:
if len(_missingImport) > 0:
print >> sys.stderr, ("%i imports missing in this test environment"
diff --git a/tools/pip-requires b/tools/pip-requires
index f2f2e50ad6..82f0289e54 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -6,7 +6,6 @@ boto==2.1.1
eventlet>=0.9.17
kombu==1.0.4
lxml==2.3
-python-daemon==1.5.5
routes==1.12.3
WebOb==1.0.8
greenlet>=0.3.1
@@ -16,7 +15,6 @@ sqlalchemy-migrate>=0.7.2
netaddr
suds==0.4
paramiko
-feedparser
Babel>=0.9.6
iso8601>=0.1.4
httplib2
diff --git a/tools/test-requires b/tools/test-requires
index e5f63d274e..1659f123a1 100644
--- a/tools/test-requires
+++ b/tools/test-requires
@@ -8,3 +8,4 @@ openstack.nose_plugin>=0.7
nosehtmloutput
pep8==1.1
sphinx>=1.1.2
+feedparser