diff options
Diffstat (limited to 'kpov_judge/tasks')
-rw-r--r-- | kpov_judge/tasks/isc_dhcp_live_boot/task.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/kpov_judge/tasks/isc_dhcp_live_boot/task.py b/kpov_judge/tasks/isc_dhcp_live_boot/task.py index 0c7af4f..b446450 100644 --- a/kpov_judge/tasks/isc_dhcp_live_boot/task.py +++ b/kpov_judge/tasks/isc_dhcp_live_boot/task.py @@ -88,7 +88,38 @@ params_meta = { def task(IP_DHCP, IP_GW, MAC_BOOT, BOOT_FNAME): # check the IP - # ping the DHCP server + import socket + import os + results={} + try: + if IP_DHCP.count('.')!=3 or IP_GW.count('.')!=3: + results['IPcheck']=False + socket.inet_pton(socket.AF_INET,IP_DHCP) + socket.inet_pton(socket.AF_INET,IP_GW) + results['IPcheck']=True + # ping the DHCP server + if os.system("ping "+IP_DHCP)==0: + results[PingDHCP]=True + print("Povezava z DHCP strežnikom je OK") + # check whether the fname served by the dhcp server is + # correct + datoteka=open(BOOT_FNAME,"r") + array=[] + for line in datoteka: + array.append(line) + datoteka.close() + #greš skozi array preverit ce je vse ok + else: + print("Povezava s strežnikom ni OK") + results['PingDHCP']=False + except FileNotFoundError: + results['BootFname']=False + return "Datoteka ne obstaja" + except IOError: + results['BootFname']=False + return "I/O napaka" + except OSError: + results['IPcheck']=False # check whether the fname served by the dhcp server is correct # connect to the service in the special ISO # check the MAC of the server on IP_BOOT |