foreman_virt_who_configure 0.5.18 → 0.5.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/foreman_virt_who_configure/locale/bn/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/bn_IN/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/ca/foreman_virt_who_configure.js +1 -217
- data/app/assets/javascripts/foreman_virt_who_configure/locale/cs_CZ/foreman_virt_who_configure.js +11 -138
- data/app/assets/javascripts/foreman_virt_who_configure/locale/de/foreman_virt_who_configure.js +27 -67
- data/app/assets/javascripts/foreman_virt_who_configure/locale/de_DE/foreman_virt_who_configure.js +1 -247
- data/app/assets/javascripts/foreman_virt_who_configure/locale/el/foreman_virt_who_configure.js +6 -198
- data/app/assets/javascripts/foreman_virt_who_configure/locale/en/foreman_virt_who_configure.js +0 -249
- data/app/assets/javascripts/foreman_virt_who_configure/locale/en_GB/foreman_virt_who_configure.js +1 -232
- data/app/assets/javascripts/foreman_virt_who_configure/locale/es/foreman_virt_who_configure.js +28 -68
- data/app/assets/javascripts/foreman_virt_who_configure/locale/fr/foreman_virt_who_configure.js +33 -43
- data/app/assets/javascripts/foreman_virt_who_configure/locale/gl/foreman_virt_who_configure.js +1 -235
- data/app/assets/javascripts/foreman_virt_who_configure/locale/gu/foreman_virt_who_configure.js +1 -235
- data/app/assets/javascripts/foreman_virt_who_configure/locale/he_IL/foreman_virt_who_configure.js +0 -249
- data/app/assets/javascripts/foreman_virt_who_configure/locale/hi/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/it/foreman_virt_who_configure.js +10 -169
- data/app/assets/javascripts/foreman_virt_who_configure/locale/ja/foreman_virt_who_configure.js +33 -43
- data/app/assets/javascripts/foreman_virt_who_configure/locale/ka/foreman_virt_who_configure.js +34 -38
- data/app/assets/javascripts/foreman_virt_who_configure/locale/kn/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/ko/foreman_virt_who_configure.js +13 -136
- data/app/assets/javascripts/foreman_virt_who_configure/locale/mr/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/nl_NL/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/or/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/pa/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/pl/foreman_virt_who_configure.js +1 -232
- data/app/assets/javascripts/foreman_virt_who_configure/locale/pt/foreman_virt_who_configure.js +0 -249
- data/app/assets/javascripts/foreman_virt_who_configure/locale/pt_BR/foreman_virt_who_configure.js +28 -68
- data/app/assets/javascripts/foreman_virt_who_configure/locale/ru/foreman_virt_who_configure.js +13 -136
- data/app/assets/javascripts/foreman_virt_who_configure/locale/sl/foreman_virt_who_configure.js +1 -244
- data/app/assets/javascripts/foreman_virt_who_configure/locale/sv_SE/foreman_virt_who_configure.js +1 -235
- data/app/assets/javascripts/foreman_virt_who_configure/locale/ta/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/ta_IN/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/te/foreman_virt_who_configure.js +1 -238
- data/app/assets/javascripts/foreman_virt_who_configure/locale/tr/foreman_virt_who_configure.js +0 -249
- data/app/assets/javascripts/foreman_virt_who_configure/locale/zh_CN/foreman_virt_who_configure.js +33 -43
- data/app/assets/javascripts/foreman_virt_who_configure/locale/zh_TW/foreman_virt_who_configure.js +14 -137
- data/app/models/foreman_virt_who_configure/config.rb +47 -40
- data/app/models/foreman_virt_who_configure/output_generator.rb +105 -105
- data/app/models/foreman_virt_who_configure/service_user.rb +4 -4
- data/app/services/sso/basic_with_hidden.rb +1 -1
- data/config/database.yml.example +17 -0
- data/db/migrate/20231024171433_add_organization_id_to_service_user.rb +22 -0
- data/lib/foreman_virt_who_configure/engine.rb +8 -8
- data/lib/foreman_virt_who_configure/version.rb +1 -1
- data/locale/Makefile +2 -4
- data/locale/bn/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/bn/foreman_virt_who_configure.edit.po +961 -0
- data/locale/bn/foreman_virt_who_configure.po +0 -249
- data/locale/bn/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/bn_IN/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/bn_IN/foreman_virt_who_configure.edit.po +962 -0
- data/locale/bn_IN/foreman_virt_who_configure.po +0 -249
- data/locale/bn_IN/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/bqi/foreman_virt_who_configure.edit.po +958 -0
- data/locale/bqi/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ca/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/ca/foreman_virt_who_configure.edit.po +961 -0
- data/locale/ca/foreman_virt_who_configure.po +0 -249
- data/locale/ca/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/cs_CZ/foreman_virt_who_configure.edit.po +977 -0
- data/locale/cs_CZ/foreman_virt_who_configure.po +0 -249
- data/locale/cs_CZ/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/de/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/de/foreman_virt_who_configure.edit.po +987 -0
- data/locale/de/foreman_virt_who_configure.po +0 -249
- data/locale/de/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/de_AT/foreman_virt_who_configure.edit.po +958 -0
- data/locale/de_AT/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/de_DE/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/de_DE/foreman_virt_who_configure.edit.po +964 -0
- data/locale/de_DE/foreman_virt_who_configure.po +0 -249
- data/locale/de_DE/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/el/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/el/foreman_virt_who_configure.edit.po +961 -0
- data/locale/el/foreman_virt_who_configure.po +0 -249
- data/locale/el/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/en/foreman_virt_who_configure.edit.po +957 -0
- data/locale/en/foreman_virt_who_configure.po +0 -249
- data/locale/en/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/en_GB/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/en_GB/foreman_virt_who_configure.edit.po +963 -0
- data/locale/en_GB/foreman_virt_who_configure.po +0 -249
- data/locale/en_GB/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/en_US/foreman_virt_who_configure.edit.po +958 -0
- data/locale/en_US/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/es/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/es/foreman_virt_who_configure.edit.po +984 -0
- data/locale/es/foreman_virt_who_configure.po +0 -249
- data/locale/es/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/et_EE/foreman_virt_who_configure.edit.po +958 -0
- data/locale/et_EE/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/foreman_virt_who_configure.pot +3 -335
- data/locale/fr/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/fr/foreman_virt_who_configure.edit.po +982 -0
- data/locale/fr/foreman_virt_who_configure.po +0 -249
- data/locale/fr/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/gl/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/gl/foreman_virt_who_configure.edit.po +961 -0
- data/locale/gl/foreman_virt_who_configure.po +0 -249
- data/locale/gl/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/gu/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/gu/foreman_virt_who_configure.edit.po +961 -0
- data/locale/gu/foreman_virt_who_configure.po +0 -249
- data/locale/gu/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/he_IL/foreman_virt_who_configure.edit.po +963 -0
- data/locale/he_IL/foreman_virt_who_configure.po +0 -249
- data/locale/he_IL/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/hi/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/hi/foreman_virt_who_configure.edit.po +961 -0
- data/locale/hi/foreman_virt_who_configure.po +0 -249
- data/locale/hi/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/id/foreman_virt_who_configure.edit.po +957 -0
- data/locale/id/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/it/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/it/foreman_virt_who_configure.edit.po +965 -0
- data/locale/it/foreman_virt_who_configure.po +0 -249
- data/locale/it/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/ja/foreman_virt_who_configure.edit.po +979 -0
- data/locale/ja/foreman_virt_who_configure.po +0 -249
- data/locale/ja/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ka/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/ka/foreman_virt_who_configure.edit.po +976 -0
- data/locale/ka/foreman_virt_who_configure.po +0 -249
- data/locale/ka/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/kn/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/kn/foreman_virt_who_configure.edit.po +961 -0
- data/locale/kn/foreman_virt_who_configure.po +0 -249
- data/locale/kn/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/ko/foreman_virt_who_configure.edit.po +963 -0
- data/locale/ko/foreman_virt_who_configure.po +0 -249
- data/locale/ko/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ml_IN/foreman_virt_who_configure.edit.po +958 -0
- data/locale/ml_IN/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/mr/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/mr/foreman_virt_who_configure.edit.po +961 -0
- data/locale/mr/foreman_virt_who_configure.po +0 -249
- data/locale/mr/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/nl_NL/foreman_virt_who_configure.edit.po +966 -0
- data/locale/nl_NL/foreman_virt_who_configure.po +0 -249
- data/locale/nl_NL/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/or/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/or/foreman_virt_who_configure.edit.po +961 -0
- data/locale/or/foreman_virt_who_configure.po +0 -249
- data/locale/or/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/pa/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/pa/foreman_virt_who_configure.edit.po +962 -0
- data/locale/pa/foreman_virt_who_configure.po +0 -249
- data/locale/pa/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/pl/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/pl/foreman_virt_who_configure.edit.po +964 -0
- data/locale/pl/foreman_virt_who_configure.po +0 -249
- data/locale/pl/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/pl_PL/foreman_virt_who_configure.edit.po +960 -0
- data/locale/pl_PL/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/pt/foreman_virt_who_configure.edit.po +962 -0
- data/locale/pt/foreman_virt_who_configure.po +0 -249
- data/locale/pt/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/pt_BR/foreman_virt_who_configure.edit.po +985 -0
- data/locale/pt_BR/foreman_virt_who_configure.po +0 -249
- data/locale/pt_BR/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ro/foreman_virt_who_configure.edit.po +958 -0
- data/locale/ro/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ro_RO/foreman_virt_who_configure.edit.po +959 -0
- data/locale/ro_RO/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ru/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/ru/foreman_virt_who_configure.edit.po +967 -0
- data/locale/ru/foreman_virt_who_configure.po +0 -249
- data/locale/ru/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/sl/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/sl/foreman_virt_who_configure.edit.po +962 -0
- data/locale/sl/foreman_virt_who_configure.po +0 -249
- data/locale/sl/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/sv_SE/foreman_virt_who_configure.edit.po +963 -0
- data/locale/sv_SE/foreman_virt_who_configure.po +0 -249
- data/locale/sv_SE/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ta/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/ta/foreman_virt_who_configure.edit.po +961 -0
- data/locale/ta/foreman_virt_who_configure.po +0 -249
- data/locale/ta/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/ta_IN/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/ta_IN/foreman_virt_who_configure.edit.po +962 -0
- data/locale/ta_IN/foreman_virt_who_configure.po +0 -249
- data/locale/ta_IN/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/te/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/te/foreman_virt_who_configure.edit.po +961 -0
- data/locale/te/foreman_virt_who_configure.po +0 -249
- data/locale/te/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/tr/foreman_virt_who_configure.edit.po +961 -0
- data/locale/tr/foreman_virt_who_configure.po +0 -249
- data/locale/tr/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/vi/foreman_virt_who_configure.edit.po +957 -0
- data/locale/vi/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/vi_VN/foreman_virt_who_configure.edit.po +958 -0
- data/locale/vi_VN/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/zh/foreman_virt_who_configure.edit.po +957 -0
- data/locale/zh/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/zh_CN/foreman_virt_who_configure.edit.po +979 -0
- data/locale/zh_CN/foreman_virt_who_configure.po +0 -249
- data/locale/zh_CN/foreman_virt_who_configure.po.time_stamp +0 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_virt_who_configure.mo +0 -0
- data/locale/zh_TW/foreman_virt_who_configure.edit.po +963 -0
- data/locale/zh_TW/foreman_virt_who_configure.po +0 -249
- data/locale/zh_TW/foreman_virt_who_configure.po.time_stamp +0 -0
- data/test/factories/foreman_virt_who_configure_factories.rb +2 -2
- data/test/functional/api/v2/configs_controller_test.rb +14 -13
- data/test/unit/config_test.rb +24 -12
- data/test/unit/output_generator_test.rb +1 -2
- metadata +105 -8
- data/locale/action_names.rb +0 -84
@@ -1,5 +1,5 @@
|
|
1
1
|
module ForemanVirtWhoConfigure
|
2
|
-
class Config <
|
2
|
+
class Config < ApplicationRecord
|
3
3
|
PERMITTED_PARAMS = [
|
4
4
|
:interval, :organization_id, :compute_resource_id, :whitelist, :blacklist, :hypervisor_id,
|
5
5
|
:hypervisor_type, :hypervisor_server, :hypervisor_username, :hypervisor_password, :debug,
|
@@ -9,7 +9,7 @@ module ForemanVirtWhoConfigure
|
|
9
9
|
:listing_mode, :filtering_mode, :filter_host_parents, :exclude_host_parents, :kubeconfig_path,
|
10
10
|
:prism_flavor, :ahv_internal_debug
|
11
11
|
]
|
12
|
-
audited :except => [
|
12
|
+
audited :except => [:hypervisor_password, :last_report_at, :out_of_date_at], :associations => []
|
13
13
|
include Authorizable
|
14
14
|
validates_lengths_from_database
|
15
15
|
|
@@ -28,7 +28,7 @@ module ForemanVirtWhoConfigure
|
|
28
28
|
'connection' => N_('Connection')
|
29
29
|
}
|
30
30
|
|
31
|
-
HYPERVISOR_IDS = [
|
31
|
+
HYPERVISOR_IDS = ['hostname', 'uuid', 'hwuuid']
|
32
32
|
|
33
33
|
HYPERVISOR_TYPES = {
|
34
34
|
'esx' => 'VMware vSphere / vCenter (esx)',
|
@@ -70,7 +70,7 @@ module ForemanVirtWhoConfigure
|
|
70
70
|
PRISM_FLAVORS = {
|
71
71
|
'central' => N_('Prism Central'),
|
72
72
|
'element' => N_('Prism Element')
|
73
|
-
}
|
73
|
+
}
|
74
74
|
|
75
75
|
AHV_VALID_OPTIONS = %w(prism_flavor ahv_internal_debug)
|
76
76
|
KUBEVIRT_VALID_OPTIONS = %w(kubeconfig_path)
|
@@ -84,61 +84,61 @@ module ForemanVirtWhoConfigure
|
|
84
84
|
belongs_to :http_proxy
|
85
85
|
|
86
86
|
# service user used by virt-who to report back
|
87
|
-
belongs_to :service_user
|
87
|
+
belongs_to :service_user, :inverse_of => :configs
|
88
88
|
|
89
89
|
scoped_search :on => :interval, :complete_value => true
|
90
90
|
scoped_search :on => :name
|
91
91
|
scoped_search :on => :status, :complete_value => true, :only_explicit => true, :operators => ['= '], :ext_method => :search_by_status
|
92
92
|
scoped_search :on => :out_of_date_at, :complete_value => true, :only_explicit => true
|
93
93
|
scoped_search :on => :last_report_at, :complete_value => true, :only_explicit => true
|
94
|
-
# TODO add more related objects and attributes
|
94
|
+
# TODO: add more related objects and attributes
|
95
95
|
|
96
96
|
# compatibility layer for 1.11 - pre strong params patch
|
97
|
-
if
|
97
|
+
if respond_to?(:attr_accessible)
|
98
98
|
attr_accessible(*PERMITTED_PARAMS)
|
99
99
|
end
|
100
100
|
|
101
|
-
after_create :
|
101
|
+
after_create :create_or_find_service_user
|
102
102
|
after_destroy :destroy_service_user
|
103
103
|
|
104
104
|
validates :interval, :hypervisor_type,
|
105
|
-
|
106
|
-
|
105
|
+
:satellite_url, :hypervisor_id, :organization_id, :name,
|
106
|
+
:presence => true
|
107
107
|
validates :name, :uniqueness => { :scope => :organization_id }
|
108
|
-
validates :hypervisor_password, :presence => true, :if =>
|
109
|
-
validates :hypervisor_username, :presence => true, :if =>
|
110
|
-
validates :hypervisor_server, :presence => true, :if =>
|
111
|
-
validates :kubeconfig_path, :presence => true, :if =>
|
108
|
+
validates :hypervisor_password, :presence => true, :if => proc { |c| c.hypervisor_type != 'libvirt' && c.hypervisor_type != 'kubevirt' }
|
109
|
+
validates :hypervisor_username, :presence => true, :if => proc { |c| c.hypervisor_type != 'kubevirt' }
|
110
|
+
validates :hypervisor_server, :presence => true, :if => proc { |c| c.hypervisor_type != 'kubevirt' }
|
111
|
+
validates :kubeconfig_path, :presence => true, :if => proc { |c| c.hypervisor_type == 'kubevirt' }
|
112
112
|
validates :hypervisor_type, :inclusion => HYPERVISOR_TYPES.keys
|
113
113
|
validates :hypervisor_id, :inclusion => HYPERVISOR_IDS
|
114
114
|
validates :interval, :inclusion => AVAILABLE_INTERVALS.keys.map(&:to_i)
|
115
115
|
validates :listing_mode, :inclusion => FILTERING_MODES.keys.map(&:to_i)
|
116
|
-
validates :prism_flavor, :inclusion => {:in => PRISM_FLAVORS.keys, :message => "should be either central or element"}, :if =>
|
116
|
+
validates :prism_flavor, :inclusion => {:in => PRISM_FLAVORS.keys, :message => "should be either central or element"}, :if => proc { |c| c.hypervisor_type == 'ahv' }
|
117
117
|
validate :validates_whitelist_blacklist
|
118
|
-
validate :validates_debug_settings, :if =>
|
118
|
+
validate :validates_debug_settings, :if => proc { |c| c.hypervisor_type == 'ahv' }
|
119
119
|
validate :validates_hypervisor_options
|
120
120
|
|
121
121
|
def validates_whitelist_blacklist
|
122
122
|
case listing_mode.to_i
|
123
123
|
when WHITELIST
|
124
124
|
unless whitelist.present? || filter_host_parents.present?
|
125
|
-
[:whitelist, :filter_host_parents].each {|f| errors.add(f, "Filter hosts or Filter host parents is required")}
|
125
|
+
[:whitelist, :filter_host_parents].each { |f| errors.add(f, "Filter hosts or Filter host parents is required") }
|
126
126
|
end
|
127
127
|
when BLACKLIST
|
128
128
|
unless blacklist.present? || exclude_host_parents.present?
|
129
|
-
[:blacklist, :exclude_host_parents].each {|f| errors.add(f, "Exclude hosts or Exclude host parents is required")}
|
129
|
+
[:blacklist, :exclude_host_parents].each { |f| errors.add(f, "Exclude hosts or Exclude host parents is required") }
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
134
|
def validates_debug_settings
|
135
135
|
if ahv_internal_debug && !debug
|
136
|
-
errors.add(:ahv_internal_debug, "Enable debugging output is required for Enable AHV debug")
|
136
|
+
errors.add(:ahv_internal_debug, "Enable debugging output is required for Enable AHV debug")
|
137
137
|
end
|
138
|
-
end
|
138
|
+
end
|
139
139
|
|
140
140
|
def validates_hypervisor_options
|
141
|
-
invalid_fields.each { |f| errors.add(f, "Invalid option for hypervisor [#{hypervisor_type}]") if
|
141
|
+
invalid_fields.each { |f| errors.add(f, "Invalid option for hypervisor [#{hypervisor_type}]") if send(f).present? }
|
142
142
|
end
|
143
143
|
|
144
144
|
validates_lengths_from_database
|
@@ -171,27 +171,35 @@ module ForemanVirtWhoConfigure
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
-
def
|
174
|
+
def create_or_find_service_user
|
175
|
+
service_user = ServiceUser.find_by(organization_id: organization_id)
|
176
|
+
if service_user.present?
|
177
|
+
update(service_user_id: service_user.id)
|
178
|
+
return service_user
|
179
|
+
end
|
180
|
+
|
175
181
|
User.skip_permission_check do
|
176
182
|
password = User.random_password
|
177
|
-
service_user =
|
183
|
+
service_user = build_service_user(organization_id: organization_id)
|
178
184
|
user = service_user.build_user
|
179
185
|
user.auth_source = AuthSourceHiddenWithAuthentication.default
|
180
186
|
user.password = password
|
181
|
-
user.login = "virt_who_reporter_#{
|
182
|
-
user.organizations = [
|
183
|
-
user.roles = [Role.
|
187
|
+
user.login = "virt_who_reporter_#{id}"
|
188
|
+
user.organizations = [organization]
|
189
|
+
user.roles = [Role.find_by(:name => 'Virt-who Reporter')]
|
184
190
|
user.valid? # to trigger password hashing
|
185
191
|
user.save!(:validate => false)
|
186
192
|
|
187
193
|
service_user.encrypted_password = password
|
188
194
|
service_user.save!
|
189
195
|
|
190
|
-
|
196
|
+
update_attribute :service_user_id, service_user.id
|
191
197
|
end
|
192
198
|
end
|
193
199
|
|
194
200
|
def destroy_service_user
|
201
|
+
return unless service_user.configs.count == 0
|
202
|
+
|
195
203
|
User.skip_permission_check do
|
196
204
|
# skip validation that prevents hidden user deletion
|
197
205
|
user = User.unscoped.find_by_id(service_user.user_id)
|
@@ -214,11 +222,11 @@ module ForemanVirtWhoConfigure
|
|
214
222
|
# end
|
215
223
|
|
216
224
|
def humanized_interval
|
217
|
-
_("every %s hours") % (
|
225
|
+
_("every %s hours") % (interval / 60)
|
218
226
|
end
|
219
227
|
|
220
228
|
def out_of_date?(deadline = DateTime.now.utc)
|
221
|
-
|
229
|
+
out_of_date_at.present? && out_of_date_at < deadline
|
222
230
|
end
|
223
231
|
|
224
232
|
def step_name(step_key)
|
@@ -243,24 +251,23 @@ module ForemanVirtWhoConfigure
|
|
243
251
|
end
|
244
252
|
|
245
253
|
def virt_who_config_command
|
246
|
-
"hammer virt-who-config deploy --id #{
|
254
|
+
"hammer virt-who-config deploy --id #{id} --organization-id #{organization_id}"
|
247
255
|
end
|
248
256
|
|
249
257
|
def virt_who_touch!
|
250
258
|
self.last_report_at = DateTime.now.utc
|
251
|
-
self.out_of_date_at =
|
252
|
-
self.class.skip_permission_check {
|
259
|
+
self.out_of_date_at = last_report_at + interval.minutes
|
260
|
+
self.class.skip_permission_check { save! }
|
253
261
|
end
|
254
262
|
|
255
263
|
def status
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
:out_of_date
|
264
|
+
if last_report_at.nil?
|
265
|
+
:unknown
|
266
|
+
elsif !out_of_date?
|
267
|
+
:ok
|
268
|
+
else
|
269
|
+
# out of date is currently considered ok too, virt-who does not send any report if there's no change on hypervisor
|
270
|
+
:out_of_date
|
264
271
|
end
|
265
272
|
end
|
266
273
|
|
@@ -31,7 +31,7 @@ module ForemanVirtWhoConfigure
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def error_code(error_name)
|
34
|
-
result = CONFIGURATION_RESULTS.find { |
|
34
|
+
result = CONFIGURATION_RESULTS.find { |r| r.identifier == error_name.to_s }
|
35
35
|
result.try(:code)
|
36
36
|
end
|
37
37
|
|
@@ -51,107 +51,107 @@ module ForemanVirtWhoConfigure
|
|
51
51
|
def virt_who_output(format = nil)
|
52
52
|
kubeconfig = config.hypervisor_type == 'kubevirt' ? "\nkubeconfig=#{config.kubeconfig_path}" : ''
|
53
53
|
result = ''
|
54
|
-
cr_password_base64 = Base64.strict_encode64(
|
54
|
+
cr_password_base64 = Base64.strict_encode64(cr_password.to_s)
|
55
55
|
result += "#!/bin/bash\n" if format == :bash_script
|
56
|
-
result +=
|
57
|
-
heading() {
|
58
|
-
|
59
|
-
}
|
60
|
-
|
61
|
-
step() {
|
62
|
-
|
63
|
-
|
64
|
-
}
|
65
|
-
|
66
|
-
version_lte() {
|
67
|
-
|
68
|
-
}
|
69
|
-
|
70
|
-
version_lt() {
|
71
|
-
|
72
|
-
}
|
73
|
-
|
74
|
-
verify_minimal_version() {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
}
|
85
|
-
|
86
|
-
result_code=#{error_code(:success)}
|
87
|
-
|
88
|
-
compose_install_command() {
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
}
|
93
|
-
|
94
|
-
install_virt_who() {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
}
|
103
|
-
|
104
|
-
step 1 "Installing virt-who"
|
105
|
-
install_virt_who
|
106
|
-
|
107
|
-
if verify_minimal_version; then
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
### This configuration file is managed via the virt-who configure plugin
|
115
|
-
### manual edits will be deleted.
|
116
|
-
[#{identifier}]
|
117
|
-
type=#{type}
|
118
|
-
hypervisor_id=#{hypervisor_id}
|
119
|
-
owner=#{owner}
|
120
|
-
#{connection_details}#{filtering}
|
121
|
-
rhsm_hostname=#{satellite_url}
|
122
|
-
rhsm_username=#{service_user_username}
|
123
|
-
rhsm_encrypted_password=$user_password
|
124
|
-
rhsm_prefix=/rhsm#{kubeconfig}#{ahv_config_options}
|
125
|
-
EOF
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
### This configuration file is managed via the virt-who configure plugin
|
131
|
-
### manual edits will be deleted.
|
132
|
-
[global]
|
133
|
-
debug=#{config.debug? ? 1 : 0}
|
134
|
-
interval=#{config.interval * 60}#{proxy_strings}
|
135
|
-
oneshot=False
|
136
|
-
EOF
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
else
|
143
|
-
|
144
|
-
fi
|
145
|
-
|
146
|
-
heading "Finished"
|
147
|
-
if [ $result_code -ne 0 ]; then
|
148
|
-
|
149
|
-
|
150
|
-
else
|
151
|
-
|
152
|
-
fi
|
153
|
-
|
154
|
-
|
56
|
+
result += <<~SCRIPT
|
57
|
+
heading() {
|
58
|
+
echo -e "\\n== $1 =="
|
59
|
+
}
|
60
|
+
|
61
|
+
step() {
|
62
|
+
step_count=5
|
63
|
+
heading "[$1/$step_count] $2"
|
64
|
+
}
|
65
|
+
|
66
|
+
version_lte() {
|
67
|
+
[ "$1" = "`echo -e "$1\\n$2" | sort -V | head -n1`" ]
|
68
|
+
}
|
69
|
+
|
70
|
+
version_lt() {
|
71
|
+
[ "$1" = "$2" ] && return 1 || version_lte $1 $2
|
72
|
+
}
|
73
|
+
|
74
|
+
verify_minimal_version() {
|
75
|
+
minimal_version=#{MINIMUM_VIRT_WHO_VERSION}
|
76
|
+
installed_version=`rpm -q --queryformat '%{VERSION}' virt-who`
|
77
|
+
|
78
|
+
if version_lt $installed_version $minimal_version; then
|
79
|
+
echo "virt-who $installed_version does not meet minimum requirements, please make sure this host is properly subscribed and has access to katello-host-tools repository, minimal virt-who version is $minimal_version"
|
80
|
+
return 1
|
81
|
+
else
|
82
|
+
return 0
|
83
|
+
fi
|
84
|
+
}
|
85
|
+
|
86
|
+
result_code=#{error_code(:success)}
|
87
|
+
|
88
|
+
compose_install_command() {
|
89
|
+
$1 packages unlock
|
90
|
+
$1 advanced procedure run packages-install --packages virt-who --assumeyes || result_code=$(($result_code|#{error_code(:virt_who_installation)}))
|
91
|
+
$1 packages lock
|
92
|
+
}
|
93
|
+
|
94
|
+
install_virt_who() {
|
95
|
+
if `rpm -q satellite-maintain > /dev/null`; then
|
96
|
+
compose_install_command satellite-maintain
|
97
|
+
elif `rpm -q rubygem-foreman_maintain > /dev/null`; then
|
98
|
+
compose_install_command foreman-maintain
|
99
|
+
else
|
100
|
+
yum install -y virt-who || result_code=$(($result_code|#{error_code(:virt_who_installation)}))
|
101
|
+
fi
|
102
|
+
}
|
103
|
+
|
104
|
+
step 1 "Installing virt-who"
|
105
|
+
install_virt_who
|
106
|
+
|
107
|
+
if verify_minimal_version; then
|
108
|
+
step 2 "Encrypting password"
|
109
|
+
cr_password=$(virt-who-password --password $(echo #{cr_password_base64}|base64 -d) 2> /dev/null)
|
110
|
+
user_password=$(virt-who-password --password '#{service_user_password}' 2> /dev/null)
|
111
|
+
|
112
|
+
step 3 "Creating virt-who configuration"
|
113
|
+
cat > #{config_file_path} << EOF
|
114
|
+
### This configuration file is managed via the virt-who configure plugin
|
115
|
+
### manual edits will be deleted.
|
116
|
+
[#{identifier}]
|
117
|
+
type=#{type}
|
118
|
+
hypervisor_id=#{hypervisor_id}
|
119
|
+
owner=#{owner}
|
120
|
+
#{connection_details}#{filtering}
|
121
|
+
rhsm_hostname=#{satellite_url}
|
122
|
+
rhsm_username=#{service_user_username}
|
123
|
+
rhsm_encrypted_password=$user_password
|
124
|
+
rhsm_prefix=/rhsm#{kubeconfig}#{ahv_config_options}
|
125
|
+
EOF
|
126
|
+
if [ $? -ne 0 ]; then result_code=$(($result_code|#{error_code(:virt_who_config_file_issue)})); fi
|
127
|
+
|
128
|
+
step 4 "Creating sysconfig virt-who configuration"
|
129
|
+
cat > #{default_config_path} << EOF
|
130
|
+
### This configuration file is managed via the virt-who configure plugin
|
131
|
+
### manual edits will be deleted.
|
132
|
+
[global]
|
133
|
+
debug=#{config.debug? ? 1 : 0}
|
134
|
+
interval=#{config.interval * 60}#{proxy_strings}
|
135
|
+
oneshot=False
|
136
|
+
EOF
|
137
|
+
if [ $? -ne 0 ]; then result_code=$(($result_code|#{error_code(:virt_who_sysconfig_file_issue)})); fi
|
138
|
+
|
139
|
+
step 5 "Enabling and restarting the virt-who service"
|
140
|
+
systemctl enable virt-who || result_code=$(($result_code|#{error_code(:virt_who_systemctl_issue)}))
|
141
|
+
systemctl restart virt-who || result_code=$(($result_code|#{error_code(:virt_who_service_issue)}))
|
142
|
+
else
|
143
|
+
result_code=$(($result_code|#{error_code(:virt_who_too_old)}))
|
144
|
+
fi
|
145
|
+
|
146
|
+
heading "Finished"
|
147
|
+
if [ $result_code -ne 0 ]; then
|
148
|
+
echo "There were some errors during configuration:"
|
149
|
+
#{error_handling}
|
150
|
+
else
|
151
|
+
echo "Finished successfully"
|
152
|
+
fi
|
153
|
+
|
154
|
+
SCRIPT
|
155
155
|
result += "exit $result_code\n" if format == :bash_script
|
156
156
|
result
|
157
157
|
end
|
@@ -198,7 +198,7 @@ encrypted_password=$cr_password"
|
|
198
198
|
end
|
199
199
|
|
200
200
|
def enabled_filters(filter)
|
201
|
-
filter.reject { |_, list| list.blank? }.map { |
|
201
|
+
filter.reject { |_, list| list.blank? }.map { |f, list| filtering_line_sanitized(f, list) }.join
|
202
202
|
end
|
203
203
|
|
204
204
|
def filtering_line_sanitized(filter, list)
|
@@ -245,9 +245,9 @@ encrypted_password=$cr_password"
|
|
245
245
|
def cr_password
|
246
246
|
case config.hypervisor_type
|
247
247
|
when 'libvirt'
|
248
|
-
config.hypervisor_password.
|
248
|
+
config.hypervisor_password.presence || LIBVIRT_FAKE_PASSWORD
|
249
249
|
when 'kubevirt'
|
250
|
-
config.hypervisor_password.
|
250
|
+
config.hypervisor_password.presence || KUBEVIRT_FAKE_PASSWORD
|
251
251
|
else
|
252
252
|
config.hypervisor_password
|
253
253
|
end
|
@@ -289,7 +289,7 @@ encrypted_password=$cr_password"
|
|
289
289
|
output = ''
|
290
290
|
output << "\n#{proxy_type}=#{sanitize_proxy(proxy.full_url)}" if proxy.present?
|
291
291
|
output << "\nno_proxy=#{sanitize_proxy(no_proxy)}" if no_proxy.present?
|
292
|
-
output << "\nno_proxy=*" if
|
292
|
+
output << "\nno_proxy=*" if proxy.blank? && no_proxy.blank?
|
293
293
|
output
|
294
294
|
end
|
295
295
|
|
@@ -1,22 +1,22 @@
|
|
1
1
|
module ForemanVirtWhoConfigure
|
2
2
|
# holds the encrypted password for internal user that can be deployed to virt who reporter
|
3
|
-
class ServiceUser <
|
3
|
+
class ServiceUser < ApplicationRecord
|
4
4
|
include Authorizable
|
5
5
|
include Encryptable
|
6
6
|
encrypts :encrypted_password
|
7
7
|
|
8
8
|
belongs_to :user
|
9
|
-
|
9
|
+
has_many :configs, :inverse_of => :service_user
|
10
10
|
|
11
11
|
# Foreman 1.11 specifics, can be removed later, otherwise when string does not start with "encrypts" prefix
|
12
12
|
# we get 500 when we try to create log message that relies on name method
|
13
13
|
def name
|
14
|
-
|
14
|
+
username || to_s
|
15
15
|
end
|
16
16
|
|
17
17
|
def username
|
18
18
|
User.as_anonymous_admin do
|
19
|
-
|
19
|
+
user&.login
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -6,7 +6,7 @@ module SSO
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def current_user
|
9
|
-
User.unscoped.where(:auth_source_id => ForemanVirtWhoConfigure::AuthSourceHiddenWithAuthentication.default.id).find_by_login(
|
9
|
+
User.unscoped.where(:auth_source_id => ForemanVirtWhoConfigure::AuthSourceHiddenWithAuthentication.default.id).find_by_login(user)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# For testing and CI
|
2
|
+
|
3
|
+
default: &default
|
4
|
+
adapter: postgresql
|
5
|
+
username: <%= ENV['PGUSER'] || 'foreman' %>
|
6
|
+
password: foreman
|
7
|
+
host: <%= ENV['PGHOST'] || 'localhost' %>
|
8
|
+
|
9
|
+
test:
|
10
|
+
<<: *default
|
11
|
+
database: foreman-test
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: foreman-dev
|
15
|
+
production:
|
16
|
+
<<: *default
|
17
|
+
database: foreman-prod
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class AddOrganizationIdToServiceUser < ActiveRecord::Migration[6.1]
|
2
|
+
def up
|
3
|
+
add_column :foreman_virt_who_configure_service_users, :organization_id, :integer
|
4
|
+
|
5
|
+
::ForemanVirtWhoConfigure::Config.find_each do |config|
|
6
|
+
service_user = ::ForemanVirtWhoConfigure::ServiceUser.find_by(organization_id: config.organization_id)
|
7
|
+
if service_user.present?
|
8
|
+
config.update_columns(service_user_id: service_user.id)
|
9
|
+
next
|
10
|
+
end
|
11
|
+
|
12
|
+
cfg_service_user = ::ForemanVirtWhoConfigure::ServiceUser.find_by(id: config.service_user_id)
|
13
|
+
cfg_service_user.update_columns(organization_id: config.organization_id)
|
14
|
+
end
|
15
|
+
|
16
|
+
::ForemanVirtWhoConfigure::ServiceUser.where(organization_id: nil).destroy_all
|
17
|
+
end
|
18
|
+
|
19
|
+
def down
|
20
|
+
remove_column :foreman_virt_who_configure_service_users, :organization_id, :integer
|
21
|
+
end
|
22
|
+
end
|
@@ -45,7 +45,7 @@ module ForemanVirtWhoConfigure
|
|
45
45
|
:'foreman_virt_who_configure/api/v2/configs' => [:destroy] }, permission_options
|
46
46
|
end
|
47
47
|
|
48
|
-
reporter_permissions = [
|
48
|
+
reporter_permissions = [:create_hosts, :edit_hosts, :view_lifecycle_environments, :my_organizations]
|
49
49
|
begin
|
50
50
|
if Permission.where(:name => ['create_content_hosts', 'edit_content_hosts']).count > 0
|
51
51
|
# old Katello permissions detected (6.2 era)
|
@@ -61,19 +61,19 @@ module ForemanVirtWhoConfigure
|
|
61
61
|
# could not configure role, some permissions are missing
|
62
62
|
end
|
63
63
|
|
64
|
-
role 'Virt-who Manager',
|
64
|
+
role 'Virt-who Manager', [:view_virt_who_config, :create_virt_who_config, :edit_virt_who_config, :destroy_virt_who_config], 'Role granting all permissions to manage virt-who configurations, user needs this role to create, delete or update configurations.'
|
65
65
|
|
66
|
-
role 'Virt-who Viewer',
|
66
|
+
role 'Virt-who Viewer', [:view_virt_who_config], 'Role granting permissions to see all configurations including their configuration scripts, which means viewers could still deploy the virt-who instances for existing virt-who configurations.'
|
67
67
|
|
68
68
|
# Available since Foreman 1.15
|
69
69
|
add_all_permissions_to_default_roles if respond_to?(:add_all_permissions_to_default_roles)
|
70
70
|
|
71
71
|
# add menu entry
|
72
72
|
menu :top_menu, :virt_who_configs,
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
url_hash: { controller: 'foreman_virt_who_configure/configs', action: :index },
|
74
|
+
caption: N_('Virt-who configurations'),
|
75
|
+
parent: :infrastructure_menu,
|
76
|
+
after: :compute_resources
|
77
77
|
|
78
78
|
# add dashboard widget
|
79
79
|
widget 'foreman_virt_who_configs_status_widget', :name => N_('Virt-who Configs Status'), sizex: 6, sizey: 1
|
@@ -103,7 +103,7 @@ module ForemanVirtWhoConfigure
|
|
103
103
|
# Include concerns in this config.to_prepare block
|
104
104
|
config.to_prepare do
|
105
105
|
SSO::METHODS.unshift SSO::BasicWithHidden
|
106
|
-
::Organization.
|
106
|
+
::Organization.include VirtWhoTaxonomyExtensions
|
107
107
|
end
|
108
108
|
|
109
109
|
rake_tasks do
|
data/locale/Makefile
CHANGED
@@ -43,7 +43,7 @@ uniq-po:
|
|
43
43
|
done
|
44
44
|
|
45
45
|
tx-pull: $(EDITFILES)
|
46
|
-
cd .. && tx pull -f
|
46
|
+
cd .. && tx pull -f --all
|
47
47
|
for f in $(EDITFILES) ; do \
|
48
48
|
sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
|
49
49
|
done
|
@@ -55,9 +55,7 @@ tx-update: tx-pull
|
|
55
55
|
@echo then run make -C locale mo-files to finish
|
56
56
|
@echo
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
mo-files: build-mo-files
|
58
|
+
mo-files: $(MOFILES)
|
61
59
|
git add $(POFILES) $(POTFILE) $(JSFILES) ../locale/*/LC_MESSAGES
|
62
60
|
git commit -m "i18n - pulling from tx"
|
63
61
|
@echo
|
Binary file
|