def __init__(self): self._log = fgLog.fgLog(IRUtil.getLogFile(), IRUtil.getLogLevel(), "getDistributions", False) self.returnCode = 0 kernel = self.runCmd('uname -s') if kernel == "Darwin\n" : self._log.info("Using Darwin kernel ") self.openssl_dist = 'http://www.openssl.org/source/openssl-1.0.0d.tar.gz' self.openssl_dir = 'openssl-1.0.0d' self.cherrypy_dist = 'http://download.cherrypy.org/cherrypy/3.2.0/CherryPy-3.2.0.tar.gz' self.cherrypy_dir = 'CherryPy-3.2.0' cmdOutput = 'x86_64\n'#runCmd('uname -p') if cmdOutput == "i386\n" : self.mongo_dist = 'http://fastdl.mongodb.org/osx/mongodb-osx-i386-1.8.2.tgz' self.mongo_dir = 'mongodb-osx-i386-1.8.2' elif cmdOutput == 'x86_64\n' : self._log.info('Using osx x86_64') self.mongo_dist = 'http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-1.8.2.tgz' self.mongo_dir = 'mongodb-osx-x86_64-1.8.2' elif kernel == "Linux\n" : self.info('Using Linux kernel') self.openssl_dist = 'http://www.openssl.org/source/openssl-1.0.0d.tar.gz' self.openssl_dir = 'openssl-1.0.0d' self.cherrypy_dist = 'http://download.cherrypy.org/cherrypy/3.2.0/CherryPy-3.2.0.tar.gz' self.cherrypy_dir = 'CherryPy-3.2.0' cmdOutput = 'x86_64\n' #runCmd('uname -p') if cmdOutput == "i386\n" : self.mongo_dist = 'http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz' self.mongo_dir = 'mongodb-linux-i686-1.8.2' elif cmdOutput == "x86_64\n" : self.mongo_dist = 'http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.8.2.tgz' self.mongo_dir = 'mongodb-linux-x86_64-1.8.2'
def createIR(self): cfg_new = {} for id, node in self.cfg.items(): cmd_l = [] for cmd in node.cmdList: cmd_l += [IRUtil.parseCmd(cmd)] node_new = CFGNode(node.name, node.id, node.cmdList) node_new.cmdIR_l, node_new.edges, node_new.producers, node_new.consumers, node_new.isHead, node_new.isTBlock, node_new.isFBlock, node_new.isTail = cmd_l, node.edges, node.producers, node.consumers, node.isHead, node.isTBlock, node.isFBlock, node.isTail cfg_new.update({id: node_new}) self.cfg.update(cfg_new) writeCFG(self.cfg)
def __init__(self, address, userAdmin, configFile, log): """ Initialize object Keyword parameters: _mongoaddress = mongos addresses and ports separated by commas (optional if config file exits) _items = list of imgEntry _dbName = name of the database """ super(IRUserStoreMysql, self).__init__() self._dbName = "imagesS" self._tabledata = "users" self._mysqlcfg = IRUtil.getMysqlcfg() self._iradminsuer = IRUtil.getMysqluser() self._log = log self._dbConnection = None self._mysqlAddress = address self._userAdmin = userAdmin self._configFile = configFile
def __init__(self): super(IRService, self).__init__() #Config in IRUtil self._backend = IRUtil.getBackend() self._address = IRUtil.getAddress() self._fgirimgstore = IRUtil.getFgirimgstore() self._fgserverdir = IRUtil.getFgserverdir() #Setup log self._log = fgLog.fgLog(IRUtil.getLogFile(), IRUtil.getLogLevel(), "Img Repo Server", True) if (self._backend == "mongodb"): self.metaStore = ImgMetaStoreMongo(self._address, self._fgserverdir, self._log) self.imgStore = ImgStoreMongo(self._address, self._fgserverdir, self._log) self.userStore = IRUserStoreMongo(self._address, self._fgserverdir, self._log) elif(self._backend == "mysql"): self.metaStore = ImgMetaStoreMysql(self._address, self._fgserverdir, self._log) self.imgStore = ImgStoreMysql(self._address, self._fgserverdir, self._log) self.userStore = IRUserStoreMysql(self._address, self._fgserverdir, self._log) elif(self._backend == "swiftmysql"): self.metaStore = ImgMetaStoreSwiftMysql(self._address, self._fgserverdir, self._log) self.imgStore = ImgStoreSwiftMysql(self._address, IRUtil.getAddressS(), self._fgserverdir, self._log) self.userStore = IRUserStoreSwiftMysql(self._address, self._fgserverdir, self._log) elif(self._backend == "swiftmongo"): self.metaStore = ImgMetaStoreSwiftMongo(self._address, self._fgserverdir, self._log) self.imgStore = ImgStoreSwiftMongo(self._address, IRUtil.getAddressS(), self._fgserverdir, self._log) self.userStore = IRUserStoreSwiftMongo(self._address, self._fgserverdir, self._log) elif(self._backend == "cumulusmysql"): self.metaStore = ImgMetaStoreCumulusMysql(self._address, self._fgserverdir, self._log) self.imgStore = ImgStoreCumulusMysql(self._address, IRUtil.getAddressS(), self._fgserverdir, self._log) self.userStore = IRUserStoreCumulusMysql(self._address, self._fgserverdir, self._log) elif(self._backend == "cumulusmongo"): self.metaStore = ImgMetaStoreCumulusMongo(self._address, self._fgserverdir, self._log) self.imgStore = ImgStoreCumulusMongo(self._address, IRUtil.getAddressS(), self._fgserverdir, self._log) self.userStore = IRUserStoreCumulusMongo(self._address, self._fgserverdir, self._log) else: self.metaStore = ImgMetaStoreFS() self.imgStore = ImgStoreFS() self.userStore = IRUserStoreFS()
def put(self, userId, imgId, fileName, attributeString, size): if (str(size) == 0) : print("Error size is 0 ") else : print("Logging log info for put action- user " + userId + " len(size) " + str(size)) self._log.info("user:"******" command:put args={imgId:" + imgId + ", metadata:" + attributeString + ",\ size:" + str(size) + "}") """ Register the file in the database return imgId or 0 if something fails """ status = False if type(fileName) == cherrypy._cpreqbody.Part : if (size > 0): aMeta = self._createImgMeta(userId, imgId, attributeString, False) aImg = ImgEntry(imgId, aMeta, fileName.filename, size) statusImg = self.imgStore.addRequestItem(aImg, fileName) if(statusImg): #put metadata into the image meta store #with MongoDB I put the metadata with the ImgEntry, so it skips meta add if(re.search("mongo", IRUtil.getBackend()) == None): statusMeta = self.metaStore.addItem(aMeta) else: statusMeta = True if(statusMeta): #Add size and #imgs to user statusAcc = self.userStore.updateAccounting(userId, size, 1) if (statusAcc): status = True else: self._log.error("File size must be higher than 0") else: fileName = self._fgirimgstore + imgId if (os.path.isfile(fileName)): if (size > 0): #parse attribute string and construct image metadata aMeta = self._createImgMeta(userId, imgId, attributeString, False) aImg = ImgEntry(imgId, aMeta, fileName, size) statusImg = self.imgStore.addItem(aImg) if(statusImg): #put metadata into the image meta store #with MongoDB I put the metadata with the ImgEntry, so it skips meta add if(re.search("mongo", IRUtil.getBackend()) == None): statusMeta = self.metaStore.addItem(aMeta) else: statusMeta = True if(statusMeta): #Add size and #imgs to user statusAcc = self.userStore.updateAccounting(userId, size, 1) if (statusAcc): status = True else: self._log.error("File size must be higher than 0") if(status): return aImg._imgId else: return 0
def auth(self, userId): # to be implemented when integrating with the security framework return IRUtil.auth(userId, None)
import logging from getopt import gnu_getopt, GetoptError from datetime import datetime from IRTypes import ImgMeta from IRTypes import ImgEntry from IRTypes import IRUser from IRTypes import IRCredential from cherrypy.lib import cptools import IRUtil import re from IRDataAccess import AbstractImgStore from IRDataAccess import AbstractImgMetaStore from IRDataAccess import AbstractIRUserStore if(IRUtil.getBackend() == "mongodb"): from IRDataAccessMongo import ImgStoreMongo from IRDataAccessMongo import ImgMetaStoreMongo from IRDataAccessMongo import IRUserStoreMongo elif(IRUtil.getBackend() == "mysql"): from IRDataAccessMysql import ImgStoreMysql from IRDataAccessMysql import ImgMetaStoreMysql from IRDataAccessMysql import IRUserStoreMysql elif(IRUtil.getBackend() == "swiftmysql"): from IRDataAccessMysql import ImgStoreMysql from IRDataAccessMysql import ImgMetaStoreMysql from IRDataAccessMysql import IRUserStoreMysql from IRDataAccessSwiftMysql import ImgStoreSwiftMysql from IRDataAccessSwiftMysql import ImgMetaStoreSwiftMysql from IRDataAccessSwiftMysql import IRUserStoreSwiftMysql elif(IRUtil.getBackend() == "swiftmongo"):