示例#1
0
 def wait_for_volume_removal(self, volume_path):
     """This is used to ensure that volumes are gone."""
     LOG.debug("Checking to see if SCSI volume %s has been removed.",
               volume_path)
     if os.path.exists(volume_path):
         LOG.debug("%(path)s still exists.", {'path': volume_path})
         raise exception.VolumePathNotRemoved(volume_path=volume_path)
     else:
         LOG.debug("SCSI volume %s has been removed.", volume_path)
示例#2
0
 def wait_for_volumes_removal(self, volumes_names):
     """Wait for device paths to be removed from the system."""
     str_names = ', '.join(volumes_names)
     LOG.debug('Checking to see if SCSI volumes %s have been removed.',
               str_names)
     exist = [
         volume_name for volume_name in volumes_names
         if os.path.exists('/dev/' + volume_name)
     ]
     if exist:
         LOG.debug('%s still exist.', ', '.join(exist))
         raise exception.VolumePathNotRemoved(volume_path=exist)
     LOG.debug("SCSI volumes %s have been removed.", str_names)
示例#3
0
    def wait_for_volumes_removal(self, volumes_names: List[str]) -> None:
        """Wait for device paths to be removed from the system."""
        str_names = ', '.join(volumes_names)
        LOG.debug('Checking to see if SCSI volumes %s have been removed.',
                  str_names)
        exist = ['/dev/' + volume_name for volume_name in volumes_names]

        # It can take up to 30 seconds to remove a SCSI device if the path
        # failed right before we start detaching, which is unlikely, but we
        # still shouldn't fail in that case.
        for i in range(61):
            exist = [path for path in exist if os.path.exists(path)]
            if not exist:
                LOG.debug("SCSI volumes %s have been removed.", str_names)
                return
            # Don't sleep on the last try since we are quitting
            if i < 60:
                time.sleep(0.5)
                # Log every 5 seconds
                if i % 10 == 0:
                    LOG.debug('%s still exist.', ', '.join(exist))
        raise exception.VolumePathNotRemoved(volume_path=exist)