]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
vmlist.py: allow env to override config; add comment for Cfg class
authorDan Mick <dan.mick@redhat.com>
Fri, 8 May 2015 21:20:20 +0000 (14:20 -0700)
committerDan Mick <dan.mick@redhat.com>
Fri, 8 May 2015 21:20:20 +0000 (14:20 -0700)
Signed-off-by: Dan Mick <dan.mick@redhat.com>
tools/vmlist.py

index a786c03b5c114775f0d96586d770041737f798d6..cce2e77ebd18009f30bf9e9114a9ee0b33fdf9b2 100755 (executable)
@@ -65,6 +65,11 @@ NOVACLIENT_VERSION = '2'
 
 class Cfg(object):
 
+    '''
+    Read INI-style config file; allow uppercase versions of
+    keys present in environment to override keys in the file
+    '''
+
     def __init__(self, file):
         self.cfgparser = ConfigParser.SafeConfigParser(
             defaults={
@@ -76,6 +81,9 @@ class Cfg(object):
         self.cfgparser.read(file)
 
     def get(self, key):
+        env_val = os.environ.get(key.upper())
+        if env_val:
+            return env_val
         return self.cfgparser.get('default', key)