summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
authorzk7052@student.uni-lj.si <zk7052@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-11 21:12:27 +0000
committerzk7052@student.uni-lj.si <zk7052@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-11 21:12:27 +0000
commitcf16551d1e90471f17bbb3f57f359e76495e3826 (patch)
tree2fc928e2d252854e8360766039e29360a96609eb /kpov_judge
parent95aa4ad64ffafe432a5cd89235667818416747c8 (diff)
V metodo task sem dodal preverjanje veljavnosti IPjev, pinganje strežnika dhcp in napisal sem tudi kodo ki odpre file samo nisem siguren kaj tocno mora preverjati. Stanja operacij se shranijo v slovar results.
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@35 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge')
-rw-r--r--kpov_judge/tasks/isc_dhcp_live_boot/task.py33
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