Ejemplo n.º 1
0
    def getPartList(self, serv,):

        # FIXME look up server ip use only ip 
        list =self._volDAO.getPartList(serv, self._CFG.CELL_NAME, self._CFG.Token )
      
        partList = []
        for el in list:
            part = Partition()
            part.setByDict(el)
            # Cache Stuff
            part = self._setPartIntoCache(part)
            partList.append(part)
        return partList
Ejemplo n.º 2
0
    def getFileServer(self,name_or_ip,**kw):
        """
        Retrieve Fileserver Object by hostname or IP  or uuid and update DBCache, if enabled 
        """
        self.Logger.debug("Entering getFileServer with kw=%s" % kw)
        uuid=kw.get("uuid","")
        cached=kw.get("cached","")
        _user=kw.get("_user","")

        DNSInfo=afs.LookupUtil[self._CFG.CELL_NAME].getDNSInfo(name_or_ip)
        if DNSInfo["ipaddrs"][0] in self._CFG.ignoreIPList :
            return None
        if uuid != "" :
            if uuid != afs.LookupUtil[self._CFG.CELL_NAME].getFSUUID(name_or_ip,self._CFG, cached) :
                uuid=afs.LookupUtil[self._CFG.CELL_NAME].getFSUUID(name_or_ip,self._CFG, cached)
        else :
            uuid=afs.LookupUtil[self._CFG.CELL_NAME].getFSUUID(name_or_ip,self._CFG, cached)
         
        if cached :
            this_FileServer=self.DBManager.getFromCache(FileServer,uuid=uuid)
            if this_FileServer == None : # it's not in the cache. Log it and get it from live-system
                self.Logger.warn("getFileServer: FS with uuid=%s not in DB." % uuid)
            else :
                this_FileServer.parts = self.getPartitionsByUUID(uuid,name_or_ip=this_FileServer.servernames[0],cached=cached)
                return this_FileServer

        this_FileServer = FileServer()
        # get DNS-info about server
        DNSInfo = afs.LookupUtil[self._CFG.CELL_NAME].getDNSInfo(name_or_ip)
        this_FileServer.servernames = DNSInfo["names"]
        this_FileServer.ipaddrs = DNSInfo["ipaddrs"]
        # UUID
        this_FileServer.uuid=uuid
        this_FileServer.version,this_FileServer.builddate=self._rxDAO.getVersionandBuildDate(this_FileServer.servernames[0], 7000, _cfg=self._CFG, _user=_user)
        # Partitions
        this_FileServer.parts = self.getPartitions(name_or_ip,cached=cached)
        if self._CFG.DB_CACHE :
            self.DBManager.setIntoCache(FileServer,this_FileServer,uuid=this_FileServer.uuid)
            for p in this_FileServer.parts  :
                part=Partition()
                self.Logger.debug("Setting part to %s" % this_FileServer.parts[p])
                part.setByDict(this_FileServer.parts[p])
                part.serv_uuid=this_FileServer.uuid
                self.DBManager.setIntoCache(Partition,part,serv_uuid=this_FileServer.uuid,name=p)

        # Projects
        # these we get directly from the DB_Cache
        
        this_FileServer.projects = []
        self.Logger.debug("getFileServerByUUID: returning: %s" % this_FileServer)
        return this_FileServer
Ejemplo n.º 3
0
def get_partitions(rc, output, outerr, parseParamList, Logger) :
    """
    return list of partition objects
    """
    if rc :
        raise FileServerLLAError("Error", outerr)
    RX = re.compile("Free space on partition /vicep(\S+): (\d+) K blocks out of total (\d+)")
    partitions = []
    for line in output :
        m = RX.match(line)
        if not m :
            raise FileServerLLAError("Error parsing output" , line)

        name, free, size = m.groups()
        p = Partition()
        p.name = name
        p.size_kb = long(size)
        p.free_kb = long(free)
        p.used_kb = p.size_kb - p.free_kb
        p.ExtAttr = None
        partitions.append(p)
    Logger.debug("get_partitions: returning %s" % partitions)
    return partitions