Add Global params for host obfuscation and migrate off settings#921
Add Global params for host obfuscation and migrate off settings#921chris1984 wants to merge 1 commit intotheforeman:developfrom
Conversation
3e407b8 to
efbca09
Compare
efbca09 to
2fd7b5d
Compare
ShimShtein
left a comment
There was a problem hiding this comment.
I think we will need to add a UI message on the inventory page about the ability to obfuscate using the parameter. Otherwise it will feel to the user that the setting just disappeared without replacement.
| CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_hostnames', value: false) | ||
| CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: false) |
There was a problem hiding this comment.
| CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_hostnames', value: false) | |
| CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: false) | |
| hostname_setting = CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_hostnames', value: false) | |
| ip_setting = CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: false) |
You can skip the find_by later in the code
| return insights_client_setting unless insights_client_setting.nil? | ||
|
|
||
| Setting[:obfuscate_inventory_hostnames] | ||
| CommonParameter.find_by(name: 'obfuscate_inventory_hostnames')&.value |
There was a problem hiding this comment.
You should look for a value on the host, not just the common parameter, similar to
| return insights_client_setting unless insights_client_setting.nil? | ||
|
|
||
| Setting[:obfuscate_inventory_ips] | ||
| CommonParameter.find_by(name: 'obfuscate_inventory_ips')&.value |
There was a problem hiding this comment.
If it's a parameter, you have to look up the value on the host object itself:
| if bash_hostname == foreman_hostname | ||
| fqdn(ForemanRhCloud.foreman_host) | ||
| elsif Setting[:obfuscate_inventory_hostnames] | ||
| elsif CommonParameter.find_by(name: 'obfuscate_inventory_hostnames')&.value |
There was a problem hiding this comment.
If it's a parameter, you have to look up the value on the host object itself:
| test 'generates an empty report with hidden hostname and ip' do | ||
| Setting[:obfuscate_inventory_hostnames] = true | ||
| Setting[:obfuscate_inventory_ips] = true | ||
| CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: true) |
There was a problem hiding this comment.
If the parameter exists, I think this method will not reset its value.
What are the changes introduced in this pull request?
obfuscate_inventory_hostnamesandobfuscate_inventory_ipsand set them tofalsewhich is the default value forinsights-clientobfuscate_inventory_hostnamesandobfuscate_inventory_ipsand deletes the settings from the plugin and DB