File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99from lib .common import HostAddress
1010from lib .tools import logger
11+ from lib .tools .inventory import into_inventory , load_inventory
1112from lib .tools .tasks .update import update_all
1213
1314def _command_update (args ):
14- update_all (args .hosts , args .repos )
15+ if args .inventory :
16+ inventory = load_inventory (args .inventory )
17+ else :
18+ inventory = into_inventory (args .hosts , args .repos )
19+
20+ update_all (inventory )
1521
1622
1723def cli ():
Original file line number Diff line number Diff line change 44"""
55from concurrent .futures import ThreadPoolExecutor
66
7- from lib .common import HostAddress
87from lib .host import Host
98from lib .pool import Pool
109
1110from .. import logger
1211
13- def update_all (master_hosts : list [ HostAddress ], enablerepos : list [ str ] ) -> None :
12+ def update_all (inventory : dict ) -> None :
1413 """Updates all master (primary) hosts.
1514
1615 .. note:: Host must be a master
1716
1817 Throws error if hosts are not master (primary).
1918
20- :param :py:class:`list[lib.common.HostAddress]` master_hosts:
21- A list of hosts to update.
22- :param list[str] enablerepos:
23- Repositories to enable when updating.
19+ :param dict inventory:
20+ Each host (key) holds its own config data (values).
2421 """
25- logger .debug (f"[ { master_hosts } ] enablerepos : { enablerepos } " )
22+ logger .debug (f"Inventory : { inventory } " )
2623 # init related pools
27- pools = [Pool (h ) for h in master_hosts ]
24+ pools = [Pool (h ) for h in inventory ]
2825
2926 with ThreadPoolExecutor () as executor :
3027 for p in pools :
31- executor .submit (update_host , p .master , enablerepos )
28+ executor .submit (update_host , p .master , inventory [ p . master . hostname_or_ip ][ " enablerepos" ] )
3229
3330
3431def update_host (host : Host , enablerepos : list [str ] = []):
You can’t perform that action at this time.
0 commit comments