Foreman Discovery not working with Foreman 1.3

Hi,
I upgraded to version 1.3 and now the discovery process is not working.

Both /tmp/proxy-discovery.err & /tmp/proxy-discovery.log are empty.

Would it be something to do with the view not updating in the UI?

I'll be trying to get this updated for the end of the week, so as Ohad
says, any feedback/logs/errors is much appreciated!

Greg

··· On 16 October 2013 15:32, Alan Sergeant wrote:

Hi,
I upgraded to version 1.3 and now the discovery process is not working.

Can you provide a bit more info about whats broken? do you get an error
message etc?

thanks!
Ohad

··· On Wed, Oct 16, 2013 at 5:32 PM, Alan Sergeant wrote:

Hi,
I upgraded to version 1.3 and now the discovery process is not working.

Both /tmp/proxy-discovery.err & /tmp/proxy-discovery.log are empty.

Would it be something to do with the view not updating in the UI?


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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,
Ok, so in version 1.2 i had configured foreman to use SSL certificates, but
also called "service foreman start" which started my foreman service
running on port 3000 also.
This allowed the discovery image to register using foreman.ip=<addr>:3000
in the PXE Default File. I was also able to go to http://<addr>:3000 in
browser and it displayed the UI.

Now in version 1.3, it appears to always redirect me to the HTTPS site and
i've never been able to get the discovery script to work using SSL?

··· On Wednesday, October 16, 2013 3:50:10 PM UTC+1, Greg Sutcliffe wrote: > > On 16 October 2013 15:32, Alan Sergeant <aserg...@gmail.com >wrote: > >> Hi, >> I upgraded to version 1.3 and now the discovery process is not working. >> > > I'll be trying to get this updated for the end of the week, so as Ohad > says, any feedback/logs/errors is much appreciated! > > Greg >

So a bit more digging gives me the following error:

Response: Failed to import facts: uninitialized constant
Host::Discovered::Puppet

··· On Wednesday, October 16, 2013 8:16:35 PM UTC+1, Alan Sergeant wrote: > > Hi, > Ok, so in version 1.2 i had configured foreman to use SSL certificates, > but also called "service foreman start" which started my foreman service > running on port 3000 also. > This allowed the discovery image to register using foreman.ip=:3000 > in the PXE Default File. I was also able to go to http://:3000 in > browser and it displayed the UI. > > Now in version 1.3, it appears to always redirect me to the HTTPS site and > i've never been able to get the discovery script to work using SSL? > > > > > On Wednesday, October 16, 2013 3:50:10 PM UTC+1, Greg Sutcliffe wrote: >> >> On 16 October 2013 15:32, Alan Sergeant wrote: >> >>> Hi, >>> I upgraded to version 1.3 and now the discovery process is not working. >>> >> >> I'll be trying to get this updated for the end of the week, so as Ohad >> says, any feedback/logs/errors is much appreciated! >> >> Greg >> >

I believe the error comes from
/foreman_discovery/app/models/host/discovered.rb Line 30

··· On Wednesday, October 16, 2013 8:56:17 PM UTC+1, Alan Sergeant wrote: > > So a bit more digging gives me the following error: > > Response: Failed to import facts: uninitialized constant > Host::Discovered::Puppet > > On Wednesday, October 16, 2013 8:16:35 PM UTC+1, Alan Sergeant wrote: >> >> Hi, >> Ok, so in version 1.2 i had configured foreman to use SSL certificates, >> but also called "service foreman start" which started my foreman service >> running on port 3000 also. >> This allowed the discovery image to register using foreman.ip=:3000 >> in the PXE Default File. I was also able to go to http://:3000 in >> browser and it displayed the UI. >> >> Now in version 1.3, it appears to always redirect me to the HTTPS site >> and i've never been able to get the discovery script to work using SSL? >> >> >> >> >> On Wednesday, October 16, 2013 3:50:10 PM UTC+1, Greg Sutcliffe wrote: >>> >>> On 16 October 2013 15:32, Alan Sergeant wrote: >>> >>>> Hi, >>>> I upgraded to version 1.3 and now the discovery process is not working. >>>> >>> >>> I'll be trying to get this updated for the end of the week, so as Ohad >>> says, any feedback/logs/errors is much appreciated! >>> >>> Greg >>> >>

