From 3ccc790b1d3ad0d34d42897c075ad9fddd077b54 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Fri, 19 Aug 2011 18:05:32 -0700 Subject: [PATCH] add sample code to config advanced zone --- tools/.project | 40 ++++++---- tools/testClient/configGenerator.py | 111 ++++++++++++++++++++++++++- tools/testClient/deployDataCenter.py | 1 + 3 files changed, 134 insertions(+), 18 deletions(-) diff --git a/tools/.project b/tools/.project index 91737871f85..e61ed09a924 100644 --- a/tools/.project +++ b/tools/.project @@ -1,17 +1,23 @@ - - - tools - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - + + + tools + + + + + + org.python.pydev.PyDevBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + org.python.pydev.pythonNature + + diff --git a/tools/testClient/configGenerator.py b/tools/testClient/configGenerator.py index f23f18c77ce..ac6b17615d4 100644 --- a/tools/testClient/configGenerator.py +++ b/tools/testClient/configGenerator.py @@ -287,6 +287,115 @@ def describe_setup_in_basic_mode(): return zs +'''sample code to generate setup configuration file''' +def describe_setup_in_advanced_mode(): + zs = cloudstackConfiguration() + + for l in range(1): + z = zone() + z.dns1 = "8.8.8.8" + z.dns2 = "4.4.4.4" + z.internaldns1 = "192.168.110.254" + z.internaldns2 = "192.168.110.253" + z.name = "test"+str(l) + z.networktype = 'Advanced' + z.guestcidraddress = "10.1.1.0/24" + z.vlan = "100-2000" + + '''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.netmask = "255.255.255.0" + 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) + c.hosts.append(h) + + '''add 2 primary storages''' + for m in range(2): + primary = primaryStorage() + size=1*1024*1024*1024*1024 + 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)) + 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" + ips.startip = "172.16.26.2" + ips.endip = "172.16.26.100" + 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(): + 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 generate_setup_config(config, file=None): describe = config if file is None: @@ -311,5 +420,5 @@ if __name__ == "__main__": 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() - config = describe_setup_in_basic_mode() + config = describe_setup_in_advanced_mode() generate_setup_config(config, options.output) diff --git a/tools/testClient/deployDataCenter.py b/tools/testClient/deployDataCenter.py index 3cea6062bc1..6e8a35d6c2e 100644 --- a/tools/testClient/deployDataCenter.py +++ b/tools/testClient/deployDataCenter.py @@ -142,6 +142,7 @@ class deployDataCenters(): for zone in zones: '''create a zone''' createzone = createZone.createZoneCmd() + createzone.guestcidraddress = zone.guestcidraddress createzone.dns1 = zone.dns1 createzone.dns2 = zone.dns2 createzone.internaldns1 = zone.internaldns1