foreman_netbox 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9df549aa83fb9c91e18bba3c2690cb6f9c14977ca2364198b12b20cc01140069
4
- data.tar.gz: 0adf0c06724a964efa56d7ca8b294ca73882c351a50c8063a1906f4ad3a429ac
3
+ metadata.gz: 4b8ad442bf38c2bf5ac0ed5b94580b108a16d267a2ae2a37f456a73ebb1f8cd6
4
+ data.tar.gz: e31f39d22ea73a0bda27093a4f8474740836899c4d0379cc8763a1b9ec766e24
5
5
  SHA512:
6
- metadata.gz: dcd1893a719badc47fe8d083a46fa5ee403bc9f1c31a0963d05624c34f00dad74a8320cdaaf0917e6fc484c899f62fe56db277642e62ba240ef471d1214bd67c
7
- data.tar.gz: 1e3e688b369849e00c54440e4de52507bdefd30109d4688fc478b22a1ceaa751593859be6fbc8480ce60a6ee0050f0ab783dbfc721df428d93aa3bfd44feb7de
6
+ metadata.gz: ab087e119d4a0fd10f4847a4e6aaa829e55e2b1036393058ccc90363a098ea12fa156fd7f62c1eba98d0e2a15e0f3fd0aeec77d65f4a78a515ff6b16b6739f13
7
+ data.tar.gz: 47561411ae532f4229a45ce71443f89fadc94aae271d25be9e201148500cfa7f013ff7e24c94c1134738e95f7a200ed204378a4dee65cd72e7694e64f81c5911
data/README.md CHANGED
@@ -10,6 +10,7 @@ This is a plugin for Foreman that introduces integration with [NetBox](https://n
10
10
  | -------------- | -------------- |
11
11
  | 2.8 | 1.0 |
12
12
  | 2.11 | 1.1 |
13
+ | 3.3 | 1.2 |
13
14
 
14
15
  ## Installation
15
16
 
@@ -4,9 +4,9 @@ module ForemanNetbox
4
4
  class DeviceContract < Dry::Validation::Contract
5
5
  # rubocop:disable Metrics/BlockLength
6
6
  params do
7
- optional(:tenant).hash(ForemanNetbox::Params::TenantParams.new)
8
- optional(:ip_addresses).array(ForemanNetbox::Params::IpAddressParams.new)
9
- optional(:interfaces).array(ForemanNetbox::Params::InterfaceParams.new)
7
+ optional(:tenant).hash(ForemanNetbox::Params::TenantParams)
8
+ optional(:ip_addresses).array(ForemanNetbox::Params::IpAddressParams)
9
+ optional(:interfaces).array(ForemanNetbox::Params::InterfaceParams)
10
10
 
11
11
  required(:device).filled(:hash) do
12
12
  required(:name).filled(:string)
@@ -2,15 +2,13 @@
2
2
 
3
3
  module ForemanNetbox
4
4
  module Params
5
- class InterfaceParams < Dry::Schema::Params
6
- define do
7
- required(:name).filled(:string)
8
- required(:type).filled(:hash) do
9
- required(:value).filled(:string)
10
- end
11
- optional(:mac_address).maybe(:string)
12
- optional(:tags).array(:string)
5
+ InterfaceParams = Dry::Schema.Params do
6
+ required(:name).filled(:string)
7
+ required(:type).filled(:hash) do
8
+ required(:value).filled(:string)
13
9
  end
10
+ optional(:mac_address).maybe(:string)
11
+ optional(:tags).array(:string)
14
12
  end
15
13
  end
16
14
  end
@@ -2,14 +2,12 @@
2
2
 
3
3
  module ForemanNetbox
4
4
  module Params
5
- class IpAddressParams < Dry::Schema::Params
6
- define do
7
- required(:address).filled(:string)
8
- required(:interface).filled(:hash) do
9
- required(:name).filled(:string)
10
- end
11
- optional(:tags).array(:string)
5
+ IpAddressParams = Dry::Schema.Params do
6
+ required(:address).filled(:string)
7
+ required(:interface).filled(:hash) do
8
+ required(:name).filled(:string)
12
9
  end
10
+ optional(:tags).array(:string)
13
11
  end
14
12
  end
15
13
  end
@@ -2,12 +2,10 @@
2
2
 
3
3
  module ForemanNetbox
4
4
  module Params
5
- class TenantParams < Dry::Schema::Params
6
- define do
7
- required(:name).filled(:string)
8
- required(:slug).filled(:string)
9
- optional(:tags).array(:string)
10
- end
5
+ TenantParams = Dry::Schema.Params do
6
+ required(:name).filled(:string)
7
+ required(:slug).filled(:string)
8
+ optional(:tags).array(:string)
11
9
  end
12
10
  end
13
11
  end
@@ -3,9 +3,9 @@
3
3
  module ForemanNetbox
4
4
  class VirtualMachineContract < Dry::Validation::Contract
5
5
  params do
6
- optional(:tenant).hash(ForemanNetbox::Params::TenantParams.new)
7
- optional(:ip_addresses).array(ForemanNetbox::Params::IpAddressParams.new)
8
- optional(:interfaces).array(ForemanNetbox::Params::InterfaceParams.new)
6
+ optional(:tenant).hash(ForemanNetbox::Params::TenantParams)
7
+ optional(:ip_addresses).array(ForemanNetbox::Params::IpAddressParams)
8
+ optional(:interfaces).array(ForemanNetbox::Params::InterfaceParams)
9
9
 
10
10
  required(:virtual_machine).filled(:hash) do
11
11
  required(:name).filled(:string)
@@ -21,7 +21,7 @@ module ForemanNetbox
21
21
  delegate :url, to: :netbox_facet, prefix: true, allow_nil: true
22
22
 
23
23
  def netbox_device_url
24
- "#{Setting::Netbox[:netbox_url]}/dcim/devices/#{device&.id}" if device&.id
24
+ "#{Setting[:netbox_url]}/dcim/devices/#{device&.id}" if device&.id
25
25
  end
26
26
  end
27
27
  end
@@ -62,6 +62,8 @@ module ForemanNetbox
62
62
  end
63
63
 
64
64
  def assign_site
65
+ return if device.site&.id && Setting[:netbox_skip_site_update]
66
+
65
67
  device.site = site&.id if device.site&.id != site&.id
66
68
  end
67
69
 
@@ -23,7 +23,7 @@ module ForemanNetbox
23
23
  def netbox_virtual_machine_url
24
24
  return unless context.virtual_machine&.id
25
25
 
26
- "#{Setting::Netbox[:netbox_url]}/virtualization/virtual-machines/#{context.virtual_machine&.id}"
26
+ "#{Setting[:netbox_url]}/virtualization/virtual-machines/#{context.virtual_machine&.id}"
27
27
  end
28
28
  end
29
29
  end
@@ -4,8 +4,8 @@ module ForemanNetbox
4
4
  class API
5
5
  def self.client
6
6
  NetboxClientRuby.configure do |config|
7
- config.netbox.api_base_url = "#{Setting::Netbox['netbox_url']}/api"
8
- config.netbox.auth.token = Setting::Netbox['netbox_api_token']
7
+ config.netbox.api_base_url = "#{Setting['netbox_url']}/api"
8
+ config.netbox.auth.token = Setting['netbox_api_token']
9
9
  end
10
10
  end
11
11
  end
@@ -14,7 +14,7 @@ module Orchestration
14
14
  protected
15
15
 
16
16
  def netbox_orchestration_allowed?
17
- Setting::Netbox[:netbox_orchestration_enabled] && netbox_will_change?
17
+ Setting[:netbox_orchestration_enabled] && netbox_will_change?
18
18
  end
19
19
 
20
20
  def queue_netbox_push
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FixNetboxSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
4
+ def up
5
+ # rubocop:disable Rails/SkipsModelValidations
6
+ Setting.where(category: 'Setting::Netbox').update_all(category: 'Setting') if column_exists?(:settings, :category)
7
+ # rubocop:enable Rails/SkipsModelValidations
8
+ end
9
+ end
@@ -10,14 +10,6 @@ module ForemanNetbox
10
10
 
11
11
  config.autoload_paths += Dir["#{config.root}/app/interactors"]
12
12
 
13
- initializer 'foreman_netbox.load_default_settings', before: :load_config_initializers do
14
- require_dependency File.expand_path('../../app/models/setting/netbox.rb', __dir__) if begin
15
- Setting.table_exists?
16
- rescue StandardError
17
- (false)
18
- end
19
- end
20
-
21
13
  # Add any db migrations
22
14
  initializer 'foreman_netbox.load_app_instance_data' do |app|
23
15
  ForemanNetbox::Engine.paths['db/migrate'].existent.each do |path|
@@ -27,7 +19,7 @@ module ForemanNetbox
27
19
 
28
20
  initializer 'foreman_netbox.register_plugin', :before => :finisher_hook do |_app|
29
21
  Foreman::Plugin.register :foreman_netbox do
30
- requires_foreman '>= 1.24'
22
+ requires_foreman '>= 3.1'
31
23
 
32
24
  # Netbox Facet
33
25
  register_facet(ForemanNetbox::NetboxFacet, :netbox_facet) do
@@ -42,6 +34,31 @@ module ForemanNetbox
42
34
  onlyif: proc { |host| host.netbox_facet.synchronized_at }
43
35
  end
44
36
 
37
+ settings do
38
+ category(:netbox, N_('Netbox')) do
39
+ setting 'netbox_url',
40
+ type: :string,
41
+ default: '-',
42
+ full_name: N_('Netbox URL'),
43
+ description: N_('URL where Netbox is reachable')
44
+ setting 'netbox_api_token',
45
+ type: :string,
46
+ default: '-',
47
+ full_name: N_('Netbox API token'),
48
+ description: N_('API token to Netbox')
49
+ setting 'netbox_orchestration_enabled',
50
+ type: :boolean,
51
+ default: false,
52
+ full_name: N_('Netbox Orchestration'),
53
+ description: N_('Enable Netbox Orchestration')
54
+ setting 'netbox_skip_site_update',
55
+ type: :boolean,
56
+ default: false,
57
+ full_name: N_('Skip Site Update'),
58
+ description: N_('Skip updating Site attribute for Devices')
59
+ end
60
+ end
61
+
45
62
  logger :import, enabled: true
46
63
  end
47
64
  end
@@ -54,8 +71,8 @@ module ForemanNetbox
54
71
  ::Usergroup.include(ForemanNetbox::UserUsergroupCommonExtensions)
55
72
 
56
73
  NetboxClientRuby.configure do |config|
57
- config.netbox.api_base_url = Setting::Netbox['netbox_url']
58
- config.netbox.auth.token = Setting::Netbox['netbox_api_token']
74
+ config.netbox.api_base_url = Setting['netbox_url']
75
+ config.netbox.auth.token = Setting['netbox_api_token']
59
76
  end
60
77
  rescue StandardError => e
61
78
  Rails.logger.warn "ForemanNetbox: skipping engine hook (#{e})\n#{e.backtrace.join("\n")}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanNetbox
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
@@ -61,7 +61,7 @@ class SyncRhelVirtualHostTest < ActiveSupport::TestCase
61
61
 
62
62
  assert_equal host.name, subject.virtual_machine.name
63
63
  assert_equal host.owner.netbox_tenant_name, subject.virtual_machine.tenant.name
64
- assert_equal format('%.2f', host.compute_object.cpus), subject.virtual_machine.vcpus
64
+ assert_equal host.compute_object.cpus.to_f, subject.virtual_machine.vcpus
65
65
  assert_equal host.compute_object.memory_mb, subject.virtual_machine.memory
66
66
  assert_equal host.compute_object.volumes.first.size_gb, subject.virtual_machine.disk
67
67
  assert_equal host.compute_object.cluster, subject.virtual_machine.cluster.name
@@ -56,7 +56,7 @@ class SyncHostOrganizerTest < ActiveSupport::TestCase
56
56
  end
57
57
 
58
58
  test 'save synchronization status when it succeeds' do
59
- stub_request(:patch, "#{Setting::Netbox[:netbox_url]}/api/dcim/devices/1.json").to_return(
59
+ stub_request(:patch, "#{Setting[:netbox_url]}/api/dcim/devices/1.json").to_return(
60
60
  status: 200, headers: { 'Content-Type': 'application/json' },
61
61
  body: { id: 1 }.to_json
62
62
  )
@@ -64,12 +64,12 @@ class SyncHostOrganizerTest < ActiveSupport::TestCase
64
64
  host.reload
65
65
 
66
66
  assert_not_nil host.netbox_facet.synchronized_at
67
- assert_equal "#{Setting::Netbox[:netbox_url]}/dcim/devices/1", host.netbox_facet.url
67
+ assert_equal "#{Setting[:netbox_url]}/dcim/devices/1", host.netbox_facet.url
68
68
  assert_nil host.netbox_facet.synchronization_error
69
69
  end
70
70
 
71
71
  test 'save synchronization status when it fails' do
72
- stub_request(:patch, "#{Setting::Netbox[:netbox_url]}/api/dcim/devices/1.json").to_return(
72
+ stub_request(:patch, "#{Setting[:netbox_url]}/api/dcim/devices/1.json").to_return(
73
73
  status: 500, headers: { 'Content-Type': 'application/json' }
74
74
  )
75
75
  subject
@@ -83,7 +83,7 @@ class SyncHostOrganizerTest < ActiveSupport::TestCase
83
83
  private
84
84
 
85
85
  def stub_get_netbox_request(path, results:)
86
- stub_request(:get, "#{Setting::Netbox[:netbox_url]}/api/#{path}").to_return(
86
+ stub_request(:get, "#{Setting[:netbox_url]}/api/#{path}").to_return(
87
87
  status: 200, headers: { 'Content-Type': 'application/json' },
88
88
  body: {
89
89
  count: 1,
@@ -199,4 +199,34 @@ class UpdateDeviceTest < ActiveSupport::TestCase
199
199
  end
200
200
  end
201
201
  end
202
+
203
+ context 'when netbox_skip_site_update setting is enabled' do
204
+ setup do
205
+ Setting[:netbox_skip_site_update] = true
206
+ end
207
+
208
+ let(:new_site_id) { device_data.dig(:site, :id) + 1 }
209
+ let(:site) { OpenStruct.new(id: new_site_id) }
210
+ let(:device_tags) do
211
+ default_tags.map { |t| { 'id' => t.id, 'name' => t.name, 'slug' => t.slug } }
212
+ end
213
+
214
+ it 'does not update site of device' do
215
+ device_tags.each do |t|
216
+ stub_request(:get, "#{Setting[:netbox_url]}/api/extras/tags/#{t['id']}.json")
217
+ .to_return(
218
+ status: 200, headers: { 'Content-Type': 'application/json' },
219
+ body: {
220
+ id: t['id'],
221
+ name: t['name'],
222
+ slug: t['slug']
223
+ }.to_json
224
+ )
225
+ end
226
+ stub_patch = stub_request(:patch, "#{Setting[:netbox_url]}/api/dcim/devices/#{device.id}.json")
227
+
228
+ assert_not_equal device.site.id, new_site_id
229
+ assert_not_requested(stub_patch)
230
+ end
231
+ end
202
232
  end
@@ -10,15 +10,10 @@ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories
10
10
  FactoryBot.reload
11
11
 
12
12
  def setup_default_netbox_settings(netbox_url: 'https://netbox.example.com', netbox_api_token: 'api_key')
13
- if Gem::Version.new(SETTINGS[:version].notag) < Gem::Version.new('2.6')
14
- FactoryBot.create(:setting, name: 'netbox_url', value: netbox_url, category: 'Setting::Netbox')
15
- FactoryBot.create(:setting, name: 'netbox_api_token', value: netbox_api_token, category: 'Setting::Netbox')
16
- FactoryBot.create(:setting, name: 'netbox_orchestration_enabled', value: true, category: 'Setting::Netbox')
17
- else
18
- Setting[:netbox_url] = netbox_url
19
- Setting[:netbox_api_token] = netbox_api_token
20
- Setting[:netbox_orchestration_enabled] = true
21
- end
13
+ Setting[:netbox_url] = netbox_url
14
+ Setting[:netbox_api_token] = netbox_api_token
15
+ Setting[:netbox_orchestration_enabled] = true
16
+ Setting[:netbox_skip_site_update] = false
22
17
  end
23
18
 
24
19
  def setup_netbox_integration_test
metadata CHANGED
@@ -1,99 +1,129 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_netbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dmTECH GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 0.12.0
22
+ version: '0.17'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 0.12.0
29
+ version: '0.13'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.17'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: dry-container
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.7'
40
+ - - "<"
32
41
  - !ruby/object:Gem::Version
33
- version: 0.7.0
42
+ version: '0.12'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: 0.7.0
49
+ version: '0.7'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.12'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: dry-core
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
- - - "~>"
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0.6'
60
+ - - "<"
46
61
  - !ruby/object:Gem::Version
47
- version: 0.6.0
62
+ version: '0.9'
48
63
  type: :runtime
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
- - - "~>"
67
+ - - ">="
53
68
  - !ruby/object:Gem::Version
54
- version: 0.6.0
69
+ version: '0.6'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.9'
55
73
  - !ruby/object:Gem::Dependency
56
74
  name: dry-inflector
57
75
  requirement: !ruby/object:Gem::Requirement
58
76
  requirements:
59
77
  - - '='
60
78
  - !ruby/object:Gem::Version
61
- version: 0.2.0
79
+ version: 0.3.0
62
80
  type: :runtime
63
81
  prerelease: false
64
82
  version_requirements: !ruby/object:Gem::Requirement
65
83
  requirements:
66
84
  - - '='
67
85
  - !ruby/object:Gem::Version
68
- version: 0.2.0
86
+ version: 0.3.0
69
87
  - !ruby/object:Gem::Dependency
70
88
  name: dry-schema
71
89
  requirement: !ruby/object:Gem::Requirement
72
90
  requirements:
73
- - - "~>"
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '1.6'
94
+ - - "<"
74
95
  - !ruby/object:Gem::Version
75
- version: 1.6.0
96
+ version: '1.12'
76
97
  type: :runtime
77
98
  prerelease: false
78
99
  version_requirements: !ruby/object:Gem::Requirement
79
100
  requirements:
80
- - - "~>"
101
+ - - ">="
81
102
  - !ruby/object:Gem::Version
82
- version: 1.6.0
103
+ version: '1.6'
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '1.12'
83
107
  - !ruby/object:Gem::Dependency
84
108
  name: dry-validation
85
109
  requirement: !ruby/object:Gem::Requirement
86
110
  requirements:
87
- - - "~>"
111
+ - - ">="
88
112
  - !ruby/object:Gem::Version
89
113
  version: 1.5.2
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.9.0
90
117
  type: :runtime
91
118
  prerelease: false
92
119
  version_requirements: !ruby/object:Gem::Requirement
93
120
  requirements:
94
- - - "~>"
121
+ - - ">="
95
122
  - !ruby/object:Gem::Version
96
123
  version: 1.5.2
124
+ - - "<"
125
+ - !ruby/object:Gem::Version
126
+ version: 1.9.0
97
127
  - !ruby/object:Gem::Dependency
98
128
  name: interactor
99
129
  requirement: !ruby/object:Gem::Requirement
@@ -112,16 +142,22 @@ dependencies:
112
142
  name: netbox-client-ruby
113
143
  requirement: !ruby/object:Gem::Requirement
114
144
  requirements:
115
- - - "~>"
145
+ - - ">="
116
146
  - !ruby/object:Gem::Version
117
147
  version: 0.5.5
148
+ - - "<"
149
+ - !ruby/object:Gem::Version
150
+ version: 0.8.0
118
151
  type: :runtime
119
152
  prerelease: false
120
153
  version_requirements: !ruby/object:Gem::Requirement
121
154
  requirements:
122
- - - "~>"
155
+ - - ">="
123
156
  - !ruby/object:Gem::Version
124
157
  version: 0.5.5
158
+ - - "<"
159
+ - !ruby/object:Gem::Version
160
+ version: 0.8.0
125
161
  - !ruby/object:Gem::Dependency
126
162
  name: rdoc
127
163
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +178,14 @@ dependencies:
142
178
  requirements:
143
179
  - - "~>"
144
180
  - !ruby/object:Gem::Version
145
- version: 1.10.0
181
+ version: 1.45.1
146
182
  type: :development
147
183
  prerelease: false
148
184
  version_requirements: !ruby/object:Gem::Requirement
149
185
  requirements:
150
186
  - - "~>"
151
187
  - !ruby/object:Gem::Version
152
- version: 1.10.0
188
+ version: 1.45.1
153
189
  - !ruby/object:Gem::Dependency
154
190
  name: rubocop-rails
155
191
  requirement: !ruby/object:Gem::Requirement
@@ -254,7 +290,6 @@ files:
254
290
  - app/models/concerns/foreman_netbox/user_usergroup_common_extensions.rb
255
291
  - app/models/foreman_netbox/netbox_facet.rb
256
292
  - app/models/orchestration/netbox.rb
257
- - app/models/setting/netbox.rb
258
293
  - app/services/foreman_netbox/cached_netbox_parameters.rb
259
294
  - app/services/foreman_netbox/netbox_parameters.rb
260
295
  - app/services/foreman_netbox/netbox_parameters_comparator.rb
@@ -263,6 +298,7 @@ files:
263
298
  - db/migrate/20200527135812_create_netbox_facet.rb
264
299
  - db/migrate/20200604141933_add_sync_info_to_netbox_facet.rb
265
300
  - db/migrate/20200708093607_add_raw_data_to_netbox_facet.rb
301
+ - db/migrate/20230303095650_fix_netbox_settings_category_to_dsl.rb
266
302
  - lib/foreman_netbox.rb
267
303
  - lib/foreman_netbox/engine.rb
268
304
  - lib/foreman_netbox/version.rb
@@ -348,70 +384,70 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
384
  - !ruby/object:Gem::Version
349
385
  version: '0'
350
386
  requirements: []
351
- rubygems_version: 3.3.3
387
+ rubygems_version: 3.1.6
352
388
  signing_key:
353
389
  specification_version: 4
354
390
  summary: Adds integration with NetBox
355
391
  test_files:
392
+ - test/integration/foreman_netbox/sync_rhel_physical_host_test.rb
393
+ - test/integration/foreman_netbox/sync_rhel_virtual_host_test.rb
394
+ - test/integration/foreman_netbox/sync_k8s_physical_host_test.rb
395
+ - test/models/host/managed_test.rb
396
+ - test/models/foreman_netbox/location_test.rb
397
+ - test/models/foreman_netbox/nics/base_test.rb
398
+ - test/models/foreman_netbox/usergroup_test.rb
399
+ - test/models/foreman_netbox/netbox_facet_test.rb
356
400
  - test/factories/host.rb
357
401
  - test/factories/netbox_facet.rb
358
- - test/fixtures/facts/k8s_physical_host.json
402
+ - test/fixtures/netbox_virtual_machine_raw_data.json
403
+ - test/fixtures/netbox_device_raw_data.json
359
404
  - test/fixtures/facts/rhel_physical_host.json
360
405
  - test/fixtures/facts/rhel_virtual_host.json
361
- - test/fixtures/netbox_device_raw_data.json
362
- - test/fixtures/netbox_virtual_machine_raw_data.json
363
- - test/integration/foreman_netbox/sync_k8s_physical_host_test.rb
364
- - test/integration/foreman_netbox/sync_rhel_physical_host_test.rb
365
- - test/integration/foreman_netbox/sync_rhel_virtual_host_test.rb
406
+ - test/fixtures/facts/k8s_physical_host.json
407
+ - test/test_plugin_helper.rb
408
+ - test/jobs/foreman_netbox/sync_host_job_test.rb
409
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/find_test.rb
410
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/update_test.rb
411
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/create_test.rb
412
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/find_test.rb
413
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/create_test.rb
414
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/find_test.rb
415
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/update_test.rb
416
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/delete_test.rb
417
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/find_test.rb
418
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/update_test.rb
419
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/create_test.rb
420
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/delete_test.rb
421
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/find_test.rb
422
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/update_test.rb
423
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/create_test.rb
424
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/create_test.rb
425
+ - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/save_netbox_url_test.rb
426
+ - test/interactors/foreman_netbox/sync_host/sync_tenant/find_test.rb
427
+ - test/interactors/foreman_netbox/sync_host/sync_tenant/update_test.rb
428
+ - test/interactors/foreman_netbox/sync_host/sync_tenant/create_test.rb
366
429
  - test/interactors/foreman_netbox/sync_host/organizer_test.rb
367
- - test/interactors/foreman_netbox/sync_host/sync_device/create_test.rb
430
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_site/find_test.rb
431
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_site/update_test.rb
432
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_site/create_test.rb
368
433
  - test/interactors/foreman_netbox/sync_host/sync_device/find_test.rb
369
- - test/interactors/foreman_netbox/sync_host/sync_device/save_netbox_url_test.rb
370
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/create_test.rb
371
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/find_test.rb
372
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/create_test.rb
434
+ - test/interactors/foreman_netbox/sync_host/sync_device/update_test.rb
373
435
  - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/find_test.rb
374
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/create_test.rb
375
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/find_test.rb
376
436
  - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/update_test.rb
377
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create_test.rb
378
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/delete_test.rb
379
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/find_test.rb
380
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/create_test.rb
437
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/find_test.rb
438
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/create_test.rb
439
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/create_test.rb
381
440
  - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/delete_test.rb
382
441
  - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/find_test.rb
383
442
  - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/update_test.rb
443
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/create_test.rb
444
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/delete_test.rb
445
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/find_test.rb
384
446
  - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/update_test.rb
385
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_site/create_test.rb
386
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_site/find_test.rb
387
- - test/interactors/foreman_netbox/sync_host/sync_device/sync_site/update_test.rb
388
- - test/interactors/foreman_netbox/sync_host/sync_device/update_test.rb
389
- - test/interactors/foreman_netbox/sync_host/sync_tenant/create_test.rb
390
- - test/interactors/foreman_netbox/sync_host/sync_tenant/find_test.rb
391
- - test/interactors/foreman_netbox/sync_host/sync_tenant/update_test.rb
392
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/create_test.rb
393
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/find_test.rb
394
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/save_netbox_url_test.rb
395
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/create_test.rb
396
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/find_test.rb
397
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/create_test.rb
398
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/find_test.rb
399
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/update_test.rb
400
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/create_test.rb
401
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/delete_test.rb
402
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/find_test.rb
403
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/create_test.rb
404
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/delete_test.rb
405
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/find_test.rb
406
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/update_test.rb
407
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/update_test.rb
408
- - test/interactors/foreman_netbox/sync_host/sync_virtual_machine/update_test.rb
409
- - test/jobs/foreman_netbox/sync_host_job_test.rb
410
- - test/models/foreman_netbox/location_test.rb
411
- - test/models/foreman_netbox/netbox_facet_test.rb
412
- - test/models/foreman_netbox/nics/base_test.rb
413
- - test/models/foreman_netbox/usergroup_test.rb
414
- - test/models/host/managed_test.rb
447
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create_test.rb
448
+ - test/interactors/foreman_netbox/sync_host/sync_device/create_test.rb
449
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/find_test.rb
450
+ - test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/create_test.rb
451
+ - test/interactors/foreman_netbox/sync_host/sync_device/save_netbox_url_test.rb
415
452
  - test/services/foreman_netbox/netbox_attributes_test.rb
416
453
  - test/services/foreman_netbox/netbox_parameters_comparator_test.rb
417
- - test/test_plugin_helper.rb
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Setting
4
- class Netbox < ::Setting
5
- BLANK_ATTRS << 'netbox_url'
6
- BLANK_ATTRS << 'netbox_api_token'
7
- URI_BLANK_ATTRS << 'netbox_url'
8
-
9
- def self.default_settings
10
- [
11
- set('netbox_url', N_('URL where Netbox is reachable'), nil, N_('Netbox URL')),
12
- set('netbox_api_token', N_('API token to Netbox'), nil, N_('Netbox API token'), nil, encrypted: true),
13
- set('netbox_orchestration_enabled', N_('Enable Netbox Orchestration'), false, N_('Netbox Orchestration'))
14
- ]
15
- end
16
-
17
- def self.load_defaults
18
- # Check the table exists
19
- return unless super
20
-
21
- transaction do
22
- default_settings.each { |s| create! s.update(category: 'Setting::Netbox') }
23
- end
24
-
25
- true
26
- end
27
-
28
- def self.humanized_category
29
- N_('Netbox')
30
- end
31
- end
32
- end