cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [29/36] git commit: Ignore comments in config files during loading
Date Fri, 10 Aug 2012 17:50:04 GMT
Ignore comments in config files during loading


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/038608b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/038608b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/038608b5

Branch: refs/heads/vpc
Commit: 038608b54f34952aab39acd8724b127dc0427339
Parents: f72146e
Author: Prasanna Santhanam <Prasanna.Santhanam@citrix.com>
Authored: Thu Aug 9 17:37:16 2012 +0530
Committer: Prasanna Santhanam <Prasanna.Santhanam@citrix.com>
Committed: Thu Aug 9 17:37:43 2012 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/configGenerator.py  |   12 ++++++++++--
 tools/marvin/marvin/deployDataCenter.py |    4 ++--
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/038608b5/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index ba4b00b..0e5e4d8 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -632,18 +632,26 @@ def get_setup_config(file):
     if not os.path.exists(file):
         raise IOError("config file %s not found. please specify a valid config file"%file)
     config = cloudstackConfiguration()
-    fp = open(file, 'r')
-    config = json.load(fp)
+    configLines = []
+    with open(file, 'r') as fp:
+        for line in fp:
+            ws = line.strip()
+            if not ws.startswith("#"):
+                configLines.append(ws)
+    config = json.loads("\n".join(configLines))
     return jsonHelper.jsonLoader(config)
 
 if __name__ == "__main__":
     parser = OptionParser()
   
+    parser.add_option("-i", "--input", action="store", default=None , dest="inputfile", help="input
file")
     parser.add_option("-a", "--advanced", action="store_true", default=False, dest="advanced",
help="use advanced networking")
     parser.add_option("-o", "--output", action="store", default="./datacenterCfg", dest="output",
help="the path where the json config file generated, by default is ./datacenterCfg")
     
     (options, args) = parser.parse_args()
     
+    if options.inputfile:
+        config = get_setup_config(options.inputfile)
     if options.advanced:
         config = describe_setup_in_advanced_mode()
     else:

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/038608b5/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py
index 68e2350..52c701b 100644
--- a/tools/marvin/marvin/deployDataCenter.py
+++ b/tools/marvin/marvin/deployDataCenter.py
@@ -243,7 +243,7 @@ class deployDataCenters():
                         dev.physicalnetworkid = phynetwrk.id
                         self.apiClient.addF5LoadBalancer(dev)
                     else:
-                        print "Device %s doesn't match any know provider type"%device
+                        raise cloudstackException.InvalidParameterException("Device %s doesn't
match any know provider type"%device)
                 self.enableProvider(result.id)
             
     def addTrafficTypes(self, physical_network_id, traffictypes):
@@ -348,7 +348,7 @@ class deployDataCenters():
             self.config = configGenerator.get_setup_config(self.configFile)
         except:
             raise cloudstackException.InvalidParameterException( \
-                            "Failed to load config %s" %sys.exc_info())
+                            "Failed to load config %s"%self.configFile)
 
         mgt = self.config.mgtSvr[0]
 


Mime
View raw message