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)
评论列表
文章目录