def rescan(self, __hosts, __bus, __target, __lun):
        """ Rescan SCSI
        invokes a rescan via /sys/class/scsi_host/hostH/scan interface
        IDEAS
        INPUTS
          * host - name of scsi host ( - for all )
          * bus - number of scsi bus (- for all )
          * target - number of target ( - for all )
          * lun - number of lun ( - for all )

        """
        __syspath = "/sys/class/scsi_host"

        if not os.path.isdir( __syspath ):
            raise ComException(__syspath + " not found")
    
        if __hosts == "-":
            __hosts=self.getAllSCSIHosts()

        if  not ( ComUtils.isInt(__bus) or  __bus == "-"):
            raise ComException( __bus + " is not valid to scan SCSI Bus"); 
    
        if  not ( ComUtils.isInt(__target) or  __target == "-"):
            raise ComException( __bus + " is not valid to scan SCSI Target")

        if  not (ComUtils.isInt(__lun) or  __lun == "-"):
            raise ComException( __bus + " is not valid to scan SCSI Lun")

        print "Hosts: ", __hosts

        for __host in __hosts:
            ComSystem.execLocal( "echo \""+__bus+"\" \""+ __target+"\" \""+ __lun+ "\" > "+__syspath+"/"+__host+"/scan")
    def rescan(self, __hosts, __bus, __target, __lun):
        """ Rescan SCSI
        invokes a rescan via /sys/class/scsi_host/hostH/scan interface
        IDEAS
        INPUTS
          * host - name of scsi host ( - for all )
          * bus - number of scsi bus (- for all )
          * target - number of target ( - for all )
          * lun - number of lun ( - for all )

        """
        __syspath = "/sys/class/scsi_host"

        if not os.path.isdir(__syspath):
            raise ComException(__syspath + " not found")

        if __hosts == "-":
            __hosts = self.getAllSCSIHosts()

        if not (ComUtils.isInt(__bus) or __bus == "-"):
            raise ComException(__bus + " is not valid to scan SCSI Bus")

        if not (ComUtils.isInt(__target) or __target == "-"):
            raise ComException(__bus + " is not valid to scan SCSI Target")

        if not (ComUtils.isInt(__lun) or __lun == "-"):
            raise ComException(__bus + " is not valid to scan SCSI Lun")

        print "Hosts: ", __hosts

        for __host in __hosts:
            ComSystem.execLocal(
                'echo "' + __bus + '" "' + __target + '" "' + __lun + '" > ' + __syspath + "/" + __host + "/scan"
            )
