cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject git commit: updated refs/heads/master to f0ab05d
Date Fri, 21 Jun 2013 12:55:19 GMT
Updated Branches:
  refs/heads/master 3e5937e01 -> f0ab05dc0


CLOUDSTACK-3096: format configGenerator.py


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

Branch: refs/heads/master
Commit: f0ab05dc041ddf48ba1584e7dcec16622b2004e0
Parents: 3e5937e
Author: Daan Hoogland <dhoogland@schubergphilis.com>
Authored: Fri Jun 21 14:40:54 2013 +0200
Committer: Sebastien Goasguen <runseb@gmail.com>
Committed: Fri Jun 21 08:55:08 2013 -0400

----------------------------------------------------------------------
 tools/marvin/marvin/configGenerator.py | 343 ++++++++++++++++------------
 1 file changed, 194 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f0ab05dc/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index b53c46e..a33a3f4 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,13 +20,15 @@ import os
 from optparse import OptionParser
 import jsonHelper
 
+
 class managementServer():
     def __init__(self):
         self.mgtSvrIp = None
         self.port = 8096
         self.apiKey = None
         self.securityKey = None
-        
+
+
 class dbServer():
     def __init__(self):
         self.dbSvr = None
@@ -35,17 +37,20 @@ class dbServer():
         self.passwd = "cloud"
         self.db = "cloud"
 
+
 class configuration():
     def __init__(self):
         self.name = None
         self.value = None
 
+
 class logger():
     def __init__(self):
         '''TestCase/TestClient'''
         self.name = None
         self.file = None
 
+
 class cloudstackConfiguration():
     def __init__(self):
         self.zones = []
@@ -54,6 +59,7 @@ class cloudstackConfiguration():
         self.globalConfig = []
         self.logger = []
 
+
 class zone():
     def __init__(self):
         self.dns1 = None
@@ -72,21 +78,24 @@ class zone():
         self.secondaryStorages = []
         self.cacheStorages = []
 
-        
+
 class traffictype():
     def __init__(self, typ, labeldict=None):
-        self.typ = typ #Guest/Management/Public
+        self.typ = typ  # Guest/Management/Public
         if labeldict:
             self.xen = labeldict['xen'] if 'xen' in labeldict.keys() else None
             self.kvm = labeldict['kvm'] if 'kvm' in labeldict.keys() else None
-            self.vmware = labeldict['vmware'] if 'vmware' in labeldict.keys() else None
-            self.simulator = labeldict['simulator'] if 'simulator' in labeldict.keys() else
None
+            self.vmware = labeldict['vmware']\
+                if 'vmware' in labeldict.keys() else None
+            self.simulator = labeldict['simulator']\
+                if 'simulator' in labeldict.keys() else None
         #{
         #    'xen' : 'cloud-xen',
         #    'kvm' : 'cloud-kvm',
         #    'vmware' : 'cloud-vmware'
         #}
 
+
 class pod():
     def __init__(self):
         self.gateway = None
@@ -99,6 +108,7 @@ class pod():
         '''Used in basic network mode'''
         self.guestIpRanges = []
 
+
 class cluster():
     def __init__(self):
         self.clustername = None
@@ -111,7 +121,8 @@ class cluster():
         self.username = None
         self.hosts = []
         self.primaryStorages = []
-  
+
+
 class host():
     def __init__(self):
         self.hypervisor = None
@@ -127,7 +138,8 @@ class host():
         self.hostmac = None
         self.hosttags = None
         self.memory = None
-        
+
+
 class physical_network():
     def __init__(self):
         self.name = None
@@ -141,6 +153,7 @@ class physical_network():
         vrouter.name = 'VirtualRouter'
         self.providers = [vrouter]
 
+
 class provider():
     def __init__(self, name=None):
         self.name = name
@@ -150,6 +163,7 @@ class provider():
         self.servicelist = []
         self.devices = []
 
+
 class network():
     def __init__(self):
         self.displaytext = None
@@ -160,7 +174,8 @@ class network():
         self.networkdomain = None
         self.networkofferingid = None
         self.ipranges = []
-      
+
+
 class iprange():
     def __init__(self):
         '''tagged/untagged'''
