mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	add sample code to config advanced zone
This commit is contained in:
		
							parent
							
								
									b607e4aa1c
								
							
						
					
					
						commit
						49f283f364
					
				| @ -5,6 +5,11 @@ | ||||
| 	<projects> | ||||
| 	</projects> | ||||
| 	<buildSpec> | ||||
| 		<buildCommand> | ||||
| 			<name>org.python.pydev.PyDevBuilder</name> | ||||
| 			<arguments> | ||||
| 			</arguments> | ||||
| 		</buildCommand> | ||||
| 		<buildCommand> | ||||
| 			<name>org.eclipse.jdt.core.javabuilder</name> | ||||
| 			<arguments> | ||||
| @ -13,5 +18,6 @@ | ||||
| 	</buildSpec> | ||||
| 	<natures> | ||||
| 		<nature>org.eclipse.jdt.core.javanature</nature> | ||||
| 		<nature>org.python.pydev.pythonNature</nature> | ||||
| 	</natures> | ||||
| </projectDescription> | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user