def main()

in tools/torset-tool/torset-tool.py [0:0]


def main():
    args = parse_args()
    Path(args.output_dir).mkdir(exist_ok=True)
    logger.add(f"{args.output_dir}/torset-tool.log", rotation = "500 MB", enqueue= True, level="INFO")
    torset_tool = TorsetTool(args.output_dir, args.hosts, args.sharp_cmd_path)
    
    logger.info("Running ibstat on hosts to collect InfiniBand device GUIDs")
    guid_to_host_map = torset_tool.retrieve_guids(args.pkey_path)
    logger.info("Finished collecting InfiniBand device GUIDs from hosts")
    torset_tool.write_guids_to_file()
    logger.info(f"Finished writing guids to {torset_tool.guids_file}") 
    torset_tool.generate_topo_file()
    logger.info(f"Topology file generated at {torset_tool.topo_file}")
    torset_tool.device_guids_per_switch =  torset_tool.group_guids_per_switch()
    logger.info("Finished grouping device guids per switch")
    torset_tool.host_to_torset_map = torset_tool.identify_torsets()
    logger.info("Identified torsets for hosts")
    torset_tool.torsets = torset_tool.group_hosts_by_torset()
    logger.info("Finished grouping hosts by torsets")
    torset_tool.write_hosts_by_torset()
    logger.info(f"Hosts grouped by torset are written to files in {torset_tool.output_dir} directory")