> I believe the error comes from
> /foreman_discovery/app/models/host/discovered.rb Line 30
>

Yep, you are correct, feel free to remove 30-32 and tell us if it works?

Thanks!
Ohad

··· On Thu, Oct 17, 2013 at 11:54 AM, Alan Sergeant wrote:

On Wednesday, October 16, 2013 8:56:17 PM UTC+1, Alan Sergeant wrote:

So a bit more digging gives me the following error:

Response: Failed to import facts: uninitialized constant
Host::Discovered::Puppet

On Wednesday, October 16, 2013 8:16:35 PM UTC+1, Alan Sergeant wrote:

Hi,
Ok, so in version 1.2 i had configured foreman to use SSL certificates,
but also called “service foreman start” which started my foreman service
running on port 3000 also.
This allowed the discovery image to register using
foreman.ip=:3000 in the PXE Default File. I was also able to go to
http://:3000 in browser and it displayed the UI.

Now in version 1.3, it appears to always redirect me to the HTTPS site
and i’ve never been able to get the discovery script to work using SSL?

On Wednesday, October 16, 2013 3:50:10 PM UTC+1, Greg Sutcliffe wrote:

On 16 October 2013 15:32, Alan Sergeant aserg...@gmail.com wrote:

Hi,
I upgraded to version 1.3 and now the discovery process is not working.

I’ll be trying to get this updated for the end of the week, so as Ohad
says, any feedback/logs/errors is much appreciated!

Greg


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.
For more options, visit https://groups.google.com/groups/opt_out.

Ok, i tried it and it didn't work. I think due to the fact the smart-proxy
isn't outputting a hash when <ip>:8443/facts is called.

The output from this is:

