Use static IP when PING provisioning

This commit is contained in:
Frank 2011-05-06 19:43:40 -07:00
parent 8316569710
commit fd24a1e240

View File

@ -32,7 +32,7 @@ TIMEOUT 26
DISPLAY boot.msg
LABEL default
KERNEL kernel
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"
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"
'''
tftp_dir = ''
@ -43,6 +43,9 @@ directory = ''
image_to_restore = ''
cifs_username = ''
cifs_password = ''
ip = ''
netmask = ''
gateway = ''
def prepare_boot_file():
try:
@ -53,7 +56,7 @@ def prepare_boot_file():
cfg_name = "01-" + mac.replace(':','-').lower()
cfg_path = join(pxelinux, cfg_name)
f = open(cfg_path, "w")
stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password)
stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password, ip, netmask, gateway)
f.write(stuff)
f.close()
return 0
@ -62,8 +65,8 @@ def prepare_boot_file():
return 1
if __name__ == "__main__":
if len(sys.argv) < 9:
print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password"
if len(sys.argv) < 12:
print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway"
exit(1)
tftp_dir = sys.argv[1]
@ -74,6 +77,10 @@ if __name__ == "__main__":
image_to_restore = sys.argv[6]
cifs_username = sys.argv[7]
cifs_password = sys.argv[8]
ip = sys.argv[9]
netmask = sys.argv[10]
gateway = sys.argv[11]
ret = prepare_boot_file()
exit(ret)