コード例 #1
0
 def __init__(self, arch, OS, version, user, software, givenname, desc, getimg, passwd, verbose, printLogStdout):
     super(IMGenerate, self).__init__()
     
     self.arch = arch
     self.OS = OS
     self.version = version
     self.user = user
     self.passwd = passwd
     self.software = software
     self.givenname = givenname
     self.desc = desc
     self.getimg = getimg
     self._verbose = verbose
     self.printLogStdout = printLogStdout
     
     #Load Configuration from file
     self._genConf = IMClientConf()
     self._genConf.load_generationConfig()        
     self.serveraddr = self._genConf.getServeraddr()
     self.gen_port = self._genConf.getGenPort()
     
     self._ca_certs = self._genConf.getCaCertsGen()
     self._certfile = self._genConf.getCertFileGen()
     self._keyfile = self._genConf.getKeyFileGen()
     
     self._log = fgLog.fgLog(self._genConf.getLogFileGen(), self._genConf.getLogLevelGen(), "GenerateClient", printLogStdout)
コード例 #2
0
 def __init__(self, user, verbose, printLogStdout):
     super(RainClient, self).__init__()
     
     self.user = user
     self.verbose = verbose
     self.printLogStdout = printLogStdout
     
     self._rainConf = RainClientConf()
     self._log = fgLog.fgLog(self._rainConf.getLogFile(), self._rainConf.getLogLevel(), "RainClient", printLogStdout)
     self.refresh = self._rainConf.getRefresh()
     self.moab_max_wait = self._rainConf.getMoabMaxWait()
     self.moab_images_file = self._rainConf.getMoabImagesFile()
コード例 #3
0
ファイル: fgCLI.py プロジェクト: futuregrid/rain2-donotuse
    def __init__(self, silent, user, passwd):

        self.base_cmds = ['exec', 'help', 'history','manual', 'quit', 'use', 'contexts', 'script']
        base_cmd2 = ['li', 'load', 'pause', 'py', 'run', 'save', 'shortcuts', 'set', 'show', 'historysession']
        self.base_cmds += base_cmd2

        self._locals = {}
        self._globals = {}

        self.user = user
        self.passwd = ""
        
        self.passwdtype = "ldappass"
        userCred = FGCredential(self.passwdtype,passwd)
        if not self.check_simpleauth(userCred):
            sys.exit()


        #Load Config
        self._conf = fgShellConf()
        
        #Setup log  
        self._log = fgLog(self._conf.getLogFile(), self._conf.getLogLevel(), "FGShell", False)

        self._log.debug("\nReading Configuration file from " + self._conf.getConfigFile() + "\n")

        Cmd.__init__(self)        
        fgShellUtils.__init__(self)        

        #Context        
        self.env = ["repo", "hadoop", "image", "rain", ""]
        self.text = {'image': 'Image Management',
                     'repo':'Image Repository',
                     'rain':'FG Dynamic Provisioning',
                     'hadoop':'Apache Hadoop'}
        self._use = ""
        self._requirements = []
        self._contextOn = [] # initialized contexts

        #Help
        self._docHelp = []
        self._undocHelp = []
        self._specdocHelp = []
        self.getDocUndoc("")

        self.prompt = "fg> "
        self.silent = silent
        if self.silent:
            self.intro = ""
        else:
            self.intro = self.loadBanner()
        ##Load History
        self.loadhist("no argument needed")
コード例 #4
0
    def __init__(self, verbose, printLogStdout):
        super(IRServiceProxy, self).__init__()

        #Load Config
        self._conf = IRClientConf()
        #self._backend = self._conf.getBackend()
        #self._fgirimgstore = self._conf.getFgirimgstore()
        self._port = self._conf.getPort()
        self._serveraddr = self._conf.getServeraddr()
        self.verbose = verbose
        
        self._ca_certs = self._conf.getCaCerts()
        self._certfile = self._conf.getCertFile()
        self._keyfile = self._conf.getKeyFile()
        
        self._connIrServer = None
        
        self.passwdtype = "ldappassmd5"
        #Setup log
        self._log = fgLog.fgLog(self._conf.getLogFile(), self._conf.getLogLevel(), "Img Repo Client", printLogStdout)
コード例 #5
0
    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()
