Skip to content

Commit fd24a1e

Browse files
committed
Use static IP when PING provisioning
1 parent 8316569 commit fd24a1e

1 file changed

Lines changed: 35 additions & 28 deletions

File tree

scripts/network/ping/prepare_tftp_bootfile.py

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
DISPLAY boot.msg
3333
LABEL default
3434
KERNEL kernel
35-
APPEND vga=normal devfs=nomount pxe ramdisk_size=66000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw noapic nolapic lba combined_mode=libata ide0=noprobe nomce pci=nomsi irqpoll quiet Server="%s" Share="%s" Directory="%s" Image_To_Restore="%s" After_Completion="Reboot" CIFS_Preferred="Y" Zsplit_Preferred="Y" AUTO="Y" User="%s" Passwd="%s" Extend_Parts_Whenever_Possible="N" Replace_BIOS="N"
35+
APPEND vga=normal devfs=nomount pxe ramdisk_size=66000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw noapic nolapic lba combined_mode=libata ide0=noprobe nomce pci=nomsi irqpoll quiet Server="%s" Share="%s" Directory="%s" Image_To_Restore="%s" After_Completion="Reboot" CIFS_Preferred="Y" Zsplit_Preferred="Y" AUTO="Y" User="%s" Passwd="%s" Extend_Parts_Whenever_Possible="N" Replace_BIOS="N" IP="%s" Netmask="%s" Gateway="%s"
3636
'''
3737

3838
tftp_dir = ''
@@ -43,37 +43,44 @@
4343
image_to_restore = ''
4444
cifs_username = ''
4545
cifs_password = ''
46+
ip = ''
47+
netmask = ''
48+
gateway = ''
4649

4750
def prepare_boot_file():
48-
try:
49-
pxelinux = join(tftp_dir, "pxelinux.cfg")
50-
if exists(pxelinux) == False:
51-
makedirs(pxelinux)
51+
try:
52+
pxelinux = join(tftp_dir, "pxelinux.cfg")
53+
if exists(pxelinux) == False:
54+
makedirs(pxelinux)
5255

53-
cfg_name = "01-" + mac.replace(':','-').lower()
54-
cfg_path = join(pxelinux, cfg_name)
55-
f = open(cfg_path, "w")
56-
stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password)
57-
f.write(stuff)
58-
f.close()
59-
return 0
60-
except IOError, e:
61-
print e
62-
return 1
56+
cfg_name = "01-" + mac.replace(':','-').lower()
57+
cfg_path = join(pxelinux, cfg_name)
58+
f = open(cfg_path, "w")
59+
stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password, ip, netmask, gateway)
60+
f.write(stuff)
61+
f.close()
62+
return 0
63+
except IOError, e:
64+
print e
65+
return 1
6366

6467
if __name__ == "__main__":
65-
if len(sys.argv) < 9:
66-
print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password"
67-
exit(1)
68+
if len(sys.argv) < 12:
69+
print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway"
70+
exit(1)
6871

69-
tftp_dir = sys.argv[1]
70-
mac = sys.argv[2]
71-
cifs_server = sys.argv[3]
72-
share = sys.argv[4]
73-
directory = sys.argv[5]
74-
image_to_restore = sys.argv[6]
75-
cifs_username = sys.argv[7]
76-
cifs_password = sys.argv[8]
72+
tftp_dir = sys.argv[1]
73+
mac = sys.argv[2]
74+
cifs_server = sys.argv[3]
75+
share = sys.argv[4]
76+
directory = sys.argv[5]
77+
image_to_restore = sys.argv[6]
78+
cifs_username = sys.argv[7]
79+
cifs_password = sys.argv[8]
80+
ip = sys.argv[9]
81+
netmask = sys.argv[10]
82+
gateway = sys.argv[11]
83+
7784

78-
ret = prepare_boot_file()
79-
exit(ret)
85+
ret = prepare_boot_file()
86+
exit(ret)

0 commit comments

Comments
 (0)