Adding BMC interface via the API

As manually inserting the machine first NIC MAC is bothersome enough I want
the IPMI interface MAC address and other configuration to be updated
automagically.
The plan is to use something similar to this<https://gist.github.com/ohadlevy/4147992> in
a puppet provider or a plain ruby script to add the new interface in all my
machines but I'm having problem understanding how the API works when adding
a new interface:

This is a snippet from foreman log when adding a new interface via the web
GUI :

{"new_interfaces"=>
{"domain_id"=>"",
"_destroy"=>"false",
"type"=>"Nic::Managed",
"provider"=>"IPMI",
"name"=>"",
"mac"=>"",
"ip"=>"",
"subnet_id"=>""},
"new_1369055668139"=>
{"domain_id"=>"3",
"_destroy"=>"false",
"type"=>"Nic::Managed",
"provider"=>"IPMI",
"name"=>"454545",
"mac"=>"ff:ff:ff:ff:ff:ff",
"ip"=>"10.10.0.70",
"subnet_id"=>"1"}},

So it looks like two interface data structures sent, one with mostly empty
value and another named "new_" +epoch in milliseconds with the actual data,
do I need to send both or is this just something the JS does?
Another question is about the the rest of host object being sent on an
update (stuff like hostgroup, environment and whatnot) is this necessary or
also a web GUI JS only thing?

Oded

Hi,

While I am not sure if the following will fully address your question here
goes.
A few months back I started a new puppet provider/type to control the BMC
interface. Additionally, I added some facts in anticipation for auto
populating foreman or some other software.

These facts if placed in your own module would probably work (although
untested) which would get all the necessary BMC information via facts. As
far as auto populating foreman with the bmc network info facts, that task
would require some new code to be written and a new foreman feature request
to pull this info from facts. This way no API scripting would be nessessary
and automagic updates would be possible.

Ohad/Sam

Can fields like bmc ip, bmc mac be mapped to puppet facts?

Bmc facts:
https://github.com/logicminds/bmclib/blob/master/lib/facter/bmc.rb

As I mentioned above I wrote a puppet type/provider that is generic enough
to work on almost all systems. The one problem is that I was never able to
test it. So if you have time and want to test it, I would love to get some
input and a pull request so I can publish this provider to puppet forge.

https://github.com/logicminds/bmclib

Corey

··· On Monday, May 20, 2013 7:11:54 AM UTC-7, Oded wrote: > > As manually inserting the machine first NIC MAC is bothersome enough I > want the IPMI interface MAC address and other configuration to be updated > automagically. > The plan is to use something similar to this in > a puppet provider or a plain ruby script to add the new interface in all my > machines but I'm having problem understanding how the API works when adding > a new interface: > > This is a snippet from foreman log when adding a new interface via the web > GUI : > > > {"new_interfaces"=> > {"domain_id"=>"", > "_destroy"=>"false", > "type"=>"Nic::Managed", > "provider"=>"IPMI", > "name"=>"", > "mac"=>"", > "ip"=>"", > "subnet_id"=>""}, > "new_1369055668139"=> > {"domain_id"=>"3", > "_destroy"=>"false", > "type"=>"Nic::Managed", > "provider"=>"IPMI", > "name"=>"454545", > "mac"=>"ff:ff:ff:ff:ff:ff", > "ip"=>"10.10.0.70", > "subnet_id"=>"1"}}, > > > So it looks like two interface data structures sent, one with mostly empty > value and another named "new_" +epoch in milliseconds with the actual data, > do I need to send both or is this just something the JS does? > Another question is about the the rest of host object being sent on an > update (stuff like hostgroup, environment and whatnot) is this necessary or > also a web GUI JS only thing? > > > Oded >

Thanks, I'l give the bmclib module a try and give you an update.
As for adding a new Foreman feature for auto-populating the bmc network
config, while I prefer it over my own script I'm not sure how it would
work, timing wise - these new Puppet facts will not be available on a new
host creation so the host object will need to updated after they appear.

Oded