コード例 #6
0
ファイル: FGAuth.py プロジェクト: javidiaz/rain
def auth(userId, cred):
    ret = False
    testmode = False
    # find the config file
    _localpath = "~/.fg/"
    _configfile = os.path.expanduser(_localpath) + "/" + configFileName
    _fgpath = ""
    try:
        _fgpath = os.environ['FG_PATH']
    except KeyError:
        _fgpath = os.path.dirname(os.path.abspath(__file__)) + "/../"
    
    if not os.path.isfile(_configfile):
        _configfile = "/etc/futuregrid/" + configFileName #os.path.expanduser(_fgpath) + "/etc/" + configFileName
        #if not os.path.isfile(_configfile):
        #    _configfile = os.path.expanduser(os.path.dirname(__file__)) + "/" + configFileName
        if not os.path.isfile(_configfile):   
            print "ERROR: configuration file " + configFileName + " not found"
            sys.exit(1)
                
    configFile = _configfile
    config = ConfigParser.ConfigParser()
    config.read(configFile)
    logfile = os.path.expanduser(config.get("LDAP", "log"))
    try:
        testinput=eval(config.get("LDAP", "test"))
        if testinput != False and testinput != True:
            testmode = False
        else:
            testmode=testinput
    except:
        testmode = False

    log = fgLog(logfile, logging.INFO, "utils.FGAuth Auth", False)

    authProvider = cred.getProvider()
    authCred = cred.getCred()
    # print "'" + userId + "':'" + authProvider + "':'" + authCred + "'"
    if(authProvider == "ldappass" or authProvider == "ldappassmd5"):
        if(authCred != ""):
            host = config.get('LDAP', 'LDAPHOST')
            adminuser = config.get('LDAP', 'LDAPUSER')
            adminpass = config.get('LDAP', 'LDAPPASS')
            #print adminuser, adminpass
            userdn = "uid=" + userId + ",ou=People,dc=futuregrid,dc=org"
            #print userdn
            ldapconn = ldap.initialize("ldap://" + host)
            log.info("Initializing the LDAP connection to server: " + host)
            try:
                ldapconn.start_tls_s()
                log.info("tls started...")
                ldapconn.bind_s(adminuser, adminpass)
                passwd_input = authCred
                if(authProvider == "ldappass"):
                    m = hashlib.md5()
                    m.update(authCred)
                    passwd_input = m.hexdigest()

                #print passwd_input
                passwd_processed = "{MD5}" + base64.b64encode(binascii.unhexlify(passwd_input))
                #print passwd_processed
                #print base64.b64encode(passwd_processed)
                if(ldapconn.compare_s(userdn, 'userPassword', passwd_processed)):
                    ret = True
                    log.info("User '" + userId + "' successfully authenticated")
                else:
                    ret = False
                    log.info("User '" + userId + "' failed to authenticate due to incorrect credential")
                #print ldapconn.compare_s(userdn, 'mail', "*****@*****.**")
                #basedn = "ou=People,dc=futuregrid,dc=org"
                #filter = "(uid=" + userId + ")"
                #attrs = ['userPassword']
                #print ldapconn.search_s( basedn, ldap.SCOPE_SUBTREE, filter, attrs )
            except ldap.INVALID_CREDENTIALS:
                log.info("Your username or password is incorrect. Cannot bind as admin.")
                ret = False
            except ldap.LDAPError:
                log.info("User '" + userId + "' failed to authenticate due to LDAP error. The user may not exist."+ str(sys.exc_info()))
                ret = False
            except:
                ret = False
                log.info("User '" + userId + "' failed to authenticate due to possible password encryption error."+str(sys.exc_info()))
            finally:
                log.info("Unbinding from the LDAP.")
                ldapconn.unbind()
    elif(authProvider == "drupalplain"):
        import MySQLdb
        if(authCred != ""):
            m = hashlib.md5()
            m.update(authCred)
            passwd_input = m.hexdigest()

            dbhost = config.get('PortalDB', 'host')
            dbuser = config.get('PortalDB', 'user')
            dbpasswd = config.get('PortalDB', 'passwd')
            dbname = config.get('PortalDB', 'db')
            
            conn = MySQLdb.connect(dbhost,dbuser,dbpasswd,dbname)
            cursor = conn.cursor()
            queryuser = "******" + userId + "'"
            cursor.execute(queryuser)
            passwd_db = ""
            passwd = cursor.fetchall()
            for thepass in passwd:
                passwd_db = list(thepass)[0]
            if(passwd_db != "" and passwd_db==passwd_input):
                ret = True
                log.info("User " + userId + " successfully authenticated")
            else:
                ret = False
                log.info("User " + userId + " failed to authenticate")
    if not testmode:
        return ret
    else:
        return True
