Updated Branches:
  refs/heads/4.2 0f0889ae2 -> fba874120

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.eduku...@citrix.com>

Conflicts:
        tools/marvin/marvin/codes.py
        tools/marvin/marvin/integration/lib/utils.py


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fba87412
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fba87412
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fba87412

Branch: refs/heads/4.2
Commit: fba874120bb40ddeceacbc7ef51217f34d3749de
Parents: 6e1821f
Author: Santhosh Edukulla <santhosh.eduku...@citrix.com>
Authored: Mon Oct 28 12:48:05 2013 +0530
Committer: Girish Shilamkar <gir...@clogeny.com>
Committed: Fri Nov 8 14:40:58 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/codes.py                 |  2 +-
 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, 33 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fba87412/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index 3fe7b74..b6580d0 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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fba87412/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py 
b/tools/marvin/marvin/configGenerator.py
index eb8dc2c..132b4f6 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -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:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fba87412/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py 
b/tools/marvin/marvin/deployDataCenter.py
index efb4150..4cb5b78 100644
--- a/tools/marvin/marvin/deployDataCenter.py
+++ b/tools/marvin/marvin/deployDataCenter.py
@@ -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)
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fba87412/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 a8d676c..bd22fa6 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):
@@ -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):
        '''

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fba87412/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)

Reply via email to