Added fix for CLOUDSTACK-6316 Added changes for CLOUDSTACK-6316. More details in the bug
Signed-off-by: Santhosh Edukulla <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/95a64534 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/95a64534 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/95a64534 Branch: refs/heads/master Commit: 95a645349fc14bb16ea30509a265c2731736b206 Parents: e4053bc Author: Santhosh Edukulla <[email protected]> Authored: Tue Apr 1 20:58:11 2014 +0530 Committer: SrikanteswaraRao Talluri <[email protected]> Committed: Tue Apr 1 16:02:59 2014 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/configGenerator.py | 110 +++++++++++++++++----------- 1 file changed, 67 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/95a64534/tools/marvin/marvin/configGenerator.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py index 43b4d7c..68ec24e 100644 --- a/tools/marvin/marvin/configGenerator.py +++ b/tools/marvin/marvin/configGenerator.py @@ -25,6 +25,7 @@ from marvin.config.test_data import test_data class managementServer(object): + def __init__(self): self.mgtSvrIp = None self.port = 8096 @@ -36,6 +37,7 @@ class managementServer(object): class dbServer(object): + def __init__(self): self.dbSvr = None self.port = 3306 @@ -85,6 +87,7 @@ class zone(object): class trafficType(object): + def __init__(self, typ, labeldict=None): self.typ = typ # Guest/Management/Public if labeldict: @@ -97,6 +100,7 @@ class trafficType(object): class pod(object): + def __init__(self): self.gateway = None self.name = None @@ -111,6 +115,7 @@ class pod(object): class VmwareDc(object): + def __init__(self): self.zoneid = None self.name = None @@ -120,6 +125,7 @@ class VmwareDc(object): class cluster(object): + def __init__(self): self.clustername = None self.clustertype = None @@ -134,6 +140,7 @@ class cluster(object): class host(object): + def __init__(self): self.hypervisor = None self.password = None @@ -151,6 +158,7 @@ class host(object): class physicalNetwork(object): + def __init__(self): self.name = None self.tags = [] @@ -165,6 +173,7 @@ class physicalNetwork(object): class provider(object): + def __init__(self, name=None): self.name = name self.state = None @@ -175,6 +184,7 @@ class provider(object): class network(object): + def __init__(self): self.displaytext = None self.name = None @@ -187,6 +197,7 @@ class network(object): class iprange(object): + def __init__(self): '''tagged/untagged''' self.gateway = None @@ -200,12 +211,14 @@ class iprange(object): class primaryStorage(object): + def __init__(self): self.name = None self.url = None class secondaryStorage(object): + def __init__(self): self.url = None self.provider = None @@ -213,6 +226,7 @@ class secondaryStorage(object): class cacheStorage(object): + def __init__(self): self.url = None self.provider = None @@ -220,6 +234,7 @@ class cacheStorage(object): class s3(object): + def __init__(self): self.accesskey = None self.secretkey = None @@ -232,6 +247,7 @@ class s3(object): class netscaler(object): + def __init__(self, hostname=None, username='nsroot', password='nsroot'): self.hostname = hostname self.username = username @@ -248,11 +264,12 @@ class netscaler(object): 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(object): + def __init__(self, hostname=None, username='root', password='admin'): self.hostname = hostname self.username = username @@ -271,11 +288,12 @@ class srx(object): 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(object): + def __init__(self, hostname=None, username='root', password='default'): self.hostname = hostname self.username = username @@ -292,11 +310,12 @@ class bigip(object): 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 ConfigManager(object): + ''' @Name: ConfigManager @Desc: 1. It provides the basic configuration facilities to marvin. @@ -328,6 +347,7 @@ class ConfigManager(object): 8. Users can use their own configuration file passed to "getConfig" API,once configObj is returned. ''' + def __init__(self, cfg_file=None): self.__filePath = cfg_file self.__parsedCfgDict = None @@ -364,8 +384,8 @@ class ConfigManager(object): configLines.append(ws) config = json.loads("\n".join(configLines)) config_dict = config - except Exception, e: - #Will replace with log once we have logging done + except Exception as e: + # Will replace with log once we have logging done print "\n Exception occurred under ConfigManager:__parseConfig" \ " :%s", GetDetailExceptionInfo(e) finally: @@ -413,9 +433,9 @@ class ConfigManager(object): 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 @@ -430,11 +450,11 @@ def descSetupInBasicMode(): z.dns2 = "8.8.4.4" z.internaldns1 = "192.168.110.254" z.internaldns2 = "192.168.110.253" - z.name = "test"+str(l) + z.name = "test" + str(l) z.networktype = 'Basic' z.securitygroupenabled = 'True' - #If security groups are reqd + # If security groups are reqd sgprovider = provider() sgprovider.broadcastdomainrange = 'Pod' sgprovider.name = 'SecurityGroupProvider' @@ -460,15 +480,15 @@ def descSetupInBasicMode(): 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.clustername = "test" + str(l) + str(i) + str(j) c.clustertype = "CloudManaged" c.hypervisor = "Simulator" @@ -477,15 +497,16 @@ def descSetupInBasicMode(): h = host() h.username = "root" h.password = "password" - memory = 8*1024*1024*1024 - localstorage = 1*1024*1024*1024*1024 + memory = 8 * 1024 * 1024 * 1024 + 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.name = "primary" + \ + 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) @@ -497,7 +518,7 @@ def descSetupInBasicMode(): '''add two secondary''' for i in range(5): secondary = secondaryStorage() - secondary.url = "nfs://localhost/path"+str(l) + str(i) + secondary.url = "nfs://localhost/path" + str(l) + str(i) z.secondaryStorages.append(secondary) zs.zones.append(z) @@ -539,7 +560,7 @@ def descSetupInEipMode(): z.dns2 = "8.8.4.4" z.internaldns1 = "192.168.110.254" z.internaldns2 = "192.168.110.253" - z.name = "test"+str(l) + z.name = "test" + str(l) z.networktype = 'Basic' ips = iprange() @@ -550,7 +571,7 @@ def descSetupInEipMode(): ips.netmask = "255.255.255.0" z.ipranges.append(ips) - #If security groups are reqd + # If security groups are reqd sgprovider = provider() sgprovider.broadcastdomainrange = 'Pod' sgprovider.name = 'SecurityGroupProvider' @@ -584,15 +605,15 @@ def descSetupInEipMode(): 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.clustername = "test" + str(l) + str(i) + str(j) c.clustertype = "CloudManaged" c.hypervisor = "Simulator" @@ -607,7 +628,8 @@ def descSetupInEipMode(): '''add 2 primary storages''' for m in range(2): primary = primaryStorage() - primary.name = "primary"+str(l) + str(i) + str(j) + str(m) + primary.name = "primary" + \ + str(l) + str(i) + str(j) + str(m) primary.url = "nfs://localhost/path%s" % (str(l) + str(i) + str(j) + str(m)) @@ -620,7 +642,7 @@ def descSetupInEipMode(): '''add two secondary''' for i in range(5): secondary = secondaryStorage() - secondary.url = "nfs://localhost/path"+str(l) + str(i) + secondary.url = "nfs://localhost/path" + str(l) + str(i) z.secondaryStorages.append(secondary) zs.zones.append(z) @@ -660,7 +682,7 @@ def descSetupInAdvancedMode(): z.dns2 = "8.8.4.4" z.internaldns1 = "192.168.110.254" z.internaldns2 = "192.168.110.253" - z.name = "test"+str(l) + z.name = "test" + str(l) z.networktype = 'Advanced' z.guestcidraddress = "10.1.1.0/24" z.vlan = "100-2000" @@ -696,7 +718,7 @@ def descSetupInAdvancedMode(): '''add 10 clusters''' for j in range(2): c = cluster() - c.clustername = "test"+str(l)+str(i) + str(j) + c.clustername = "test" + str(l) + str(i) + str(j) c.clustertype = "CloudManaged" c.hypervisor = "Simulator" @@ -707,7 +729,7 @@ def descSetupInAdvancedMode(): 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&\ + # 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) @@ -716,8 +738,9 @@ def descSetupInAdvancedMode(): '''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" % + 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) @@ -731,7 +754,7 @@ def descSetupInAdvancedMode(): '''add two secondary''' for i in range(5): secondary = secondaryStorage() - secondary.url = "nfs://localhost/path"+str(l) + str(i) + secondary.url = "nfs://localhost/path" + str(l) + str(i) z.secondaryStorages.append(secondary) '''add default public network''' @@ -781,7 +804,7 @@ def descSetupInAdvancedsgMode(): z.dns2 = "8.8.4.4" z.internaldns1 = "192.168.110.254" z.internaldns2 = "192.168.110.253" - z.name = "test"+str(l) + z.name = "test" + str(l) z.networktype = 'Advanced' z.vlan = "100-2000" z.securitygroupenabled = "true" @@ -790,7 +813,7 @@ def descSetupInAdvancedsgMode(): pn.name = "test-network" pn.traffictypes = [trafficType("Guest"), trafficType("Management")] - #If security groups are reqd + # If security groups are reqd sgprovider = provider() sgprovider.broadcastdomainrange = 'ZONE' sgprovider.name = 'SecurityGroupProvider' @@ -810,7 +833,7 @@ def descSetupInAdvancedsgMode(): '''add 10 clusters''' for j in range(2): c = cluster() - c.clustername = "test"+str(l)+str(i) + str(j) + c.clustername = "test" + str(l) + str(i) + str(j) c.clustertype = "CloudManaged" c.hypervisor = "Simulator" @@ -821,17 +844,18 @@ def descSetupInAdvancedsgMode(): 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/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" % \ + 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)) @@ -844,7 +868,7 @@ def descSetupInAdvancedsgMode(): '''add two secondary''' for i in range(5): secondary = secondaryStorage() - secondary.url = "nfs://localhost/path"+str(l) + str(i) + secondary.url = "nfs://localhost/path" + str(l) + str(i) z.secondaryStorages.append(secondary) '''add default guest network''' @@ -904,7 +928,7 @@ def getSetupConfig(file): configLines.append(ws) config = json.loads("\n".join(configLines)) return jsonHelper.jsonLoader(config) - except Exception, e: + except Exception as e: print "\nException Occurred under getSetupConfig %s" % \ GetDetailExceptionInfo(e)
