foreman_wreckingball 1.0.0 → 2.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/app/controllers/foreman_wreckingball/hosts_controller.rb +2 -0
  4. data/app/helpers/concerns/foreman_wreckingball/hosts_helper_extensions.rb +4 -2
  5. data/app/jobs/update_hosts_vmware_facets.rb +3 -1
  6. data/app/lib/actions/foreman_wreckingball/host/refresh_vmware_facet.rb +2 -0
  7. data/app/lib/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem.rb +2 -0
  8. data/app/lib/actions/foreman_wreckingball/vmware/schedule_vmware_sync.rb +2 -0
  9. data/app/lib/actions/foreman_wreckingball/vmware/sync_compute_resource.rb +2 -0
  10. data/app/lib/vsphere_os_identifiers.rb +3 -1
  11. data/app/lib/vsphere_os_identifiers/os.rb +2 -0
  12. data/app/models/concerns/foreman_wreckingball/compute_resource_extensions.rb +2 -0
  13. data/app/models/concerns/foreman_wreckingball/host_extensions.rb +2 -0
  14. data/app/models/concerns/foreman_wreckingball/vmware_extensions.rb +2 -0
  15. data/app/models/concerns/foreman_wreckingball/vmware_facet_host_extensions.rb +2 -0
  16. data/app/models/concerns/foreman_wreckingball/vmware_hypervisor_facet_host_extensions.rb +2 -0
  17. data/app/models/foreman_wreckingball/cpu_hot_add_status.rb +3 -1
  18. data/app/models/foreman_wreckingball/operatingsystem_status.rb +3 -1
  19. data/app/models/foreman_wreckingball/tools_status.rb +2 -0
  20. data/app/models/foreman_wreckingball/vmware_cluster.rb +3 -1
  21. data/app/models/foreman_wreckingball/vmware_facet.rb +3 -1
  22. data/app/models/foreman_wreckingball/vmware_hypervisor_facet.rb +3 -1
  23. data/app/services/foreman_wreckingball/vmware_cluster_importer.rb +2 -0
  24. data/app/services/foreman_wreckingball/vmware_hypervisor_importer.rb +2 -0
  25. data/config/routes.rb +2 -0
  26. data/db/migrate/20171106155000_create_vmware_facets.rb +3 -1
  27. data/lib/foreman_wreckingball.rb +2 -0
  28. data/lib/foreman_wreckingball/engine.rb +4 -2
  29. data/lib/foreman_wreckingball/scheduled_jobs.rb +2 -0
  30. data/lib/foreman_wreckingball/version.rb +3 -1
  31. data/lib/tasks/foreman_vmware_checks_tasks.rake +2 -0
  32. data/locale/gemspec.rb +2 -0
  33. data/test/actions/foreman_wreckingball/host/refresh_vmware_facet_test.rb +4 -2
  34. data/test/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem_test.rb +5 -3
  35. data/test/actions/foreman_wreckingball/vmware/schedule_vmware_sync_test.rb +2 -0
  36. data/test/actions/foreman_wreckingball/vmware/sync_compute_resource_test.rb +3 -1
  37. data/test/controllers/foreman_wreckingball/hosts_controller_test.rb +13 -11
  38. data/test/factories/compute_resource.rb +3 -1
  39. data/test/factories/foreman_wreckingball_factories.rb +3 -1
  40. data/test/factories/host.rb +3 -1
  41. data/test/models/compute_resource_test.rb +2 -0
  42. data/test/models/compute_resources/vmware_test.rb +3 -1
  43. data/test/models/foreman_wreckingball/cpu_hot_add_status_test.rb +6 -4
  44. data/test/models/foreman_wreckingball/operatingsystem_status_test.rb +5 -3
  45. data/test/models/foreman_wreckingball/tools_status_test.rb +4 -2
  46. data/test/models/foreman_wreckingball/vmware_cluster_test.rb +2 -0
  47. data/test/models/foreman_wreckingball/vmware_facet_test.rb +2 -0
  48. data/test/models/foreman_wreckingball/vmware_hypervisor_facet_test.rb +2 -0
  49. data/test/models/host_test.rb +2 -0
  50. data/test/test_plugin_helper.rb +4 -2
  51. data/test/unit/foreman_wreckingball/vmware_cluster_importer_test.rb +4 -2
  52. data/test/unit/foreman_wreckingball/vmware_hypervisor_importer_test.rb +6 -4
  53. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed7b165c08c4f0621f0c1b550730e4754f2cc8208ecc94705648536f5c0583aa
