foreman_wreckingball 4.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/Rakefile +2 -2
- data/app/controllers/foreman_wreckingball/hosts_controller.rb +30 -13
- data/app/helpers/{concerns/foreman_wreckingball/hosts_helper_extensions.rb → foreman_wreckingball/hosts_helper.rb} +1 -1
- data/app/helpers/foreman_wreckingball/hypervisors_helper.rb +2 -1
- data/app/helpers/foreman_wreckingball/statuses_helper.rb +9 -7
- data/app/jobs/update_hosts_vmware_facets.rb +3 -2
- data/app/lib/actions/foreman_wreckingball/bulk_remediate.rb +4 -1
- data/app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb +3 -1
- data/app/lib/actions/foreman_wreckingball/host/remediate_spectre_v2.rb +3 -1
- data/app/lib/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem.rb +14 -10
- data/app/lib/actions/foreman_wreckingball/vmware/schedule_vmware_sync.rb +1 -1
- data/app/lib/actions/foreman_wreckingball/vmware/sync_compute_resource.rb +2 -2
- data/app/lib/fog_extensions/foreman_wreckingball/vsphere/host.rb +2 -0
- data/app/lib/fog_extensions/foreman_wreckingball/vsphere/mock.rb +3 -1
- data/app/lib/fog_extensions/foreman_wreckingball/vsphere/real.rb +7 -2
- data/app/lib/fog_extensions/foreman_wreckingball/vsphere/server.rb +2 -0
- data/app/lib/vsphere_os_identifiers/data.yaml +7 -0
- data/app/models/concerns/foreman_wreckingball/compute_resource_extensions.rb +11 -5
- data/app/models/concerns/foreman_wreckingball/host_extensions.rb +9 -4
- data/app/models/concerns/foreman_wreckingball/vmware_facet_host_extensions.rb +42 -11
- data/app/models/concerns/foreman_wreckingball/vmware_hypervisor_facet_host_extensions.rb +6 -2
- data/app/models/foreman_wreckingball/cpu_hot_add_status.rb +1 -1
- data/app/models/foreman_wreckingball/hardware_version_status.rb +1 -1
- data/app/models/foreman_wreckingball/operatingsystem_status.rb +2 -0
- data/app/models/foreman_wreckingball/spectre_v2_status.rb +2 -2
- data/app/models/foreman_wreckingball/vmware_cluster.rb +14 -13
- data/app/models/foreman_wreckingball/vmware_facet.rb +18 -12
- data/app/models/foreman_wreckingball/vmware_hypervisor_facet.rb +3 -1
- data/app/services/foreman_wreckingball/vmware_cluster_importer.rb +7 -4
- data/app/services/foreman_wreckingball/vmware_hypervisor_importer.rb +44 -41
- data/app/views/foreman_wreckingball/hosts/_hosts.json.rabl +2 -2
- data/app/views/foreman_wreckingball/hosts/status_hosts.json.rabl +4 -4
- data/config/environments/production.rb +1 -1
- data/config/routes.rb +3 -2
- data/db/migrate/20181021111543_add_indexes_to_vmware_hypervisor_facets.rb +1 -1
- data/db/migrate/20240201094513_fix_wreckingball_settings_category_to_dsl.rb +13 -0
- data/lib/foreman_wreckingball/engine.rb +79 -87
- data/lib/foreman_wreckingball/scheduled_jobs.rb +1 -1
- data/lib/foreman_wreckingball/version.rb +1 -1
- data/lib/tasks/foreman_vmware_checks_tasks.rake +1 -21
- data/test/actions/foreman_wreckingball/bulk_remediate_test.rb +0 -1
- data/test/actions/foreman_wreckingball/host/refresh_vmware_facet_test.rb +6 -7
- data/test/actions/foreman_wreckingball/host/remediate_hardware_version_test.rb +6 -7
- data/test/actions/foreman_wreckingball/host/remediate_spectre_v2_test.rb +6 -7
- data/test/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem_test.rb +8 -9
- data/test/actions/foreman_wreckingball/vmware/sync_compute_resource_test.rb +2 -2
- data/test/controllers/compute_resources_controller_test.rb +2 -2
- data/test/controllers/foreman_wreckingball/hosts_controller_test.rb +19 -18
- data/test/factories/foreman_wreckingball_factories.rb +10 -10
- data/test/integration/hosts_status_dashboard_test.rb +0 -4
- data/test/integration/hosts_status_managed_hosts_test.rb +4 -5
- data/test/models/compute_resources/vmware_test.rb +1 -1
- data/test/models/foreman_wreckingball/cpu_hot_add_status_test.rb +2 -2
- data/test/models/foreman_wreckingball/hardware_version_status_test.rb +3 -4
- data/test/models/foreman_wreckingball/operatingsystem_status_test.rb +5 -5
- data/test/models/foreman_wreckingball/spectre_v2_status_test.rb +4 -4
- data/test/models/foreman_wreckingball/tools_status_test.rb +2 -2
- data/test/models/foreman_wreckingball/vmware_facet_test.rb +10 -10
- data/test/models/foreman_wreckingball/vmware_hypervisor_facet_test.rb +4 -4
- data/test/models/host_test.rb +54 -52
- data/test/test_plugin_helper.rb +1 -1
- data/test/unit/foreman_wreckingball/access_permissions_test.rb +18 -0
- data/test/unit/foreman_wreckingball/vmware_cluster_importer_test.rb +6 -6
- data/test/unit/foreman_wreckingball/vmware_hypervisor_importer_test.rb +4 -4
- metadata +56 -40
- data/app/models/setting/wreckingball.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bde7fe1aee80e0de8f3d9afcfcde63556f093c740f20938508c36e52aca0fa7f
|
4
|
+
data.tar.gz: 4055b53d1655946d1073ed9dc54f0ff928573857ded8f01b35d7a08e79aecb93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3325f265c70db7c202a648d6f5af9283a200515c267e0efa40cd84f6d8f93cf4c163df961cb502a5228cbb9fded5277f915d819f398b0bce1640ecbe6503505
|
7
|
+
data.tar.gz: 7a1b0093c759f3572bb04a11018d3730cf07129c24a92f0c46bc4dffaad2bca618c615a8c4fc32d6fb1f2b8d26c8b6896c716fde2d884ef9d466eabf25095918
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ForemanWreckingball
|
2
2
|
|
3
|
-
[<img src="https://
|
3
|
+
[<img src="https://raw.githubusercontent.com/dm-drogeriemarkt/.github/refs/heads/main/assets/dmtech-open-source-badge.svg">](https://www.dmtech.de/)
|
4
4
|
|
5
5
|
This is a plugin for Foreman that adds several VMware related status checks to your Hosts in Foreman. For performance reasons, these checks are only run periodically.
|
6
6
|
|
@@ -13,6 +13,8 @@ This is a plugin for Foreman that adds several VMware related status checks to y
|
|
13
13
|
| >= 1.17 | ~> 2.0 |
|
14
14
|
| >= 1.21 | ~> 3.0 |
|
15
15
|
| >= 2.3 | ~> 4.0 |
|
16
|
+
| >= 3.9 | ~> 5.0 |
|
17
|
+
| >= 3.13 | ~> 6.0 |
|
16
18
|
|
17
19
|
## Installation
|
18
20
|
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
APP_RAKEFILE = File.expand_path('
|
23
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
24
24
|
|
25
25
|
Bundler::GemHelper.install_tasks
|
26
26
|
|
@@ -38,7 +38,7 @@ task default: :test
|
|
38
38
|
begin
|
39
39
|
require 'rubocop/rake_task'
|
40
40
|
RuboCop::RakeTask.new
|
41
|
-
rescue
|
41
|
+
rescue LoadError
|
42
42
|
puts 'Rubocop not loaded.'
|
43
43
|
end
|
44
44
|
|
@@ -7,13 +7,16 @@ module ForemanWreckingball
|
|
7
7
|
include ::AuthorizeHelper
|
8
8
|
|
9
9
|
AJAX_REQUESTS = [:status_hosts].freeze
|
10
|
-
before_action :ajax_request, :
|
11
|
-
before_action :find_statuses, :
|
10
|
+
before_action :ajax_request, only: AJAX_REQUESTS
|
11
|
+
before_action :find_statuses, only: %i[schedule_remediate submit_remediate]
|
12
12
|
|
13
|
+
# rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
13
14
|
def status_dashboard
|
14
15
|
@newest_data = Host.authorized(:view_hosts).joins(:vmware_facet).maximum('vmware_facets.updated_at')
|
15
16
|
host_ids = Host.authorized(:view_hosts)
|
16
|
-
.try
|
17
|
+
.try do |query|
|
18
|
+
params[:owned_only] ? query.owned_by_current_user_or_group_with_current_user : query
|
19
|
+
end
|
17
20
|
.pluck(:id)
|
18
21
|
|
19
22
|
@data = HostStatus.wreckingball_statuses.map do |status|
|
@@ -31,18 +34,20 @@ module ForemanWreckingball
|
|
31
34
|
counter: {
|
32
35
|
ok: counter[HostStatus::Global::OK] || 0,
|
33
36
|
warning: counter[HostStatus::Global::WARN] || 0,
|
34
|
-
critical: counter[HostStatus::Global::ERROR] || 0
|
35
|
-
}
|
37
|
+
critical: counter[HostStatus::Global::ERROR] || 0,
|
38
|
+
},
|
36
39
|
}
|
37
40
|
end
|
38
41
|
end
|
42
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
39
43
|
|
44
|
+
# rubocop:todo Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
40
45
|
def status_managed_hosts_dashboard
|
41
46
|
vmware_compute_resources = Foreman::Model::Vmware.unscoped.all
|
42
47
|
|
43
48
|
@errors = {}
|
44
49
|
|
45
|
-
# NOTE The call to ComputeResource#vms may slow things down
|
50
|
+
# NOTE: The call to ComputeResource#vms may slow things down
|
46
51
|
vms_by_compute_resource_id = vmware_compute_resources.each_with_object({}) do |cr, memo|
|
47
52
|
memo[cr.id] = cr.vms.all
|
48
53
|
rescue StandardError => e
|
@@ -68,7 +73,6 @@ module ForemanWreckingball
|
|
68
73
|
.where(compute_resource: vmware_compute_resources)
|
69
74
|
.try { |query| params[:owned_only] ? query.owned_by_current_user_or_group_with_current_user : query }
|
70
75
|
.each do |host|
|
71
|
-
|
72
76
|
compute_resources = @vm_compute_resource_mapping[host.uuid]
|
73
77
|
|
74
78
|
if compute_resources.empty?
|
@@ -86,15 +90,20 @@ module ForemanWreckingball
|
|
86
90
|
@compute_resource_authorizer = Authorizer.new(User.current, collection: vmware_compute_resources)
|
87
91
|
@host_authorizer = Authorizer.new(User.current)
|
88
92
|
end
|
93
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
89
94
|
|
90
95
|
# ajax method
|
96
|
+
# rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
91
97
|
def status_hosts
|
92
98
|
@status = HostStatus.find_wreckingball_status_by_host_association(params.fetch(:status))
|
93
99
|
|
94
100
|
all_hosts = Host.authorized(:view_hosts, Host)
|
95
101
|
.joins(@status.host_association)
|
96
|
-
.try
|
97
|
-
|
102
|
+
.try do |query|
|
103
|
+
params[:owned_only] ? query.owned_by_current_user_or_group_with_current_user : query
|
104
|
+
end
|
105
|
+
.includes([*(:environment if Host::Managed.reflect_on_environment?), @status.host_association,
|
106
|
+
:vmware_facet])
|
98
107
|
.where.not('host_status.status': @status.global_ok_list)
|
99
108
|
.preload(:owner)
|
100
109
|
.order(:name)
|
@@ -105,12 +114,14 @@ module ForemanWreckingball
|
|
105
114
|
respond_to do |format|
|
106
115
|
format.json do
|
107
116
|
Rabl::Renderer.json(@hosts, 'foreman_wreckingball/hosts/status_hosts',
|
108
|
-
|
109
|
-
|
117
|
+
view_path: "#{ForemanWreckingball::Engine.root}/app/views",
|
118
|
+
scope: self)
|
110
119
|
end
|
111
120
|
end
|
112
121
|
end
|
122
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
113
123
|
|
124
|
+
# rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
114
125
|
def refresh_status_dashboard
|
115
126
|
if ForemanTasks::Task.active.where(label: ::Actions::ForemanWreckingball::Vmware::ScheduleVmwareSync.to_s).empty?
|
116
127
|
flash[:success] = _('Refresh Compute Resource data task was successfully scheduled.')
|
@@ -119,15 +130,18 @@ module ForemanWreckingball
|
|
119
130
|
end
|
120
131
|
redirect_to(foreman_tasks_task_path(task.id))
|
121
132
|
else
|
122
|
-
flash[:warning] =
|
133
|
+
flash[:warning] =
|
134
|
+
_('Refresh Compute Resource data task is already running. Please wait for the running task to finish.')
|
123
135
|
redirect_to status_dashboard_hosts_path
|
124
136
|
end
|
125
137
|
end
|
138
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
126
139
|
|
127
140
|
def schedule_remediate
|
128
141
|
@triggering = ForemanTasks::Triggering.new(mode: :immediate)
|
129
142
|
end
|
130
143
|
|
144
|
+
# rubocop:todo Metrics/MethodLength
|
131
145
|
def submit_remediate
|
132
146
|
return not_found unless @statuses.any?
|
133
147
|
|
@@ -145,6 +159,7 @@ module ForemanWreckingball
|
|
145
159
|
|
146
160
|
redirect_to foreman_tasks_task_path(task.id)
|
147
161
|
end
|
162
|
+
# rubocop:enable Metrics/MethodLength
|
148
163
|
|
149
164
|
private
|
150
165
|
|
@@ -158,6 +173,7 @@ module ForemanWreckingball
|
|
158
173
|
@statuses_params ||= params.permit(:host_association, :owned_only, status_ids: [])
|
159
174
|
end
|
160
175
|
|
176
|
+
# rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
161
177
|
def find_statuses
|
162
178
|
@statuses = begin
|
163
179
|
host_association = statuses_params[:host_association]
|
@@ -166,7 +182,7 @@ module ForemanWreckingball
|
|
166
182
|
Host.authorized(:remediate_vmware_status_hosts, Host)
|
167
183
|
.joins(status_class.host_association)
|
168
184
|
.includes(status_class.host_association)
|
169
|
-
.try { |query| statuses_params[:owned_only] ? query.owned_by_current_user_or_group_with_current_user : query }
|
185
|
+
.try { |query| statuses_params[:owned_only] ? query.owned_by_current_user_or_group_with_current_user : query } # rubocop:disable Layout/LineLength
|
170
186
|
.where.not('host_status.status': status_class.global_ok_list)
|
171
187
|
.map { |host| host.send(status_class.host_association) }
|
172
188
|
else
|
@@ -176,6 +192,7 @@ module ForemanWreckingball
|
|
176
192
|
end
|
177
193
|
end
|
178
194
|
end
|
195
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
179
196
|
|
180
197
|
def action_permission
|
181
198
|
case params[:action]
|
@@ -8,7 +8,8 @@ module ForemanWreckingball
|
|
8
8
|
elsif vmware_hypervisor_facet.provides_spectre_features?
|
9
9
|
icon_text('ok', '', kind: 'pficon', title: _('CPU-Features are present on this host.'))
|
10
10
|
else
|
11
|
-
icon_text('error-circle-o', '', kind: 'pficon',
|
11
|
+
icon_text('error-circle-o', '', kind: 'pficon',
|
12
|
+
title: _('Required CPU features are missing. This host is most likely vulnerable.')) # rubocop:disable Layout/LineLength
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -2,20 +2,22 @@
|
|
2
2
|
|
3
3
|
module ForemanWreckingball
|
4
4
|
module StatusesHelper
|
5
|
+
# rubocop:todo Metrics/MethodLength
|
5
6
|
def status_actions(host_association, owned_only, supports_remediate)
|
6
7
|
actions = []
|
7
8
|
actions << display_link_if_authorized(_('Refresh'),
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
hash_for_refresh_status_dashboard_hosts_path,
|
10
|
+
title: _('Refresh Data'),
|
11
|
+
method: :put)
|
11
12
|
if supports_remediate
|
12
13
|
actions << display_link_if_authorized(_('Remediate All'),
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
hash_for_schedule_remediate_hosts_path,
|
15
|
+
'data-host-association': host_association,
|
16
|
+
'data-owned-only': owned_only,
|
17
|
+
onClick: 'show_modal(this); return false;')
|
17
18
|
end
|
18
19
|
actions.reject(&:blank?)
|
19
20
|
end
|
21
|
+
# rubocop:enable Metrics/MethodLength
|
20
22
|
end
|
21
23
|
end
|
@@ -6,7 +6,10 @@ module Actions
|
|
6
6
|
def plan(statuses)
|
7
7
|
sequence do
|
8
8
|
statuses.group_by(&:class).each do |statuses_klass, statuses_list|
|
9
|
-
|
9
|
+
if statuses_klass.respond_to?(:remediate_action)
|
10
|
+
plan_action(::Actions::BulkAction, statuses_klass.remediate_action,
|
11
|
+
statuses_list.map(&:host))
|
12
|
+
end
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
@@ -16,6 +16,7 @@ module Actions
|
|
16
16
|
plan_self
|
17
17
|
end
|
18
18
|
|
19
|
+
# rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
19
20
|
def run
|
20
21
|
host = ::Host.find(input[:host][:id])
|
21
22
|
|
@@ -29,7 +30,7 @@ module Actions
|
|
29
30
|
if initially_powered_on
|
30
31
|
vm.stop
|
31
32
|
vm.wait_for { power_state == 'poweredOff' }
|
32
|
-
|
33
|
+
raise _('Could not shut down VM.') if vm.ready?
|
33
34
|
end
|
34
35
|
|
35
36
|
vm.vm_upgrade_hardware
|
@@ -40,6 +41,7 @@ module Actions
|
|
40
41
|
ensure
|
41
42
|
vm.start if vm && initially_powered_on
|
42
43
|
end
|
44
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
43
45
|
|
44
46
|
def humanized_name
|
45
47
|
_('Upgrade VM Hardware Version')
|
@@ -16,6 +16,7 @@ module Actions
|
|
16
16
|
plan_self
|
17
17
|
end
|
18
18
|
|
19
|
+
# rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
19
20
|
def run
|
20
21
|
host = ::Host.find(input[:host][:id])
|
21
22
|
|
@@ -27,7 +28,7 @@ module Actions
|
|
27
28
|
if initially_powered_on
|
28
29
|
vm.stop
|
29
30
|
vm.wait_for { power_state == 'poweredOff' }
|
30
|
-
|
31
|
+
raise _('Could not shut down VM.') if vm.ready?
|
31
32
|
end
|
32
33
|
|
33
34
|
vm.start if vm && initially_powered_on
|
@@ -35,6 +36,7 @@ module Actions
|
|
35
36
|
state = host.refresh_vmware_facet!
|
36
37
|
output[:state] = state
|
37
38
|
end
|
39
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
38
40
|
|
39
41
|
def humanized_name
|
40
42
|
_('Power-Cycle VM')
|
@@ -16,11 +16,12 @@ module Actions
|
|
16
16
|
plan_self
|
17
17
|
end
|
18
18
|
|
19
|
+
# rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
19
20
|
def run
|
20
21
|
host = ::Host.find(input[:host][:id])
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
raise _('Foreman does not know the Architecture of this host.') unless host.architecture
|
24
|
+
raise _('Foreman does not know the Operatingsystem of this host.') unless host.operatingsystem
|
24
25
|
|
25
26
|
initially_powered_on = host.power.ready?
|
26
27
|
output[:initially_powered_on] = initially_powered_on
|
@@ -29,11 +30,11 @@ module Actions
|
|
29
30
|
current_os = VsphereOsIdentifiers.lookup(current_os_id)
|
30
31
|
|
31
32
|
selectors = {
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
33
|
+
architecture: host.architecture.name,
|
34
|
+
osfamily: host.operatingsystem.family,
|
35
|
+
name: host.operatingsystem.name,
|
36
|
+
major: host.operatingsystem.major.to_i,
|
37
|
+
release: host.facts['os::release::full'],
|
37
38
|
}
|
38
39
|
|
39
40
|
desired_os = VsphereOsIdentifiers.find_by(selectors)
|
@@ -43,9 +44,11 @@ module Actions
|
|
43
44
|
desired_os ||= VsphereOsIdentifiers.find_by(selectors.except(:major, :name))
|
44
45
|
desired_os ||= VsphereOsIdentifiers.find_by(selectors.except(:major, :name, :release))
|
45
46
|
|
46
|
-
|
47
|
+
raise _('Could not auto detect desired operatingsystem.') unless desired_os
|
47
48
|
|
48
|
-
|
49
|
+
if current_os == desired_os
|
50
|
+
raise _('VMs current and desired OS (%s) already match. No update necessary.') % current_os.description
|
51
|
+
end
|
49
52
|
|
50
53
|
output[:old_operatingsystem] = current_os.description
|
51
54
|
output[:old_operatingsystem_id] = current_os.id
|
@@ -57,7 +60,7 @@ module Actions
|
|
57
60
|
if initially_powered_on
|
58
61
|
vm.stop
|
59
62
|
vm.wait_for { power_state == 'poweredOff' }
|
60
|
-
|
63
|
+
raise _('Could not shut down VM.') if vm.ready?
|
61
64
|
end
|
62
65
|
|
63
66
|
vm.vm_reconfig_hardware('guestId' => desired_os.id)
|
@@ -67,6 +70,7 @@ module Actions
|
|
67
70
|
ensure
|
68
71
|
vm.start if vm && initially_powered_on
|
69
72
|
end
|
73
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
70
74
|
|
71
75
|
def humanized_name
|
72
76
|
_('Correct VM Operatingsystem')
|
@@ -5,7 +5,7 @@ module Actions
|
|
5
5
|
module Vmware
|
6
6
|
class ScheduleVmwareSync < Actions::EntryAction
|
7
7
|
def plan
|
8
|
-
compute_resources = ComputeResource.where(:
|
8
|
+
compute_resources = ComputeResource.where(type: 'Foreman::Model::Vmware')
|
9
9
|
sequence do
|
10
10
|
compute_resources.each do |compute_resource|
|
11
11
|
plan_action(::Actions::ForemanWreckingball::Vmware::SyncComputeResource, compute_resource)
|
@@ -14,11 +14,11 @@ module Actions
|
|
14
14
|
def run
|
15
15
|
compute_resource = ComputeResource.find(input[:compute_resource][:id])
|
16
16
|
::ForemanWreckingball::VmwareClusterImporter.new(
|
17
|
-
:
|
17
|
+
compute_resource: compute_resource
|
18
18
|
).import!
|
19
19
|
|
20
20
|
::ForemanWreckingball::VmwareHypervisorImporter.new(
|
21
|
-
:
|
21
|
+
compute_resource: compute_resource.reload
|
22
22
|
).import!
|
23
23
|
|
24
24
|
compute_resource.hosts.each(&:refresh_vmware_facet!)
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FogExtensions
|
2
4
|
module ForemanWreckingball
|
3
5
|
module Vsphere
|
4
6
|
module Mock
|
5
7
|
extend ActiveSupport::Concern
|
6
8
|
|
7
|
-
def vm_upgrade_hardware(
|
9
|
+
def vm_upgrade_hardware(*)
|
8
10
|
{ 'task_state' => 'success' }
|
9
11
|
end
|
10
12
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FogExtensions
|
2
4
|
module ForemanWreckingball
|
3
5
|
module Vsphere
|
@@ -12,7 +14,10 @@ module FogExtensions
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def list_hosts(filters = {})
|
15
|
-
super.map
|
17
|
+
super.map do |h|
|
18
|
+
h[:feature_capabilities] = h[:feature_capabilities].map(&:key)
|
19
|
+
h
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
@@ -20,7 +25,7 @@ module FogExtensions
|
|
20
25
|
prepend Overrides
|
21
26
|
end
|
22
27
|
|
23
|
-
def vm_upgrade_hardware(version: nil
|
28
|
+
def vm_upgrade_hardware(instance_uuid:, version: nil)
|
24
29
|
vm_mob_ref = get_vm_ref(instance_uuid)
|
25
30
|
task = vm_mob_ref.UpgradeVM_Task(version: version)
|
26
31
|
task.wait_for_completion
|
@@ -395,6 +395,13 @@ rhel8_64Guest:
|
|
395
395
|
:name: RedHat
|
396
396
|
:major: 8
|
397
397
|
:since: 6.5
|
398
|
+
rhel9_64Guest:
|
399
|
+
:description: Red Hat Enterprise Linux 9 (64-bit)
|
400
|
+
:architecture: x86_64
|
401
|
+
:osfamily: Redhat
|
402
|
+
:name: RedHat
|
403
|
+
:major: 9
|
404
|
+
:since: 7.0
|
398
405
|
sjdsGuest:
|
399
406
|
:description: Sun Java Desktop System
|
400
407
|
sles10Guest:
|
@@ -6,13 +6,19 @@ module ForemanWreckingball
|
|
6
6
|
include ForemanTasks::Concerns::ActionSubject
|
7
7
|
|
8
8
|
included do
|
9
|
-
has_many :vmware_clusters,
|
10
|
-
|
9
|
+
has_many :vmware_clusters,
|
10
|
+
class_name: 'ForemanWreckingball::VmwareCluster',
|
11
|
+
inverse_of: :compute_resource, dependent: :destroy
|
11
12
|
|
12
|
-
has_many :vmware_hypervisor_facets,
|
13
|
-
|
13
|
+
has_many :vmware_hypervisor_facets,
|
14
|
+
class_name: '::ForemanWreckingball::VmwareHypervisorFacet',
|
15
|
+
through: :vmware_clusters,
|
16
|
+
inverse_of: :compute_resource
|
14
17
|
|
15
|
-
has_many :hypervisor_hosts,
|
18
|
+
has_many :hypervisor_hosts,
|
19
|
+
class_name: 'Host::Managed',
|
20
|
+
through: :vmware_hypervisor_facets,
|
21
|
+
source: :host, inverse_of: :compute_resource
|
16
22
|
end
|
17
23
|
|
18
24
|
def action_input_key
|
@@ -7,15 +7,20 @@ module ForemanWreckingball
|
|
7
7
|
|
8
8
|
included do
|
9
9
|
ForemanWreckingball::Engine::WRECKINGBALL_STATUSES.map(&:constantize).each do |status|
|
10
|
-
has_one(
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
has_one(
|
11
|
+
status.host_association,
|
12
|
+
class_name: status.to_s,
|
13
|
+
foreign_key: 'host_id',
|
14
|
+
inverse_of: :host,
|
15
|
+
dependent: :destroy
|
16
|
+
)
|
14
17
|
end
|
15
18
|
|
19
|
+
# rubocop:disable Layout/LineLength
|
16
20
|
scope :owned_by_current_user, -> { where(owner_type: 'User', owner_id: User.current.id) }
|
17
21
|
scope :owned_by_group_with_current_user, -> { where(owner_type: 'Usergroup', owner_id: User.current.usergroup_ids_with_parents) }
|
18
22
|
scope :owned_by_current_user_or_group_with_current_user, -> { owned_by_current_user.or(owned_by_group_with_current_user) }
|
23
|
+
# rubocop:enable Layout/LineLength
|
19
24
|
|
20
25
|
def self.reflect_on_environment?
|
21
26
|
reflect_on_association(:environment).present?
|
@@ -4,21 +4,52 @@ module ForemanWreckingball
|
|
4
4
|
module VmwareFacetHostExtensions
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
+
# rubocop:disable Metrics/BlockLength
|
7
8
|
included do
|
8
|
-
has_one :vmware_facet,
|
9
|
+
has_one :vmware_facet,
|
10
|
+
class_name: '::ForemanWreckingball::VmwareFacet',
|
11
|
+
foreign_key: :host_id,
|
12
|
+
inverse_of: :host, dependent: :destroy
|
9
13
|
|
10
14
|
before_provision :queue_vmware_facet_refresh
|
11
15
|
|
12
|
-
scoped_search on: :hardware_version,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
scoped_search on: :
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
scoped_search on: :hardware_version,
|
17
|
+
relation: :vmware_facet,
|
18
|
+
rename: :vsphere_hardware_version,
|
19
|
+
complete_value: true,
|
20
|
+
only_explicit: true
|
21
|
+
scoped_search on: :guest_id,
|
22
|
+
relation: :vmware_facet,
|
23
|
+
rename: :vsphere_guest_id,
|
24
|
+
complete_value: true,
|
25
|
+
only_explicit: true
|
26
|
+
scoped_search on: :cpus,
|
27
|
+
relation: :vmware_facet,
|
28
|
+
rename: :vsphere_cpus,
|
29
|
+
complete_value: true,
|
30
|
+
only_explicit: true
|
31
|
+
scoped_search on: :corespersocket,
|
32
|
+
relation: :vmware_facet,
|
33
|
+
rename: :vsphere_corespersocket,
|
34
|
+
complete_value: true,
|
35
|
+
only_explicit: true
|
36
|
+
scoped_search on: :memory_mb,
|
37
|
+
relation: :vmware_facet,
|
38
|
+
rename: :vsphere_memory_mb,
|
39
|
+
complete_value: true,
|
40
|
+
only_explicit: true
|
41
|
+
scoped_search on: :power_state,
|
42
|
+
relation: :vmware_facet,
|
43
|
+
rename: :vsphere_power_state,
|
44
|
+
only_explicit: true,
|
45
|
+
complete_value: ForemanWreckingball::VmwareFacet::VALID_POWER_STATES.map { |status| [status, ForemanWreckingball::VmwareFacet.power_states[status]] }.to_h # rubocop:todo Rails/IndexWith, Layout/LineLength
|
46
|
+
scoped_search on: :tools_state,
|
47
|
+
relation: :vmware_facet,
|
48
|
+
rename: :vsphere_tools_state,
|
49
|
+
only_explicit: true,
|
50
|
+
complete_value: ForemanWreckingball::VmwareFacet::VALID_GUEST_STATUSES.map { |status| [status, ForemanWreckingball::VmwareFacet.tools_states[status]] }.to_h # rubocop:todo Rails/IndexWith, Layout/LineLength
|
21
51
|
end
|
52
|
+
# rubocop:enable Metrics/BlockLength
|
22
53
|
|
23
54
|
def refresh_vmware_facet!
|
24
55
|
facet = vmware_facet || build_vmware_facet
|
@@ -31,7 +62,7 @@ module ForemanWreckingball
|
|
31
62
|
User.as_anonymous_admin do
|
32
63
|
ForemanTasks.delay(
|
33
64
|
::Actions::ForemanWreckingball::Host::RefreshVmwareFacet,
|
34
|
-
{ :
|
65
|
+
{ start_at: Time.now.utc + 5.minutes },
|
35
66
|
self
|
36
67
|
)
|
37
68
|
end
|
@@ -5,8 +5,12 @@ module ForemanWreckingball
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
has_one :vmware_hypervisor_facet,
|
9
|
-
|
8
|
+
has_one :vmware_hypervisor_facet,
|
9
|
+
class_name: '::ForemanWreckingball::VmwareHypervisorFacet',
|
10
|
+
foreign_key: :host_id,
|
11
|
+
inverse_of: :host,
|
12
|
+
dependent: :destroy
|
13
|
+
has_one :vmware_cluster, through: :vmware_hypervisor_facet
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
@@ -14,7 +14,7 @@ module ForemanWreckingball
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.description
|
17
|
-
N_('Enabling CPU hot-add disables vNUMA, the virtual machine will instead use UMA. This might cause a performance degration.')
|
17
|
+
N_('Enabling CPU hot-add disables vNUMA, the virtual machine will instead use UMA. This might cause a performance degration.') # rubocop:disable Layout/LineLength
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.supports_remediate?
|