def main(options): url, dbName = splitCouchServiceURL(options.dburl) db = CouchServer(url).connectDatabase(dbName) reqmgr_requests = generate_reqmgr_requests(options.requests) agent_requests = generate_agent_requests(options.requests, options.iterations) if options.add_couchapp: installCouchApp(url, dbName, "WMStats", options.couchapp_base) if options.add_reqmgr_data: for req in reqmgr_requests: db.queue(req) db.commit() print("Added %s reqmgr requests" % len(reqmgr_requests)) if options.add_agent_data: for req in agent_requests: db.queue(req) jobDocs = generate_jobsummary(req['workflow']) for job in jobDocs: db.queue(job) db.commit() print("Added %s agent requests" % len(agent_requests)) print("Added %s job Docs" % (len(agent_requests) * len(jobDocs)))
class WMStatSevice(): def __init__(self, couchURL): # set the connection for local couchDB call self.couchURL, self.dbName = splitCouchServiceURL(couchURL) self.couchDB = CouchServer(self.couchURL).connectDatabase( self.dbName, False) def uploadData(self, docs): """ upload to given couchURL using cert and key authentication and authorization """ # add delete docs as well for the compaction # need to check whether delete and update is successful for doc in docs: self.couchDB.queue(doc) return self.couchDB.commit(returndocs=True)
class WMStatSevice(): def __init__(self, couchURL): # set the connection for local couchDB call self.couchURL, self.dbName = splitCouchServiceURL(couchURL) self.couchDB = CouchServer(self.couchURL).connectDatabase(self.dbName, False) def uploadData(self, docs): """ upload to given couchURL using cert and key authentication and authorization """ # add delete docs as well for the compaction # need to check whether delete and update is successful for doc in docs: self.couchDB.queue(doc) return self.couchDB.commit(returndocs = True)