theforeman / foreman_expire_hosts

Foreman plugin for limiting host lifetime
GNU General Public License v3.0
5 stars 12 forks source link

Expiration date is not available using API call #8

Closed wheeskers closed 6 years ago

wheeskers commented 7 years ago

Current version of foreman_expire_hosts plugin does not provide any method to query expiration date for specific host. Expiration date is available on host page when using UI but I can't find any way to get that value using API.

mmoll commented 7 years ago

http://projects.theforeman.org/issues/20203 has a bit more info, but as there's no category for this plugin in redmine, I guess it's using GitHub as issue tracker.

timogoebel commented 7 years ago

This is indeed a missing feature. I'll gladly take a look in a week when I'm back in the office. Sorry for the delay. Patches are welcome. :-)

wheeskers commented 7 years ago

@timogoebel, thank you a lot for the reply and looking into this! I wish I could help more but my experience with Rails is somewhat limited and I'm still learning how it actually works :)

timogoebel commented 7 years ago

@wheeskers: I looked into what needs to be done to add this feature. Unfortunately, it's rather complex as there is no easy to use extension point in foreman core. This might take some time to get implemented, sorry.

wheeskers commented 7 years ago

@timogoebel, thanks! I got it.

Please let me (and I hope I'm not the one who thinks this feature is useful) know when you or team manage to expose this parameter through Foreman API.

Thanks again for looking into this.

wheeskers commented 6 years ago

@timogoebel, could you please let me know if there any updates on this? This is not critical in any way but maybe I am missing something.

timogoebel commented 6 years ago

@wheeskers: Sorry, no progress so far on this.

wheeskers commented 6 years ago

@timogoebel, thank you for the fast reply. Please share any updates if something changes or some kind of workaround will be possible. We export a lot of information using Foreman API and this parameter is very useful for end users to estimate their VM expiration status in summary reports (personal email notifications are great but serve different purpose).

timogoebel commented 6 years ago

@wheeskers: If you want, you could just add one line to /usr/share/foreman/app/views/api/v2/hosts/main.json.rabl (on RedHat, just replace /usr/share/foreman by the correct forman install directory for Debian). The line needs to look like this:

attributes :expired_on

This will get overwritten by every update to Foreman, but might still be worth the effort.

wheeskers commented 6 years ago

@timogoebel, Great little hack but I guess it is not optimal to use it in production if it will be overwritten on every update, this will break external scripts that are used to interact with Foreman and depend on API.

Anyway, thanks a lot! Please let us know if this parameter will be supported as standard option.

timogoebel commented 6 years ago

@wheeskers: I opened a PR to get the necessary changes in core. If that is in, we can proceed here. It's a piece of cake then. https://github.com/theforeman/foreman/pull/5048

wheeskers commented 6 years ago

@timogoebel, thanks, great news.

timogoebel commented 6 years ago

@wheeskers: The core pull request is merged and will be part of Foreman 1.17. I have opened a PR against this plug-in to make use of the new features.