··· On Tuesday, May 21, 2013 8:16:07 AM UTC+3, Corey Osman wrote: > > Hi, > > While I am not sure if the following will fully address your question here > goes. > A few months back I started a new puppet provider/type to control the BMC > interface. Additionally, I added some facts in anticipation for auto > populating foreman or some other software. > > These facts if placed in your own module would probably work (although > untested) which would get all the necessary BMC information via facts. As > far as auto populating foreman with the bmc network info facts, that task > would require some new code to be written and a new foreman feature request > to pull this info from facts. This way no API scripting would be nessessary > and automagic updates would be possible. > > Ohad/Sam > > Can fields like bmc ip, bmc mac be mapped to puppet facts? > > Bmc facts: > https://github.com/logicminds/bmclib/blob/master/lib/facter/bmc.rb > > As I mentioned above I wrote a puppet type/provider that is generic enough > to work on almost all systems. The one problem is that I was never able to > test it. So if you have time and want to test it, I would love to get some > input and a pull request so I can publish this provider to puppet forge. > > https://github.com/logicminds/bmclib > > > Corey > > > On Monday, May 20, 2013 7:11:54 AM UTC-7, Oded wrote: >> >> As manually inserting the machine first NIC MAC is bothersome enough I >> want the IPMI interface MAC address and other configuration to be updated >> automagically. >> The plan is to use something similar to this in >> a puppet provider or a plain ruby script to add the new interface in all my >> machines but I'm having problem understanding how the API works when adding >> a new interface: >> >> This is a snippet from foreman log when adding a new interface via the >> web GUI : >> >> >> {"new_interfaces"=> >> {"domain_id"=>"", >> "_destroy"=>"false", >> "type"=>"Nic::Managed", >> "provider"=>"IPMI", >> "name"=>"", >> "mac"=>"", >> "ip"=>"", >> "subnet_id"=>""}, >> "new_1369055668139"=> >> {"domain_id"=>"3", >> "_destroy"=>"false", >> "type"=>"Nic::Managed", >> "provider"=>"IPMI", >> "name"=>"454545", >> "mac"=>"ff:ff:ff:ff:ff:ff", >> "ip"=>"10.10.0.70", >> "subnet_id"=>"1"}}, >> >> >> So it looks like two interface data structures sent, one with mostly >> empty value and another named "new_" +epoch in milliseconds with >> the actual data, do I need to send both or is this just something the JS >> does? >> Another question is about the the rest of host object being sent on an >> update (stuff like hostgroup, environment and whatnot) is this necessary or >> also a web GUI JS only thing? >> >> >> Oded >> >

> Hi,
>
> While I am not sure if the following will fully address your question here
> goes.
> A few months back I started a new puppet provider/type to control the BMC
> interface. Additionally, I added some facts in anticipation for auto
> populating foreman or some other software.
>
> These facts if placed in your own module would probably work (although
> untested) which would get all the necessary BMC information via facts. As
> far as auto populating foreman with the bmc network info facts, that task
> would require some new code to be written and a new foreman feature request
> to pull this info from facts. This way no API scripting would be nessessary
> and automagic updates would be possible.
>
> Ohad/Sam
>
> Can fields like bmc ip, bmc mac be mapped to puppet facts?
>
> Bmc facts:
> https://github.com/logicminds/bmclib/blob/master/lib/facter/bmc.rb
>
> As I mentioned above I wrote a puppet type/provider that is generic enough
> to work on almost all systems. The one problem is that I was never able to
> test it. So if you have time and want to test it, I would love to get some
> input and a pull request so I can publish this provider to puppet forge.
>
> https://github.com/logicminds/bmclib
>
> sweet! that would be very useful in the discovery image as well… thanks
Corey!

Ohad

··· On Tue, May 21, 2013 at 8:16 AM, Corey Osman wrote:

Corey

On Monday, May 20, 2013 7:11:54 AM UTC-7, Oded wrote:

As manually inserting the machine first NIC MAC is bothersome enough I
want the IPMI interface MAC address and other configuration to be updated
automagically.
The plan is to use something similar to thishttps://gist.github.com/ohadlevy/4147992 in
a puppet provider or a plain ruby script to add the new interface in all my
machines but I’m having problem understanding how the API works when adding
a new interface:

This is a snippet from foreman log when adding a new interface via the
web GUI :

{“new_interfaces”=>
{“domain_id”=>"",
"_destroy"=>“false”,
“type”=>“Nic::Managed”,
“provider”=>“IPMI”,
“name”=>"",
“mac”=>"",
“ip”=>"",
“subnet_id”=>""},
“new_1369055668139”=>
{“domain_id”=>“3”,
"_destroy"=>“false”,
“type”=>“Nic::Managed”,
“provider”=>“IPMI”,
“name”=>“454545”,
“mac”=>“ff:ff:ff:ff:ff:ff”,
“ip”=>“10.10.0.70”,
“subnet_id”=>“1”}},

So it looks like two interface data structures sent, one with mostly
empty value and another named “new_” +epoch in milliseconds with
the actual data, do I need to send both or is this just something the JS
does?
Another question is about the the rest of host object being sent on an
update (stuff like hostgroup, environment and whatnot) is this necessary or
also a web GUI JS only thing?

Oded


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 http://groups.google.com/group/foreman-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

So, guys, do you think this could be implemented via Corey's fact
route(having foreman configure the BMC Interfaces internally by using data
from fact stored in its DB ) or should I continue with my API/script
venture?

··· On Tuesday, May 21, 2013 10:07:13 AM UTC+3, ohad wrote: > > > > On Tue, May 21, 2013 at 8:16 AM, Corey Osman <co...@logicminds.biz > > wrote: > >> Hi, >> >> While I am not sure if the following will fully address your question >> here goes. >> A few months back I started a new puppet provider/type to control the BMC >> interface. Additionally, I added some facts in anticipation for auto >> populating foreman or some other software. >> >> These facts if placed in your own module would probably work (although >> untested) which would get all the necessary BMC information via facts. As >> far as auto populating foreman with the bmc network info facts, that task >> would require some new code to be written and a new foreman feature request >> to pull this info from facts. This way no API scripting would be nessessary >> and automagic updates would be possible. >> >> Ohad/Sam >> >> Can fields like bmc ip, bmc mac be mapped to puppet facts? >> >> Bmc facts: >> https://github.com/logicminds/bmclib/blob/master/lib/facter/bmc.rb >> >> As I mentioned above I wrote a puppet type/provider that is generic >> enough to work on almost all systems. The one problem is that I was never >> able to test it. So if you have time and want to test it, I would love to >> get some input and a pull request so I can publish this provider to puppet >> forge. >> >> https://github.com/logicminds/bmclib >> >> sweet! that would be very useful in the discovery image as well.. thanks > Corey! > > Ohad > >> >> Corey >> >> >> On Monday, May 20, 2013 7:11:54 AM UTC-7, Oded wrote: >>> >>> As manually inserting the machine first NIC MAC is bothersome enough I >>> want the IPMI interface MAC address and other configuration to be updated >>> automagically. >>> The plan is to use something similar to this in >>> a puppet provider or a plain ruby script to add the new interface in all my >>> machines but I'm having problem understanding how the API works when adding >>> a new interface: >>> >>> This is a snippet from foreman log when adding a new interface via the >>> web GUI : >>> >>> >>> {"new_interfaces"=> >>> {"domain_id"=>"", >>> "_destroy"=>"false", >>> "type"=>"Nic::Managed", >>> "provider"=>"IPMI", >>> "name"=>"", >>> "mac"=>"", >>> "ip"=>"", >>> "subnet_id"=>""}, >>> "new_1369055668139"=> >>> {"domain_id"=>"3", >>> "_destroy"=>"false", >>> "type"=>"Nic::Managed", >>> "provider"=>"IPMI", >>> "name"=>"454545", >>> "mac"=>"ff:ff:ff:ff:ff:ff", >>> "ip"=>"10.10.0.70", >>> "subnet_id"=>"1"}}, >>> >>> >>> So it looks like two interface data structures sent, one with mostly >>> empty value and another named "new_" +epoch in milliseconds with >>> the actual data, do I need to send both or is this just something the JS >>> does? >>> Another question is about the the rest of host object being sent on an >>> update (stuff like hostgroup, environment and whatnot) is this necessary or >>> also a web GUI JS only thing? >>> >>> >>> Oded >>> >> -- >> 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 http://groups.google.com/group/foreman-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >

