host.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:intel-manager-for-lustre 作者: intel-hpdd 项目源码 文件源码
def run(self, kwargs):
        from chroma_core.models import ManagedHost
        from chroma_core.lib.detection import DetectScan

        # Get all the host data
        host_data = {}
        threads = []
        host_target_devices = defaultdict(list)

        for host in ManagedHost.objects.filter(id__in = kwargs['host_ids']):
            volume_nodes = VolumeNode.objects.filter(host = host)

            for volume_node in volume_nodes:
                resource = volume_node.volume.storage_resource.to_resource()
                try:
                    uuid = resource.uuid
                except AttributeError:
                    uuid = None

                host_target_devices[host].append({"path": volume_node.path,
                                                  "type": resource.device_type(),
                                                  "uuid": uuid})

            with transaction.commit_on_success():
                self.log("Scanning server %s..." % host)

            thread = ExceptionThrowingThread(target=self.detect_scan,
                                             args=(host, host_data, host_target_devices[host]))
            thread.start()
            threads.append(thread)

        ExceptionThrowingThread.wait_for_threads(threads)               # This will raise an exception if any of the threads raise an exception

        with transaction.commit_on_success():
            DetectScan(self).run(host_data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号