@@ -173,23 +188,27 @@ class iprange():
         self.account = None
         self.domain = None
 
+
 class primaryStorage():
     def __init__(self):
         self.name = None
         self.url = None
 
+
 class secondaryStorage():
     def __init__(self):
         self.url = None
         self.provider = None
         self.details = None
 
+
 class cacheStorage():
     def __init__(self):
         self.url = None
         self.provider = None
         self.details = None
-        
+
+
 class s3():
     def __init__(self):
         self.accesskey = None
@@ -201,6 +220,7 @@ class s3():
         self.maxerrorrety = None
         self.usehttps = None
 
+
 class netscaler():
     def __init__(self, hostname=None, username='nsroot', password='nsroot'):
         self.hostname = hostname
@@ -218,8 +238,9 @@ class netscaler():
 
     def __repr__(self):
         req = zip(self.__dict__.keys(), self.__dict__.values())
-        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]]) \
-                                                     for r in req])
+        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
+                                             for r in req])
+
 
 class srx():
     def __init__(self, hostname=None, username='root', password='admin'):
@@ -240,8 +261,9 @@ class srx():
 
     def __repr__(self):
         req = zip(self.__dict__.keys(), self.__dict__.values())
-        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]]) \
-                                                     for r in req])
+        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
+                                             for r in req])
+
 
 class bigip():
     def __init__(self, hostname=None, username='root', password='default'):
@@ -260,22 +282,24 @@ class bigip():
 
     def __repr__(self):
         req = zip(self.__dict__.keys(), self.__dict__.values())
-        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]]) \
-                                                     for r in req])
+        return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
+                                             for r in req])
+
 
 def getDeviceUrl(obj):
     req = zip(obj.__dict__.keys(), obj.__dict__.values())
     if obj.hostname:
-        return "http://" + obj.hostname+"?" + "&".join(["=".join([r[0], r[1]]) \
-                                                     for r in req])
+        return "http://" + obj.hostname+"?" + "&".join(["=".join([r[0],
+                                                                  r[1]])
+                                                        for r in req])
     else:
         return None
 
-  
-'''sample code to generate setup configuration file'''
+
 def describe_setup_in_basic_mode():
+    '''sample code to generate setup configuration file'''
     zs = cloudstackConfiguration()
-    
+
     for l in range(1):
         z = zone()
         z.dns1 = "8.8.8.8"
@@ -285,118 +309,118 @@ def describe_setup_in_basic_mode():
         z.name = "test"+str(l)
         z.networktype = 'Basic'
         z.securitygroupenabled = 'True'
-    
+
         #If security groups are reqd
         sgprovider = provider()
         sgprovider.broadcastdomainrange = 'Pod'
         sgprovider.name = 'SecurityGroupProvider'
-        
+
         pn = physical_network()
         pn.name = "test-network"
         pn.traffictypes = [traffictype("Guest"), traffictype("Management")]
         pn.providers.append(sgprovider)
-        
+
         z.physical_networks.append(pn)
-        
+
         '''create 10 pods'''
         for i in range(2):
             p = pod()
-            p.name = "test" +str(l) + str(i)
-            p.gateway = "192.168.%d.1"%i
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
             p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.150"%i
-            p.endip = "192.168.%d.220"%i
-        
+            p.startip = "192.168.%d.150" % i
+            p.endip = "192.168.%d.220" % i
+
             '''add two pod guest ip ranges'''
             for j in range(2):
                 ip = iprange()
                 ip.gateway = p.gateway
                 ip.netmask = p.netmask
-                ip.startip = "192.168.%d.%d"%(i,j*20)
-                ip.endip = "192.168.%d.%d"%(i,j*20+10)
-            
+                ip.startip = "192.168.%d.%d" % (i, j*20)
+                ip.endip = "192.168.%d.%d" % (i, j*20+10)
+
                 p.guestIpRanges.append(ip)
-        
+
             '''add 10 clusters'''
             for j in range(2):
                 c = cluster()
                 c.clustername = "test"+str(l)+str(i) + str(j)
                 c.clustertype = "CloudManaged"
                 c.hypervisor = "Simulator"
-            
+
                 '''add 10 hosts'''
                 for k in range(2):
                     h = host()
                     h.username = "root"
                     h.password = "password"
                     memory = 8*1024*1024*1024
