Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E0370C08F for ; Sun, 23 Jun 2013 15:25:27 +0000 (UTC) Received: (qmail 5090 invoked by uid 500); 23 Jun 2013 15:25:27 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 4934 invoked by uid 500); 23 Jun 2013 15:25:27 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 4927 invoked by uid 99); 23 Jun 2013 15:25:26 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jun 2013 15:25:26 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DF00A82EDC8; Sun, 23 Jun 2013 15:25:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebgoa@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 3fdcf18 Date: Sun, 23 Jun 2013 15:25:25 +0000 (UTC) Updated Branches: refs/heads/master 08d4ab79f -> 3fdcf1836 CLOUDSTACK-3096 format cloudsteackTestClient.py Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3fdcf183 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3fdcf183 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3fdcf183 Branch: refs/heads/master Commit: 3fdcf1836c22567746c34a42db60505a42fbf6bc Parents: 08d4ab7 Author: Daan Hoogland Authored: Sat Jun 22 23:21:05 2013 +0200 Committer: Sebastien Goasguen Committed: Sun Jun 23 11:25:16 2013 -0400 ---------------------------------------------------------------------- tools/marvin/marvin/cloudstackTestClient.py | 69 ++++++++++++++---------- 1 file changed, 41 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3fdcf183/tools/marvin/marvin/cloudstackTestClient.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py index 37380d6..ea32b90 100644 --- a/tools/marvin/marvin/cloudstackTestClient.py +++ b/tools/marvin/marvin/cloudstackTestClient.py @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,23 +23,26 @@ import random import string import hashlib + class cloudstackTestClient(object): def __init__(self, mgtSvr=None, port=8096, user=None, passwd=None, apiKey=None, securityKey=None, asyncTimeout=3600, defaultWorkerThreads=10, logging=None): self.connection = \ - cloudstackConnection.cloudConnection( - mgtSvr, port, user, - passwd, apiKey, securityKey, - asyncTimeout, logging) - self.apiClient = cloudstackAPIClient.CloudStackAPIClient(self.connection) + cloudstackConnection.cloudConnection(mgtSvr, port, user, passwd, + apiKey, securityKey, + asyncTimeout, logging) + self.apiClient =\ + cloudstackAPIClient.CloudStackAPIClient(self.connection) self.dbConnection = None self.asyncJobMgr = None self.ssh = None self.defaultWorkerThreads = defaultWorkerThreads - def dbConfigure(self, host="localhost", port=3306, user='cloud', passwd='cloud', db='cloud'): - self.dbConnection = dbConnection.dbConnection(host, port, user, passwd, db) + def dbConfigure(self, host="localhost", port=3306, user='cloud', + passwd='cloud', db='cloud'): + self.dbConnection = dbConnection.dbConnection(host, port, user, passwd, + db) def isAdminContext(self): """ @@ -53,11 +56,11 @@ class cloudstackTestClient(object): listdomres = self.apiClient.listDomains(listdom) rootdom = listdomres[0].name if rootdom == 'ROOT': - return 1 #admin + return 1 # admin else: - return 2 #domain-admin + return 2 # domain-admin except: - return 0 #user + return 0 # user def random_gen(self, size=6, chars=string.ascii_uppercase + string.digits): """Generate Random Strings of variable length""" @@ -93,7 +96,8 @@ class cloudstackTestClient(object): createAcctCmd = createAccount.createAccountCmd() createAcctCmd.accounttype = acctType createAcctCmd.domainid = domId - createAcctCmd.email = "test-" + self.random_gen() + "@cloudstack.org" + createAcctCmd.email = "test-" + self.random_gen()\ + + "@cloudstack.org" createAcctCmd.firstname = UserName createAcctCmd.lastname = UserName createAcctCmd.password = mdf_pass @@ -116,10 +120,16 @@ class cloudstackTestClient(object): apiKey = registerUserRes.apikey securityKey = registerUserRes.secretkey - newUserConnection = cloudstackConnection.cloudConnection(self.connection.mgtSvr, self.connection.port, - self.connection.user, self.connection.passwd, - apiKey, securityKey, self.connection.asyncTimeout, self.connection.logging) - self.userApiClient = cloudstackAPIClient.CloudStackAPIClient(newUserConnection) + newUserConnection =\ + cloudstackConnection.cloudConnection(self.connection.mgtSvr, + self.connection.port, + self.connection.user, + self.connection.passwd, + apiKey, securityKey, + self.connection.asyncTimeout, + self.connection.logging) + self.userApiClient =\ + cloudstackAPIClient.CloudStackAPIClient(newUserConnection) self.userApiClient.connection = newUserConnection self.userApiClient.hypervisor = self.apiClient.hypervisor return self.userApiClient @@ -156,24 +166,27 @@ class cloudstackTestClient(object): return self.userApiClient return None - - '''FixME, httplib has issue if more than one thread submitted''' - def submitCmdsAndWait(self, cmds, workers=1): + '''FixME, httplib has issue if more than one thread submitted''' if self.asyncJobMgr is None: - self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, self.dbConnection) + self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, + self.dbConnection) return self.asyncJobMgr.submitCmdsAndWait(cmds, workers) - '''submit one job and execute the same job ntimes, with nums_threads of threads''' - def submitJob(self, job, ntimes=1, nums_threads=10, interval=1): + ''' + submit one job and execute the same job ntimes, with nums_threads + of threads + ''' if self.asyncJobMgr is None: - self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, self.dbConnection) - self.asyncJobMgr.submitJobExecuteNtimes(job, ntimes, nums_threads, interval) - - '''submit n jobs, execute them with nums_threads of threads''' + self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, + self.dbConnection) + self.asyncJobMgr.submitJobExecuteNtimes(job, ntimes, nums_threads, + interval) def submitJobs(self, jobs, nums_threads=10, interval=1): + '''submit n jobs, execute them with nums_threads of threads''' if self.asyncJobMgr is None: - self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, self.dbConnection) + self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, + self.dbConnection) self.asyncJobMgr.submitJobs(jobs, nums_threads, interval)