Skip to content

Commit bc2bb51

Browse files
authored
Merge pull request #5 from jabl/boot_py_log_error
Log boot.py exceptions Merging it so that we can test it tomorrow. We'll do a complete test cluster re installation. thanks @jabl
2 parents ced836c + ce43e34 commit bc2bb51

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

files/boot.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@
33
import os
44
import socket
55
import json
6+
import syslog
67
sys.stderr = sys.stdout
78
print "Content-Type: text/plain"
89
print
910

11+
def pxe_abort():
12+
"""Abort the PXE boot, continue with the next boot device in the BIOS boot order"""
13+
print "#!ipxe"
14+
print "exit"
15+
sys.exit(0)
16+
1017
try:
1118
# from the name, e.g. c1-3 take c1-3
1219
hostname = socket.gethostbyaddr(os.environ["REMOTE_ADDR"])[0].split(".")[0]
1320

14-
os.remove("/var/www/provision/reinstall/" + hostname)
21+
try:
22+
os.remove("/var/www/provision/reinstall/" + hostname)
23+
except OSError as e:
24+
syslog.syslog(syslog.LOG_INFO, str(e))
25+
pxe_abort()
26+
1527
with open('/var/www/provision/nodes/pxe_nodes.json') as f:
1628
j = json.load(f)
1729
nodesettings = j[hostname]
@@ -25,6 +37,6 @@
2537
print "initrd http://" + nodesettings["kickstart_server_ip"] + "/ks/initrd.img"
2638
print "boot"
2739

28-
except:
29-
print "#!ipxe"
30-
print "exit"
40+
except Exception as e:
41+
syslog.syslog(syslog.LOG_ERR, str(e))
42+
pxe_abort()

0 commit comments

Comments
 (0)