conditional entry
Was trying to add 'uptime' to hosts page, but based on the host status, that is if not in sync, then leave blank, otherwise report fact_hash['uptime'], should this one work? while it doesn't
:uptime_hosts_page: :title: Uptime :after: last_report :content: facts_hash['uptime'] :conditional: :last_report < "60 minutes ago"
Thnx in advance for any advice on that!
It should work, but reading the code (https://github.com/GregSutcliffe/foreman_column_view/blob/master/app/helpers/foreman_column_view/hosts_helper_extension.rb#L15-L19), I think it's actually expecting an array instead of a string. Could you try:
:conditional:
- :last_report
- <
- 60 minutes ago
If that works, could you raise a bug? It would be easy enough to call .split on :conditional...
@dgtim also, sorry for the slow reply :)
Thank you for the reply! but seems that no effect.
:uptime_hosts_page: :title: Uptime :after: last_report :content: facts_hash['uptime'] :conditional: - :last_report - < - 60 minutes ago
And no syntax errors in both case, just a notice in the /var/log/foreman/production.log:
Deface:ESC[0m 'content_updates_hosts_page' matched 1 times with 'td:contains('last_report' )'
Interesting. You did restart Foreman after the changes, right?
Jep, I did. Even several times.
Wanted to jump in on this. I haven't been able to decipher how to use the conditional section either. I want to add in a bunch of params to display that i know aren't set on all my hosts - but i know they are on some. Currently if i try this without a conditional it bombs out completely because the value(s) of some are null, so i know i need the conditional.
The doc's mention needing to use a "conditional executed on my host". After a bit of googling of the example - i think it means the methods referenced here: http://www.rubydoc.info/github/theforeman/foreman/Host/Managed HOWEVER - i do not see a method in that list called last_report.
So my question is (and it builds on the original question posed and still unresolved here) - what really constitutes a valid "method" available to use here? Can we be given a few options of "valid" items beyond the single boolean example shown?