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 DISPLAY boot.msg
LABEL default LABEL default
KERNEL kernel 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 = '' tftp_dir = ''
@ -43,37 +43,44 @@ directory = ''
image_to_restore = '' image_to_restore = ''
cifs_username = '' cifs_username = ''
cifs_password = '' cifs_password = ''
ip = ''
netmask = ''
gateway = ''
def prepare_boot_file(): def prepare_boot_file():
try: try:
pxelinux = join(tftp_dir, "pxelinux.cfg") pxelinux = join(tftp_dir, "pxelinux.cfg")
if exists(pxelinux) == False: if exists(pxelinux) == False:
makedirs(pxelinux) makedirs(pxelinux)
cfg_name = "01-" + mac.replace(':','-').lower() cfg_name = "01-" + mac.replace(':','-').lower()
cfg_path = join(pxelinux, cfg_name) cfg_path = join(pxelinux, cfg_name)
f = open(cfg_path, "w") 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.write(stuff)
f.close() f.close()
return 0 return 0
except IOError, e: except IOError, e:
print e print e
return 1 return 1
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 9: 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" 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) exit(1)
tftp_dir = sys.argv[1] tftp_dir = sys.argv[1]
mac = sys.argv[2] mac = sys.argv[2]
cifs_server = sys.argv[3] cifs_server = sys.argv[3]
share = sys.argv[4] share = sys.argv[4]
directory = sys.argv[5] directory = sys.argv[5]
image_to_restore = sys.argv[6] image_to_restore = sys.argv[6]
cifs_username = sys.argv[7] cifs_username = sys.argv[7]
cifs_password = sys.argv[8] cifs_password = sys.argv[8]
ip = sys.argv[9]
netmask = sys.argv[10]
gateway = sys.argv[11]
ret = prepare_boot_file() ret = prepare_boot_file()
exit(ret) exit(ret)