summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorBrian Lamar <brian.lamar@rackspace.com>2011-06-23 21:31:00 -0400
committerBrian Lamar <brian.lamar@rackspace.com>2011-06-23 21:31:00 -0400
commit655a783d5a0ef2ddadcf119793cd34513a45fe27 (patch)
tree0c48676a13c628c802028d2e3c6402de10cd6051 /nova/utils.py
parent2690e31bbd8c515771ca69a0a73e9ff5761a9079 (diff)
downloadnova-655a783d5a0ef2ddadcf119793cd34513a45fe27.tar.gz
nova-655a783d5a0ef2ddadcf119793cd34513a45fe27.tar.xz
nova-655a783d5a0ef2ddadcf119793cd34513a45fe27.zip
Created Bootstrapper to handle Nova bootstrapping logic.
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py
index a9b0f3128..a6b8d4cbe 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -743,3 +743,40 @@ def is_uuid_like(val):
if not isinstance(val, basestring):
return False
return (len(val) == 36) and (val.count('-') == 4)
+
+
+class Bootstrapper(object):
+ """Provides environment bootstrapping capabilities for entry points."""
+
+ @staticmethod
+ def bootstrap_binary(argv):
+ """Initialize the Nova environment using command line arguments."""
+ Bootstrapper.setup_flags(argv)
+ Bootstrapper.setup_logging()
+ Bootstrapper.log_flags()
+
+ @staticmethod
+ def setup_logging():
+ """Initialize logging and log a message indicating the Nova version."""
+ logging.setup()
+ logging.audit(_("Nova Version (%s)") %
+ version.version_string_with_vcs())
+
+ @staticmethod
+ def setup_flags(input_flags):
+ """Initialize flags, load flag file, and print help if needed."""
+ default_flagfile(args=input_flags)
+ FLAGS(input_flags or [])
+ flags.DEFINE_flag(flags.HelpFlag())
+ flags.DEFINE_flag(flags.HelpshortFlag())
+ flags.DEFINE_flag(flags.HelpXMLFlag())
+ FLAGS.ParseNewFlags()
+
+ @staticmethod
+ def log_flags():
+ """Log the list of all active flags being used."""
+ logging.audit(_("Currently active flags:"))
+ for key in FLAGS:
+ value = FLAGS.get(key, None)
+ logging.audit(_("%(key)s : %(value)s" % locals()))
+