コード例 #7
0
ファイル: FGAuth.py プロジェクト: javidiaz/rain
def simpleauth(userId, cred):
    ret = False
    testmode = False
    # find the config file
    _localpath = "~/.fg/"
    _configfile = os.path.expanduser(_localpath) + "/" + configFileNameClient
    _fgpath = ""
    try:
        _fgpath = os.environ['FG_PATH']
    except KeyError:
        _fgpath = os.path.dirname(os.path.abspath(__file__)) + "/../"
    
    if not os.path.isfile(_configfile):
        _configfile = "/etc/futuregrid/" + configFileNameClient #os.path.expanduser(_fgpath) + "/etc/" + configFileNameClient
        #if not os.path.isfile(_configfile):
        #    _configfile = os.path.expanduser(os.path.dirname(__file__)) + "/" + configFileNameClient
        if not os.path.isfile(_configfile):   
            print "ERROR: configuration file " + configFileNameClient + " not found"
            sys.exit(1)
                
    configFile = _configfile
    config = ConfigParser.ConfigParser()
    config.read(configFile)
    logfile = os.path.expanduser(os.path.expandvars(config.get("LDAP", "log")))
    
    log = fgLog(logfile, logging.INFO, "utils.FGAuth Auth", False)
    try:
        testinput=eval(config.get("LDAP", "test"))
        if testinput != False and testinput != True:
            testmode = False
        else:
            testmode=testinput
    except:
        testmode = False

    authProvider = cred.getProvider()
    authCred = cred.getCred()
    # print "'" + userId + "':'" + authProvider + "':'" + authCred + "'"
    if(authProvider == "ldappass"):
        if(authCred != ""):
            host = config.get('LDAP', 'LDAPHOST')            
            #print adminuser, adminpass
            userdn = "uid=" + userId + ",ou=People,dc=futuregrid,dc=org"
            #print userdn
            ldapconn = ldap.initialize("ldap://" + host)
            log.info("Initializing the LDAP connection to server: " + host)
            try:
                ldapconn.start_tls_s()
                log.info("tls started...")
                ldapconn.bind_s(userdn, authCred)
                ret = True                
            except ldap.INVALID_CREDENTIALS:
                log.info("Your username or password is incorrect. Cannot bind.")
                ret = False
            except ldap.LDAPError:
                log.info("User '" + userId + "' failed to authenticate due to LDAP error. The user may not exist."+ str(sys.exc_info()))
                ret = False
            except:
                ret = False
                log.info("User '" + userId + "' failed to authenticate due to possible password encryption error."+str(sys.exc_info()))
            finally:
                log.info("Unbinding from the LDAP.")
                ldapconn.unbind()
    if not testmode:
        return ret
    else:
        return True
