foreman_wreckingball 3.0.1 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/assets/javascripts/foreman_wreckingball/modal.js +26 -18
- data/app/assets/javascripts/foreman_wreckingball/status_hosts_table.js +81 -0
- data/app/assets/javascripts/foreman_wreckingball/status_managed_hosts_dashboard.js +14 -0
- data/app/assets/javascripts/foreman_wreckingball/status_row.js +17 -0
- data/app/assets/stylesheets/foreman_wreckingball/status_hosts_table.css.scss +13 -0
- data/app/assets/stylesheets/foreman_wreckingball/status_managed_hosts_dashboard.css.scss +8 -0
- data/app/controllers/foreman_wreckingball/hosts_controller.rb +143 -43
- data/app/helpers/concerns/foreman_wreckingball/hosts_helper_extensions.rb +0 -15
- data/app/helpers/foreman_wreckingball/statuses_helper.rb +21 -0
- data/app/lib/actions/foreman_wreckingball/bulk_remediate.rb +27 -0
- data/app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb +63 -0
- data/app/lib/actions/foreman_wreckingball/host/remediate_spectre_v2.rb +58 -0
- data/app/lib/fog_extensions/foreman_wreckingball/vsphere/mock.rb +13 -0
- data/app/lib/fog_extensions/foreman_wreckingball/vsphere/real.rb +7 -0
- data/app/lib/fog_extensions/foreman_wreckingball/vsphere/server.rb +14 -0
- data/app/models/concerns/foreman_wreckingball/host_extensions.rb +10 -20
- data/app/models/concerns/foreman_wreckingball/host_status_extensions.rb +13 -0
- data/app/models/concerns/foreman_wreckingball/user_extensions.rb +12 -0
- data/app/models/concerns/foreman_wreckingball/usergroup_extensions.rb +18 -0
- data/app/models/concerns/foreman_wreckingball/vmware_facet_host_extensions.rb +10 -0
- data/app/models/foreman_wreckingball/cpu_hot_add_status.rb +8 -0
- data/app/models/foreman_wreckingball/hardware_version_status.rb +70 -0
- data/app/models/foreman_wreckingball/operatingsystem_status.rb +8 -0
- data/app/models/foreman_wreckingball/spectre_v2_status.rb +19 -3
- data/app/models/foreman_wreckingball/tools_status.rb +9 -1
- data/app/models/foreman_wreckingball/vmware_facet.rb +9 -4
- data/app/models/foreman_wreckingball/vmware_hypervisor_facet.rb +4 -7
- data/app/models/setting/wreckingball.rb +22 -0
- data/app/services/foreman_wreckingball/vmware_cluster_importer.rb +7 -7
- data/app/services/foreman_wreckingball/vmware_hypervisor_importer.rb +17 -4
- data/app/views/foreman_wreckingball/hosts/_hosts.json.rabl +35 -0
- data/app/views/foreman_wreckingball/hosts/_status_dashboard_content.erb +13 -23
- data/app/views/foreman_wreckingball/hosts/_status_managed_hosts_dashboard_cards.html.erb +16 -0
- data/app/views/foreman_wreckingball/hosts/_status_managed_hosts_dashboard_cards_card.html.erb +11 -0
- data/app/views/foreman_wreckingball/hosts/_status_row.html.erb +16 -55
- data/app/views/foreman_wreckingball/hosts/_status_row_actions.html.erb +22 -0
- data/app/views/foreman_wreckingball/hosts/_status_row_hosts_table.html.erb +24 -0
- data/app/views/foreman_wreckingball/hosts/_status_row_hosts_table_actions.html.erb +9 -0
- data/app/views/foreman_wreckingball/hosts/schedule_remediate.html.erb +44 -26
- data/app/views/foreman_wreckingball/hosts/status_dashboard.html.erb +9 -6
- data/app/views/foreman_wreckingball/hosts/status_hosts.json.rabl +13 -0
- data/app/views/foreman_wreckingball/hosts/status_managed_hosts_dashboard.html.erb +142 -0
- data/config/environments/production.rb +7 -0
- data/config/routes.rb +4 -4
- data/db/migrate/20181020174609_add_power_state_to_vmware_facets.rb +7 -0
- data/db/migrate/20181021111543_add_indexes_to_vmware_hypervisor_facets.rb +8 -0
- data/lib/foreman_wreckingball/engine.rb +71 -23
- data/lib/foreman_wreckingball/version.rb +1 -1
- data/lib/tasks/foreman_vmware_checks_tasks.rake +1 -1
- data/test/actions/foreman_wreckingball/bulk_remediate_test.rb +31 -0
- data/test/actions/foreman_wreckingball/host/refresh_vmware_facet_test.rb +5 -4
- data/test/actions/foreman_wreckingball/host/remediate_hardware_version_test.rb +63 -0
- data/test/actions/foreman_wreckingball/host/remediate_spectre_v2_test.rb +62 -0
- data/test/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem_test.rb +4 -2
- data/test/controllers/foreman_wreckingball/hosts_controller_test.rb +278 -39
- data/test/factories/compute_resource.rb +6 -1
- data/test/factories/foreman_wreckingball_factories.rb +166 -115
- data/test/factories/host.rb +16 -0
- data/test/factories/task.rb +17 -0
- data/test/helpers/foreman_wreckingball/status_helper.rb +10 -0
- data/test/integration/hosts_status_dashboard_test.rb +50 -0
- data/test/integration/hosts_status_managed_hosts_test.rb +105 -0
- data/test/integration_test_plugin_helper.rb +13 -0
- data/test/models/foreman_wreckingball/hardware_version_status_test.rb +88 -0
- data/test/models/foreman_wreckingball/tools_status_test.rb +5 -2
- data/test/models/foreman_wreckingball/vmware_facet_test.rb +27 -6
- data/test/models/host_status_test.rb +22 -0
- data/test/models/host_test.rb +64 -4
- data/test/models/usergroup_test.rb +25 -0
- data/test/test_plugin_helper.rb +19 -0
- data/test/unit/foreman_wreckingball/vmware_cluster_importer_test.rb +17 -2
- data/test/unit/foreman_wreckingball/vmware_hypervisor_importer_test.rb +11 -0
- metadata +55 -8
- data/app/services/foreman_wreckingball/debris_collector.rb +0 -249
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'integration_test_helper'
|
4
|
+
|
5
|
+
require 'webmock/minitest'
|
6
|
+
require 'webmock'
|
7
|
+
|
8
|
+
# Add plugin to FactoryBot's paths
|
9
|
+
FactoryBot.definition_file_paths << File.join(ForemanTasks::Engine.root, 'test', 'factories')
|
10
|
+
FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
|
11
|
+
FactoryBot.reload
|
12
|
+
|
13
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
module ForemanWreckingball
|
6
|
+
class HardwareVersionStatusTest < ActiveSupport::TestCase
|
7
|
+
setup do
|
8
|
+
User.current = users(:admin)
|
9
|
+
Setting::Wreckingball.load_defaults
|
10
|
+
end
|
11
|
+
|
12
|
+
should belong_to(:host)
|
13
|
+
|
14
|
+
let(:host) do
|
15
|
+
FactoryBot.create(
|
16
|
+
:host,
|
17
|
+
:managed,
|
18
|
+
:with_vmware_facet
|
19
|
+
)
|
20
|
+
end
|
21
|
+
let(:status) { ForemanWreckingball::HardwareVersionStatus.new(host: host) }
|
22
|
+
|
23
|
+
test 'has a host association' do
|
24
|
+
status.save!
|
25
|
+
assert_equal status, host.public_send(status.class.host_association)
|
26
|
+
end
|
27
|
+
|
28
|
+
test '#relevant is only for hosts with a vmware facet' do
|
29
|
+
h = FactoryBot.build(:host, :managed)
|
30
|
+
refute ForemanWreckingball::ToolsStatus.new(host: h).relevant?
|
31
|
+
assert status.relevant?
|
32
|
+
end
|
33
|
+
|
34
|
+
test '#relevant is for hosts with a hardware version' do
|
35
|
+
assert status.relevant?
|
36
|
+
host.vmware_facet.hardware_version = nil
|
37
|
+
refute status.relevant?
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'status calculation' do
|
41
|
+
test 'is out of date when version is too old' do
|
42
|
+
status.host.vmware_facet.hardware_version = 'vmx-9'
|
43
|
+
assert_equal HardwareVersionStatus::OUTOFDATE, status.to_status
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'is ok when version is recent enough' do
|
47
|
+
status.host.vmware_facet.hardware_version = 'vmx-13'
|
48
|
+
assert_equal HardwareVersionStatus::OK, status.to_status
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'status labels' do
|
53
|
+
test 'when version is out of date' do
|
54
|
+
status.status = HardwareVersionStatus::OUTOFDATE
|
55
|
+
assert_equal 'Out of date', status.to_label
|
56
|
+
end
|
57
|
+
|
58
|
+
test 'when version is recent' do
|
59
|
+
status.status = HardwareVersionStatus::OK
|
60
|
+
assert_equal 'OK', status.to_label
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'global status' do
|
65
|
+
test 'is warning when version is out of date' do
|
66
|
+
status.status = HardwareVersionStatus::OUTOFDATE
|
67
|
+
assert_equal HostStatus::Global::WARN, status.to_global
|
68
|
+
end
|
69
|
+
|
70
|
+
test 'is ok when version is recent' do
|
71
|
+
status.status = HardwareVersionStatus::OK
|
72
|
+
assert_equal HostStatus::Global::OK, status.to_global
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#recent_hw_version?' do
|
77
|
+
test 'is true when hw version is new' do
|
78
|
+
status.host.vmware_facet.hardware_version = 'vmx-13'
|
79
|
+
assert status.recent_hw_version?
|
80
|
+
end
|
81
|
+
|
82
|
+
test 'is false when hw version is ancient' do
|
83
|
+
status.host.vmware_facet.hardware_version = 'vmx-3'
|
84
|
+
refute status.recent_hw_version?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -32,13 +32,16 @@ module ForemanWreckingball
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe 'status calculation' do
|
35
|
+
setup do
|
36
|
+
Host::Managed.any_instance.stubs(:supports_power?).returns(true)
|
37
|
+
end
|
38
|
+
|
35
39
|
test 'when host is powered down' do
|
36
|
-
|
40
|
+
host.vmware_facet.update(power_state: 'poweredOff')
|
37
41
|
assert_equal ForemanWreckingball::ToolsStatus::POWERDOWN, status.to_status
|
38
42
|
end
|
39
43
|
|
40
44
|
test 'when host is powered on' do
|
41
|
-
Host::Managed.any_instance.stubs(:supports_power_and_running?).returns(true)
|
42
45
|
assert_equal 2, status.to_status
|
43
46
|
end
|
44
47
|
end
|
@@ -8,6 +8,26 @@ module ForemanWreckingball
|
|
8
8
|
should belong_to(:vmware_cluster)
|
9
9
|
should have_many(:vmware_hypervisor_facets)
|
10
10
|
|
11
|
+
describe '#vm_ready?' do
|
12
|
+
let(:host) do
|
13
|
+
FactoryBot.create(
|
14
|
+
:host,
|
15
|
+
:managed,
|
16
|
+
:with_vmware_facet
|
17
|
+
)
|
18
|
+
end
|
19
|
+
let(:vmware_facet) { host.vmware_facet }
|
20
|
+
|
21
|
+
test 'is true when vm is powered on' do
|
22
|
+
assert_equal true, vmware_facet.vm_ready?
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'is false when vm is not powered on' do
|
26
|
+
vmware_facet.power_state = 'suspended'
|
27
|
+
assert_equal false, vmware_facet.vm_ready?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
11
31
|
describe '#refresh!' do
|
12
32
|
let(:uuid) { '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
|
13
33
|
let(:vm) do
|
@@ -25,7 +45,7 @@ module ForemanWreckingball
|
|
25
45
|
end
|
26
46
|
|
27
47
|
let(:compute_resource) do
|
28
|
-
cr = FactoryBot.create(:compute_resource, :vmware, :uuid => 'Solutions')
|
48
|
+
cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, :uuid => 'Solutions')
|
29
49
|
ComputeResource.find(cr.id)
|
30
50
|
end
|
31
51
|
|
@@ -42,12 +62,12 @@ module ForemanWreckingball
|
|
42
62
|
|
43
63
|
setup do
|
44
64
|
::Fog.mock!
|
45
|
-
::
|
65
|
+
::ForemanWreckingball.fog_vsphere_namespace::Mock.any_instance.stubs(:get_vm_ref).returns(vm)
|
46
66
|
# this is not stubbed correctly in fog-vsphere
|
47
|
-
::
|
48
|
-
::
|
49
|
-
::
|
50
|
-
::
|
67
|
+
::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
|
68
|
+
::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:hardware_version).returns('vmx-9')
|
69
|
+
::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:corespersocket).returns(1)
|
70
|
+
::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:power_state).returns('poweredOn')
|
51
71
|
end
|
52
72
|
teardown { ::Fog.unmock! }
|
53
73
|
|
@@ -58,6 +78,7 @@ module ForemanWreckingball
|
|
58
78
|
assert_equal 2196, vmware_facet.memory_mb
|
59
79
|
assert_equal 'rhel6_64Guest', vmware_facet.guest_id
|
60
80
|
assert_equal 'toolsOk', vmware_facet.tools_state
|
81
|
+
assert_equal 'poweredOn', vmware_facet.power_state
|
61
82
|
assert_equal false, vmware_facet.cpu_hot_add
|
62
83
|
assert_equal ['cpuid.SSE3', 'cpuid.AES', 'cpuid.Intel'], vmware_facet.cpu_features
|
63
84
|
assert_equal 'vmx-9', vmware_facet.hardware_version
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
class HostStatusTest < ActiveSupport::TestCase
|
6
|
+
describe '#wreckingball_statuses' do
|
7
|
+
test 'returns wreckingball statuses' do
|
8
|
+
expected = ForemanWreckingball::Engine::WRECKINGBALL_STATUSES.sort.map(&:constantize)
|
9
|
+
actual = HostStatus.wreckingball_statuses.sort_by(&:to_s)
|
10
|
+
assert_equal expected, actual
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#find_wreckingball_status_by_host_association' do
|
15
|
+
test 'returns expected wreckingball status' do
|
16
|
+
expected = ForemanWreckingball::Engine::WRECKINGBALL_STATUSES.first.constantize
|
17
|
+
actual = HostStatus.find_wreckingball_status_by_host_association(expected.host_association)
|
18
|
+
|
19
|
+
assert_equal expected, actual
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/models/host_test.rb
CHANGED
@@ -6,8 +6,68 @@ class Host::ManagedTest < ActiveSupport::TestCase
|
|
6
6
|
should have_one(:vmware_facet)
|
7
7
|
should have_one(:vmware_cluster)
|
8
8
|
should have_one(:vmware_hypervisor_facet)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
|
10
|
+
HostStatus.wreckingball_statuses.each do |status|
|
11
|
+
should have_one(status.host_association)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#owned_by_current_user_or_group_with_current_user' do
|
15
|
+
test 'returns only hosts owned by current user' do
|
16
|
+
usergroup_with_user = FactoryBot.create(:usergroup, users: [User.current], usergroups: [FactoryBot.create(:usergroup, users: [])])
|
17
|
+
|
18
|
+
FactoryBot.create :host, :managed, owner: FactoryBot.create(:user)
|
19
|
+
FactoryBot.create :host, :managed, owner: FactoryBot.create(:usergroup, users: [])
|
20
|
+
FactoryBot.create :host, :managed, owner: usergroup_with_user.usergroups.first
|
21
|
+
|
22
|
+
expected = [
|
23
|
+
FactoryBot.create(:host, :managed, owner: User.current),
|
24
|
+
FactoryBot.create(:host, :managed, owner: usergroup_with_user),
|
25
|
+
FactoryBot.create(:host, :managed, owner: FactoryBot.create(:usergroup, usergroups: [usergroup_with_user]))
|
26
|
+
]
|
27
|
+
actual = Host::Managed.owned_by_current_user_or_group_with_current_user.all
|
28
|
+
|
29
|
+
assert_same_elements expected, actual
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'scoped search' do
|
34
|
+
setup do
|
35
|
+
@host = FactoryBot.create(:host, :with_vmware_facet)
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'search by hardware_version' do
|
39
|
+
hosts = Host.search_for('vsphere_hardware_version = vmx-10')
|
40
|
+
assert_includes hosts, @host
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'search by power_state' do
|
44
|
+
hosts = Host.search_for('vsphere_power_state = poweredOn')
|
45
|
+
assert_includes hosts, @host
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'search by tools_state' do
|
49
|
+
hosts = Host.search_for('vsphere_tools_state = toolsOk')
|
50
|
+
assert_includes hosts, @host
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'search by guest_id' do
|
54
|
+
hosts = Host.search_for('vsphere_guest_id = rhel6_64Guest')
|
55
|
+
assert_includes hosts, @host
|
56
|
+
end
|
57
|
+
|
58
|
+
test 'search by cpus' do
|
59
|
+
hosts = Host.search_for('vsphere_cpus = 2')
|
60
|
+
assert_includes hosts, @host
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'search by corespersocket' do
|
64
|
+
hosts = Host.search_for('vsphere_corespersocket = 1')
|
65
|
+
assert_includes hosts, @host
|
66
|
+
end
|
67
|
+
|
68
|
+
test 'search by memory_mb' do
|
69
|
+
hosts = Host.search_for('vsphere_memory_mb = 8192')
|
70
|
+
assert_includes hosts, @host
|
71
|
+
end
|
72
|
+
end
|
13
73
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
class UsergroupTest < ActiveSupport::TestCase
|
6
|
+
describe '#parent_usergroup_ids' do
|
7
|
+
it 'returns the ids of all parents of a usergroup' do
|
8
|
+
child = FactoryBot.create(:usergroup)
|
9
|
+
|
10
|
+
subject = FactoryBot.create(:usergroup, usergroups: [child])
|
11
|
+
|
12
|
+
parent1 = FactoryBot.create(:usergroup, usergroups: [subject])
|
13
|
+
parent2 = FactoryBot.create(:usergroup, usergroups: [parent1])
|
14
|
+
parent3 = FactoryBot.create(:usergroup, usergroups: [parent1])
|
15
|
+
|
16
|
+
assert_equal subject.parent_usergroup_ids, [parent1, parent2, parent3].map(&:id)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns empty array if usergroup has no parents' do
|
20
|
+
subject = FactoryBot.create(:usergroup)
|
21
|
+
|
22
|
+
assert_equal subject.parent_usergroup_ids, []
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -2,8 +2,27 @@
|
|
2
2
|
|
3
3
|
# This calls the main test_helper in Foreman-core
|
4
4
|
require 'test_helper'
|
5
|
+
require 'database_cleaner'
|
5
6
|
require 'dynflow/testing'
|
6
7
|
|
8
|
+
Dir["#{__dir__}/helpers/foreman_wreckingball/**.rb"].each { |f| require f }
|
9
|
+
|
7
10
|
# Add plugin to FactoryBot's paths
|
11
|
+
FactoryBot.definition_file_paths << File.join(ForemanTasks::Engine.root, 'test', 'factories')
|
8
12
|
FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
|
9
13
|
FactoryBot.reload
|
14
|
+
|
15
|
+
# Foreman's setup doesn't handle cleaning in plugin
|
16
|
+
DatabaseCleaner.strategy = :transaction
|
17
|
+
|
18
|
+
module Minitest
|
19
|
+
class Spec
|
20
|
+
before :each do
|
21
|
+
DatabaseCleaner.start
|
22
|
+
end
|
23
|
+
|
24
|
+
after :each do
|
25
|
+
DatabaseCleaner.clean
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -26,10 +26,25 @@ module ForemanWreckingball
|
|
26
26
|
assert_includes clusters, 'Nested/Lastcluster'
|
27
27
|
end
|
28
28
|
|
29
|
-
test 'removes old clusters' do
|
30
|
-
old_cluster = FactoryBot.create(:vmware_cluster,
|
29
|
+
test 'removes old clusters without associated records' do
|
30
|
+
old_cluster = FactoryBot.create(:vmware_cluster,
|
31
|
+
:with_hosts,
|
32
|
+
:with_vmware_facets,
|
33
|
+
:with_vmware_hypervisor_facets,
|
34
|
+
compute_resource: compute_resource)
|
35
|
+
|
36
|
+
compute_resource_id = old_cluster.compute_resource.id
|
37
|
+
host_ids = old_cluster.hosts.pluck(:id)
|
38
|
+
vmware_facet_ids = old_cluster.vmware_facets.pluck(:id)
|
39
|
+
vmware_hypervisor_facet_ids = old_cluster.vmware_hypervisor_facets.pluck(:id)
|
40
|
+
|
31
41
|
importer.import!
|
32
42
|
refute ForemanWreckingball::VmwareCluster.find_by(id: old_cluster.id)
|
43
|
+
|
44
|
+
assert Foreman::Model::Vmware.find_by(id: compute_resource_id)
|
45
|
+
assert_equal host_ids.count, Host.where(id: host_ids).count
|
46
|
+
assert_equal vmware_facet_ids.count, ForemanWreckingball::VmwareFacet.where(id: vmware_facet_ids).count
|
47
|
+
assert_equal vmware_hypervisor_facet_ids.count, ForemanWreckingball::VmwareHypervisorFacet.where(id: vmware_hypervisor_facet_ids).count
|
33
48
|
end
|
34
49
|
|
35
50
|
test 'can be run twice without a change' do
|
@@ -63,6 +63,17 @@ module ForemanWreckingball
|
|
63
63
|
assert_equal '4c4c4544-0051-3610-8046-c4c44f584a32', host.vmware_hypervisor_facet.uuid
|
64
64
|
end
|
65
65
|
|
66
|
+
test 'removes hypervisor facets from stale hosts' do
|
67
|
+
host_on_other_cluster = FactoryBot.create(:host, :managed, :with_vmware_hypervisor_facet)
|
68
|
+
stale_facet = FactoryBot.create(:vmware_hypervisor_facet, vmware_cluster: cluster, compute_resource: compute_resource)
|
69
|
+
|
70
|
+
importer.import!
|
71
|
+
|
72
|
+
assert_nil ForemanWreckingball::VmwareHypervisorFacet.find_by(id: stale_facet.id)
|
73
|
+
assert_not_nil Host::Managed.find_by(name: 'host1.example.com').vmware_hypervisor_facet
|
74
|
+
assert_not_nil Host::Managed.find_by(id: host_on_other_cluster.id).vmware_hypervisor_facet
|
75
|
+
end
|
76
|
+
|
66
77
|
test 'updates host by katello name' do
|
67
78
|
host = FactoryBot.create(:host, organization: organization)
|
68
79
|
host.update!(:name => "virt-who-host1.example.com-#{organization.id}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_wreckingball
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Goebel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman-tasks
|
@@ -63,45 +63,71 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
65
|
- app/assets/javascripts/foreman_wreckingball/modal.js
|
66
|
+
- app/assets/javascripts/foreman_wreckingball/status_hosts_table.js
|
67
|
+
- app/assets/javascripts/foreman_wreckingball/status_managed_hosts_dashboard.js
|
68
|
+
- app/assets/javascripts/foreman_wreckingball/status_row.js
|
69
|
+
- app/assets/stylesheets/foreman_wreckingball/status_hosts_table.css.scss
|
70
|
+
- app/assets/stylesheets/foreman_wreckingball/status_managed_hosts_dashboard.css.scss
|
66
71
|
- app/controllers/foreman_wreckingball/hosts_controller.rb
|
67
72
|
- app/helpers/concerns/foreman_wreckingball/hosts_helper_extensions.rb
|
68
73
|
- app/helpers/foreman_wreckingball/hypervisors_helper.rb
|
74
|
+
- app/helpers/foreman_wreckingball/statuses_helper.rb
|
69
75
|
- app/jobs/update_hosts_vmware_facets.rb
|
76
|
+
- app/lib/actions/foreman_wreckingball/bulk_remediate.rb
|
70
77
|
- app/lib/actions/foreman_wreckingball/host/refresh_vmware_facet.rb
|
78
|
+
- app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb
|
79
|
+
- app/lib/actions/foreman_wreckingball/host/remediate_spectre_v2.rb
|
71
80
|
- app/lib/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem.rb
|
72
81
|
- app/lib/actions/foreman_wreckingball/vmware/schedule_vmware_sync.rb
|
73
82
|
- app/lib/actions/foreman_wreckingball/vmware/sync_compute_resource.rb
|
74
83
|
- app/lib/fog_extensions/foreman_wreckingball/vsphere/host.rb
|
84
|
+
- app/lib/fog_extensions/foreman_wreckingball/vsphere/mock.rb
|
75
85
|
- app/lib/fog_extensions/foreman_wreckingball/vsphere/real.rb
|
86
|
+
- app/lib/fog_extensions/foreman_wreckingball/vsphere/server.rb
|
76
87
|
- app/lib/vsphere_os_identifiers.rb
|
77
88
|
- app/lib/vsphere_os_identifiers/data.yaml
|
78
89
|
- app/lib/vsphere_os_identifiers/os.rb
|
79
90
|
- app/models/concerns/foreman_wreckingball/compute_resource_extensions.rb
|
80
91
|
- app/models/concerns/foreman_wreckingball/host_extensions.rb
|
92
|
+
- app/models/concerns/foreman_wreckingball/host_status_extensions.rb
|
93
|
+
- app/models/concerns/foreman_wreckingball/user_extensions.rb
|
94
|
+
- app/models/concerns/foreman_wreckingball/usergroup_extensions.rb
|
81
95
|
- app/models/concerns/foreman_wreckingball/vmware_extensions.rb
|
82
96
|
- app/models/concerns/foreman_wreckingball/vmware_facet_host_extensions.rb
|
83
97
|
- app/models/concerns/foreman_wreckingball/vmware_hypervisor_facet_host_extensions.rb
|
84
98
|
- app/models/foreman_wreckingball/cpu_hot_add_status.rb
|
99
|
+
- app/models/foreman_wreckingball/hardware_version_status.rb
|
85
100
|
- app/models/foreman_wreckingball/operatingsystem_status.rb
|
86
101
|
- app/models/foreman_wreckingball/spectre_v2_status.rb
|
87
102
|
- app/models/foreman_wreckingball/tools_status.rb
|
88
103
|
- app/models/foreman_wreckingball/vmware_cluster.rb
|
89
104
|
- app/models/foreman_wreckingball/vmware_facet.rb
|
90
105
|
- app/models/foreman_wreckingball/vmware_hypervisor_facet.rb
|
91
|
-
- app/
|
106
|
+
- app/models/setting/wreckingball.rb
|
92
107
|
- app/services/foreman_wreckingball/vmware_cluster_importer.rb
|
93
108
|
- app/services/foreman_wreckingball/vmware_hypervisor_importer.rb
|
94
109
|
- app/views/compute_resources/_hypervisors_tab.html.erb
|
110
|
+
- app/views/foreman_wreckingball/hosts/_hosts.json.rabl
|
95
111
|
- app/views/foreman_wreckingball/hosts/_status_dashboard_content.erb
|
96
112
|
- app/views/foreman_wreckingball/hosts/_status_dashboard_empty.erb
|
113
|
+
- app/views/foreman_wreckingball/hosts/_status_managed_hosts_dashboard_cards.html.erb
|
114
|
+
- app/views/foreman_wreckingball/hosts/_status_managed_hosts_dashboard_cards_card.html.erb
|
97
115
|
- app/views/foreman_wreckingball/hosts/_status_row.html.erb
|
116
|
+
- app/views/foreman_wreckingball/hosts/_status_row_actions.html.erb
|
117
|
+
- app/views/foreman_wreckingball/hosts/_status_row_hosts_table.html.erb
|
118
|
+
- app/views/foreman_wreckingball/hosts/_status_row_hosts_table_actions.html.erb
|
98
119
|
- app/views/foreman_wreckingball/hosts/schedule_remediate.html.erb
|
99
120
|
- app/views/foreman_wreckingball/hosts/status_dashboard.html.erb
|
121
|
+
- app/views/foreman_wreckingball/hosts/status_hosts.json.rabl
|
122
|
+
- app/views/foreman_wreckingball/hosts/status_managed_hosts_dashboard.html.erb
|
123
|
+
- config/environments/production.rb
|
100
124
|
- config/routes.rb
|
101
125
|
- db/migrate/20171106155000_create_vmware_facets.rb
|
102
126
|
- db/migrate/20180504135345_add_cpu_features_to_vmware_facets.rb
|
103
127
|
- db/migrate/20180504135515_add_hardware_version_to_vmware_facets.rb
|
104
128
|
- db/migrate/20180614105545_add_feature_capabilities_to_vmware_hypervisor_facets.rb
|
129
|
+
- db/migrate/20181020174609_add_power_state_to_vmware_facets.rb
|
130
|
+
- db/migrate/20181021111543_add_indexes_to_vmware_hypervisor_facets.rb
|
105
131
|
- lib/foreman_wreckingball.rb
|
106
132
|
- lib/foreman_wreckingball/engine.rb
|
107
133
|
- lib/foreman_wreckingball/scheduled_jobs.rb
|
@@ -111,7 +137,10 @@ files:
|
|
111
137
|
- locale/en/foreman_wreckingball.po
|
112
138
|
- locale/foreman_wreckingball.pot
|
113
139
|
- locale/gemspec.rb
|
140
|
+
- test/actions/foreman_wreckingball/bulk_remediate_test.rb
|
114
141
|
- test/actions/foreman_wreckingball/host/refresh_vmware_facet_test.rb
|
142
|
+
- test/actions/foreman_wreckingball/host/remediate_hardware_version_test.rb
|
143
|
+
- test/actions/foreman_wreckingball/host/remediate_spectre_v2_test.rb
|
115
144
|
- test/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem_test.rb
|
116
145
|
- test/actions/foreman_wreckingball/vmware/schedule_vmware_sync_test.rb
|
117
146
|
- test/actions/foreman_wreckingball/vmware/sync_compute_resource_test.rb
|
@@ -120,16 +149,24 @@ files:
|
|
120
149
|
- test/factories/compute_resource.rb
|
121
150
|
- test/factories/foreman_wreckingball_factories.rb
|
122
151
|
- test/factories/host.rb
|
152
|
+
- test/factories/task.rb
|
153
|
+
- test/helpers/foreman_wreckingball/status_helper.rb
|
154
|
+
- test/integration/hosts_status_dashboard_test.rb
|
155
|
+
- test/integration/hosts_status_managed_hosts_test.rb
|
156
|
+
- test/integration_test_plugin_helper.rb
|
123
157
|
- test/models/compute_resource_test.rb
|
124
158
|
- test/models/compute_resources/vmware_test.rb
|
125
159
|
- test/models/foreman_wreckingball/cpu_hot_add_status_test.rb
|
160
|
+
- test/models/foreman_wreckingball/hardware_version_status_test.rb
|
126
161
|
- test/models/foreman_wreckingball/operatingsystem_status_test.rb
|
127
162
|
- test/models/foreman_wreckingball/spectre_v2_status_test.rb
|
128
163
|
- test/models/foreman_wreckingball/tools_status_test.rb
|
129
164
|
- test/models/foreman_wreckingball/vmware_cluster_test.rb
|
130
165
|
- test/models/foreman_wreckingball/vmware_facet_test.rb
|
131
166
|
- test/models/foreman_wreckingball/vmware_hypervisor_facet_test.rb
|
167
|
+
- test/models/host_status_test.rb
|
132
168
|
- test/models/host_test.rb
|
169
|
+
- test/models/usergroup_test.rb
|
133
170
|
- test/test_plugin_helper.rb
|
134
171
|
- test/unit/foreman_wreckingball/vmware_cluster_importer_test.rb
|
135
172
|
- test/unit/foreman_wreckingball/vmware_hypervisor_importer_test.rb
|
@@ -137,7 +174,7 @@ homepage: https://github.com/dm-drogeriemarkt/foreman_wreckingball
|
|
137
174
|
licenses:
|
138
175
|
- GPL-3.0
|
139
176
|
metadata: {}
|
140
|
-
post_install_message:
|
177
|
+
post_install_message:
|
141
178
|
rdoc_options: []
|
142
179
|
require_paths:
|
143
180
|
- lib
|
@@ -152,31 +189,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
189
|
- !ruby/object:Gem::Version
|
153
190
|
version: '0'
|
154
191
|
requirements: []
|
155
|
-
|
156
|
-
|
157
|
-
signing_key:
|
192
|
+
rubygems_version: 3.1.4
|
193
|
+
signing_key:
|
158
194
|
specification_version: 4
|
159
195
|
summary: Adds status checks of the VMWare VMs to Foreman.
|
160
196
|
test_files:
|
161
197
|
- test/unit/foreman_wreckingball/vmware_cluster_importer_test.rb
|
162
198
|
- test/unit/foreman_wreckingball/vmware_hypervisor_importer_test.rb
|
199
|
+
- test/integration/hosts_status_dashboard_test.rb
|
200
|
+
- test/integration/hosts_status_managed_hosts_test.rb
|
163
201
|
- test/models/compute_resource_test.rb
|
164
202
|
- test/models/host_test.rb
|
203
|
+
- test/models/usergroup_test.rb
|
165
204
|
- test/models/foreman_wreckingball/operatingsystem_status_test.rb
|
166
205
|
- test/models/foreman_wreckingball/spectre_v2_status_test.rb
|
167
206
|
- test/models/foreman_wreckingball/vmware_hypervisor_facet_test.rb
|
207
|
+
- test/models/foreman_wreckingball/hardware_version_status_test.rb
|
168
208
|
- test/models/foreman_wreckingball/cpu_hot_add_status_test.rb
|
169
209
|
- test/models/foreman_wreckingball/vmware_cluster_test.rb
|
170
210
|
- test/models/foreman_wreckingball/vmware_facet_test.rb
|
171
211
|
- test/models/foreman_wreckingball/tools_status_test.rb
|
212
|
+
- test/models/host_status_test.rb
|
172
213
|
- test/models/compute_resources/vmware_test.rb
|
173
214
|
- test/factories/compute_resource.rb
|
174
215
|
- test/factories/host.rb
|
175
216
|
- test/factories/foreman_wreckingball_factories.rb
|
217
|
+
- test/factories/task.rb
|
176
218
|
- test/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem_test.rb
|
219
|
+
- test/actions/foreman_wreckingball/host/remediate_hardware_version_test.rb
|
177
220
|
- test/actions/foreman_wreckingball/host/refresh_vmware_facet_test.rb
|
221
|
+
- test/actions/foreman_wreckingball/host/remediate_spectre_v2_test.rb
|
222
|
+
- test/actions/foreman_wreckingball/bulk_remediate_test.rb
|
178
223
|
- test/actions/foreman_wreckingball/vmware/sync_compute_resource_test.rb
|
179
224
|
- test/actions/foreman_wreckingball/vmware/schedule_vmware_sync_test.rb
|
180
225
|
- test/test_plugin_helper.rb
|
181
226
|
- test/controllers/compute_resources_controller_test.rb
|
182
227
|
- test/controllers/foreman_wreckingball/hosts_controller_test.rb
|
228
|
+
- test/helpers/foreman_wreckingball/status_helper.rb
|
229
|
+
- test/integration_test_plugin_helper.rb
|