Feature #20522

Command: dhcp list/add/remove reservation

Added by Kavita Gaikwad 10 months ago. Updated 8 months ago.

Status:Ready For Testing
Priority:Normal
Assigned To:Kavita Gaikwad
Category:-
Target version:Foreman - Team Anurag Iteration 20
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman_maintain/pull/84
Story points-
Velocity based estimate-

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.


Related issues

Related to Foreman Maintain - Refactor #20722: Refactoring needed for foreman-proxy feature for DHCP con... Duplicate 08/24/2017

History

#1 Updated by Kavita Gaikwad 10 months ago

  • Tracker changed from Bug to Feature

#2 Updated by Kavita Gaikwad 9 months ago

  • Target version set to Team Anurag Iteration 19

#3 Updated by Kavita Gaikwad 9 months ago

  • Pull request https://github.com/theforeman/foreman_maintain/pull/84 added

#4 Updated by Kavita Gaikwad 9 months ago

  • Status changed from New to Ready For Testing

#5 Updated by Kavita Gaikwad 9 months ago

  • Target version changed from Team Anurag Iteration 19 to Team Anurag Iteration 20

#6 Updated by Kavita Gaikwad 9 months ago

  • Related to Refactor #20722: Refactoring needed for foreman-proxy feature for DHCP config check added

Also available in: Atom PDF