-                    localstorage=1*1024*1024*1024*1024
-                    #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&memory=%d&localstorage=%d"%(l,i,j,k,memory,localstorage)
-                    h.url = "http://sim/%d%d%d%d"%(l,i,j,k)
+                    localstorage = 1*1024*1024*1024*1024
+                    h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
                     c.hosts.append(h)
-                
+
                 '''add 2 primary storages'''
                 for m in range(2):
                     primary = primaryStorage()
                     primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
-                    #primary.url = "nfs://localhost/path%s/size=%d"%(str(l) + str(i) + str(j)
+ str(m), size)
-                    primary.url = "nfs://localhost/path%s"%(str(l) + str(i) + str(j) + str(m))
+                    primary.url = "nfs://localhost/path%s" % (str(l) + str(i) +
+                                                              str(j) + str(m))
                     c.primaryStorages.append(primary)
-        
+
                 p.clusters.append(c)
-            
+
             z.pods.append(p)
-            
+
         '''add two secondary'''
         for i in range(5):
             secondary = secondaryStorage()
             secondary.url = "nfs://localhost/path"+str(l) + str(i)
             z.secondaryStorages.append(secondary)
-        
+
         zs.zones.append(z)
-    
+
     '''Add one mgt server'''
     mgt = managementServer()
     mgt.mgtSvrIp = "localhost"
     zs.mgtSvr.append(mgt)
-    
+
     '''Add a database'''
     db = dbServer()
     db.dbSvr = "localhost"
-    
+
     zs.dbSvr = db
-    
+
     '''add global configuration'''
     global_settings = {'expunge.delay': '60',
                        'expunge.interval': '60',
                        'expunge.workers': '3',
                        }
-    for k,v in global_settings.iteritems():
+    for k, v in global_settings.iteritems():
         cfg = configuration()
         cfg.name = k
         cfg.value = v
         zs.globalConfig.append(cfg)
-    
+
     ''''add loggers'''
     testClientLogger = logger()
     testClientLogger.name = "TestClient"
     testClientLogger.file = "/tmp/testclient.log"
-    
+
     testCaseLogger = logger()
     testCaseLogger.name = "TestCase"
     testCaseLogger.file = "/tmp/testcase.log"
-    
+
     zs.logger.append(testClientLogger)
     zs.logger.append(testCaseLogger)
-    
+
     return zs
 
+
 def describe_setup_in_eip_mode():
     """
     Setting up an EIP/ELB enabled zone with netscaler provider
     """
     zs = cloudstackConfiguration()
-    
+
     for l in range(1):
         z = zone()
         z.dns1 = "8.8.8.8"
@@ -413,119 +437,123 @@ def describe_setup_in_eip_mode():
         ips.gateway = "10.147.49.1"
         ips.netmask = "255.255.255.0"
         z.ipranges.append(ips)
-        
+
         #If security groups are reqd
         sgprovider = provider()
         sgprovider.broadcastdomainrange = 'Pod'
         sgprovider.name = 'SecurityGroupProvider'
-        
+
         nsprovider = provider()
         nsprovider.name = 'Netscaler'
         ns = netscaler()
         ns.hostname = '10.147.40.100'
         nsprovider.devices.append(ns)
-        
+
         pn = physical_network()
         pn.name = "test-network"
-        pn.traffictypes = [traffictype("Guest", {"xen": "cloud-guest"}), traffictype("Management"),
traffictype("Public", { "xen": "cloud-public"})]
+        pn.traffictypes = [traffictype("Guest",
+                                       {"xen": "cloud-guest"}),
+                           traffictype("Management"),
+                           traffictype("Public", {"xen": "cloud-public"})]
         pn.providers.extend([sgprovider, nsprovider])
         z.physical_networks.append(pn)
-        
+
         '''create 10 pods'''
         for i in range(2):
             p = pod()
-            p.name = "test" +str(l) + str(i)
-            p.gateway = "192.168.%d.1"%i
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
             p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.150"%i
