Feature #20522
closedCommand: dhcp list/add/remove reservation
Description
Lukas's comment on github issue[https://github.com/theforeman/foreman_maintain/issues/75]:
Hello,
I wrote and tested these commands on both Server and Capsule versions 6.2 and 6.3. It would be nice idea to write a small script/command to allow users to add/list/delete DHCP reservations:
foreman-maintain dhcp list-reservations [subnet]
foreman-maintain dhcp add-reservation [subnet] [ip] [mac] [name]
foreman-maintain dhcp remove-reservation [subnet] [ip]
- LIST OF RESERVATIONS FOR NETWORK 192.168.220.0
curl -ks --cert /etc/foreman/client_cert.pem --key /etc/foreman/client_key.pem --cacert /etc/foreman/proxy_ca.pem https://$(hostname):9090/dhcp/192.168.220.0 | json_reformat
- ADD RESERVATION FOR 52:51:00:aa:bb:cc IP 192.168.220.201 AND NAME one.nested.lan
curl -ks --cert /etc/foreman/client_cert.pem --key /etc/foreman/client_key.pem --cacert /etc/foreman/proxy_ca.pem -X POST -d '' "https://$(hostname):9090/dhcp/192.168.220.0?ip=192.168.220.201&mac=52:51:00:aa:bb:cc&name=one.nested.lan"
- DELETE RESERVATION IP 192.168.220.201
curl -ks --cert /etc/foreman/client_cert.pem --key /etc/foreman/client_key.pem --cacert /etc/foreman/proxy_ca.pem -X DELETE "https://$(hostname):9090/dhcp/192.168.220.0/192.168.220.201"
- On Capsule server the path for certification files is different, the rest is the same:
curl -ks --cert /etc/foreman-proxy/foreman_ssl_cert.pem --key /etc/foreman-proxy/foreman_ssl_key.pem --cacert /etc/foreman-proxy/foreman_ssl_ca.pem https://$(hostname):9090/dhcp/192.168.220.0 | json_reformat
The script needs to check if PEM file exists so it will work on both Capsule and Server.
Using Ruby REST HTTP library would be preferred. Note this DHCP API is very stable and does not change a lot.
Updated by Kavita Gaikwad over 6 years ago
- Pull request https://github.com/theforeman/foreman_maintain/pull/84 added
Updated by Kavita Gaikwad over 6 years ago
- Status changed from New to Ready For Testing
Updated by Kavita Gaikwad over 6 years ago
- Target version changed from 1.17.0 to 216
Updated by Kavita Gaikwad over 6 years ago
- Related to Refactor #20722: Refactoring needed for foreman-proxy feature for DHCP config check added
Updated by Eric Helms 2 months ago
- Status changed from Ready For Testing to Rejected