add sample code to config advanced zone

This commit is contained in:
Edison Su 2011-08-19 18:05:32 -07:00
parent b607e4aa1c
commit 49f283f364
3 changed files with 134 additions and 18 deletions

View File

@ -1,17 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>tools</name> <name>tools</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.python.pydev.PyDevBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> <buildCommand>
<natures> <name>org.eclipse.jdt.core.javabuilder</name>
<nature>org.eclipse.jdt.core.javanature</nature> <arguments>
</natures> </arguments>
</projectDescription> </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

View File

@ -287,6 +287,115 @@ def describe_setup_in_basic_mode():
return zs 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): def generate_setup_config(config, file=None):
describe = config describe = config
if file is None: 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") 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() (options, args) = parser.parse_args()
config = describe_setup_in_basic_mode() config = describe_setup_in_advanced_mode()
generate_setup_config(config, options.output) generate_setup_config(config, options.output)

View File

@ -142,6 +142,7 @@ class deployDataCenters():
for zone in zones: for zone in zones:
'''create a zone''' '''create a zone'''
createzone = createZone.createZoneCmd() createzone = createZone.createZoneCmd()
createzone.guestcidraddress = zone.guestcidraddress
createzone.dns1 = zone.dns1 createzone.dns1 = zone.dns1
createzone.dns2 = zone.dns2 createzone.dns2 = zone.dns2
createzone.internaldns1 = zone.internaldns1 createzone.internaldns1 = zone.internaldns1