-            p.endip = "192.168.%d.220"%i
-        
+            p.startip = "192.168.%d.150" % i
+            p.endip = "192.168.%d.220" % i
+
             '''add two pod guest ip ranges'''
             for j in range(2):
                 ip = iprange()
                 ip.gateway = p.gateway
                 ip.netmask = p.netmask
-                ip.startip = "192.168.%d.%d"%(i,j*20)
-                ip.endip = "192.168.%d.%d"%(i,j*20+10)
-            
+                ip.startip = "192.168.%d.%d" % (i, j*20)
+                ip.endip = "192.168.%d.%d" % (i, j*20+10)
+
                 p.guestIpRanges.append(ip)
-        
+
             '''add 10 clusters'''
             for j in range(2):
                 c = cluster()
                 c.clustername = "test"+str(l)+str(i) + str(j)
                 c.clustertype = "CloudManaged"
                 c.hypervisor = "Simulator"
-            
+
                 '''add 10 hosts'''
                 for k in range(2):
                     h = host()
                     h.username = "root"
                     h.password = "password"
-                    #h.url = "http://Sim/%d%d%d%d/cpucore=1&cpuspeed=8000&memory=%d&localstorage=%d"%(l,i,j,k,memory,localstorage)
-                    h.url = "http://Sim/%d%d%d%d"%(l,i,j,k)
+                    h.url = "http://Sim/%d%d%d%d" % (l, i, j, k)
                     c.hosts.append(h)
-                
+
                 '''add 2 primary storages'''
                 for m in range(2):
                     primary = primaryStorage()
                     primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
-                    #primary.url = "nfs://localhost/path%s/size=%d"%(str(l) + str(i) + str(j)
+ str(m), size)
-                    primary.url = "nfs://localhost/path%s"%(str(l) + str(i) + str(j) + str(m))
+                    primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
+                                                              + str(j)
+                                                              + str(m))
                     c.primaryStorages.append(primary)
-        
+
                 p.clusters.append(c)
-            
+
             z.pods.append(p)
-            
+
         '''add two secondary'''
         for i in range(5):
             secondary = secondaryStorage()
             secondary.url = "nfs://localhost/path"+str(l) + str(i)
             z.secondaryStorages.append(secondary)
-        
+
         zs.zones.append(z)
-    
+
     '''Add one mgt server'''
     mgt = managementServer()
     mgt.mgtSvrIp = "localhost"
     zs.mgtSvr.append(mgt)
-    
+
     '''Add a database'''
     db = dbServer()
     db.dbSvr = "localhost"
-    
+
     zs.dbSvr = db
-    
+
     '''add global configuration'''
     global_settings = {'expunge.delay': '60',
                        'expunge.interval': '60',
                        'expunge.workers': '3',
                        }
-    for k,v in global_settings.iteritems():
+    for k, v in global_settings.iteritems():
         cfg = configuration()
         cfg.name = k
         cfg.value = v
         zs.globalConfig.append(cfg)
-    
+
     ''''add loggers'''
     testClientLogger = logger()
     testClientLogger.name = "TestClient"
     testClientLogger.file = "/tmp/testclient.log"
-    
+
     testCaseLogger = logger()
     testCaseLogger.name = "TestCase"
     testCaseLogger.file = "/tmp/testcase.log"
-    
+
     zs.logger.append(testClientLogger)
     zs.logger.append(testCaseLogger)
-    
+
     return zs
-    
-'''sample code to generate setup configuration file'''
+
+
 def describe_setup_in_advanced_mode():
+    '''sample code to generate setup configuration file'''
     zs = cloudstackConfiguration()
-    
+
     for l in range(1):
         z = zone()
         z.dns1 = "8.8.8.8"
@@ -536,10 +564,11 @@ def describe_setup_in_advanced_mode():
         z.networktype = 'Advanced'
         z.guestcidraddress = "10.1.1.0/24"
         z.vlan = "100-2000"
-        
+
         pn = physical_network()
         pn.name = "test-network"
-        pn.traffictypes = [traffictype("Guest"), traffictype("Management"), traffictype("Public")]
+        pn.traffictypes = [traffictype("Guest"), traffictype("Management"),
+                           traffictype("Public")]
 
         vpcprovider = provider('VpcVirtualRouter')
 
