Migrating networks being smartproxy controlled

Hello,

We have five networks that aren't being controlled by a foreman smart
proxy, but would like them to be. There are already hosts on the network
that are DHCP clients. I have already gotten a list and would like to add
these hosts into foreman's DHCP before I switch over to controlling the
networks with the smart proxy so their IP addresses don't change. Is there
a way to do this via the API or hammer?

Thanks,
Justin

Hey,

so you want to create dynamic lease reservations for them, so they are
then managable by Foreman? You can either manually edit dhcp.leases
file and put them there (see other dhcpd.leases under foremans control
for examples), or you can use DHCP API of the DHCP smart proxy to put
the records in. It's super simple, undocumented tho:

Getting stuff is super easy, posting stuff is little bit more work
(you do HTTP PUT/POST requests):

[lzap@lzapx foreman]$ curl-proxy /dhcp/192.168.122.0
{
"reservations": [
{
"name": "mac5254007338ec.local.lan",
"ip": "192.168.122.116",
"mac": "52:54:00:73:38:ec",
"subnet": "192.168.122.0/255.255.255.0",
"type": "reservation",
"hostname": "mac5254007338ec.local.lan",
"deleteable": true,
"hardware_type": "ethernet",
"filename": "pxelinux.0",
"nextServer": "192.168.122.1"
},
{
"name": "mac525400549b27.local.lan",
"ip": "192.168.122.136",
"mac": "52:54:00:54:9b:27",
"subnet": "192.168.122.0/255.255.255.0",
"type": "reservation",
"hostname": "mac525400549b27.local.lan",
"deleteable": true,
"hardware_type": "ethernet",
"filename": "pxelinux.0",
"nextServer": "192.168.122.1"
},
{
"name": "jimmy-lavatch.local.lan",
"ip": "192.168.122.110",
"mac": "52:54:00:f0:67:7c",
"subnet": "192.168.122.0/255.255.255.0",
"type": "reservation",
"hostname": "jimmy-lavatch.local.lan",
"deleteable": true,
"hardware_type": "ethernet",
"filename": "pxelinux.0",
"nextServer": "192.168.122.1"
},
{
"name": "dummy-host-1.local.lan",
"ip": "192.168.122.112",
"mac": "aa:bb:cc:dd:ee:ff",
"subnet": "192.168.122.0/255.255.255.0",
"type": "reservation",
"hostname": "dummy-host-1.local.lan",
"deleteable": true,
"hardware_type": "ethernet",
"filename": "pxelinux.0",
"nextServer": "192.168.122.1"
},
{
"name": "mac52540052f68a.local.lan",
"ip": "192.168.122.56",
"mac": "52:54:00:52:f6:8a",
"subnet": "192.168.122.0/255.255.255.0",
"type": "reservation",
"hostname": "mac52540052f68a.local.lan",
"deleteable": true,
"hardware_type": "ethernet",
"filename": "pxelinux.0",
"nextServer": "192.168.122.1"
}
],
"leases": [

]

}
[lzap@lzapx foreman]$ curl-proxy /dhcp/192.168.122.0/ip/192.168.122.56
[
{
"name": "mac52540052f68a.local.lan",
"ip": "192.168.122.56",
"mac": "52:54:00:52:f6:8a",
"subnet": "192.168.122.0/255.255.255.0",
"type": "reservation",
"hostname": "mac52540052f68a.local.lan",
"deleteable": true,
"hardware_type": "ethernet",
"filename": "pxelinux.0",
"nextServer": "192.168.122.1"
}
]

··· On Mon, Jun 5, 2017 at 1:52 PM, justin parker wrote: > Hello, > > We have five networks that aren't being controlled by a foreman smart proxy, > but would like them to be. There are already hosts on the network that are > DHCP clients. I have already gotten a list and would like to add these > hosts into foreman's DHCP before I switch over to controlling the networks > with the smart proxy so their IP addresses don't change. Is there a way to > do this via the API or hammer? > > Thanks, > Justin > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at https://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout.


