Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theforeman/foreman_column_view
A simple Foreman plugin showcasing Deface for altering the Hosts view
https://github.com/theforeman/foreman_column_view
engine foreman hacktoberfest rails ruby
Last synced: 7 days ago
JSON representation
A simple Foreman plugin showcasing Deface for altering the Hosts view
- Host: GitHub
- URL: https://github.com/theforeman/foreman_column_view
- Owner: theforeman
- License: gpl-3.0
- Archived: true
- Created: 2013-03-02T17:44:00.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-05-17T08:22:22.000Z (over 1 year ago)
- Last Synced: 2025-01-03T04:16:40.754Z (24 days ago)
- Topics: engine, foreman, hacktoberfest, rails, ruby
- Language: Ruby
- Size: 41 KB
- Stars: 23
- Watchers: 6
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**Note**
The plugin's functionality was integrated in Foreman itself with version 3.5, making it obsolete.# foreman\_column\_view
A small plugin to showcase the awesome [Deface](https://github.com/spree/deface)
library. It simply adds a column to the Hosts list or properties table. It also
serves as a simple example of including a new Helper in the plugin.## Compatibility
| Foreman Version | Plugin Version |
| --------------- | --------------:|
| <= 1.15 | ~> 0.3 |
| == 1.16 | untested |
| >= 1.17 | ~> 0.4 |# Installation
Require the gem in Foreman (you may need extra dependencies such as libxml or libxslt
to build the nokogiri dependency)```yaml
gem 'foreman_column_view'
```Update Foreman with the new gems:
bundle update foreman_column_view
# Configuration
By default the plugin will display the Domain associated by each host. This is not
massively useful. To set your own choice of column, add this to Foreman's plugin config file
`foreman_column_view.yaml`. For package based installs this should be in
`/etc/foreman/plugins/foreman_column_view.yaml`. For source installs this should be in
`config/settings.plugins.d` within your install directory.```yaml
:column_view:
:name1:
:title: Shortname1
:after: last_report
:content: shortname1
:name2:
:title: Shortname2
:after: name1
:content: facts_hash['shortname2']
````title` is an arbitrary string which is displayed as the column header. `content` is
a method call to the `Host` object, using `host.send`. In these examples `facts_hash`
and `params` are method calls to `Host` returning hash values.```yaml
:column_view:
:architecture:
:title: Architecture
:after: last_report
:content: facts_hash['architecture']
:uptime:
:title: Uptime
:after: architecture
:content: facts_hash['uptime']
:color:
:title: Color
:after: last_report
:content: params['favorite_color']```
Additional rows can also be added to the Properties table on the host page by setting
`:view: :hosts_properties`. The position is also controlled by `:after` using either a
numeric index to represent the row or the name of the previous row (however this will
not work well when the Foreman language is switched). An example configuration:```yaml
:column_view:
:uptime:
:title: Uptime
:after: 6
:content: facts_hash['uptime']
:view: :hosts_properties
```You can also control the width of the added column by giving a value to the `:width`
attribute. If the width is not set, the default is set to 10%. Note that the original
host list already has 100% width set, so adding more columns will cause other columns
to resize, which may cause some of the table layout to break a bit. For example:```yaml
:column_view:
:domain:
:title: Domain
:after: model
:content: domain
:width: 7%
```If you need to add information not readily available in a host, you can add information that
will be evaluated on runtime by adding `:eval_content: true` to your additional row.
Also, some times you do not want to show the additional row if a certain condition is not met,
in order to show that row conditionally, add `:conditional: :condition_symbol` to your configuration,
and that conditional will be executed on your host.As an example, the following yaml shows a link to a custom URL if the method host.bmc_available? is true.
```yaml
:console:
:title: Console
:after: 0
:content: link_to(_("Console"), "https://#{host.interfaces.first.name}.domainname", { :class => "btn btn-info" } )
:conditional: :bmc_available?
:eval_content: true
:view: :hosts_properties
```If your conditional method needs arguments to work, the arguments should go after the method name separated by
spaces, as in `:custom_method arg1 arg2`You will need to restart Foreman for changes to take effect, as the `settings.yaml` is
only read at startup.# TODO
* Add plugin settings to the Settings UI
* Make the column sortable
* Support adding data to other pages# Copyright
Copyright (c) 2013 Greg Sutcliffe
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program. If not, see .