foreman_netbox 1.1.1 → 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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/app/interactors/foreman_netbox/delete_host/delete_device.rb +1 -1
  4. data/app/interactors/foreman_netbox/delete_host/delete_virtual_machine.rb +1 -1
  5. data/app/interactors/foreman_netbox/delete_host/organizer.rb +1 -1
  6. data/app/interactors/foreman_netbox/sync_host/organizer.rb +1 -1
  7. data/app/interactors/foreman_netbox/sync_host/sync_device/create.rb +1 -1
  8. data/app/interactors/foreman_netbox/sync_host/sync_device/find.rb +3 -5
  9. data/app/interactors/foreman_netbox/sync_host/sync_device/organizer.rb +10 -10
  10. data/app/interactors/foreman_netbox/sync_host/sync_device/save_netbox_url.rb +1 -1
  11. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/create.rb +1 -1
  12. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/find.rb +1 -1
  13. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/organizer.rb +1 -1
  14. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/create.rb +1 -1
  15. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/find.rb +1 -1
  16. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/organizer.rb +3 -3
  17. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/create.rb +1 -1
  18. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/find.rb +4 -5
  19. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/organizer.rb +1 -1
  20. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create.rb +1 -1
  21. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/find.rb +2 -2
  22. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/organizer.rb +4 -4
  23. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/create.rb +2 -2
  24. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/delete.rb +3 -1
  25. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/find.rb +2 -2
  26. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/organizer.rb +3 -3
  27. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_site/create.rb +1 -1
  28. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_site/find.rb +1 -1
  29. data/app/interactors/foreman_netbox/sync_host/sync_device/sync_site/organizer.rb +2 -2
  30. data/app/interactors/foreman_netbox/sync_host/sync_tags/create.rb +1 -1
  31. data/app/interactors/foreman_netbox/sync_host/sync_tags/find.rb +1 -1
  32. data/app/interactors/foreman_netbox/sync_host/sync_tags/organizer.rb +2 -2
  33. data/app/interactors/foreman_netbox/sync_host/sync_tenant/create.rb +1 -1
  34. data/app/interactors/foreman_netbox/sync_host/sync_tenant/find.rb +1 -1
  35. data/app/interactors/foreman_netbox/sync_host/sync_tenant/organizer.rb +2 -2
  36. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/create.rb +1 -1
  37. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/find.rb +2 -4
  38. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/organizer.rb +8 -8
  39. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/save_netbox_url.rb +1 -1
  40. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/create.rb +1 -1
  41. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/find.rb +1 -1
  42. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/organizer.rb +3 -3
  43. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/create.rb +1 -1
  44. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/find.rb +1 -1
  45. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/organizer.rb +1 -1
  46. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/create.rb +8 -8
  47. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/find.rb +2 -2
  48. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/organizer.rb +4 -4
  49. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/create.rb +2 -2
  50. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/delete.rb +3 -3
  51. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/find.rb +2 -2
  52. data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/organizer.rb +3 -3
  53. data/app/lib/foreman_netbox/api.rb +11 -2
  54. data/app/models/orchestration/netbox.rb +2 -4
  55. data/app/services/foreman_netbox/cached_netbox_parameters.rb +11 -11
  56. data/app/services/foreman_netbox/netbox_parameters.rb +29 -29
  57. data/app/services/foreman_netbox/netbox_parameters_comparator.rb +14 -8
  58. data/db/migrate/20230303095650_fix_netbox_settings_category_to_dsl.rb +0 -2
  59. data/lib/foreman_netbox/engine.rb +47 -40
  60. data/lib/foreman_netbox/version.rb +1 -1
  61. data/lib/tasks/foreman_netbox_tasks.rake +0 -50
  62. data/test/fixtures/netbox_device_raw_data.json +1 -1
  63. data/test/integration/foreman_netbox/sync_k8s_physical_host_test.rb +8 -8
  64. data/test/integration/foreman_netbox/sync_rhel_physical_host_test.rb +8 -8
  65. data/test/integration/foreman_netbox/sync_rhel_virtual_host_test.rb +8 -8
  66. data/test/interactors/foreman_netbox/sync_host/organizer_test.rb +9 -9
  67. data/test/interactors/foreman_netbox/sync_host/sync_device/create_test.rb +2 -2
  68. data/test/interactors/foreman_netbox/sync_host/sync_device/save_netbox_url_test.rb +2 -2
  69. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/create_test.rb +1 -1
  70. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/find_test.rb +4 -4
  71. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/create_test.rb +1 -1
  72. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/find_test.rb +4 -4
  73. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/create_test.rb +1 -1
  74. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/find_test.rb +6 -6
  75. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/update_test.rb +2 -2
  76. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create_test.rb +3 -3
  77. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/delete_test.rb +2 -2
  78. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/find_test.rb +4 -4
  79. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/create_test.rb +5 -5
  80. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/delete_test.rb +7 -7
  81. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/find_test.rb +3 -3
  82. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/update_test.rb +5 -5
  83. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/update_test.rb +10 -10
  84. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_site/create_test.rb +1 -1
  85. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_site/find_test.rb +3 -3
  86. data/test/interactors/foreman_netbox/sync_host/sync_device/sync_site/update_test.rb +3 -3
  87. data/test/interactors/foreman_netbox/sync_host/sync_device/update_test.rb +11 -11
  88. data/test/interactors/foreman_netbox/sync_host/sync_tenant/create_test.rb +1 -1
  89. data/test/interactors/foreman_netbox/sync_host/sync_tenant/find_test.rb +3 -3
  90. data/test/interactors/foreman_netbox/sync_host/sync_tenant/update_test.rb +2 -2
  91. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/create_test.rb +2 -2
  92. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/save_netbox_url_test.rb +2 -2
  93. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/create_test.rb +1 -1
  94. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/find_test.rb +2 -2
  95. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/find_test.rb +4 -4
  96. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/update_test.rb +2 -2
  97. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/create_test.rb +3 -3
  98. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/delete_test.rb +2 -2
  99. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/find_test.rb +4 -4
  100. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/create_test.rb +5 -5
  101. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/delete_test.rb +7 -7
  102. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/find_test.rb +3 -3
  103. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/update_test.rb +7 -7
  104. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/update_test.rb +9 -9
  105. data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/update_test.rb +10 -10
  106. data/test/models/foreman_netbox/netbox_facet_test.rb +1 -1
  107. data/test/models/foreman_netbox/nics/base_test.rb +1 -1
  108. data/test/services/foreman_netbox/netbox_attributes_test.rb +16 -16
  109. data/test/services/foreman_netbox/netbox_parameters_comparator_test.rb +31 -31
  110. data/test/test_plugin_helper.rb +1 -1
  111. data/test/unit/foreman_netbox/api_test.rb +52 -0
  112. metadata +88 -165
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b8ad442bf38c2bf5ac0ed5b94580b108a16d267a2ae2a37f456a73ebb1f8cd6
4
- data.tar.gz: e31f39d22ea73a0bda27093a4f8474740836899c4d0379cc8763a1b9ec766e24
3
+ metadata.gz: e2c91a8bd4a7bee1886c7d066161f77810c6cb11180feb3a10e559e317de1f57
4
+ data.tar.gz: a0cecb684f0a2b3c6866afa1cd0ec59809f9f9f24d8f9d8c4161f0b4ffb2d40c
5
5
  SHA512:
6
- metadata.gz: ab087e119d4a0fd10f4847a4e6aaa829e55e2b1036393058ccc90363a098ea12fa156fd7f62c1eba98d0e2a15e0f3fd0aeec77d65f4a78a515ff6b16b6739f13
7
- data.tar.gz: 47561411ae532f4229a45ce71443f89fadc94aae271d25be9e201148500cfa7f013ff7e24c94c1134738e95f7a200ed204378a4dee65cd72e7694e64f81c5911
6
+ metadata.gz: 02bb7f16c232d7fae6b8f51b7959c2a89161eef2625a2daae1e0c7c97a93d898a7d99e4efc396a61a59e570a4c9f90693e05edbb5fe9ce6bbb375e2ee71fccd2
7
+ data.tar.gz: fb3f6c70f8e3b4594438ca99d72078ac5193e586d8abb449d452cfec17cba0f502908acd60744a70c66bb6b660df4c7e0a1260e1e2fa65a3a9c38b3348436248
data/README.md CHANGED
@@ -1,16 +1,17 @@
1
1
  # ForemanNetbox
2
2
 
3
- [<img src="https://opensourcelogos.aws.dmtech.cloud/dmTECH_opensource_logo.svg" height="21" width="130">](https://www.dmtech.de/)
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 introduces integration with [NetBox](https://netbox.readthedocs.io)
6
6
 
7
7
  ## Compatibility
8
8
 
9
- | Netbox Version | Plugin Version |
10
- | -------------- | -------------- |
11
- | 2.8 | 1.0 |
12
- | 2.11 | 1.1 |
13
- | 3.3 | 1.2 |
9
+ | Foreman Version | Netbox Version | Plugin Version |
10
+ | --------------- | -------------- | -------------- |
11
+ | <3.13 | 2.8 | 1.0 |
12
+ | <3.13 | 2.11 | 1.1 |
13
+ | <3.13 | 3.3 | 1.2 |
14
+ | >=3.13 | 3.5 | 2.0 |
14
15
 
15
16
  ## Installation
16
17
 
@@ -10,7 +10,7 @@ module ForemanNetbox
10
10
  end
11
11
 
12
12
  def call
13
- ForemanNetbox::API.client.dcim.devices.find_by(name: context.host.name)&.delete
13
+ ForemanNetbox::Api.client.dcim.devices.find_by(name: context.host.name)&.delete
14
14
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
15
15
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
16
16
  context.fail!(error: "#{self.class}: #{e}")
@@ -10,7 +10,7 @@ module ForemanNetbox
10
10
  end
11
11
 
12
12
  def call
13
- ForemanNetbox::API.client.virtualization.virtual_machines.find_by(name: context.host.name)&.delete
13
+ ForemanNetbox::Api.client.virtualization.virtual_machines.find_by(name: context.host.name)&.delete
14
14
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
15
15
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
16
16
  context.fail!(error: "#{self.class}: #{e}")
@@ -6,7 +6,7 @@ module ForemanNetbox
6
6
  include ::Interactor::Organizer
7
7
 
8
8
  organize DeleteHost::DeleteVirtualMachine,
9
- DeleteHost::DeleteDevice
9
+ DeleteHost::DeleteDevice
10
10
  end
11
11
  end
12
12
  end
@@ -11,7 +11,7 @@ module ForemanNetbox
11
11
  end
12
12
 
13
13
  organize SyncHost::SyncVirtualMachine::Organizer,
14
- SyncHost::SyncDevice::Organizer
14
+ SyncHost::SyncDevice::Organizer
15
15
 
16
16
  def call
17
17
  super
@@ -12,7 +12,7 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  def call
15
- context.device = ForemanNetbox::API.client::DCIM::Device.new(params).save
15
+ context.device = ForemanNetbox::Api.client::DCIM::Device.new(params).save
16
16
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
17
17
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
18
18
  context.fail!(error: "#{self.class}: #{e}")
@@ -7,9 +7,7 @@ module ForemanNetbox
7
7
  include ::Interactor
8
8
 
9
9
  def call
10
- # rubocop:disable Rails/DynamicFindBy
11
10
  context.device = find_by_serial || find_by_mac || find_by_name
12
- # rubocop:enable Rails/DynamicFindBy
13
11
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
14
12
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
15
13
  context.fail!(error: "#{self.class}: #{e}")
@@ -23,17 +21,17 @@ module ForemanNetbox
23
21
  def find_by_serial
24
22
  serial = netbox_params.dig(:device, :serial)
25
23
 
26
- ForemanNetbox::API.client.dcim.devices.filter(serial: serial).first if serial
24
+ ForemanNetbox::Api.client.dcim.devices.filter(serial: serial).first if serial
27
25
  end
28
26
 
29
27
  def find_by_mac
30
- ForemanNetbox::API.client.dcim.devices.filter(mac_address: mac).first if mac
28
+ ForemanNetbox::Api.client.dcim.devices.filter(mac_address: mac).first if mac
31
29
  end
32
30
 
33
31
  def find_by_name
34
32
  name = netbox_params.dig(:device, :name)
35
33
 
36
- ForemanNetbox::API.client.dcim.devices.find_by(name: name)
34
+ ForemanNetbox::Api.client.dcim.devices.find_by(name: name)
37
35
  end
38
36
  end
39
37
  end
@@ -15,16 +15,16 @@ module ForemanNetbox
15
15
  end
16
16
 
17
17
  organize SyncDevice::Validate,
18
- SyncHost::SyncTags::Organizer,
19
- SyncHost::SyncTenant::Organizer,
20
- SyncDevice::SyncSite::Organizer,
21
- SyncDevice::SyncDeviceRole::Organizer,
22
- SyncDevice::SyncDeviceType::Organizer,
23
- SyncDevice::Find,
24
- SyncDevice::Create,
25
- SyncDevice::SyncInterfaces::Organizer,
26
- SyncDevice::Update,
27
- SyncDevice::SaveNetboxUrl
18
+ SyncHost::SyncTags::Organizer,
19
+ SyncHost::SyncTenant::Organizer,
20
+ SyncDevice::SyncSite::Organizer,
21
+ SyncDevice::SyncDeviceRole::Organizer,
22
+ SyncDevice::SyncDeviceType::Organizer,
23
+ SyncDevice::Find,
24
+ SyncDevice::Create,
25
+ SyncDevice::SyncInterfaces::Organizer,
26
+ SyncDevice::Update,
27
+ SyncDevice::SaveNetboxURL
28
28
  end
29
29
  end
30
30
  end
@@ -3,7 +3,7 @@
3
3
  module ForemanNetbox
4
4
  module SyncHost
5
5
  module SyncDevice
6
- class SaveNetboxUrl
6
+ class SaveNetboxURL
7
7
  include ::Interactor
8
8
 
9
9
  around do |interactor|
@@ -12,7 +12,7 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  def call
15
- context.device_role = ForemanNetbox::API.client::DCIM::DeviceRole.new(params).save
15
+ context.device_role = ForemanNetbox::Api.client::DCIM::DeviceRole.new(params).save
16
16
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
17
17
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
18
18
  context.fail!(error: "#{self.class}: #{e}")
@@ -8,7 +8,7 @@ module ForemanNetbox
8
8
  include ::Interactor
9
9
 
10
10
  def call
11
- context.device_role = ForemanNetbox::API.client.dcim.device_roles.find_by(params)
11
+ context.device_role = ForemanNetbox::Api.client.dcim.device_roles.find_by(params)
12
12
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
13
13
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
14
14
  context.fail!(error: "#{self.class}: #{e}")
@@ -12,7 +12,7 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  organize SyncDeviceRole::Find,
15
- SyncDeviceRole::Create
15
+ SyncDeviceRole::Create
16
16
  end
17
17
  end
18
18
  end
@@ -13,7 +13,7 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  def call
16
- context.device_type = ForemanNetbox::API.client::DCIM::DeviceType.new(params).save
16
+ context.device_type = ForemanNetbox::Api.client::DCIM::DeviceType.new(params).save
17
17
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
18
18
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
19
19
  context.fail!(error: "#{self.class}: #{e}")
@@ -8,7 +8,7 @@ module ForemanNetbox
8
8
  include ::Interactor
9
9
 
10
10
  def call
11
- context.device_type = ForemanNetbox::API.client.dcim.device_types.find_by(params)
11
+ context.device_type = ForemanNetbox::Api.client.dcim.device_types.find_by(params)
12
12
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
13
13
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
14
14
  context.fail!(error: "#{self.class}: #{e}")
@@ -12,9 +12,9 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  organize SyncDeviceType::SyncManufacturer::Organizer,
15
- SyncDeviceType::Find,
16
- SyncDeviceType::Update,
17
- SyncDeviceType::Create
15
+ SyncDeviceType::Find,
16
+ SyncDeviceType::Update,
17
+ SyncDeviceType::Create
18
18
  end
19
19
  end
20
20
  end
@@ -13,7 +13,7 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  def call
16
- context.manufacturer = ForemanNetbox::API.client::DCIM::Manufacturer.new(params).save
16
+ context.manufacturer = ForemanNetbox::Api.client::DCIM::Manufacturer.new(params).save
17
17
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
18
18
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
19
19
  context.fail!(error: "#{self.class}: #{e}")
@@ -9,10 +9,9 @@ module ForemanNetbox
9
9
  include ::Interactor
10
10
 
11
11
  def call
12
- # rubocop:disable Rails/DynamicFindBy
13
12
  context.manufacturer = find_by_slug || find_by_name
14
- # rubocop:enable Rails/DynamicFindBy
15
- rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
13
+ rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError,
14
+ NetboxClientRuby::RemoteError => e
16
15
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
17
16
  context.fail!(error: "#{self.class}: #{e}")
18
17
  end
@@ -24,13 +23,13 @@ module ForemanNetbox
24
23
  def find_by_slug
25
24
  params = netbox_params.fetch(:manufacturer).slice(:slug)
26
25
 
27
- ForemanNetbox::API.client.dcim.manufacturers.find_by(params)
26
+ ForemanNetbox::Api.client.dcim.manufacturers.find_by(params)
28
27
  end
29
28
 
30
29
  def find_by_name
31
30
  params = netbox_params.fetch(:manufacturer).slice(:name)
32
31
 
33
- ForemanNetbox::API.client.dcim.manufacturers.find_by(params)
32
+ ForemanNetbox::Api.client.dcim.manufacturers.find_by(params)
34
33
  end
35
34
  end
36
35
  end
@@ -13,7 +13,7 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  organize SyncManufacturer::Find,
16
- SyncManufacturer::Create
16
+ SyncManufacturer::Create
17
17
  end
18
18
  end
19
19
  end
@@ -17,7 +17,7 @@ module ForemanNetbox
17
17
  .select { |i| i[:name] }
18
18
  .reject { |i| interfaces.map(&:name).include?(i[:name]) }
19
19
  .map do |new_interface|
20
- ForemanNetbox::API.client::DCIM::Interface.new(
20
+ ForemanNetbox::Api.client::DCIM::Interface.new(
21
21
  new_interface.except(:type)
22
22
  .merge(
23
23
  type: new_interface.dig(:type, :value),
@@ -8,7 +8,7 @@ module ForemanNetbox
8
8
  include ::Interactor
9
9
 
10
10
  def call
11
- context.interfaces = ForemanNetbox::API.client.dcim.interfaces.filter(params)
11
+ context.interfaces = ForemanNetbox::Api.client.dcim.interfaces.filter(params)
12
12
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
13
13
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
14
14
  context.fail!(error: "#{self.class}: #{e}")
@@ -20,7 +20,7 @@ module ForemanNetbox
20
20
 
21
21
  def params
22
22
  {
23
- device_id: device.id
23
+ device_id: device.id,
24
24
  }
25
25
  end
26
26
  end
@@ -12,10 +12,10 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  organize SyncInterfaces::Find,
15
- SyncInterfaces::Delete,
16
- SyncInterfaces::Create,
17
- SyncInterfaces::SyncIpAddresses::Organizer,
18
- SyncInterfaces::Update
15
+ SyncInterfaces::Delete,
16
+ SyncInterfaces::Create,
17
+ SyncInterfaces::SyncIpAddresses::Organizer,
18
+ SyncInterfaces::Update
19
19
  end
20
20
  end
21
21
  end
@@ -14,14 +14,14 @@ module ForemanNetbox
14
14
  interface_id = interfaces_map.fetch(ip_address.dig(:interface, :name), nil)
15
15
 
16
16
  next unless interface_id
17
- next unless ForemanNetbox::API.client
17
+ next unless ForemanNetbox::Api.client
18
18
  .ipam
19
19
  .ip_addresses
20
20
  .filter(interface_id: interface_id, address: ip_address[:address])
21
21
  .total
22
22
  .zero?
23
23
 
24
- ForemanNetbox::API.client::IPAM::IpAddress.new(
24
+ ForemanNetbox::Api.client::IPAM::IpAddress.new(
25
25
  ip_address.slice(:address)
26
26
  .merge(
27
27
  assigned_object_type: 'dcim.interface', assigned_object_id: interface_id,
@@ -21,7 +21,9 @@ module ForemanNetbox
21
21
  ip_addresses_netbox_params = netbox_params.fetch(:ip_addresses, [])
22
22
 
23
23
  context.interfaces.each do |netbox_interface|
24
- host_interface_ips = ip_addresses_netbox_params.select { |i| i.dig(:interface, :name) == netbox_interface.name }
24
+ host_interface_ips = ip_addresses_netbox_params.select do |i|
25
+ i.dig(:interface, :name) == netbox_interface.name
26
+ end
25
27
  .map { |i| i.fetch(:address) }
26
28
 
27
29
  context.ip_addresses
@@ -9,7 +9,7 @@ module ForemanNetbox
9
9
  include ::Interactor
10
10
 
11
11
  def call
12
- context.ip_addresses = ForemanNetbox::API.client.ipam.ip_addresses.filter(params)
12
+ context.ip_addresses = ForemanNetbox::Api.client.ipam.ip_addresses.filter(params)
13
13
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
14
14
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
15
15
  context.fail!(error: "#{self.class}: #{e}")
@@ -21,7 +21,7 @@ module ForemanNetbox
21
21
 
22
22
  def params
23
23
  {
24
- device_id: device.id
24
+ device_id: device.id,
25
25
  }
26
26
  end
27
27
  end
@@ -13,9 +13,9 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  organize SyncIpAddresses::Find,
16
- SyncIpAddresses::Delete,
17
- SyncIpAddresses::Update,
18
- SyncIpAddresses::Create
16
+ SyncIpAddresses::Delete,
17
+ SyncIpAddresses::Update,
18
+ SyncIpAddresses::Create
19
19
  end
20
20
  end
21
21
  end
@@ -13,7 +13,7 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  def call
16
- context.site = ForemanNetbox::API.client::DCIM::Site.new(params).save
16
+ context.site = ForemanNetbox::Api.client::DCIM::Site.new(params).save
17
17
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
18
18
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
19
19
  context.fail!(error: "#{self.class}: #{e}")
@@ -8,7 +8,7 @@ module ForemanNetbox
8
8
  include ::Interactor
9
9
 
10
10
  def call
11
- context.site = ForemanNetbox::API.client.dcim.sites.find_by(params)
11
+ context.site = ForemanNetbox::Api.client.dcim.sites.find_by(params)
12
12
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
13
13
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
14
14
  context.fail!(error: "#{self.class}: #{e}")
@@ -16,8 +16,8 @@ module ForemanNetbox
16
16
  end
17
17
 
18
18
  organize SyncSite::Find,
19
- SyncSite::Update,
20
- SyncSite::Create
19
+ SyncSite::Update,
20
+ SyncSite::Create
21
21
  end
22
22
  end
23
23
  end
@@ -15,7 +15,7 @@ module ForemanNetbox
15
15
  def new_tags
16
16
  SyncTags::Organizer::DEFAULT_TAGS
17
17
  .reject { |params| existing_slugs.include?(params[:slug]) }
18
- .map { |params| ForemanNetbox::API.client::Extras::Tag.new(params).save }
18
+ .map { |params| ForemanNetbox::Api.client::Extras::Tag.new(params).save }
19
19
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
20
20
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
21
21
  context.fail!(error: "#{self.class}: #{e}")
@@ -8,7 +8,7 @@ module ForemanNetbox
8
8
 
9
9
  def call
10
10
  context.tags = slugs.map do |slug|
11
- ForemanNetbox::API.client.extras.tags.find_by(slug: slug)
11
+ ForemanNetbox::Api.client.extras.tags.find_by(slug: slug)
12
12
  end.compact
13
13
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
14
14
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
@@ -7,7 +7,7 @@ module ForemanNetbox
7
7
  include ::Interactor::Organizer
8
8
 
9
9
  DEFAULT_TAGS = [
10
- { name: 'foreman', slug: 'foreman' }
10
+ { name: 'foreman', slug: 'foreman' },
11
11
  ].freeze
12
12
 
13
13
  after do
@@ -15,7 +15,7 @@ module ForemanNetbox
15
15
  end
16
16
 
17
17
  organize SyncTags::Find,
18
- SyncTags::Create
18
+ SyncTags::Create
19
19
  end
20
20
  end
21
21
  end
@@ -12,7 +12,7 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  def call
15
- context.tenant = ForemanNetbox::API.client::Tenancy::Tenant.new(params).save
15
+ context.tenant = ForemanNetbox::Api.client::Tenancy::Tenant.new(params).save
16
16
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
17
17
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
18
18
  context.fail!(error: "#{self.class}: #{e}")
@@ -7,7 +7,7 @@ module ForemanNetbox
7
7
  include ::Interactor
8
8
 
9
9
  def call
10
- context.tenant = ForemanNetbox::API.client.tenancy.tenants.find_by(params)
10
+ context.tenant = ForemanNetbox::Api.client.tenancy.tenants.find_by(params)
11
11
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
12
12
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
13
13
  context.fail!(error: "#{self.class}: #{e}")
@@ -11,8 +11,8 @@ module ForemanNetbox
11
11
  end
12
12
 
13
13
  organize SyncTenant::Find,
14
- SyncTenant::Update,
15
- SyncTenant::Create
14
+ SyncTenant::Update,
15
+ SyncTenant::Create
16
16
  end
17
17
  end
18
18
  end
@@ -12,7 +12,7 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  def call
15
- context.virtual_machine = ForemanNetbox::API.client::Virtualization::VirtualMachine.new(params).save
15
+ context.virtual_machine = ForemanNetbox::Api.client::Virtualization::VirtualMachine.new(params).save
16
16
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
17
17
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
18
18
  context.fail!(error: "#{self.class}: #{e}")
@@ -7,9 +7,7 @@ module ForemanNetbox
7
7
  include ::Interactor
8
8
 
9
9
  def call
10
- # rubocop:disable Rails/DynamicFindBy
11
10
  context.virtual_machine = find_by_mac || find_by_name
12
- # rubocop:enable Rails/DynamicFindBy
13
11
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
14
12
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
15
13
  context.fail!(error: "#{self.class}: #{e}")
@@ -21,12 +19,12 @@ module ForemanNetbox
21
19
  delegate :mac, to: :host
22
20
 
23
21
  def find_by_mac
24
- ForemanNetbox::API.client.virtualization.virtual_machines.filter(mac_address: mac).first if mac
22
+ ForemanNetbox::Api.client.virtualization.virtual_machines.filter(mac_address: mac).first if mac
25
23
  end
26
24
 
27
25
  def find_by_name
28
26
  params = netbox_params.fetch(:virtual_machine).slice(:name)
29
- ForemanNetbox::API.client.virtualization.virtual_machines.find_by(params)
27
+ ForemanNetbox::Api.client.virtualization.virtual_machines.find_by(params)
30
28
  end
31
29
  end
32
30
  end
@@ -15,14 +15,14 @@ module ForemanNetbox
15
15
  end
16
16
 
17
17
  organize SyncVirtualMachine::Validate,
18
- SyncHost::SyncTags::Organizer,
19
- SyncHost::SyncTenant::Organizer,
20
- SyncVirtualMachine::SyncCluster::Organizer,
21
- SyncVirtualMachine::Find,
22
- SyncVirtualMachine::Create,
23
- SyncVirtualMachine::SyncInterfaces::Organizer,
24
- SyncVirtualMachine::Update,
25
- SyncVirtualMachine::SaveNetboxUrl
18
+ SyncHost::SyncTags::Organizer,
19
+ SyncHost::SyncTenant::Organizer,
20
+ SyncVirtualMachine::SyncCluster::Organizer,
21
+ SyncVirtualMachine::Find,
22
+ SyncVirtualMachine::Create,
23
+ SyncVirtualMachine::SyncInterfaces::Organizer,
24
+ SyncVirtualMachine::Update,
25
+ SyncVirtualMachine::SaveNetboxURL
26
26
  end
27
27
  end
28
28
  end
@@ -3,7 +3,7 @@
3
3
  module ForemanNetbox
4
4
  module SyncHost
5
5
  module SyncVirtualMachine
6
- class SaveNetboxUrl
6
+ class SaveNetboxURL
7
7
  include ::Interactor
8
8
 
9
9
  around do |interactor|
@@ -13,7 +13,7 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  def call
16
- context.cluster = ForemanNetbox::API.client::Virtualization::Cluster.new(params).save
16
+ context.cluster = ForemanNetbox::Api.client::Virtualization::Cluster.new(params).save
17
17
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
18
18
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
19
19
  context.fail!(error: "#{self.class}: #{e}")
@@ -8,7 +8,7 @@ module ForemanNetbox
8
8
  include ::Interactor
9
9
 
10
10
  def call
11
- context.cluster = ForemanNetbox::API.client.virtualization.clusters.find_by(params)
11
+ context.cluster = ForemanNetbox::Api.client.virtualization.clusters.find_by(params)
12
12
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
13
13
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
14
14
  context.fail!(error: "#{self.class}: #{e}")
@@ -12,9 +12,9 @@ module ForemanNetbox
12
12
  end
13
13
 
14
14
  organize SyncCluster::SyncClusterType::Organizer,
15
- SyncCluster::Find,
16
- SyncCluster::Update,
17
- SyncCluster::Create
15
+ SyncCluster::Find,
16
+ SyncCluster::Update,
17
+ SyncCluster::Create
18
18
  end
19
19
  end
20
20
  end
@@ -13,7 +13,7 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  def call
16
- context.cluster_type = ForemanNetbox::API.client::Virtualization::ClusterType.new(params).save
16
+ context.cluster_type = ForemanNetbox::Api.client::Virtualization::ClusterType.new(params).save
17
17
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
18
18
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
19
19
  context.fail!(error: "#{self.class}: #{e}")
@@ -11,7 +11,7 @@ module ForemanNetbox
11
11
  def call
12
12
  return unless params
13
13
 
14
- context.cluster_type = ForemanNetbox::API.client.virtualization.cluster_types.find_by(params)
14
+ context.cluster_type = ForemanNetbox::Api.client.virtualization.cluster_types.find_by(params)
15
15
  rescue NetboxClientRuby::LocalError, NetboxClientRuby::ClientError, NetboxClientRuby::RemoteError => e
16
16
  ::Foreman::Logging.logger('foreman_netbox/import').error("#{self.class} error #{e}: #{e.backtrace}")
17
17
  context.fail!(error: "#{self.class}: #{e}")
@@ -13,7 +13,7 @@ module ForemanNetbox
13
13
  end
14
14
 
15
15
  organize SyncClusterType::Find,
16
- SyncClusterType::Create
16
+ SyncClusterType::Create
17
17
  end
18
18
  end
19
19
  end