Later,
Lukas @lzap Zapletal

Thanks for this info. This will def. help me out.

··· On Monday, June 5, 2017 at 10:17:48 AM UTC-4, Lukas Zapletal wrote: > > Hey, > > so you want to create dynamic lease reservations for them, so they are > then managable by Foreman? You can either manually edit dhcp.leases > file and put them there (see other dhcpd.leases under foremans control > for examples), or you can use DHCP API of the DHCP smart proxy to put > the records in. It's super simple, undocumented tho: > > Getting stuff is super easy, posting stuff is little bit more work > (you do HTTP PUT/POST requests): > > [lzap@lzapx foreman]$ curl-proxy /dhcp/192.168.122.0 > { > "reservations": [ > { > "name": "mac5254007338ec.local.lan", > "ip": "192.168.122.116", > "mac": "52:54:00:73:38:ec", > "subnet": "192.168.122.0/255.255.255.0", > "type": "reservation", > "hostname": "mac5254007338ec.local.lan", > "deleteable": true, > "hardware_type": "ethernet", > "filename": "pxelinux.0", > "nextServer": "192.168.122.1" > }, > { > "name": "mac525400549b27.local.lan", > "ip": "192.168.122.136", > "mac": "52:54:00:54:9b:27", > "subnet": "192.168.122.0/255.255.255.0", > "type": "reservation", > "hostname": "mac525400549b27.local.lan", > "deleteable": true, > "hardware_type": "ethernet", > "filename": "pxelinux.0", > "nextServer": "192.168.122.1" > }, > { > "name": "jimmy-lavatch.local.lan", > "ip": "192.168.122.110", > "mac": "52:54:00:f0:67:7c", > "subnet": "192.168.122.0/255.255.255.0", > "type": "reservation", > "hostname": "jimmy-lavatch.local.lan", > "deleteable": true, > "hardware_type": "ethernet", > "filename": "pxelinux.0", > "nextServer": "192.168.122.1" > }, > { > "name": "dummy-host-1.local.lan", > "ip": "192.168.122.112", > "mac": "aa:bb:cc:dd:ee:ff", > "subnet": "192.168.122.0/255.255.255.0", > "type": "reservation", > "hostname": "dummy-host-1.local.lan", > "deleteable": true, > "hardware_type": "ethernet", > "filename": "pxelinux.0", > "nextServer": "192.168.122.1" > }, > { > "name": "mac52540052f68a.local.lan", > "ip": "192.168.122.56", > "mac": "52:54:00:52:f6:8a", > "subnet": "192.168.122.0/255.255.255.0", > "type": "reservation", > "hostname": "mac52540052f68a.local.lan", > "deleteable": true, > "hardware_type": "ethernet", > "filename": "pxelinux.0", > "nextServer": "192.168.122.1" > } > ], > "leases": [ > > ] > } > [lzap@lzapx foreman]$ curl-proxy /dhcp/192.168.122.0/ip/192.168.122.56 > [ > { > "name": "mac52540052f68a.local.lan", > "ip": "192.168.122.56", > "mac": "52:54:00:52:f6:8a", > "subnet": "192.168.122.0/255.255.255.0", > "type": "reservation", > "hostname": "mac52540052f68a.local.lan", > "deleteable": true, > "hardware_type": "ethernet", > "filename": "pxelinux.0", > "nextServer": "192.168.122.1" > } > ] > > On Mon, Jun 5, 2017 at 1:52 PM, justin parker > wrote: > > Hello, > > > > We have five networks that aren't being controlled by a foreman smart > proxy, > > but would like them to be. There are already hosts on the network that > are > > DHCP clients. I have already gotten a list and would like to add these > > hosts into foreman's DHCP before I switch over to controlling the > networks > > with the smart proxy so their IP addresses don't change. Is there a way > to > > do this via the API or hammer? > > > > Thanks, > > Justin > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to foreman-user...@googlegroups.com . > > To post to this group, send email to forema...@googlegroups.com > . > > Visit this group at https://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > Later, > Lukas @lzap Zapletal >