@@ -554,52 +583,57 @@ def describe_setup_in_advanced_mode():
 
         pn.providers.extend([vpcprovider, nsprovider, srxprovider, f5provider])
         z.physical_networks.append(pn)
-    
+
         '''create 10 pods'''
         for i in range(2):
             p = pod()
-            p.name = "test" +str(l) + str(i)
-            p.gateway = "192.168.%d.1"%i
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
             p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.200"%i
-            p.endip = "192.168.%d.220"%i
-        
+            p.startip = "192.168.%d.200" % i
+            p.endip = "192.168.%d.220" % i
+
             '''add 10 clusters'''
             for j in range(2):
                 c = cluster()
                 c.clustername = "test"+str(l)+str(i) + str(j)
                 c.clustertype = "CloudManaged"
                 c.hypervisor = "Simulator"
-            
+
                 '''add 10 hosts'''
                 for k in range(2):
                     h = host()
                     h.username = "root"
                     h.password = "password"
-                    memory = 8*1024*1024*1024
-                    localstorage=1*1024*1024*1024*1024
-                    #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&memory=%d&localstorage=%d"%(l,i,j,k,memory,localstorage)
-                    h.url = "http://sim/%d%d%d%d"%(l,i,j,k)
+                    memory = 8 * 1024 * 1024 * 1024
+                    localstorage = 1 * 1024 * 1024 * 1024 * 1024
+                    #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
+                    #    memory=%d&localstorage=%d"%(l, i, j, k, memory,
+                    #                                localstorage)
+                    h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
                     c.hosts.append(h)
-                
+
                 '''add 2 primary storages'''
                 for m in range(2):
                     primary = primaryStorage()
                     primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
-                    #primary.url = "nfs://localhost/path%s/size=%d"%(str(l) + str(i) + str(j)
+ str(m), size)
-                    primary.url = "nfs://localhost/path%s"%(str(l) + str(i) + str(j) + str(m))
+                    #primary.url = "nfs://localhost/path%s/size=%d" %
+                    #    (str(l) + str(i) + str(j) + str(m), size)
+                    primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
+                                                              + str(j)
+                                                              + str(m))
                     c.primaryStorages.append(primary)
-        
+
                 p.clusters.append(c)
-            
+
             z.pods.append(p)
-            
+
         '''add two secondary'''
         for i in range(5):
             secondary = secondaryStorage()
             secondary.url = "nfs://localhost/path"+str(l) + str(i)
             z.secondaryStorages.append(secondary)
-        
+
         '''add default public network'''
         ips = iprange()
         ips.vlan = "26"
@@ -608,47 +642,48 @@ def describe_setup_in_advanced_mode():
         ips.gateway = "172.16.26.1"
         ips.netmask = "255.255.255.0"
         z.ipranges.append(ips)
-        
-        
+
         zs.zones.append(z)
-    
+
     '''Add one mgt server'''
     mgt = managementServer()
     mgt.mgtSvrIp = "localhost"
     zs.mgtSvr.append(mgt)
-    
+
     '''Add a database'''
     db = dbServer()
     db.dbSvr = "localhost"
-    
+
     zs.dbSvr = db
-    
+
     '''add global configuration'''
     global_settings = {'expunge.delay': '60',
                        'expunge.interval': '60',
                        'expunge.workers': '3',
                        }
-    for k,v in global_settings.iteritems():
+    for k, v in global_settings.iteritems():
         cfg = configuration()
         cfg.name = k
         cfg.value = v
         zs.globalConfig.append(cfg)
-    
+
     ''''add loggers'''
     testClientLogger = logger()
     testClientLogger.name = "TestClient"
     testClientLogger.file = "/tmp/testclient.log"
-    
+
     testCaseLogger = logger()
     testCaseLogger.name = "TestCase"
     testCaseLogger.file = "/tmp/testcase.log"
-    
+
     zs.logger.append(testClientLogger)
     zs.logger.append(testCaseLogger)
-    
+
     return zs
 
 '''sample code to generate setup configuration file'''
+
+
 def describe_setup_in_advancedsg_mode():
     zs = cloudstackConfiguration()
 
@@ -671,18 +706,18 @@ def describe_setup_in_advancedsg_mode():
         sgprovider = provider()
         sgprovider.broadcastdomainrange = 'ZONE'
         sgprovider.name = 'SecurityGroupProvider'