Пример #3
0
    def scanOptions(self, device, mountpoint=None):
        """ Scans a mountded gfs and puts the meta information into the DOM
        raises ComException
        """

        if mountpoint:
            __mountpoint = mountpoint.getAttribute("name")
        else:
            __mountpoint, fstype = device.scanMountPoint()
        if not __mountpoint:
            raise ComException("device " + device.getDevicePath() +
                               " is not mounted.")
        __cmd = CMD_GFS_TOOL + " getsb " + __mountpoint
        __rc, __ret = ComSystem.execLocalGetResult(__cmd)
        if __rc != 0:
            raise ComException(__cmd + __ret)

        if __ret[0] == ComSystem.SKIPPED:
            # Just to keep up working when SIMULATING
            self.setAttribute("bsize", "4096")
            self.setAttribute("lockproto", "lock_dlm")
            self.setAttribute("clustername", "testcluster")
            self.setAttribute("journals", "4")
        else:
            __bsize = ComUtils.grepInLines(__ret, "  sb_bsize = ([0-9]*)")[0]
            log.debug("scan Options bsize: " + __bsize)
            self.setAttribute("bsize", __bsize)

            __lockproto = ComUtils.grepInLines(__ret,
                                               "  sb_lockproto = (.*)")[0]
            log.debug("scan Options lockproto: " + __lockproto)
            self.setAttribute("lockproto", __lockproto)

            __locktable = ComUtils.grepInLines(__ret,
                                               "  sb_locktable = .*?:(.*)")
            if len(__locktable) == 1:
                log.debug("scan Options locktable: " + __locktable[0])
                self.setAttribute("locktable", __locktable[0])

            __clustername = ComUtils.grepInLines(__ret,
                                                 "  sb_locktable = (.*?):.*")
            if len(__clustername) == 1:
                log.debug("scan Options clustername: " + __clustername[0])
                self.setAttribute("clustername", __clustername[0])

            __cmd = CMD_GFS_TOOL + " df " + __mountpoint
            __rc, __ret = ComSystem.execLocalGetResult(__cmd)
            if __rc != 0:
                raise ComException(__cmd + __ret)
            __journals = ComUtils.grepInLines(__ret,
                                              "  Journals = ([0-9]+)")[0]
            log.debug("scan Options Journals: " + __journals)
            self.setAttribute("journals", __journals)
   def scanOptions(self, device, mountpoint=None):
      """ Scans a mountded gfs2 and puts the meta information into the DOM
      raises ComException
      """

      if mountpoint:
         mountpoint=mountpoint.getAttribute("name")
      else:
         mountpoint = device.scanMountPoint()[0]
         
      if not mountpoint:
         raise ComException("device " + device.getDevicePath() + " is not mounted.")
      cmd = CMD_GFS2_TOOL + " sb " + device.getDevicePath() + " all"
      rc, ret = ComSystem.execLocalGetResult(cmd)
      if rc != 0:
         raise ComException(cmd + ret)

      if ret[0] == ComSystem.SKIPPED:
         # Just to keep up working when SIMULATING
         self.setAttribute("bsize", "4096")
         self.setAttribute("lockproto", "lock_dlm")
         self.setAttribute("clustername", "testcluster")
         self.setAttribute("journals", "4")
      else:
         bsize=ComUtils.grepInLines(ret, "  sb_bsize = ([0-9]*)")[0]
         log.debug("scan Options bsize: " + bsize)
         self.setAttribute("bsize", bsize)

         lockproto=ComUtils.grepInLines(ret, "  sb_lockproto = (.*)")[0]
         log.debug("scan Options lockproto: " + lockproto)
         self.setAttribute("lockproto", lockproto)

         locktable=ComUtils.grepInLines(ret, "  sb_locktable = .*?:(.*)")
         if len(locktable) == 1:
            log.debug("scan Options locktable: " + locktable[0])
            self.setAttribute("locktable", locktable[0])

         clustername=ComUtils.grepInLines(ret, "  sb_locktable = (.*?):.*")
         if len(clustername) == 1:
            log.debug("scan Options clustername: " +clustername[0])
            self.setAttribute("clustername", clustername[0])

         # FIXME: Bug in gfs2_tool journals / does not work. Only for bindmounts on /
         if mountpoint == "/":
            mountpoint = device.scanMountPoint(mountpoint)[0]
         cmd = CMD_GFS2_TOOL + " journals " + mountpoint
         rc, ret = ComSystem.execLocalGetResult(cmd)
         if rc != 0:
            raise ComException(cmd + ret)
         journals=ComUtils.grepInLines(ret, "^([0-9])+ journal\(s\) found.")[0]
         log.debug("scan Options Journals: " +journals)
         self.setAttribute("journals", journals)
    def scanOptions(self, device, mountpoint=None):
        """ Scans a mountded gfs and puts the meta information into the DOM
        raises ComException
        """

        if mountpoint:
            __mountpoint=mountpoint.getAttribute("name")
        else:
            __mountpoint, fstype = device.scanMountPoint()
        if not __mountpoint:
            raise ComException("device " + device.getDevicePath() + " is not mounted.")
        __cmd = CMD_GFS_TOOL + " getsb " + __mountpoint
        __rc, __ret = ComSystem.execLocalGetResult(__cmd)
        if __rc != 0:
            raise ComException(__cmd + __ret)

        if __ret[0] == ComSystem.SKIPPED:
            # Just to keep up working when SIMULATING
            self.setAttribute("bsize", "4096")
            self.setAttribute("lockproto", "lock_dlm")
            self.setAttribute("clustername", "testcluster")
            self.setAttribute("journals", "4")
        else:
            __bsize=ComUtils.grepInLines(__ret, "  sb_bsize = ([0-9]*)")[0]
            log.debug("scan Options bsize: " + __bsize)
            self.setAttribute("bsize", __bsize)

            __lockproto=ComUtils.grepInLines(__ret, "  sb_lockproto = (.*)")[0]
            log.debug("scan Options lockproto: " + __lockproto)
            self.setAttribute("lockproto",__lockproto)

            __locktable=ComUtils.grepInLines(__ret, "  sb_locktable = .*?:(.*)")
            if len(__locktable) == 1:
                log.debug("scan Options locktable: " + __locktable[0])
                self.setAttribute("locktable", __locktable[0])

            __clustername=ComUtils.grepInLines(__ret, "  sb_locktable = (.*?):.*")
            if len(__clustername) == 1:
                log.debug("scan Options clustername: " +__clustername[0])
                self.setAttribute("clustername", __clustername[0])

            __cmd = CMD_GFS_TOOL + " df " + __mountpoint
            __rc, __ret = ComSystem.execLocalGetResult(__cmd)
            if __rc != 0:
                raise ComException(__cmd + __ret)
            __journals=ComUtils.grepInLines(__ret, "  Journals = ([0-9]+)")[0]
            log.debug("scan Options Journals: " +__journals)
            self.setAttribute("journals", __journals)
 def scanMountPoint(self):
     """ returns first mountpoint of device and fstype if mounted
     returns None if not mounted
     """
     from comoonics.ecbase import ComUtils
     lines = self.getMountList()
     exp = "^" + self.getDevicePath() + " (/.*?) .*"
     self.getLog().debug(exp)
     mp = ComUtils.grepInLines(lines, exp)
     if len(mp) == 0:
         return [None, None]
     exp = "^" + self.getDevicePath() + " " + mp[0] + " (.*?) .*"
     fs = ComUtils.grepInLines(lines, exp)
     if len(fs) == 0:
         return [None, None]
     self.getLog().debug("mountpoint %s filesystem %s", mp[0], fs[0])
     return [mp[0], fs[0]]
 def scanMountPoint(self):
     """ returns first mountpoint of device and fstype if mounted
     returns None if not mounted
     """
     from comoonics.ecbase import ComUtils
     lines=self.getMountList()
     exp="^" + self.getDevicePath() + " (/.*?) .*"
     self.getLog().debug(exp)
     mp=ComUtils.grepInLines(lines, exp)
     if len(mp) == 0:
         return [None, None]
     exp="^" + self.getDevicePath() + " " + mp[0] + " (.*?) .*"
     fs=ComUtils.grepInLines(lines, exp)
     if len(fs) == 0:
         return [None, None]
     self.getLog().debug("mountpoint %s filesystem %s", mp[0], fs[0])
     return [mp[0], fs[0]]