Ejemplo n.º 1
0
 def _initiate_rescan(self,
                      wait_for_completion=True,
                      raise_error=False,
                      do_rescan=True,
                      do_refresh=False):
     from infi.storagemodel.base.gevent_wrapper import spawn, is_thread_alive
     host = self._client.get_managed_object_by_reference(self._moref)
     # we've seen several time in the tests that host.configManager is a list; how weird is that?
     # according to the API documntation, this is not a list; not sure how how to deal with this case
     # so for debugging, we do this:
     config_manager = host.configManager
     storage_system = config_manager.storageSystem
     if self._refresh_thread is not None and is_thread_alive(
             self._refresh_thread):
         self._debug("Skipping refresh - referesh thread is already active")
         if wait_for_completion:
             self._debug("Waiting for refresh thread to complete")
             if raise_error:
                 self._refresh_thread.get(
                 )  # this joins + raises exceptions if there were any
             else:
                 self._refresh_thread.join()
     else:
         self._refresh_thread = spawn(self._refresh_host_storage,
                                      storage_system,
                                      do_rescan=do_rescan,
                                      do_refresh=do_refresh)
         if wait_for_completion:
             self._debug("Waiting for refresh thread to complete")
             if raise_error:
                 self._refresh_thread.get(
                 )  # this joins + raises exceptions if there were any
             else:
                 self._refresh_thread.join()
Ejemplo n.º 2
0
 def _initiate_rescan(self, wait_for_completion=True, raise_error=False, do_rescan=True, do_refresh=False):
     from infi.storagemodel.base.gevent_wrapper import spawn, is_thread_alive
     host = self._client.get_managed_object_by_reference(self._moref)
     # we've seen several time in the tests that host.configManager is a list; how weird is that?
     # according to the API documntation, this is not a list; not sure how how to deal with this case
     # so for debugging, we do this:
     summary = host.summary
     config_manager = host.configManager
     storage_system = config_manager.storageSystem
     if self._refresh_thread is not None and is_thread_alive(self._refresh_thread):
         self._debug("Skipping refresh - referesh thread is already active")
         if wait_for_completion:
             self._debug("Waiting for refresh thread to complete")
             if raise_error:
                 self._refresh_thread.get()       # this joins + raises exceptions if there were any
             else:
                 self._refresh_thread.join()
     else:
         self._refresh_thread = spawn(self._refresh_host_storage, storage_system, do_rescan=do_rescan, do_refresh=do_refresh)
         if wait_for_completion:
             self._debug("Waiting for refresh thread to complete")
             if raise_error:
                 self._refresh_thread.get()       # this joins + raises exceptions if there were any
             else:
                 self._refresh_thread.join()
Ejemplo n.º 3
0
 def _initiate_rescan(self, wait_for_completion=True, raise_error=False):
     from infi.devicemanager import DeviceManager
     from infi.storagemodel.base.gevent_wrapper import joinall, defer, spawn
     dm = DeviceManager()
     rescan_callables = (defer(controller.rescan) for controller in dm.storage_controllers)
     greenlets = [spawn(item) for item in rescan_callables]
     if wait_for_completion:
         joinall(greenlets, raise_error=True)
Ejemplo n.º 4
0
 def _initiate_rescan(self, wait_for_completion=True, raise_error=False):
     from infi.devicemanager import DeviceManager
     from infi.storagemodel.base.gevent_wrapper import joinall, defer, spawn
     dm = DeviceManager()
     rescan_callables = (defer(controller.rescan)
                         for controller in dm.storage_controllers)
     greenlets = [spawn(item) for item in rescan_callables]
     if wait_for_completion:
         joinall(greenlets, raise_error=True)
Ejemplo n.º 5
0
def rescan_scsi_host(host, timeout=None):
    from infi.storagemodel.base.gevent_wrapper import spawn
    channels = get_channels(host)
    subprocesses = []
    if not is_there_a_bug_in_sysfs_async_scanning():
        scsi_host_scan(host)
        channels = get_channels(host)
    for channel in channels:
        targets = get_targets(host, channel)
        for target in targets:
            subprocesses.append(spawn(block_target_scan, host, channel, target, timeout))
    return subprocesses
Ejemplo n.º 6
0
def rescan_scsi_host(host, timeout=None):
    from infi.storagemodel.base.gevent_wrapper import spawn
    channels = get_channels(host)
    subprocesses = []
    if not is_there_a_bug_in_sysfs_async_scanning():
        scsi_host_scan(host)
        channels = get_channels(host)
    for channel in channels:
        targets = get_targets(host, channel)
        for target in targets:
            subprocesses.append(
                spawn(block_target_scan, host, channel, target, timeout))
    return subprocesses
Ejemplo n.º 7
0
    def _initiate_rescan(self, wait_for_completion=True, raise_error=False):
        from infi.storagemodel.base import gevent_wrapper

        if self.rescan_process_start_time:
            if (datetime.now() - self.rescan_process_start_time).total_seconds() > self.rescan_subprocess_timeout:
                logger.debug("rescan process timed out, killing it")
                self.terminate_rescan_process()
                return self._initiate_rescan(wait_for_completion, raise_error)
            else:
                logger.debug("previous rescan process is still running")
                if wait_for_completion:
                    self.join_on_rescan_process()
        else:
            self.terminate_rescan_process()
            event = gevent_wrapper.Event()
            rescan_process = gevent_wrapper.spawn(self.block_on_rescan_process, event)
            event.wait()
            self.rescan_process = rescan_process
            logger.debug("rescan process started")
            if wait_for_completion:
                self.join_on_rescan_process()