-		
+
         pn.providers.append(sgprovider)
         z.physical_networks.append(pn)
 
         '''create 10 pods'''
         for i in range(2):
             p = pod()
-            p.name = "test" +str(l) + str(i)
-            p.gateway = "192.168.%d.1"%i
+            p.name = "test" + str(l) + str(i)
+            p.gateway = "192.168.%d.1" % i
             p.netmask = "255.255.255.0"
-            p.startip = "192.168.%d.200"%i
-            p.endip = "192.168.%d.220"%i
+            p.startip = "192.168.%d.200" % i
+            p.endip = "192.168.%d.220" % i
 
             '''add 10 clusters'''
             for j in range(2):
@@ -696,18 +731,22 @@ def describe_setup_in_advancedsg_mode():
                     h = host()
                     h.username = "root"
                     h.password = "password"
-                    memory = 8*1024*1024*1024
-                    localstorage=1*1024*1024*1024*1024
-                    #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&memory=%d&localstorage=%d"%(l,i,j,k,memory,localstorage)
-                    h.url = "http://sim/%d%d%d%d"%(l,i,j,k)
+                    memory = 8 * 1024 * 1024 * 1024
+                    localstorage = 1 * 1024 * 1024 * 1024 * 1024
+                    #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
+                        #memory=%d&localstorage=%d" % (l, i, j, k, memory,
+                        #localstorage)
+                    h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
                     c.hosts.append(h)
 
                 '''add 2 primary storages'''
                 for m in range(2):
                     primary = primaryStorage()
                     primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
-                    #primary.url = "nfs://localhost/path%s/size=%d"%(str(l) + str(i) + str(j)
+ str(m), size)
-                    primary.url = "nfs://localhost/path%s"%(str(l) + str(i) + str(j) + str(m))
+                    #primary.url = "nfs://localhost/path%s/size=%d" % \
+                        #(str(l) + str(i) + str(j) + str(m), size)
+                    primary.url = "nfs://localhost/path%s" % \
+                        (str(l) + str(i) + str(j) + str(m))
                     c.primaryStorages.append(primary)
 
                 p.clusters.append(c)
@@ -729,7 +768,6 @@ def describe_setup_in_advancedsg_mode():
         ips.netmask = "255.255.255.0"
         z.ipranges.append(ips)
 
-
         zs.zones.append(z)
 
     '''Add one mgt server'''
@@ -748,7 +786,7 @@ def describe_setup_in_advancedsg_mode():
                        'expunge.interval': '60',
                        'expunge.workers': '3',
                        }
-    for k,v in global_settings.iteritems():
+    for k, v in global_settings.iteritems():
         cfg = configuration()
         cfg.name = k
         cfg.value = v
@@ -768,6 +806,7 @@ def describe_setup_in_advancedsg_mode():
 
     return zs
 
+
 def generate_setup_config(config, file=None):
     describe = config
     if file is None:
@@ -776,11 +815,12 @@ def generate_setup_config(config, file=None):
         fp = open(file, 'w')
         json.dump(jsonHelper.jsonDump.dump(describe), fp, indent=4)
         fp.close()
-        
-    
+
+
 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)
+        raise IOError("config file %s not found. \
+please specify a valid config file" % file)
     config = cloudstackConfiguration()
     configLines = []
     with open(file, 'r') as fp:
@@ -793,14 +833,21 @@ def get_setup_config(file):
 
 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("-s", "--advancedsg", action="store_true", default=False, dest="advancedsg",
help="use advanced networking with security groups")
-    parser.add_option("-o", "--output", action="store", default="./datacenterCfg", dest="output",
help="the path where the json config file generated, by default is ./datacenterCfg")
-    
+
+    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("-s", "--advancedsg", action="store_true", default=False,
+                      dest="advancedsg", help="use advanced networking \
+with security groups")
+    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:
@@ -809,7 +856,5 @@ if __name__ == "__main__":
         config = describe_setup_in_advancedsg_mode()
     else:
         config = describe_setup_in_basic_mode()
-        
+
     generate_setup_config(config, options.output)
-    
-    


Mime
View raw message