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/02 18:42:14 UTC
[44/50] [abbrv] git commit: updated refs/heads/marvin-refactor to
bbaf354
marvin_refactor: pep8 all python files
Signed-off-by: Prasanna Santhanam <ts...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f76b1029
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f76b1029
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f76b1029
Branch: refs/heads/marvin-refactor
Commit: f76b1029d6e55fcf949006df013d76a4fcbf5376
Parents: 3aa10ef
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Oct 2 12:05:38 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Wed Oct 2 20:28:10 2013 +0530
----------------------------------------------------------------------
tools/marvin/marvin/cloudstackConnection.py | 3 ++-
tools/marvin/marvin/codegenerator.py | 20 +++++++++++---------
tools/marvin/marvin/dbConnection.py | 7 +++++--
tools/marvin/marvin/deployAndRun.py | 22 +++++++++++++---------
tools/marvin/marvin/factory/data/vm.py | 2 +-
tools/marvin/marvin/jsonHelper.py | 17 +++++++----------
tools/marvin/marvin/util.py | 10 ++++++++--
7 files changed, 47 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f76b1029/tools/marvin/marvin/cloudstackConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py
index 1e4298e..6cd65b7 100644
--- a/tools/marvin/marvin/cloudstackConnection.py
+++ b/tools/marvin/marvin/cloudstackConnection.py
@@ -22,7 +22,8 @@ try:
from requests import Timeout
from requests import RequestException
except ImportError:
- raise Exception("requests installation not found. use pip install requests to continue")
+ raise Exception("requests installation not found. use pip install \
+ requests to continue")
import urllib
import base64
import hmac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f76b1029/tools/marvin/marvin/codegenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codegenerator.py b/tools/marvin/marvin/codegenerator.py
index a736039..5ef7c41 100644
--- a/tools/marvin/marvin/codegenerator.py
+++ b/tools/marvin/marvin/codegenerator.py
@@ -21,6 +21,7 @@ from argparse import ArgumentParser
from generate.xmltoapi import codeGenerator
from generate.apitoentity import generate
+
def get_api_cmds():
""" Returns the API cmdlet instances
@@ -28,13 +29,13 @@ def get_api_cmds():
"""
namespace = {}
execfile('cloudstackAPI/__init__.py', namespace)
- api_classes = __import__('cloudstackAPI', globals().update(namespace), fromlist=['*'], level=-1)
-
+ api_classes = __import__(
+ 'cloudstackAPI', globals().update(namespace), fromlist=['*'], level=-1)
cmdlist = map(
lambda f: getattr(api_classes, f),
filter(
- lambda t: t.startswith('__') == False,
+ lambda t: t.startswith('__') is False,
dir(api_classes)
)
)
@@ -45,7 +46,8 @@ def get_api_cmds():
clslist = map(
lambda g: getattr(g, g.__name__.split('.')[-1] + 'Cmd'),
filter(
- lambda h: h.__name__.split('.')[-1] not in ['baseCmd', 'baseResponse', 'cloudstackAPIClient'],
+ lambda h: h.__name__.split('.')[-1] not in [
+ 'baseCmd', 'baseResponse', 'cloudstackAPIClient'],
cmdlist
)
)
@@ -55,16 +57,16 @@ def get_api_cmds():
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("-o", "--output", dest="output",
- help="The path to the generated code entities, default\
+ help="The path to the generated code entities, default\
is .")
parser.add_argument("-s", "--specfile", dest="spec",
- help="The path and name of the api spec xml file,\
+ help="The path and name of the api spec xml file,\
default is /etc/cloud/cli/commands.xml")
parser.add_argument("-e", "--endpoint", dest="endpoint",
- help="The endpoint mgmt server (with open 8096) where\
+ help="The endpoint mgmt server (with open 8096) where\
apis are discovered, default is localhost")
parser.add_argument("-y", "--entity", dest="entity", action="store_true",
- help="Generate entity based classes")
+ help="Generate entity based classes")
options = parser.parse_args()
@@ -98,4 +100,4 @@ response=json' % options.endpoint
cg.generateCodeFromJSON(endpointUrl)
if options.entity:
- generate(get_api_cmds())
\ No newline at end of file
+ generate(get_api_cmds())
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f76b1029/tools/marvin/marvin/dbConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/dbConnection.py b/tools/marvin/marvin/dbConnection.py
index 98c72c5..70bd511 100644
--- a/tools/marvin/marvin/dbConnection.py
+++ b/tools/marvin/marvin/dbConnection.py
@@ -20,13 +20,16 @@ try:
from mysql import connector
from mysql.connector import errors
except ImportError:
- raise Exception("mysql-connector-python not installed. pip install mysql-connector-python to continue")
+ raise Exception(
+ "mysql-connector-python not installed. pip install \
+ mysql-connector-python to continue")
import contextlib
import cloudstackException
import os
class dbConnection(object):
+
def __init__(self, host="localhost", port=3306, user='cloud',
passwd='cloud', db='cloud'):
self.host = host
@@ -52,7 +55,7 @@ class dbConnection(object):
try:
resultRow = cursor.fetchall()
except errors.InterfaceError:
- #Raised on empty result - DML
+ # Raised on empty result - DML
resultRow = []
return resultRow
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f76b1029/tools/marvin/marvin/deployAndRun.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployAndRun.py b/tools/marvin/marvin/deployAndRun.py
index b7485aa..8bb24b3 100644
--- a/tools/marvin/marvin/deployAndRun.py
+++ b/tools/marvin/marvin/deployAndRun.py
@@ -73,20 +73,24 @@ if __name__ == "__main__":
n = 0
while(n < iterates):
engine = \
- TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient,
- deploy.getCfg(),
- testCaseLogFile,
- testResultLogFile)
+ TestCaseExecuteEngine.TestCaseExecuteEngine(
+ deploy.testClient,
+ deploy.getCfg(
+ ),
+ testCaseLogFile,
+ testResultLogFile)
engine.loadTestsFromFile(options.module)
engine.run()
n = n + 1
else:
n = 0
- while(n<iterates):
- engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient,
- deploy.getCfg(),
- testCaseLogFile,
- testResultLogFile)
+ while(n < iterates):
+ engine = TestCaseExecuteEngine.TestCaseExecuteEngine(
+ deploy.testClient,
+ deploy.getCfg(
+ ),
+ testCaseLogFile,
+ testResultLogFile)
engine.loadTestsFromDir(options.testCaseFolder)
engine.run()
n = n + 1
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f76b1029/tools/marvin/marvin/factory/data/vm.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/data/vm.py b/tools/marvin/marvin/factory/data/vm.py
index 713c9b5..3f50b52 100644
--- a/tools/marvin/marvin/factory/data/vm.py
+++ b/tools/marvin/marvin/factory/data/vm.py
@@ -39,7 +39,7 @@ class VirtualMachineWithStaticNat(VirtualMachineFactory):
domainid=self.domainid,
zoneid=self.zoneid,
)
- ipassoc.enableStaticNat(
+ self.enableStaticNat(
apiclient=self.apiclient,
ipaddressid=ipassoc.id,
virtualmachineid=self.id
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f76b1029/tools/marvin/marvin/jsonHelper.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/jsonHelper.py b/tools/marvin/marvin/jsonHelper.py
index a395e6b..41d5ede 100644
--- a/tools/marvin/marvin/jsonHelper.py
+++ b/tools/marvin/marvin/jsonHelper.py
@@ -22,6 +22,7 @@ from cloudstackAPI import *
class jsonLoader(object):
+
'''The recursive class for building and representing objects with.'''
def __init__(self, obj):
@@ -53,6 +54,7 @@ class jsonLoader(object):
class jsonDump:
+
@staticmethod
def __serialize(obj):
"""Recursively walk object's hierarchy."""
@@ -75,7 +77,7 @@ class jsonDump:
elif hasattr(obj, '__dict__'):
return jsonDump.__serialize(obj.__dict__)
else:
- return repr(obj) # Don't know how to handle, convert to string
+ return repr(obj) # Don't know how to handle, convert to string
@staticmethod
def dump(obj):
@@ -85,7 +87,8 @@ class jsonDump:
def getClass(module, name):
"""Get the CloudStack command class in a module given the name
@param module: cloudstack API module eg: createVolume
- @param name: string name of the class within the module eg: createVolumeResponse
+ @param name: string name of the class within the module eg:
+ createVolumeResponse
@return: response class
"""
module = inspect.getmodule(module)
@@ -258,7 +261,7 @@ due to missing parameter jobid"
except cloudstackException.cloudstackAPIException, e:
print e
- result = { "queryasyncjobresultresponse" : {} }
+ result = {"queryasyncjobresultresponse": {}}
asynJob = getResultObj(result)
print "AsyncJob %s" % asynJob
@@ -282,13 +285,7 @@ due to missing parameter jobid"
zone = getResultObj(result, res)
print "Zone id %s" % zone.id
- result = { "queryasyncjobresultresponse" : {"accountid":"4a8c3cd0-a696-11e2-b7a5-1aab0c3b0463","userid":"4a8c671e-a696-11e2-b7a5-1aab0c3b0463","cmd":"org.apache.cloudstack.api.command.admin.network.CreatePhysicalNetworkCmd","jobstatus":1,"jobprocstatus":0,"jobresultcode":0,"jobresulttype":"object","jobresult":{"physicalnetwork":{"id":"e0bc9017-9ba8-4551-a6f9-6b3b2ac1d59c","name":"Sandbox-pnet","broadcastdomainrange":"ZONE","zoneid":"88e796cd-953a-44b9-9445-a7c3ee205cc2","state":"Disabled"}},"created":"2013-04-16T18:37:01+0530","jobid":"8fc09350-f42a-4e04-9427-3d1b68f73dd0"} }
- res = createPhysicalNetwork.createPhysicalNetworkResponse()
- res = getResultObj(result, res)
- print "PhysicalNetworkResponse %s" % res
- print "PhysicalNetwork %s" % res.jobresult.id
-
- result = { "listtemplatesresponse" : { } }
+ result = {"listtemplatesresponse": {}}
print getResultObj(result, listTemplates.listTemplatesResponse())
result = '''{
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f76b1029/tools/marvin/marvin/util.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/util.py b/tools/marvin/marvin/util.py
index 609e696..51a91ca 100644
--- a/tools/marvin/marvin/util.py
+++ b/tools/marvin/marvin/util.py
@@ -20,6 +20,7 @@ from marvin.entity.zone import Zone
from marvin.entity.serviceoffering import ServiceOffering
from marvin.entity.domain import Domain
+
def get_domain(apiclient):
"Returns a default `ROOT` domain"
@@ -31,6 +32,7 @@ def get_domain(apiclient):
else:
raise Exception("Failed to find any domains")
+
def get_zone(apiclient):
"Returns the default enabled zone"
@@ -46,6 +48,7 @@ def get_zone(apiclient):
else:
raise Exception("Failed to find specified zone.")
+
def get_service_offering(apiclient, storagetype='shared', scope=None):
"""Returns the service offering that is available in the zone
@@ -62,6 +65,7 @@ def get_service_offering(apiclient, storagetype='shared', scope=None):
return service
raise Exception("No service offering for storagetype %s available")
+
def get_template(apiclient, description=None):
"Returns a featured template with a specific description"
templates = Template.list(
@@ -74,6 +78,8 @@ def get_template(apiclient, description=None):
if template.isready:
return template
else:
- raise Exception("None of the templates are ready in your deployment")
+ raise Exception(
+ "None of the templates are ready in your deployment")
else:
- raise Exception("Failed to find ready and featured template of : %s" % description)
+ raise Exception(
+ "Failed to find ready and featured template of : %s" % description)