4
- data.tar.gz: 31fe06c727fa67c07336d615204ca286f2de9f4905fba85bd97dd460faab4d08
3
+ metadata.gz: cc7a11036e0646a12bade27dd0103e62ded2dfebf765635f25d4183b1ef526ec
4
+ data.tar.gz: 6f699717b502e437359a62a220c54ae6ed9caaf2d8cc967dea5ba09646ecdd05
5
5
  SHA512:
6
- metadata.gz: 6a9951b05899b8657331428cf5f8afe9bd0a806f6aed6fb3354a60782d34ffc6dc2b5a0dc076551a6208ab9273f11a0205f299a569105a4b840b8aecb73982fe
7
- data.tar.gz: b5989a99b88494efa790f6ece0b07f53c7d083111b55bd7a8941039c621a73d87f908908f3c0e3f8e51cf64a4415ac7f2c4aa2192f4715a7e4a0b6dfa2d72789
6
+ metadata.gz: 9fd15f5abf4995dc3818c4f27d6b8e4a7de4a0a23873c705f82b8b194464fa1fb7619220533bf408d1f4c9cf1e64c71b9e523965a245cd7545d650f131707f2b
7
+ data.tar.gz: c836945e900b536003732099503b532504d1f298a1c59d295a73db0cc4d00d9026c4a36ab1d2f10e222f93b5f6abda2f81965aebbae6b1e2bf0a08a7c83a6cb3
data/README.md CHANGED
@@ -8,6 +8,7 @@ This is a plugin for Foreman that adds several VMware related status checks to y
8
8
  | --------------- | -------------- |
9
9
  | >= 1.15 | ~> 0.1 |
10
10
  | >= 1.16 | ~> 1.0 |
11
+ | >= 1.17 | ~> 2.0 |
11
12
 
12
13
  ## Installation
13
14
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  class HostsController < ::HostsController
3
5
  before_action :find_resource, :only => [:remediate]
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  module HostsHelperExtensions
3
5
  extend ActiveSupport::Concern
4
6
 
5
7
  def classes_for_vmware_status_row(counter)
6
- return 'pficon-error-circle-o list-view-pf-icon-danger' if (counter[:critical] || 0) > 0
7
- return 'pficon-warning-triangle-o list-view-pf-icon-warning' if (counter[:warning] || 0) > 0
8
+ return 'pficon-error-circle-o list-view-pf-icon-danger' if (counter[:critical] || 0).positive?
9
+ return 'pficon-warning-triangle-o list-view-pf-icon-warning' if (counter[:warning] || 0).positive?
8
10
  'pficon-ok list-view-pf-icon-success'
9
11
  end
10
12
 
@@ -1,4 +1,6 @@
1
- class UpdateHostsVmwareFacets < ActiveJob::Base
1
+ # frozen_string_literal: true
2
+
3
+ class UpdateHostsVmwareFacets < ApplicationJob
2
4
  after_perform do
3
5
  self.class.set(:wait => 12.hours).perform_later
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Actions
2
4
  module ForemanWreckingball
3
5
  module Host
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Actions
2
4
  module ForemanWreckingball
3
5
  module Host
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Actions
2
4
  module ForemanWreckingball
3
5
  module Vmware
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Actions
2
4
  module ForemanWreckingball
3
5
  module Vmware
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VsphereOsIdentifiers
2
4
  def self.data
3
5
  @data ||= load_data
@@ -9,7 +11,7 @@ module VsphereOsIdentifiers
9
11
  end
10
12
 
11
13
  def self.load_data
12
- YAML.load_file(File.expand_path('../vsphere_os_identifiers/data.yaml', __FILE__))
14
+ YAML.load_file(File.expand_path('vsphere_os_identifiers/data.yaml', __dir__))
13
15
  end
14
16
 
15
17
  def self.all
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VsphereOsIdentifiers
2
4
  class Os
3
5
  attr_reader :id, :description, :architecture, :since, :osfamily, :major, :name, :release
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  module ComputeResourceExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  module HostExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  module VmwareExtensions
3
5
  def hypervisors(opts = {})
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  module VmwareFacetHostExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  module VmwareHypervisorFacetHostExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  class CpuHotAddStatus < ::HostStatus::Status
3
5
  OK = 0
