# pxecfg
**Repository Path**: kill121/pxecfg
## Basic Information
- **Project Name**: pxecfg
- **Description**: pxe config web ui
- **Primary Language**: Python
- **License**: GPL-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2019-09-12
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# PXE Server Configuration App
Simplify PXE configuration.
## Work Flow
- Set configuration files folder and pxelinux.cfg folder in cfg.ini.
- Create pxe configuration template files.
- Create PXE plan for clients.
- App will create pxe configuration file for client and track PXE boot.
## Path
There are 2 folders need to be set:
- configuration files folder: save template files
- pxelinux.cfg folder: save client configuration files
Please modify cfg.ini and restart this server.
## Cfg
pxelinux configuration file.
```html
label centos7.3-diskless
kernel os/diskless/centos7/boot/vmlinuz
append initrd=os/diskless/centos7/boot/initramfs-nfs.img root=nfs4:192.168.1.200:/srv/tftpboot/os/diskless/centos7:rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,local_lock=none ip=dhcp
```
## Plan
Client PXE boot plan.
```bash
diskless/centos.cfg,3
diskless/sles.cfg,3
```
There are 2 parts in each line: template file and cycles, separated by comma(,). For example:
"diskless/centos.cfg,3" means boot to template file "diskless/centos.cfg" 3 times.
## command line
```bash
# Create plans for clients
mac=08:00:27:00:4d:01 && curl 'http://127.0.0.1:5555/plan/create' --data-urlencode "mac=$mac" --data-urlencode 'pxe_list=test2.cfg,3'
for i in {1..3};do echo $i;curl 'http://127.0.0.1:5555/plan/create' --data-urlencode "mac=08:00:27:00:4d:0$i" --data-urlencode 'pxe_list=test2.cfg,3';done
mac=08:00:27:00:4d:01 && curl 'http://127.0.0.1:5555/plan/create' --data-urlencode "mac=$mac" --data-urlencode 'pxe_list@x.cfg'
for ((i=1;i<100;i++));do mac=$(printf '08:00:27:00:4d:%02x' $i);echo $mac;curl 'http://127.0.0.1:5555/plan/create' --data-urlencode "mac=$mac" --data-urlencode 'pxe_list@x.cfg';done
curl "http://127.0.0.1:5555/batch/plan/create" -d 'rack=lab' -d 'node=2' --data-urlencode 'mac_list@mac.txt' --data-urlencode 'pxe_list@x.cfg' -L
cat mac.txt
----
08:00:27:df:0e:00
08:00:27:00:4d:b6
08:00:27:a7:5c:d9
08:00:27:5c:c3:d8
08:00:27:b6:2c:c7
----
cat x.cfg
----
test2.cfg,3
test3.cfg,3
----
# Ack plan(for test only)
curl http://127.0.0.1:5555/plan/ack/08:00:27:00:4d:01
for ((i=1;i<10;i++));do mac=$(printf '08:00:27:00:4d:%02x' $i);echo $mac;curl "http://127.0.0.1:5555/plan/ack/$mac";done
# Delete plans for clents
mac=08:00:27:00:4d:02 && curl "http://127.0.0.1:5555/plan/delete" --data-urlencode "mac=$mac"
curl "http://127.0.0.1:5555/plan?out=raw&sep=," 2>/dev/null | gawk -F, 'NR>1{print $3}'
for mac in `curl "http://127.0.0.1:5555/plan?out=raw&sep=," 2>/dev/null | gawk -F, 'NR>1{print $3}'`;do echo $i;curl "http://127.0.0.1:5555/plan/delete" --data-urlencode "mac=$mac";done
```