You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/10/28 08:21:15 UTC
git commit: updated refs/heads/master to 03830c5
Updated Branches:
refs/heads/master c8b91f1b7 -> 03830c570
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 <Sa...@citrix.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/03830c57
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/03830c57
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/03830c57
Branch: refs/heads/master
Commit: 03830c570eebe25181cb9ae8a0eb5e72a542e2a9
Parents: c8b91f1
Author: Santhosh Edukulla <Sa...@citrix.com>
Authored: Mon Oct 28 12:48:05 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Mon Oct 28 12:49:41 2013 +0530
----------------------------------------------------------------------
tools/marvin/marvin/codes.py | 6 +++-
tools/marvin/marvin/configGenerator.py | 8 ++----
tools/marvin/marvin/deployDataCenter.py | 18 ++++++------
tools/marvin/marvin/integration/lib/utils.py | 35 +++++++++++++++++++++++
tools/marvin/marvin/marvinPlugin.py | 15 ++--------
5 files changed, 54 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/03830c57/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index 6099d88..3da90d6 100644
--- a/tools/marvin/marvin/codes.py
+++ b/tools/marvin/marvin/codes.py
@@ -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
@@ -33,3 +33,7 @@
ENABLED = "Enabled"
NETWORK_OFFERING = "network_offering"
ROOT = "ROOT"
+INVALID_INPUT = "INVALID INPUT"
+EMPTY_LIST = "EMPTY_LIST"
+FAIL = 0
+PASS = 1
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/03830c57/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index 50614c1..0cfad30 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -830,7 +830,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)
@@ -841,9 +841,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__":
@@ -864,7 +862,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 = describe_setup_in_advanced_mode()
elif options.advancedsg:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/03830c57/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py
index f2dccdb..3f7eebb 100644
--- a/tools/marvin/marvin/deployDataCenter.py
+++ b/tools/marvin/marvin/deployDataCenter.py
@@ -92,11 +92,11 @@ class deployDataCenters(object):
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
@@ -127,7 +127,7 @@ class deployDataCenters(object):
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:
@@ -212,7 +212,7 @@ class deployDataCenters(object):
})
self.apiClient.createSecondaryStagingStore(cachecmd)
- def createnetworks(self, networks, zoneId):
+ def createNetworks(self, networks, zoneId):
if networks is None:
return
for network in networks:
@@ -421,8 +421,8 @@ class deployDataCenters(object):
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)
@@ -430,7 +430,7 @@ class deployDataCenters(object):
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"
@@ -463,7 +463,7 @@ class deployDataCenters(object):
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)
@@ -514,7 +514,7 @@ class deployDataCenters(object):
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)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/03830c57/tools/marvin/marvin/integration/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py
index d81e80d..7d662af 100644
--- a/tools/marvin/marvin/integration/lib/utils.py
+++ b/tools/marvin/marvin/integration/lib/utils.py
@@ -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):
@@ -318,3 +319,37 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
raise Exception("SSH failed for management server: %s - %s" %
(config.mgtSvr[0].mgtSvrIp, e))
return 'snapshot exists' in result
+
+
+def validateList(inp):
+ '''
+ @name: validateList
+ @Description: 1. A utility function to validate
+ whether the input passed is a list
+ 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 ]
+ Ist Argument('Result') : FAIL : If it is not a list
+ If it is list but empty
+ PASS : If it is list and not empty
+ IInd Argument('FirstElement'): If it is list and not empty,
+ then first element
+ in it, default to None
+ IIIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
+ 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]
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/03830c57/tools/marvin/marvin/marvinPlugin.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py
index c5931e0..2a749f0 100644
--- a/tools/marvin/marvin/marvinPlugin.py
+++ b/tools/marvin/marvin/marvinPlugin.py
@@ -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)