@@ -42,7 +44,7 @@ module ForemanWreckingball
42
44
  end
43
45
 
44
46
  def relevant?(_options = {})
45
- host && host.vmware_facet && host.vmware_facet.try(:cpu_hot_add?)
47
+ host&.vmware_facet && host.vmware_facet.try(:cpu_hot_add?)
46
48
  end
47
49
 
48
50
  def performance_degration?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  class OperatingsystemStatus < ::HostStatus::Status
3
5
  OK = 0
@@ -46,7 +48,7 @@ module ForemanWreckingball
46
48
  end
47
49
 
48
50
  def relevant?(_options = {})
49
- host && host.vmware_facet
51
+ host&.vmware_facet
50
52
  end
51
53
 
52
54
  def os_matches_identifier?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  class ToolsStatus < ::HostStatus::Status
3
5
  POWERDOWN = 10
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
- class VmwareCluster < ActiveRecord::Base
4
+ class VmwareCluster < ApplicationRecord
3
5
  has_many :vmware_hypervisor_facets,
4
6
  :class_name => '::ForemanWreckingball::VmwareHypervisorFacet',
5
7
  :inverse_of => :vmware_cluster,
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
- class VmwareFacet < ActiveRecord::Base
4
+ class VmwareFacet < ApplicationRecord
3
5
  include Facets::Base
4
6
 
5
7
  VALID_GUEST_STATUSES = [:toolsNotInstalled, :toolsNotRunning, :toolsOk, :toolsOld].freeze
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
- class VmwareHypervisorFacet < ActiveRecord::Base
4
+ class VmwareHypervisorFacet < ApplicationRecord
3
5
  include Facets::Base
4
6
 
5
7
  validates_lengths_from_database
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  class VmwareClusterImporter
3
5
  delegate :logger, :to => :Rails
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
4
  class VmwareHypervisorImporter
3
5
  delegate :logger, :to => :Rails
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  scope '/wreckingball' do
3
5
  constraints(:id => /[^\/]+/) do
@@ -1,4 +1,6 @@
1
- class CreateVmwareFacets < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class CreateVmwareFacets < ActiveRecord::Migration[4.2]
2
4
  def change
3
5
  create_table :vmware_clusters do |t|
4
6
  t.string :name, limit: 255, index: true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'foreman_wreckingball/engine'
2
4
 
3
5
  module ForemanWreckingball
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dynflow'
2
4
  require 'foreman-tasks'
3
5
 
@@ -23,7 +25,7 @@ module ForemanWreckingball
23
25
 
24
26
  initializer 'foreman_wreckingball.register_plugin', :before => :finisher_hook do |_app|
25
27
  Foreman::Plugin.register :foreman_wreckingball do
26
- requires_foreman '>= 1.16'
28
+ requires_foreman '>= 1.17'
27
29
 
28
30
  security_block :foreman_wreckingball do