{"id":"root","is_virtual":"true","network_lo":"127.0.0.0","physicalprocessorcount":1,"sshdsakey":"AAAAB3NzaC1kc3MAAACBANrd27JdNac5plu2N+rID3E/Xt0dYh7Uqh0q/bk4RqK4h3WeKquYIc6IhVxV7yqH87EB9sumrKKVr4caa5BWAwzidnVfaNhYy3DKfzNxZHLUQM9/luYpePkJAru6LxP9UAUHiDwMwF3MoKmm5IB2ZwibLpFa1IYBW5w4c3hARBP9AAAAFQDzk42n/EIDLLk1VwbjKFQI2Q24WwAAAIEAvjoNpeY8zg7HAskGrqXFOSJMDORrpD4VH0z04iZ+wpIx5QmShy7hwNokZT0nwgk6UjOp7avbplZRqDH0s0wcQty3z7G7kxvNb2DeS9JjxQC76YPJdJpgW5fC76BghDvlqeNx7QUrE3oxcMh0xb3RKv6GKtJQbUjqMn2f/4YCCFgAAACBAJGMXpftGRkzdS4kgOSO4aEfh6fOtIuk9PLrxCUnn0GmOV33vCFaeoei0OWaOx8JIQWas22SWudrcAcV4jyZFjd0+t0jmslhuhEPAj60PzqB1caIDja+IkwOyo+HvL6ctKx/5QFXEOeqeNn3/mSq72XncUkFM1ol2KKY6bekR9ca","operatingsystem":"Ubuntu","netmask_lo":"255.0.0.0","ipaddress_eth1":"10.0.1.12","path":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games","hostname":"ubuntu","lsbdistrelease":"12.04","ipaddress_lo":"127.0.0.1","virtual":"virtualbox","kernel":"Linux","network_eth0":"10.55.164.0","rubysitedir":"/usr/local/lib/site_ruby/1.8","netmask":"255.255.255.0","netmask_eth1":"255.255.255.0","processor0":"Intel® Core™ i5 CPU M 540 @ 2.53GHz","macaddress_eth1":"08:00:27:43:fa:ae","augeasversion":"0.10.0","operatingsystemrelease":"12.04","memoryfree":"382.83 MB","uniqueid":"007f0101","boardmanufacturer":"Oracle Corporation","swapfree":"508.00 MB","ipaddress_eth0":"10.55.164.211","kernelmajversion":"3.8","hardwaremodel":"x86_64","uptime_days":0,"domain":"dhcp.bfsl.sap.corp","swapsize":"508.00 MB","selinux":"false","architecture":"amd64","uptime_hours":2,"boardserialnumber":"0","fqdn":"ubuntu.dhcp.bfsl.sap.corp","interfaces":"eth0,eth1,lo","productname":"VirtualBox","boardproductname":"VirtualBox","sshecdsakey":"AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHGElwArbd38NTPVBr2pzXo5FxUOu+ceYGmW2ciscAPcilkUaMEYdajLoQbkZinLGFkGHAxyYiW5z8b1NCTfabw=","sshrsakey":"AAAAB3NzaC1yc2EAAAADAQABAAABAQDZ7hbMdUz6Yg+GyUs/h/2kHGafNAUDW9yZ6DlD4ZhXpsSuu6lTKh/wSihJXWr2mnv5T46Np5VUZCsRC9fa1YRShqXm7nRbvqt5s5wJhCQ0K3NHbg7vEKa+8CgT0N/YC2KrPC7Zce58360OytdB6+i80xbTgNTVlOriFvPiqv2Hn8dvJgo7123Ywluz7AT4aVpFCLEiFZ03HLaJYZFfhtLlwYrqH6kfB7zXCS4hlnq7eyd5wW2wDYukZ8Nd/7q6KT90Mep+6usqiw8lSmJuYB9kwixl+USO6zK6wxbNsieX5H1GoNDxH8jUOc3khvGJ/vo/AeKOfFDGpRg9W+6BjHfV","serialnumber":"0","netmask_eth0":"255.255.255.0","macaddress_eth0":"08:00:27:4d:fd:32","lsbdistdescription":"Ubuntu 12.04.3 LTS","rubyversion":"1.8.7","facterversion":"1.6.5","memorytotal":"490.93 MB","timezone":"BST","ipaddress":"10.55.164.211","kernelrelease":"3.8.0-29-generic","memorysize":"490.93 MB","puppetversion":"2.7.11","macaddress":"08:00:27:4d:fd:32","kernelversion":"3.8.0","ps":"ps -ef","uptime_seconds":8031,"uptime":"2:13 hours","processorcount":"1","osfamily":"Debian","network_eth1":"10.0.1.0","lsbdistid":"Ubuntu","lsbdistcodename":"precise","type":"Other","lsbmajdistrelease":"12","hardwareisa":"x86_64","manufacturer":"innotek GmbH"}

··· On Thursday, October 17, 2013 10:08:37 AM UTC+1, ohad wrote: > > > > > On Thu, Oct 17, 2013 at 11:54 AM, Alan Sergeant <aserg...@gmail.com > > wrote: > >> I believe the error comes from >> /foreman_discovery/app/models/host/discovered.rb Line 30 >> > > Yep, you are correct, feel free to remove 30-32 and tell us if it works? > > Thanks! > Ohad > >> >> >> On Wednesday, October 16, 2013 8:56:17 PM UTC+1, Alan Sergeant wrote: >>> >>> So a bit more digging gives me the following error: >>> >>> Response: Failed to import facts: uninitialized constant >>> Host::Discovered::Puppet >>> >>> On Wednesday, October 16, 2013 8:16:35 PM UTC+1, Alan Sergeant wrote: >>>> >>>> Hi, >>>> Ok, so in version 1.2 i had configured foreman to use SSL certificates, >>>> but also called "service foreman start" which started my foreman service >>>> running on port 3000 also. >>>> This allowed the discovery image to register using >>>> foreman.ip=:3000 in the PXE Default File. I was also able to go to >>>> http://:3000 in browser and it displayed the UI. >>>> >>>> Now in version 1.3, it appears to always redirect me to the HTTPS site >>>> and i've never been able to get the discovery script to work using SSL? >>>> >>>> >>>> >>>> >>>> On Wednesday, October 16, 2013 3:50:10 PM UTC+1, Greg Sutcliffe wrote: >>>>> >>>>> On 16 October 2013 15:32, Alan Sergeant wrote: >>>>> >>>>>> Hi, >>>>>> I upgraded to version 1.3 and now the discovery process is not >>>>>> working. >>>>>> >>>>> >>>>> I'll be trying to get this updated for the end of the week, so as Ohad >>>>> says, any feedback/logs/errors is much appreciated! >>>>> >>>>> Greg >>>>> >>>> -- >> 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. >> For more options, visit https://groups.google.com/groups/opt_out. >> > >

I also tried removing the case statement and simply using:

name = facts.values["macaddress_eth0"].downcase.gsub(/:/,'')
values = facts.values

This returns can't convert String into Integer. Error comes from the name
variable i think?

··· On Thursday, October 17, 2013 10:23:11 AM UTC+1, Alan Sergeant wrote: > > Ok, i tried it and it didn't work. I think due to the fact the smart-proxy > isn't outputting a hash when :8443/facts is called. > > > The output from this is: > > {"id":"root","is_virtual":"true","network_lo":"127.0.0.0","physicalprocessorcount":1,"sshdsakey":"AAAAB3NzaC1kc3MAAACBANrd27JdNac5plu2N+rID3E/Xt0dYh7Uqh0q/bk4RqK4h3WeKquYIc6IhVxV7yqH87EB9sumrKKVr4caa5BWAwzidnVfaNhYy3DKfzNxZHLUQM9/luYpePkJAru6LxP9UAUHiDwMwF3MoKmm5IB2ZwibLpFa1IYBW5w4c3hARBP9AAAAFQDzk42n/EIDLLk1VwbjKFQI2Q24WwAAAIEAvjoNpeY8zg7HAskGrqXFOSJMDORrpD4VH0z04iZ+wpIx5QmShy7hwNokZT0nwgk6UjOp7avbplZRqDH0s0wcQty3z7G7kxvNb2DeS9JjxQC76YPJdJpgW5fC76BghDvlqeNx7QUrE3oxcMh0xb3RKv6GKtJQbUjqMn2f/4YCCFgAAACBAJGMXpftGRkzdS4kgOSO4aEfh6fOtIuk9PLrxCUnn0GmOV33vCFaeoei0OWaOx8JIQWas22SWudrcAcV4jyZFjd0+t0jmslhuhEPAj60PzqB1caIDja+IkwOyo+HvL6ctKx/5QFXEOeqeNn3/mSq72XncUkFM1ol2KKY6bekR9ca","operatingsystem":"Ubuntu","netmask_lo":"255.0.0.0","ipaddress_eth1":"10.0.1.12","path":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games","hostname":"ubuntu","lsbdistrelease":"12.04","ipaddress_lo":"127.0.0.1","virtual":"virtualbox","kernel":"Linux","network_eth0":"10.55.164.0","rubysitedir":"/usr/local/lib/site_ruby/1.8","netmask":"255.255.255.0","netmask_eth1":"255.255.255.0","processor0":"Intel(R) Core(TM) i5 CPU M 540 @ 2.53GHz","macaddress_eth1":"08:00:27:43:fa:ae","augeasversion":"0.10.0","operatingsystemrelease":"12.04","memoryfree":"382.83 MB","uniqueid":"007f0101","boardmanufacturer":"Oracle Corporation","swapfree":"508.00 MB","ipaddress_eth0":"10.55.164.211","kernelmajversion":"3.8","hardwaremodel":"x86_64","uptime_days":0,"domain":"dhcp.bfsl.sap.corp","swapsize":"508.00 MB","selinux":"false","architecture":"amd64","uptime_hours":2,"boardserialnumber":"0","fqdn":"ubuntu.dhcp.bfsl.sap.corp","interfaces":"eth0,eth1,lo","productname":"VirtualBox","boardproductname":"VirtualBox","sshecdsakey":"AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHGElwArbd38NTPVBr2pzXo5FxUOu+ceYGmW2ciscAPcilkUaMEYdajLoQbkZinLGFkGHAxyYiW5z8b1NCTfabw=","sshrsakey":"AAAAB3NzaC1yc2EAAAADAQABAAABAQDZ7hbMdUz6Yg+GyUs/h/2kHGafNAUDW9yZ6DlD4ZhXpsSuu6lTKh/wSihJXWr2mnv5T46Np5VUZCsRC9fa1YRShqXm7nRbvqt5s5wJhCQ0K3NHbg7vEKa+8CgT0N/YC2KrPC7Zce58360OytdB6+i80xbTgNTVlOriFvPiqv2Hn8dvJgo7123Ywluz7AT4aVpFCLEiFZ03HLaJYZFfhtLlwYrqH6kfB7zXCS4hlnq7eyd5wW2wDYukZ8Nd/7q6KT90Mep+6usqiw8lSmJuYB9kwixl+USO6zK6wxbNsieX5H1GoNDxH8jUOc3khvGJ/vo/AeKOfFDGpRg9W+6BjHfV","serialnumber":"0","netmask_eth0":"255.255.255.0","macaddress_eth0":"08:00:27:4d:fd:32","lsbdistdescription":"Ubuntu 12.04.3 LTS","rubyversion":"1.8.7","facterversion":"1.6.5","memorytotal":"490.93 MB","timezone":"BST","ipaddress":"10.55.164.211","kernelrelease":"3.8.0-29-generic","memorysize":"490.93 MB","puppetversion":"2.7.11","macaddress":"08:00:27:4d:fd:32","kernelversion":"3.8.0","ps":"ps -ef","uptime_seconds":8031,"uptime":"2:13 hours","processorcount":"1","osfamily":"Debian","network_eth1":"10.0.1.0","lsbdistid":"Ubuntu","lsbdistcodename":"precise","type":"Other","lsbmajdistrelease":"12","hardwareisa":"x86_64","manufacturer":"innotek GmbH"} > > > > > On Thursday, October 17, 2013 10:08:37 AM UTC+1, ohad wrote: >> >> >> >> >> On Thu, Oct 17, 2013 at 11:54 AM, Alan Sergeant wrote: >> >>> I believe the error comes from >>> /foreman_discovery/app/models/host/discovered.rb Line 30 >>> >> >> Yep, you are correct, feel free to remove 30-32 and tell us if it works? >> >> Thanks! >> Ohad >> >>> >>> >>> On Wednesday, October 16, 2013 8:56:17 PM UTC+1, Alan Sergeant wrote: >>>> >>>> So a bit more digging gives me the following error: >>>> >>>> Response: Failed to import facts: uninitialized constant >>>> Host::Discovered::Puppet >>>> >>>> On Wednesday, October 16, 2013 8:16:35 PM UTC+1, Alan Sergeant wrote: >>>>> >>>>> Hi, >>>>> Ok, so in version 1.2 i had configured foreman to use SSL >>>>> certificates, but also called "service foreman start" which started my >>>>> foreman service running on port 3000 also. >>>>> This allowed the discovery image to register using >>>>> foreman.ip=:3000 in the PXE Default File. I was also able to go to >>>>> http://:3000 in browser and it displayed the UI. >>>>> >>>>> Now in version 1.3, it appears to always redirect me to the HTTPS site >>>>> and i've never been able to get the discovery script to work using SSL? >>>>> >>>>> >>>>> >>>>> >>>>> On Wednesday, October 16, 2013 3:50:10 PM UTC+1, Greg Sutcliffe wrote: >>>>>> >>>>>> On 16 October 2013 15:32, Alan Sergeant wrote: >>>>>> >>>>>>> Hi, >>>>>>> I upgraded to version 1.3 and now the discovery process is not >>>>>>> working. >>>>>>> >>>>>> >>>>>> I'll be trying to get this updated for the end of the week, so as >>>>>> Ohad says, any feedback/logs/errors is much appreciated! >>>>>> >>>>>> Greg >>>>>> >>>>> -- >>> 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. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >>

Ok so i managed to get it to show in the UI, the only caveat is i haven't
been able to get the facts to show.
Only method I change was this:

def self.importHostAndFacts data
facts = data
name = facts["macaddress_eth0"].downcase.gsub(/:/,'')
values = facts

# filter facts
values.reject!{|k,v| k =~ 

/kernel|operatingsystem|osfamily|ruby|path|time|swap|free|fil$

if name
  h = ::Host::Discovered.find_by_name name
end
h ||= Host.new :name =&gt; name, :type =&gt; &quot;Host::Discovered&quot;
h.type = &quot;Host::Discovered&quot;
h.mac = values[&quot;macaddress_eth0&quot;].downcase


if SETTINGS[:locations_enabled]
  begin
    h.location = (Location.find_by_name Setting[:discovery_location]) 

>> Location.first
rescue
h.location = Location.first
end
end
if SETTINGS[:organizations_enabled]
begin
h.organization = (Organization.find_by_name
Setting[:discovery_organization]) || Or$
rescue
h.organization = Organization.first
end
end

h.save if h.new_record?
h.importFacts(name, values)

end

··· On Thursday, October 17, 2013 10:54:28 AM UTC+1, Greg Sutcliffe wrote: > > On 17 October 2013 10:49, Alan Sergeant <aserg...@gmail.com >wrote: > >> I also tried removing the case statement and simply using: >> >> name = facts.values["macaddress_eth0"].downcase.gsub(/:/,'') >> values = facts.values >> >> This returns can't convert String into Integer. Error comes from the name >> variable i think? >> > > The method that Discovery hooks into in Foreman Core (ImportHostAndFacts) > has changed significantly in 1.3, so I expect the plugin will need to match > that. I'll try to take a look at it this afternoon :) > > Thanks for your feedback so far, saves me a lot of time tracking down the > error :) >

Got it fully working… file attached

discovered.rb (3.22 KB)

··· On Thursday, October 17, 2013 1:50:12 PM UTC+1, Alan Sergeant wrote: > > Ok so i managed to get it to show in the UI, the only caveat is i haven't > been able to get the facts to show. > Only method I change was this: > > > def self.importHostAndFacts data > facts = data > name = facts["macaddress_eth0"].downcase.gsub(/:/,'') > values = facts > > # filter facts > values.reject!{|k,v| k =~ > /kernel|operatingsystem|osfamily|ruby|path|time|swap|free|fil$ > > if name > h = ::Host::Discovered.find_by_name name > end > h ||= Host.new :name => name, :type => "Host::Discovered" > h.type = "Host::Discovered" > h.mac = values["macaddress_eth0"].downcase > > > if SETTINGS[:locations_enabled] > begin > h.location = (Location.find_by_name Setting[:discovery_location]) > >> Location.first > rescue > h.location = Location.first > end > end > if SETTINGS[:organizations_enabled] > begin > h.organization = (Organization.find_by_name > Setting[:discovery_organization]) || Or$ > rescue > h.organization = Organization.first > end > end > > h.save if h.new_record? > h.importFacts(name, values) > end > > > > > On Thursday, October 17, 2013 10:54:28 AM UTC+1, Greg Sutcliffe wrote: >> >> On 17 October 2013 10:49, Alan Sergeant wrote: >> >>> I also tried removing the case statement and simply using: >>> >>> name = facts.values["macaddress_eth0"].downcase.gsub(/:/,'') >>> values = facts.values >>> >>> This returns can't convert String into Integer. Error comes from the >>> name variable i think? >>> >> >> The method that Discovery hooks into in Foreman Core (ImportHostAndFacts) >> has changed significantly in 1.3, so I expect the plugin will need to match >> that. I'll try to take a look at it this afternoon :) >> >> Thanks for your feedback so far, saves me a lot of time tracking down the >> error :) >> >

I should say it does require a new discovery image, with the latest
foreman_proxy code

··· On Thursday, October 17, 2013 1:56:18 PM UTC+1, Alan Sergeant wrote: > > Got it fully working...... file attached > > On Thursday, October 17, 2013 1:50:12 PM UTC+1, Alan Sergeant wrote: >> >> Ok so i managed to get it to show in the UI, the only caveat is i haven't >> been able to get the facts to show. >> Only method I change was this: >> >> >> def self.importHostAndFacts data >> facts = data >> name = facts["macaddress_eth0"].downcase.gsub(/:/,'') >> values = facts >> >> # filter facts >> values.reject!{|k,v| k =~ >> /kernel|operatingsystem|osfamily|ruby|path|time|swap|free|fil$ >> >> if name >> h = ::Host::Discovered.find_by_name name >> end >> h ||= Host.new :name => name, :type => "Host::Discovered" >> h.type = "Host::Discovered" >> h.mac = values["macaddress_eth0"].downcase >> >> >> if SETTINGS[:locations_enabled] >> begin >> h.location = (Location.find_by_name Setting[:discovery_location]) >> >> Location.first >> rescue >> h.location = Location.first >> end >> end >> if SETTINGS[:organizations_enabled] >> begin >> h.organization = (Organization.find_by_name >> Setting[:discovery_organization]) || Or$ >> rescue >> h.organization = Organization.first >> end >> end >> >> h.save if h.new_record? >> h.importFacts(name, values) >> end >> >> >> >> >> On Thursday, October 17, 2013 10:54:28 AM UTC+1, Greg Sutcliffe wrote: >>> >>> On 17 October 2013 10:49, Alan Sergeant wrote: >>> >>>> I also tried removing the case statement and simply using: >>>> >>>> name = facts.values["macaddress_eth0"].downcase.gsub(/:/,'') >>>> values = facts.values >>>> >>>> This returns can't convert String into Integer. Error comes from the >>>> name variable i think? >>>> >>> >>> The method that Discovery hooks into in Foreman Core >>> (ImportHostAndFacts) has changed significantly in 1.3, so I expect the >>> plugin will need to match that. I'll try to take a look at it this >>> afternoon :) >>> >>> Thanks for your feedback so far, saves me a lot of time tracking down >>> the error :) >>> >>

Never done that before but i've given it a go… hopefully it worked

··· On Thursday, October 17, 2013 1:59:17 PM UTC+1, Alan Sergeant wrote: > > I should say it does require a new discovery image, with the latest > foreman_proxy code > > On Thursday, October 17, 2013 1:56:18 PM UTC+1, Alan Sergeant wrote: >> >> Got it fully working...... file attached >> >> On Thursday, October 17, 2013 1:50:12 PM UTC+1, Alan Sergeant wrote: >>> >>> Ok so i managed to get it to show in the UI, the only caveat is i >>> haven't been able to get the facts to show. >>> Only method I change was this: >>> >>> >>> def self.importHostAndFacts data >>> facts = data >>> name = facts["macaddress_eth0"].downcase.gsub(/:/,'') >>> values = facts >>> >>> # filter facts >>> values.reject!{|k,v| k =~ >>> /kernel|operatingsystem|osfamily|ruby|path|time|swap|free|fil$ >>> >>> if name >>> h = ::Host::Discovered.find_by_name name >>> end >>> h ||= Host.new :name => name, :type => "Host::Discovered" >>> h.type = "Host::Discovered" >>> h.mac = values["macaddress_eth0"].downcase >>> >>> >>> if SETTINGS[:locations_enabled] >>> begin >>> h.location = (Location.find_by_name >>> Setting[:discovery_location]) || Location.first >>> rescue >>> h.location = Location.first >>> end >>> end >>> if SETTINGS[:organizations_enabled] >>> begin >>> h.organization = (Organization.find_by_name >>> Setting[:discovery_organization]) || Or$ >>> rescue >>> h.organization = Organization.first >>> end >>> end >>> >>> h.save if h.new_record? >>> h.importFacts(name, values) >>> end >>> >>> >>> >>> >>> On Thursday, October 17, 2013 10:54:28 AM UTC+1, Greg Sutcliffe wrote: >>>> >>>> On 17 October 2013 10:49, Alan Sergeant wrote: >>>> >>>>> I also tried removing the case statement and simply using: >>>>> >>>>> name = facts.values["macaddress_eth0"].downcase.gsub(/:/,'') >>>>> values = facts.values >>>>> >>>>> This returns can't convert String into Integer. Error comes from the >>>>> name variable i think? >>>>> >>>> >>>> The method that Discovery hooks into in Foreman Core >>>> (ImportHostAndFacts) has changed significantly in 1.3, so I expect the >>>> plugin will need to match that. I'll try to take a look at it this >>>> afternoon :) >>>> >>>> Thanks for your feedback so far, saves me a lot of time tracking down >>>> the error :) >>>> >>>

The method that Discovery hooks into in Foreman Core (ImportHostAndFacts)
has changed significantly in 1.3, so I expect the plugin will need to match
that. I'll try to take a look at it this afternoon :slight_smile:

Thanks for your feedback so far, saves me a lot of time tracking down the
error :slight_smile:

··· On 17 October 2013 10:49, Alan Sergeant wrote:

I also tried removing the case statement and simply using:

name = facts.values[“macaddress_eth0”].downcase.gsub(/:/,’’)
values = facts.values

This returns can’t convert String into Integer. Error comes from the name
variable i think?

Thanks Alan! would you mind sending it as PR to the discovery repo?

thanks!
Ohad

··· On Thu, Oct 17, 2013 at 3:56 PM, Alan Sergeant wrote:

Got it fully working… file attached

On Thursday, October 17, 2013 1:50:12 PM UTC+1, Alan Sergeant wrote:

Ok so i managed to get it to show in the UI, the only caveat is i haven’t
been able to get the facts to show.
Only method I change was this:

def self.importHostAndFacts data
facts = data
name = facts[“macaddress_eth0”].**downcase.gsub(/:/,’’)
values = facts

# filter facts
values.reject!{|k,v| k =~ /kernel|operatingsystem|**

osfamily>ruby>path>time>swap>**free|fil$

if name
  h = ::Host::Discovered.find_by_**name name
end
h ||= Host.new :name => name, :type => "Host::Discovered"
h.type = "Host::Discovered"
h.mac = values["macaddress_eth0"].**downcase


if SETTINGS[:locations_enabled]
  begin
    h.location = (Location.find_by_name Setting[:discovery_location])

Location.first
rescue
h.location = Location.first
end
end
if SETTINGS[:organizations_**enabled]
begin
h.organization = (Organization.find_by_name Setting[:discovery_**organization])

Or$
rescue
h.organization = Organization.first
end
end

h.save if h.new_record?
h.importFacts(name, values)

end

On Thursday, October 17, 2013 10:54:28 AM UTC+1, Greg Sutcliffe wrote:

On 17 October 2013 10:49, Alan Sergeant aserg...@gmail.com wrote:

I also tried removing the case statement and simply using:

name = facts.values[“macaddress_eth0”**].downcase.gsub(/:/,’’)
values = facts.values

This returns can’t convert String into Integer. Error comes from the
name variable i think?

The method that Discovery hooks into in Foreman Core
(ImportHostAndFacts) has changed significantly in 1.3, so I expect the
plugin will need to match that. I’ll try to take a look at it this
afternoon :slight_smile:

Thanks for your feedback so far, saves me a lot of time tracking down
the error :slight_smile:


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.
For more options, visit https://groups.google.com/groups/opt_out.

Indeed it did, thanks! Let's move patch discussion to the Pull Request :slight_smile:

Greg

··· On 17 October 2013 14:34, Alan Sergeant wrote:

Never done that before but i’ve given it a go… hopefully it worked