Project

General

Profile

Feature #20522

Command: dhcp list/add/remove reservation

Added by Kavita Gaikwad about 1 year ago. Updated 3 months ago.

Status:
Ready For Testing
Priority:
Normal
Category:
-
Target version:
-
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

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 config checkDuplicate2017-08-24

History

#1 Updated by Kavita Gaikwad about 1 year ago

  • Tracker changed from Bug to Feature

#2 Updated by Kavita Gaikwad about 1 year ago

  • Target version set to 1.17.0

#3 Updated by Kavita Gaikwad about 1 year ago

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

#4 Updated by Kavita Gaikwad about 1 year ago

  • Status changed from New to Ready For Testing

#5 Updated by Kavita Gaikwad about 1 year ago

  • Target version changed from 1.17.0 to 216

#6 Updated by Kavita Gaikwad about 1 year ago

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

#7 Updated by Anonymous 3 months ago

  • Target version deleted (1.18.0)

Also available in: Atom PDF