diff --git a/agent-simulator/scripts/kumquat/setup.py b/agent-simulator/scripts/kumquat/setup.py new file mode 100644 index 00000000000..035c70865a6 --- /dev/null +++ b/agent-simulator/scripts/kumquat/setup.py @@ -0,0 +1,181 @@ +#!/usr/bin/env python + +''' +############################################################ +# Kumquat uses nfs storage, before setting up make sure +# * optionally turn off stats collectors +# * expunge.delay and expunge.interval are 60s +############################################################ +''' + +from optparse import OptionParser +from configGenerator import * +import random + + +def getGlobalSettings(): + global_settings = {'expunge.delay': '60', + 'expunge.interval': '60', + 'capacity.skipcounting.hours': '2', + 'cpu.overprovisioning.factor': '1.5', + 'expunge.workers': '3', + 'workers': '10', + 'use.user.concentrated.pod.allocation': 'true', + 'vm.allocation.algorithm': 'random', + 'vm.op.wait.interval': '5', + 'guest.domain.suffix': 'kumquat.simulator', + 'instance.name': 'KIM', + 'direct.agent.load.size': '16', + 'default.page.size': '500', + 'linkLocalIp.nums': '10', + 'check.pod.cidrs': 'false', + 'max.account.public.ips': '10000', + 'max.account.snapshots': '10000', + 'max.account.templates': '10000', + 'max.account.user.vms': '10000', + 'max.account.volumes': '10000', + } + for k, v in global_settings.iteritems(): + cfg = configuration() + cfg.name = k + cfg.value = v + yield cfg + + +def podIpRangeGenerator(): + x=1 + y=2 + while 1: + if y == 255: + x=x+1 + if x == 255: + x=1 + break + + y=1 + + y=y+1 + #pod mangement network + yield ('172.'+str(x)+'.'+str(y)+'.129', '172.'+str(x)+'.'+str(y)+'.130', '172.'+str(x)+'.'+str(y)+'.189') + + +def vlanIpRangeGenerator(): + x=1 + y=2 + while 1: + if y == 255: + x=x+1 + if x==255: + x=1 + break + + y=1 + + y=y+1 + #vlan ip range + yield ('172.'+str(x)+'.'+str(y)+'.129', '172.'+str(x)+'.'+str(y)+'.190', '172.'+str(x)+'.'+str(y)+'.249') + + +def describeKumquatResources(dbnode='localhost', mshost='localhost'): + zs = cloudstackConfiguration() + numberofpods = 15 + + clustersPerPod = 2 + hostsPerCluster = 8 + + curpod = 0 + curhost = 0 + + z = zone() + z.dns1 = '4.2.2.2' + z.dns2 = '192.168.110.254' + z.internaldns1 = '10.91.28.6' + z.internaldns2 = '192.168.110.254' + z.name = 'Kumquat' + z.networktype = 'Advanced' + z.guestcidraddress = '10.1.1.0/24' + z.vlan='100-3000' + + for podRange,vlanRange in zip(podIpRangeGenerator(), vlanIpRangeGenerator()): + p = pod() + curpod=curpod+1 + p.name = 'POD'+str(curpod) + p.gateway=podRange[0] + p.startip=podRange[1] + p.endip=podRange[2] + p.netmask='255.255.255.128' + + for i in range(1,clustersPerPod+1): + c = cluster() + c.clustername = 'POD'+str(curpod)+'-CLUSTER'+str(i) + c.hypervisor = 'Simulator' + c.clustertype = 'CloudManaged' + + ps = primaryStorage() + ps.name = 'spool'+str(i) + ps.url = 'nfs://172.16.24.32/export/path/'+str(curpod)+'/'+str(i) + c.primaryStorages.append(ps) + + for i in range(1, hostsPerCluster + 1): + h = host() + h.username = 'root' + h.password = 'password' + h.url = "http://sim/test-%d"%(curhost) + c.hosts.append(h) + curhost=curhost+1 + + p.clusters.append(c) + + z.pods.append(p) + if curpod == numberofpods: + break + + v = iprange() + v.vlan = 'untagged' + v.gateway='172.2.1.1' + v.startip='172.2.1.2' + v.endip='172.2.255.252' + v.netmask="255.255.0.0" + z.ipranges.append(v) + + secondary = secondaryStorage() + secondary.url = 'nfs://172.16.25.32/secondary/path' + z.secondaryStorages.append(secondary) + zs.zones.append(z) + + '''Add mgt server''' + mgt = managementServer() + mgt.mgtSvrIp = mshost + zs.mgtSvr.append(mgt) + + '''Add a database''' + db = dbServer() + db.dbSvr = opts.dbnode + zs.dbSvr = db + + '''Add some configuration''' + [zs.globalConfig.append(cfg) for cfg in getGlobalSettings()] + + ''''add loggers''' + testClientLogger = logger() + testClientLogger.name = 'TestClient' + testClientLogger.file = '/var/log/testclient.log' + + testCaseLogger = logger() + testCaseLogger.name = 'TestCase' + testCaseLogger.file = '/var/log/testcase.log' + + zs.logger.append(testClientLogger) + zs.logger.append(testCaseLogger) + return zs + + +if __name__ == '__main__': + parser = OptionParser() + parser.add_option('-o', '--output', action='store', default='./KumquatCfg', dest='output', help='the path where the json config file generated') + parser.add_option('-d', '--dbnode', dest='dbnode', help='hostname/ip of the database node', action='store') + parser.add_option('-m', '--mshost', dest='mshost', help='hostname/ip of management server', action='store') + + (opts, args) = parser.parse_args() + cfg = describeKumquatResources(opts.dbnode, opts.mshost) + generate_setup_config(cfg, opts.output) diff --git a/agent-simulator/scripts/kumquat/tests/testProvision.py b/agent-simulator/scripts/kumquat/tests/testProvision.py new file mode 100644 index 00000000000..253ef34becd --- /dev/null +++ b/agent-simulator/scripts/kumquat/tests/testProvision.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +try: + import unittest2 as unittest +except ImportError: + import unittest + +import random +import hashlib +from cloudstackTestCase import * + +class Provision(cloudstackTestCase): + ''' + ''' + + so = '10' #default + + def setUp(self): + pass + + + def tearDown(self): + pass + + @unittest.skip("already done") + def test_createAccounts(self, numberOfAccounts=850): + ''' + Create a bunch of user accounts + ''' + mdf = hashlib.md5() + mdf.update('password') + mdf_pass = mdf.hexdigest() + api = self.testClient.getApiClient() + for i in range(1, numberOfAccounts + 1): + acct = createAccount.createAccountCmd() + acct.accounttype = 0 + acct.firstname = 'user' + str(i) + acct.lastname = 'user' + str(i) + acct.password = mdf_pass + acct.username = 'user' + str(i) + acct.email = 'user@example.com' + acct.account = 'user' + str(i) + acct.domainid = 1 + acctResponse = api.createAccount(acct) + self.debug(acctResponse) + + + def test_setupServiceOffering(self): + socreate = createServiceOffering.createServiceOfferingCmd() + socreate.cpunumber = 1 + socreate.cpuspeed = 100 + socreate.displaytext = 'Sample SO' + socreate.memory = 128 + socreate.name = 'Sample SO' + api = self.testClient.getApiClient() + soresponse = api.createServiceOffering(socreate) + self.so = soresponse.id + + def deployCmd(self, acct): + deployVmCmd = deployVirtualMachine.deployVirtualMachineCmd() + deployVmCmd.zoneid = 1 + deployVmCmd.hypervisor='Simulator' + deployVmCmd.account=acct + deployVmCmd.domainid=1 + deployVmCmd.templateid=2 + deployVmCmd.serviceofferingid=self.so + return deployVmCmd + + + def test_stressDeploy(self): + ''' + Deploy 5 Vms in each account + ''' + api = self.testClient.getApiClient() + for acct in range(122, 850): + [api.deployVirtualMachine(self.deployCmd('user'+str(acct))) for x in range(0, 5)] + + + def deployN(self,nargs=300,batchsize=0): + ''' + Deploy Nargs number of VMs concurrently in batches of size {batchsize}. + When batchsize is 0 all Vms are deployed in one batch + VMs will be deployed in 5:2:6 ratio + ''' + cmds = [] + + if batchsize == 0: + self.testClient.submitCmdsAndWait(cmds) + else: + while len(z) > 0: + try: + newbatch = [cmds.pop() for b in range(batchsize)] #pop batchsize items + self.testClient.submitCmdsAndWait(newbatch) + except IndexError: + break