1
+ from __future__ import annotations
2
+
1
3
from lib .commands import ssh , scp
2
4
from data import ARP_SERVER , PXE_CONFIG_SERVER
3
5
4
6
PXE_CONFIG_DIR = "/pxe/configs/custom"
5
7
6
- def generate_boot_conf (directory , installer , action ) :
8
+ def generate_boot_conf (directory : str , installer : str , action : str ) -> None :
7
9
# in case of restore, we disable the text ui from the installer completely,
8
10
# to workaround a bug that leaves us stuck on a confirmation dialog at the end of the operation.
9
11
rt = 'rt=1' if action == 'restore' else ''
@@ -15,25 +17,25 @@ def generate_boot_conf(directory, installer, action):
15
17
{ rt }
16
18
""" )
17
19
18
- def server_push_config (mac_address , tmp_local_path ) :
20
+ def server_push_config (mac_address : str , tmp_local_path : str ) -> None :
19
21
assert mac_address
20
22
remote_dir = f'{ PXE_CONFIG_DIR } /{ mac_address } /'
21
23
server_remove_config (mac_address )
22
24
ssh (PXE_CONFIG_SERVER , ['mkdir' , '-p' , remote_dir ])
23
25
scp (PXE_CONFIG_SERVER , f'{ tmp_local_path } /boot.conf' , remote_dir )
24
26
scp (PXE_CONFIG_SERVER , f'{ tmp_local_path } /answerfile.xml' , remote_dir )
25
27
26
- def server_remove_config (mac_address ) :
28
+ def server_remove_config (mac_address : str ) -> None :
27
29
assert mac_address # protection against deleting the whole parent dir!
28
30
remote_dir = f'{ PXE_CONFIG_DIR } /{ mac_address } /'
29
31
ssh (PXE_CONFIG_SERVER , ['rm' , '-rf' , remote_dir ])
30
32
31
- def server_remove_bootconf (mac_address ) :
33
+ def server_remove_bootconf (mac_address : str ) -> None :
32
34
assert mac_address
33
35
distant_file = f'{ PXE_CONFIG_DIR } /{ mac_address } /boot.conf'
34
36
ssh (PXE_CONFIG_SERVER , ['rm' , '-rf' , distant_file ])
35
37
36
- def arp_addresses_for (mac_address ) :
38
+ def arp_addresses_for (mac_address : str ) -> list [ str ] :
37
39
output = ssh (
38
40
ARP_SERVER ,
39
41
['ip' , 'neigh' , 'show' , 'nud' , 'reachable' ,
0 commit comments