From cf16551d1e90471f17bbb3f57f359e76495e3826 Mon Sep 17 00:00:00 2001 From: "zk7052@student.uni-lj.si" Date: Thu, 11 Dec 2014 21:12:27 +0000 Subject: =?UTF-8?q?V=20metodo=20task=20sem=20dodal=20preverjanje=20veljavn?= =?UTF-8?q?osti=20IPjev,=20pinganje=20stre=C5=BEnika=20dhcp=20in=20napisal?= =?UTF-8?q?=20sem=20tudi=20kodo=20ki=20odpre=20file=20samo=20nisem=20sigur?= =?UTF-8?q?en=20kaj=20tocno=20mora=20preverjati.=20Stanja=20operacij=20se?= =?UTF-8?q?=20shranijo=20v=20slovar=20results.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@35 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/isc_dhcp_live_boot/task.py | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'kpov_judge/tasks/isc_dhcp_live_boot') 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 -- cgit v1.2.1