I didn't, got sidetracked :slight_smile:
I assumed adding an interface can be done via a 'PUT /api/hosts/:id' API
call, are you saying this can't be done with current release?

··· On Wed, Jun 5, 2013 at 1:18 PM, Daniel Lobato wrote:

I think exposing this through the API would work better. Oded, how far
have you got with that?

On Tuesday, May 21, 2013 2:09:58 PM UTC+2, Oded wrote:

So, guys, do you think this could be implemented via Corey’s fact
route(having foreman configure the BMC Interfaces internally by using data
from fact stored in its DB ) or should I continue with my API/script
venture?

On Tuesday, May 21, 2013 10:07:13 AM UTC+3, ohad wrote:

On Tue, May 21, 2013 at 8:16 AM, Corey Osman co...@logicminds.bizwrote:

Hi,

While I am not sure if the following will fully address your question
here goes.
A few months back I started a new puppet provider/type to control the
BMC interface. Additionally, I added some facts in anticipation for auto
populating foreman or some other software.

These facts if placed in your own module would probably work (although
untested) which would get all the necessary BMC information via facts. As
far as auto populating foreman with the bmc network info facts, that task
would require some new code to be written and a new foreman feature request
to pull this info from facts. This way no API scripting would be nessessary
and automagic updates would be possible.

Ohad/Sam

Can fields like bmc ip, bmc mac be mapped to puppet facts?

Bmc facts: https://github.com/logicminds/**
bmclib/blob/master/lib/facter/**bmc.rbhttps://github.com/logicminds/bmclib/blob/master/lib/facter/bmc.rb

As I mentioned above I wrote a puppet type/provider that is generic
enough to work on almost all systems. The one problem is that I was never
able to test it. So if you have time and want to test it, I would love to
get some input and a pull request so I can publish this provider to puppet
forge.

https://github.com/logicminds/**bmclibhttps://github.com/logicminds/bmclib

sweet! that would be very useful in the discovery image as well…
thanks Corey!

Ohad

Corey

On Monday, May 20, 2013 7:11:54 AM UTC-7, Oded wrote:

As manually inserting the machine first NIC MAC is bothersome enough I
want the IPMI interface MAC address and other configuration to be updated
automagically.
The plan is to use something similar to thishttps://gist.github.com/ohadlevy/4147992 in
a puppet provider or a plain ruby script to add the new interface in all my
machines but I’m having problem understanding how the API works when adding
a new interface:

This is a snippet from foreman log when adding a new interface via the
web GUI :

{“new_interfaces”=>
{“domain_id”=>"",
"_destroy"=>“false”,
“type”=>“Nic::Managed”,
“provider”=>“IPMI”,
“name”=>"",
“mac”=>"",
“ip”=>"",
“subnet_id”=>""},
“new_1369055668139”=>
{“domain_id”=>“3”,
"_destroy"=>“false”,
“type”=>“Nic::Managed”,
“provider”=>“IPMI”,
“name”=>“454545”,
“mac”=>“ff:ff:ff:ff:ff:ff”,
“ip”=>“10.10.0.70”,
“subnet_id”=>“1”}},

So it looks like two interface data structures sent, one with mostly
empty value and another named “new_” +epoch in milliseconds with
the actual data, do I need to send both or is this just something the JS
does?
Another question is about the the rest of host object being sent on an
update (stuff like hostgroup, environment and whatnot) is this necessary or
also a web GUI JS only thing?

Oded


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 http://groups.google.com/

group/foreman-users?hl=enhttp://groups.google.com/group/foreman-users?hl=en
.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.


You received this message because you are subscribed to a topic in the
Google Groups “Foreman users” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/foreman-users/MbEUOgaAZ2g/unsubscribe?hl=en
.
To unsubscribe from this group and all its topics, 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 http://groups.google.com/group/foreman-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

I finally got around doing this myself, hopefully it'll be on the next
release

https://github.com/theforeman/foreman/pull/762