mirror of https://github.com/apache/cloudstack.git
Adding few changes and cleaning up the code
- Added few common naming conventions - Cleanedup code - Added a simple utility function Signed-off-by: Santhosh Edukulla <Santhosh.Edukulla@citrix.com> Conflicts: tools/marvin/marvin/codes.py tools/marvin/marvin/integration/lib/utils.py
This commit is contained in:
parent
6e1821f585
commit
fba874120b
|
|
@ -24,7 +24,7 @@
|
|||
a code viz., ENABLED with value "Enabled",then using \
|
||||
this code in a sample feature say test_a.py as below. \
|
||||
|
||||
from marvinCodes import *
|
||||
from codes import *
|
||||
if obj.getvalue() == ENABLED
|
||||
|
||||
@DateAdded: 20th October 2013
|
||||
|
|
|
|||
|
|
@ -951,7 +951,7 @@ def generate_setup_config(config, file=None):
|
|||
fp.close()
|
||||
|
||||
|
||||
def get_setup_config(file):
|
||||
def getSetupConfig(file):
|
||||
if not os.path.exists(file):
|
||||
raise IOError("config file %s not found. \
|
||||
please specify a valid config file" % file)
|
||||
|
|
@ -962,9 +962,7 @@ def get_setup_config(file):
|
|||
ws = line.strip()
|
||||
if not ws.startswith("#"):
|
||||
configLines.append(ws)
|
||||
k = json.loads("\n".join(configLines))
|
||||
#config = json.loads("\n".join(configLines))
|
||||
config = k
|
||||
config = json.loads("\n".join(configLines))
|
||||
return jsonHelper.jsonLoader(config)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
@ -985,7 +983,7 @@ by default is ./datacenterCfg")
|
|||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.inputfile:
|
||||
config = get_setup_config(options.inputfile)
|
||||
config = getSetupConfig(options.inputfile)
|
||||
if options.advanced:
|
||||
config = descSetupInAdvancedMode()
|
||||
elif options.advancedsg:
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ specify a valid config file" % cfgFile)
|
|||
if cluster.hypervisor.lower() != "vmware":
|
||||
self.addHosts(cluster.hosts, zoneId, podId, clusterId,
|
||||
cluster.hypervisor)
|
||||
self.wait_for_host(zoneId, clusterId)
|
||||
self.waitForHost(zoneId, clusterId)
|
||||
self.createPrimaryStorages(cluster.primaryStorages, zoneId, podId,
|
||||
clusterId)
|
||||
|
||||
def wait_for_host(self, zoneId, clusterId):
|
||||
def waitForHost(self, zoneId, clusterId):
|
||||
"""
|
||||
Wait for the hosts in the zoneid, clusterid to be up
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ specify a valid config file" % cfgFile)
|
|||
primarycmd.clusterid = clusterId
|
||||
self.apiClient.createStoragePool(primarycmd)
|
||||
|
||||
def createpods(self, pods, zoneId, networkId=None):
|
||||
def createPods(self, pods, zoneId, networkId=None):
|
||||
if pods is None:
|
||||
return
|
||||
for pod in pods:
|
||||
|
|
@ -208,7 +208,7 @@ specify a valid config file" % cfgFile)
|
|||
})
|
||||
self.apiClient.createSecondaryStagingStore(cachecmd)
|
||||
|
||||
def createnetworks(self, networks, zoneId):
|
||||
def createNetworks(self, networks, zoneId):
|
||||
if networks is None:
|
||||
return
|
||||
for network in networks:
|
||||
|
|
@ -417,8 +417,8 @@ specify a valid config file" % cfgFile)
|
|||
guestntwrk.networkofferingid = \
|
||||
listnetworkofferingresponse[0].id
|
||||
|
||||
networkid = self.createnetworks([guestntwrk], zoneId)
|
||||
self.createpods(zone.pods, zoneId, networkid)
|
||||
networkid = self.createNetworks([guestntwrk], zoneId)
|
||||
self.createPods(zone.pods, zoneId, networkid)
|
||||
if self.isEipElbZone(zone):
|
||||
self.createVlanIpRanges(zone.networktype, zone.ipranges,
|
||||
zoneId, forvirtualnetwork=True)
|
||||
|
|
@ -426,7 +426,7 @@ specify a valid config file" % cfgFile)
|
|||
isPureAdvancedZone = (zone.networktype == "Advanced"
|
||||
and zone.securitygroupenabled != "true")
|
||||
if isPureAdvancedZone:
|
||||
self.createpods(zone.pods, zoneId)
|
||||
self.createPods(zone.pods, zoneId)
|
||||
self.createVlanIpRanges(zone.networktype, zone.ipranges,
|
||||
zoneId)
|
||||
elif (zone.networktype == "Advanced"
|
||||
|
|
@ -459,7 +459,7 @@ specify a valid config file" % cfgFile)
|
|||
|
||||
networkcmdresponse = self.apiClient.createNetwork(networkcmd)
|
||||
networkId = networkcmdresponse.id
|
||||
self.createpods(zone.pods, zoneId, networkId)
|
||||
self.createPods(zone.pods, zoneId, networkId)
|
||||
|
||||
'''Note: Swift needs cache storage first'''
|
||||
self.createCacheStorages(zone.cacheStorages, zoneId)
|
||||
|
|
@ -510,7 +510,7 @@ specify a valid config file" % cfgFile)
|
|||
|
||||
def loadCfg(self):
|
||||
try:
|
||||
self.config = configGenerator.get_setup_config(self.configFile)
|
||||
self.config = configGenerator.getSetupConfig(self.configFile)
|
||||
except:
|
||||
raise cloudstackException.InvalidParameterException("Failed to load config %s" % self.configFile)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import urlparse
|
|||
import datetime
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.remoteSSHClient import remoteSSHClient
|
||||
from marvin.codes import *
|
||||
|
||||
|
||||
def restart_mgmt_server(server):
|
||||
|
|
@ -321,14 +322,14 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
|
|||
|
||||
def validateList(inp):
|
||||
'''
|
||||
@name: validateList
|
||||
@Description: 1. A utility function to validate
|
||||
@name: validateList
|
||||
@Description: 1. A utility function to validate
|
||||
whether the input passed is a list
|
||||
2. The list is empty or not
|
||||
2. The list is empty or not
|
||||
3. If it is list and not empty, return PASS and first element
|
||||
4. If not reason for FAIL
|
||||
@Input: Input to be validated
|
||||
@output: List, containing [ Result,FirstElement,Reason ]
|
||||
@Input: Input to be validated
|
||||
@output: List, containing [ Result,FirstElement,Reason ]
|
||||
Ist Argument('Result') : FAIL : If it is not a list
|
||||
If it is list but empty
|
||||
PASS : If it is list and not empty
|
||||
|
|
@ -339,18 +340,18 @@ def validateList(inp):
|
|||
default to None.
|
||||
INVALID_INPUT
|
||||
EMPTY_LIST
|
||||
'''
|
||||
ret = [FAIL, None, None]
|
||||
if inp is None:
|
||||
ret[2] = INVALID_INPUT
|
||||
return ret
|
||||
if not isinstance(inp, list):
|
||||
ret[2] = INVALID_INPUT
|
||||
return ret
|
||||
if len(inp) == 0:
|
||||
ret[2] = EMPTY_LIST
|
||||
return ret
|
||||
return [PASS, inp[0], None]
|
||||
'''
|
||||
ret = [FAIL, None, None]
|
||||
if inp is None:
|
||||
ret[2] = INVALID_INPUT
|
||||
return ret
|
||||
if not isinstance(inp, list):
|
||||
ret[2] = INVALID_INPUT
|
||||
return ret
|
||||
if len(inp) == 0:
|
||||
ret[2] = EMPTY_LIST
|
||||
return ret
|
||||
return [PASS, inp[0], None]
|
||||
|
||||
def verifyElementInList(inp, toverify, pos = 0):
|
||||
'''
|
||||
|
|
|
|||
|
|
@ -33,13 +33,6 @@ class MarvinPlugin(Plugin):
|
|||
name = "marvin"
|
||||
|
||||
def configure(self, options, config):
|
||||
if hasattr(options, self.enableOpt):
|
||||
if not getattr(options, self.enableOpt):
|
||||
self.enabled = False
|
||||
return
|
||||
else:
|
||||
self.enabled = True
|
||||
|
||||
self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - " +
|
||||
"%(name)s - %(message)s")
|
||||
|
||||
|
|
@ -59,7 +52,7 @@ class MarvinPlugin(Plugin):
|
|||
else:
|
||||
self.result_stream = sys.stdout
|
||||
|
||||
deploy = deployDataCenter.deployDataCenters(options.config)
|
||||
deploy = deployDataCenter.deployDataCenters(options.config_file)
|
||||
deploy.loadCfg() if options.load else deploy.deploy()
|
||||
self.setClient(deploy.testClient)
|
||||
self.setConfig(deploy.getCfg())
|
||||
|
|
@ -74,7 +67,7 @@ class MarvinPlugin(Plugin):
|
|||
"""
|
||||
parser.add_option("--marvin-config", action="store",
|
||||
default=env.get('MARVIN_CONFIG', './datacenter.cfg'),
|
||||
dest="config",
|
||||
dest="config_file",
|
||||
help="Marvin's configuration file where the " +
|
||||
"datacenter information is specified " +
|
||||
"[MARVIN_CONFIG]")
|
||||
|
|
@ -146,10 +139,6 @@ class MarvinPlugin(Plugin):
|
|||
str(time.ctime(self.startTime)), str(time.ctime(endTime))))
|
||||
|
||||
def _injectClients(self, test):
|
||||
self.debug_stream. \
|
||||
setFormatter(logging.
|
||||
Formatter("%(asctime)s - %(levelname)s - %(name)s" +
|
||||
" - %(message)s"))
|
||||
setattr(test, "debug", self.logger.debug)
|
||||
setattr(test, "info", self.logger.info)
|
||||
setattr(test, "warn", self.logger.warning)
|
||||
|
|
|
|||
Loading…
Reference in New Issue