コード例 #8
0
ファイル: IRService.py プロジェクト: futuregrid/rain
    def __init__(self):
        super(IRService, self).__init__()

        #load config
        self._repoConf = IRServerConf()
        self._repoConf.loadRepoServerConfig()
        
        #self._authorizedUsers=self._repoConf.getAuthorizedUsers()  #to be removed    
        self._backend = self._repoConf.getBackend()        
        
        self._address = self._repoConf.getAddress()
        self._userAdmin = self._repoConf.getUserAdmin()
        self._configFile = self._repoConf.getConfigFile()        
        self._imgStore = self._repoConf.getImgStore()
        self._addressS = self._repoConf.getAddressS()
        self._userAdminS = self._repoConf.getUserAdminS()
        self._configFileS = self._repoConf.getConfigFileS()
        #self._idp = self._repoConf.getIdp()
        
        print "\nReading Configuration file from " + self._repoConf.getServerConfig() + "\n"
        
        #Setup log. 
        #When integrate ALL FG software, we may need to create this somewhere else and send the log object to all classes like this        
        self._log = fgLog.fgLog(self._repoConf.getLogRepo(), self._repoConf.getLogLevelRepo(), "Img Repo Server", False)
        
        if (self._backend == "mongodb"):
            from IRDataAccessMongo import ImgStoreMongo
            from IRDataAccessMongo import ImgMetaStoreMongo
            from IRDataAccessMongo import IRUserStoreMongo
            self.metaStore = ImgMetaStoreMongo(self._address, self._userAdmin, self._configFile, self._log)
            self.imgStore = ImgStoreMongo(self._address, self._userAdmin, self._configFile, self._imgStore, self._log)
            self.userStore = IRUserStoreMongo(self._address, self._userAdmin, self._configFile, self._log)
        elif(self._backend == "mysql"):
            from IRDataAccessMysql import ImgStoreMysql
            from IRDataAccessMysql import ImgMetaStoreMysql
            from IRDataAccessMysql import IRUserStoreMysql
            self.metaStore = ImgMetaStoreMysql(self._address, self._userAdmin, self._configFile, self._log)
            self.imgStore = ImgStoreMysql(self._address, self._userAdmin, self._configFile, self._imgStore, self._log)
            self.userStore = IRUserStoreMysql(self._address, self._userAdmin, self._configFile, self._log)
        elif(self._backend == "swiftmysql"):
            from IRDataAccessSwiftMysql import ImgStoreSwiftMysql
            from IRDataAccessSwiftMysql import ImgMetaStoreSwiftMysql
            from IRDataAccessSwiftMysql import IRUserStoreSwiftMysql
            self.metaStore = ImgMetaStoreSwiftMysql(self._address, self._userAdmin, self._configFile, self._log)
            self.imgStore = ImgStoreSwiftMysql(self._address, self._userAdmin, self._configFile, self._addressS, self._userAdminS, self._configFileS, self._imgStore, self._log)
            self.userStore = IRUserStoreSwiftMysql(self._address, self._userAdmin, self._configFile, self._log)
        elif(self._backend == "swiftmongo"):
            from IRDataAccessSwiftMongo import ImgStoreSwiftMongo
            from IRDataAccessSwiftMongo import ImgMetaStoreSwiftMongo
            from IRDataAccessSwiftMongo import IRUserStoreSwiftMongo
            self.metaStore = ImgMetaStoreSwiftMongo(self._address, self._userAdmin, self._configFile, self._log)
            self.imgStore = ImgStoreSwiftMongo(self._address, self._userAdmin, self._configFile, self._addressS, self._userAdminS, self._configFileS, self._imgStore, self._log)
            self.userStore = IRUserStoreSwiftMongo(self._address, self._userAdmin, self._configFile, self._log)
        elif(self._backend == "cumulusmysql"):
            from IRDataAccessCumulusMysql import ImgStoreCumulusMysql
            from IRDataAccessCumulusMysql import ImgMetaStoreCumulusMysql
            from IRDataAccessCumulusMysql import IRUserStoreCumulusMysql
            self.metaStore = ImgMetaStoreCumulusMysql(self._address, self._userAdmin, self._configFile, self._log)
            self.imgStore = ImgStoreCumulusMysql(self._address, self._userAdmin, self._configFile, self._addressS, self._userAdminS, self._configFileS, self._imgStore, self._log)
            self.userStore = IRUserStoreCumulusMysql(self._address, self._userAdmin, self._configFile, self._log)
        elif(self._backend == "cumulusmongo"):
            from IRDataAccessCumulusMongo import ImgStoreCumulusMongo
            from IRDataAccessCumulusMongo import ImgMetaStoreCumulusMongo
            from IRDataAccessCumulusMongo import IRUserStoreCumulusMongo
            self.metaStore = ImgMetaStoreCumulusMongo(self._address, self._userAdmin, self._configFile, self._log)
            self.imgStore = ImgStoreCumulusMongo(self._address, self._userAdmin, self._configFile, self._addressS, self._userAdminS, self._configFileS, self._imgStore, self._log)
            self.userStore = IRUserStoreCumulusMongo(self._address, self._userAdmin, self._configFile, self._log)
        else:
            print "Wrong backend"
            sys.exit()