29
31
  permission :refresh_vmware_status_hosts, {
@@ -82,7 +84,7 @@ module ForemanWreckingball
82
84
  end
83
85
 
84
86
  initializer 'foreman_wreckingball.register_gettext', after: :load_config_initializers do |_app|
85
- locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
87
+ locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
86
88
  locale_domain = 'foreman_wreckingball'
87
89
  Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
88
90
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # First, we check if there's a job already enqueued
2
4
  pending_jobs = ::Foreman::Application.dynflow.world.persistence.find_execution_plans(filters: { :state => 'scheduled' })
3
5
  scheduled_job = pending_jobs.select do |job|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanWreckingball
2
- VERSION = '1.0.0'.freeze
4
+ VERSION = '2.0.0'.freeze
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/testtask'
2
4
 
3
5
  # Tasks
data/locale/gemspec.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Matches foreman_wreckingball.gemspec
2
4
  _('Adds status checks of the VMWare VMs to Foreman.')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module Actions
@@ -13,14 +15,14 @@ module Actions
13
15
  teardown { ::Fog.unmock! }
14
16
 
15
17
  let(:compute_resource) do
16
- cr = FactoryGirl.create(:compute_resource, :vmware, :uuid => 'Solutions')
18
+ cr = FactoryBot.create(:compute_resource, :vmware, :uuid => 'Solutions')
17
19
  ComputeResource.find(cr.id)
18
20
  end
19
21
  let(:uuid) { '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
20
22
  let(:vm) { compute_resource.find_vm_by_uuid(uuid) }
21
23
 
22
24
  let(:host) do
23
- FactoryGirl.create(
25
+ FactoryBot.create(
24
26
  :host,
25
27
  :managed,
26
28
  :with_vmware_facet,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module Actions
@@ -13,14 +15,14 @@ module Actions
13
15
  teardown { ::Fog.unmock! }
14
16
 
15
17
  let(:compute_resource) do
16
- cr = FactoryGirl.create(:compute_resource, :vmware, :uuid => 'Solutions')
18
+ cr = FactoryBot.create(:compute_resource, :vmware, :uuid => 'Solutions')
17
19
  ComputeResource.find(cr.id)
18
20
  end
19
21
  let(:uuid) { '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
20
22
  let(:vm) { compute_resource.find_vm_by_uuid(uuid) }
21
23
 
22
24
  let(:operatingsystem) do
23
- FactoryGirl.create(
25
+ FactoryBot.create(
24
26
  :operatingsystem,
25
27
  architectures: [architectures(:x86_64)],
26
28
  major: 6,
@@ -31,7 +33,7 @@ module Actions
31
33
  end
32
34
 
33
35
  let(:host) do
34
- FactoryGirl.create(
36
+ FactoryBot.create(
35
37
  :host,
36
38
  :managed,
37
39
  :with_vmware_facet,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module Actions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module Actions
@@ -14,7 +16,7 @@ module Actions
14
16
 
15
17
  let(:action_class) { ::Actions::ForemanWreckingball::Vmware::SyncComputeResource }
16
18
  let(:compute_resource) do
17
- FactoryGirl.create(
19
+ FactoryBot.create(
18
20
  :vmware_cr,
19
21
  uuid: 'Solutions'
20
22
  )
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -11,13 +13,13 @@ module ForemanWreckingball
11
13
 
12
14
  describe '#status_dashboard' do
13
15
  test 'shows an empty status page' do
14
- get :status_dashboard, {}, set_session_user
16
+ get :status_dashboard, session: set_session_user
15
17
  assert_response :success
16
18
  end
17
19
 
18
20
  test 'shows a status page' do
19
- FactoryGirl.create_list(:host, 5, :with_wreckingball_statuses)
20
- get :status_dashboard, {}, set_session_user
21
+ FactoryBot.create_list(:host, 5, :with_wreckingball_statuses)
22
+ get :status_dashboard, session: set_session_user
21
23
  assert_response :success
22
24
  end
23
25
  end
@@ -25,7 +27,7 @@ module ForemanWreckingball
25
27
  describe '#refresh_status_dashboard' do
26
28
  test 'redirects to scheduled task' do
27
29
  ForemanTasks.expects(:async_task).returns(fake_task)
28
- put :refresh_status_dashboard, {}, set_session_user
30
+ put :refresh_status_dashboard, session: set_session_user
29
31
  assert_response :redirect
30
32
  assert_includes flash[:success], 'successfully scheduled'
31
33
  assert_redirected_to foreman_tasks_task_path(123)
@@ -34,32 +36,32 @@ module ForemanWreckingball
34
36
 
35
37
  describe '#remediate' do
36
38
  let(:host) do
37
- FactoryGirl.create(:host, :with_wreckingball_statuses)
39
+ FactoryBot.create(:host, :with_wreckingball_statuses)
38
40
  end
39
41
 
40
42
  test 'redirects to scheduled task' do
41
43
  ForemanTasks.expects(:async_task).returns(fake_task)
42
- put :remediate, { status_id: host.vmware_operatingsystem_status_object.id, id: host.id }, set_session_user
44
+ put :remediate, params: { status_id: host.vmware_operatingsystem_status_object.id, id: host.id }, session: set_session_user
43
45
  assert_response :redirect
44
46
  assert_includes flash[:success], 'successfully scheduled'
45
47
  assert_redirected_to foreman_tasks_task_path(123)
46
48
  end
47
49
 
48
50
  test 'raises error when status can not be remediated' do
49
- FactoryGirl.create(:host, :with_wreckingball_statuses)
51
+ FactoryBot.create(:host, :with_wreckingball_statuses)
50
52
  assert_raises Foreman::Exception do
51
- put :remediate, { status_id: host.vmware_tools_status_object.id, id: host.id }, set_session_user
53
+ put :remediate, params: { status_id: host.vmware_tools_status_object.id, id: host.id }, session: set_session_user
52
54
  end
53
55
  end
54
56
 
55
57
  test 'returns not found when host id is invalid' do
56
- put :remediate, { status_id: nil, id: 'invalid' }, set_session_user
58
+ put :remediate, params: { status_id: nil, id: 'invalid' }, session: set_session_user
57
59
  assert_response :not_found
58
60
  end
59
61
 
60
62
  test 'returns not found when status id is invalid' do
61
- FactoryGirl.create(:host, :with_wreckingball_statuses)
62
- put :remediate, { status_id: 'invalid', id: host.id }, set_session_user
63
+ FactoryBot.create(:host, :with_wreckingball_statuses)
64
+ put :remediate, params: { status_id: 'invalid', id: host.id }, session: set_session_user
63
65
  assert_response :not_found
64
66
  end
65
67
  end
@@ -1,4 +1,6 @@
1
- FactoryGirl.modify do
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.modify do
2
4
  factory :compute_resource do
3
5
  trait :with_vmware_clusters do
4
6
  transient do
@@ -1,4 +1,6 @@
1
- FactoryGirl.define do
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
2
4
  factory :vmware_facet, class: 'ForemanWreckingball::VmwareFacet' do
3
5
  vmware_cluster
4
6
  tools_state 2 #:toolsOk
@@ -1,4 +1,6 @@
1
- FactoryGirl.modify do
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.modify do
2
4
  factory :host do
3
5
  trait :with_vmware_facet do
4
6
  vmware_facet
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  class ComputeResourceTest < ActiveSupport::TestCase
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  class VmwareTest < ActiveSupport::TestCase
4
6
  setup { Fog.mock! }
5
7
  teardown { Fog.unmock! }
6
- let(:compute_resource) { FactoryGirl.build(:vmware_cr, :uuid => 'Solutions') }
8
+ let(:compute_resource) { FactoryBot.build(:vmware_cr, :uuid => 'Solutions') }
7
9
 
8
10
  test '#hypervisors returns hosts by cluster' do
9
11
  hosts = compute_resource.hypervisors(cluster_id: 'Solutionscluster').map(&:name)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -9,7 +11,7 @@ module ForemanWreckingball
9
11
  should belong_to(:host)
10
12
 
11
13
  let(:host) do
12
- FactoryGirl.create(:host, :managed, :with_vmware_facet)
14
+ FactoryBot.create(:host, :managed, :with_vmware_facet)
13
15
  end
14
16
  let(:status) { ForemanWreckingball::CpuHotAddStatus.new(host: host) }
15
17
 
@@ -67,7 +69,7 @@ module ForemanWreckingball
67
69
  end
68
70
 
69
71
  test 'no performance degration is indicated' do
70
- FactoryGirl.create(:vmware_hypervisor_facet, cpu_cores: 4, vmware_cluster: host.vmware_facet.vmware_cluster)
72
+ FactoryBot.create(:vmware_hypervisor_facet, cpu_cores: 4, vmware_cluster: host.vmware_facet.vmware_cluster)
71
73
  host.vmware_facet.cpus = 100
72
74
  assert status.performance_degration?
73
75
  end
@@ -76,8 +78,8 @@ module ForemanWreckingball
76
78
 
77
79
  describe '#hypervisor_min_cores' do
78
80
  test 'returns the minimum core count from all hypervisors in the same cluster' do
79
- FactoryGirl.create(:vmware_hypervisor_facet, cpu_cores: 4, vmware_cluster: host.vmware_facet.vmware_cluster)
80
- FactoryGirl.create(:vmware_hypervisor_facet, cpu_cores: 8, vmware_cluster: host.vmware_facet.vmware_cluster)
81
+ FactoryBot.create(:vmware_hypervisor_facet, cpu_cores: 4, vmware_cluster: host.vmware_facet.vmware_cluster)
82
+ FactoryBot.create(:vmware_hypervisor_facet, cpu_cores: 8, vmware_cluster: host.vmware_facet.vmware_cluster)
81
83
  status.host.reload
82
84
  assert_equal 4, status.hypervisor_min_cores
83
85
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -9,7 +11,7 @@ module ForemanWreckingball
9
11
  should belong_to(:host)
10
12
 
11
13
  let(:operatingsystem) do
12
- FactoryGirl.create(
14
+ FactoryBot.create(
13
15
  :operatingsystem,
14
16
  architectures: [architectures(:x86_64)],
15
17
  major: 6,
@@ -19,7 +21,7 @@ module ForemanWreckingball
19
21
  )
20
22
  end
21
23
  let(:host) do
22
- FactoryGirl.create(
24
+ FactoryBot.create(
23
25
  :host,
24
26
  :managed,
25
27
  :with_vmware_facet,
@@ -35,7 +37,7 @@ module ForemanWreckingball
35
37
  end
36
38
 
37
39
  test '#relevant is only for hosts with a vmware facet' do
38
- h = FactoryGirl.build(:host, :managed)
40
+ h = FactoryBot.build(:host, :managed)
39
41
  refute ForemanWreckingball::ToolsStatus.new(host: h).relevant?
40
42
  assert status.relevant?
41
43
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -8,7 +10,7 @@ module ForemanWreckingball
8
10
 
9
11
  should belong_to(:host)
10
12
 
11
- let(:host) { FactoryGirl.create(:host, :with_vmware_facet) }
13
+ let(:host) { FactoryBot.create(:host, :with_vmware_facet) }
12
14
  let(:status) { ForemanWreckingball::ToolsStatus.new(host: host) }
13
15
 
14
16
  test 'has a host association' do
@@ -25,7 +27,7 @@ module ForemanWreckingball
25
27
  end
26
28
 
27
29
  test '#relevant is only for hosts with a vmware facet' do
28
- h = FactoryGirl.build(:host, :managed)
30
+ h = FactoryBot.build(:host, :managed)
29
31
  refute ForemanWreckingball::ToolsStatus.new(host: h).relevant?
30
32
  end
31
33
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  class Host::ManagedTest < ActiveSupport::TestCase
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This calls the main test_helper in Foreman-core
2
4
  require 'test_helper'
3
5
  require 'dynflow/testing'
4
6
 
5
7
  # Add plugin to FactoryBot's paths
6
- FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
7
- FactoryGirl.reload
8
+ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
9
+ FactoryBot.reload
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -8,7 +10,7 @@ module ForemanWreckingball
8
10
  end
9
11
  teardown { Fog.unmock! }
10
12
 
11
- let(:compute_resource) { FactoryGirl.create(:vmware_cr, :uuid => 'Solutions') }
13
+ let(:compute_resource) { FactoryBot.create(:vmware_cr, :uuid => 'Solutions') }
12
14
  let(:importer) do
13
15
  VmwareClusterImporter.new(
14
16
  compute_resource: compute_resource
@@ -25,7 +27,7 @@ module ForemanWreckingball
25
27
  end
26
28
 
27
29
  test 'removes old clusters' do
28
- old_cluster = FactoryGirl.create(:vmware_cluster, compute_resource: compute_resource)
30
+ old_cluster = FactoryBot.create(:vmware_cluster, compute_resource: compute_resource)
29
31
  importer.import!
30
32
  refute ForemanWreckingball::VmwareCluster.find_by(id: old_cluster.id)
31
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanWreckingball
@@ -15,7 +17,7 @@ module ForemanWreckingball
15
17
  Location.find_by(name: 'Location 1')
16
18
  end
17
19
  let(:compute_resource) do
18
- FactoryGirl.create(
20
+ FactoryBot.create(
19
21
  :vmware_cr,
20
22
  uuid: 'Solutions',
21
23
  organizations: [organization],
@@ -23,7 +25,7 @@ module ForemanWreckingball
23
25
  )
24
26
  end
25
27
  let(:cluster) do
26
- FactoryGirl.create(
28
+ FactoryBot.create(
27
29
  :vmware_cluster,
28
30
  name: 'Solutionscluster',
29
31
  compute_resource: compute_resource
@@ -62,8 +64,8 @@ module ForemanWreckingball
62
64
  end
63
65
 
64
66
  test 'updates host by katello name' do
65
- host = FactoryGirl.create(:host, organization: organization)
66
- host.update_attributes!(:name => "virt-who-host1.example.com-#{organization.id}")
67
+ host = FactoryBot.create(:host, organization: organization)
68
+ host.update!(:name => "virt-who-host1.example.com-#{organization.id}")
67
69
  importer.import!
68
70
  assert_equal 'host1.example.com', host.reload.name
69
71
  end
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: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.9
19
+ version: 0.11.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.9
26
+ version: 0.11.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.52.1
47
+ version: 0.54.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.52.1
54
+ version: 0.54.0
55
55
  description: Adds status checks of the VMWare VMs to Foreman.
56
56
  email:
57
57
  - timo.goebel@dm.de