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.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/app/interactors/foreman_netbox/delete_host/delete_device.rb +1 -1
- data/app/interactors/foreman_netbox/delete_host/delete_virtual_machine.rb +1 -1
- data/app/interactors/foreman_netbox/delete_host/organizer.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/organizer.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/find.rb +3 -5
- data/app/interactors/foreman_netbox/sync_host/sync_device/organizer.rb +10 -10
- data/app/interactors/foreman_netbox/sync_host/sync_device/save_netbox_url.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/find.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/organizer.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/find.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/organizer.rb +3 -3
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/find.rb +4 -5
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/organizer.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/find.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/organizer.rb +4 -4
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/create.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/delete.rb +3 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/find.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/organizer.rb +3 -3
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_site/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_site/find.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_device/sync_site/organizer.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_tags/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_tags/find.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_tags/organizer.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_tenant/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_tenant/find.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_tenant/organizer.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/find.rb +2 -4
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/organizer.rb +8 -8
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/save_netbox_url.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/find.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/organizer.rb +3 -3
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/create.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/find.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/organizer.rb +1 -1
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/create.rb +8 -8
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/find.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/organizer.rb +4 -4
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/create.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/delete.rb +3 -3
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/find.rb +2 -2
- data/app/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/organizer.rb +3 -3
- data/app/lib/foreman_netbox/api.rb +11 -2
- data/app/models/orchestration/netbox.rb +2 -4
- data/app/services/foreman_netbox/cached_netbox_parameters.rb +11 -11
- data/app/services/foreman_netbox/netbox_parameters.rb +29 -29
- data/app/services/foreman_netbox/netbox_parameters_comparator.rb +14 -8
- data/db/migrate/20230303095650_fix_netbox_settings_category_to_dsl.rb +0 -2
- data/lib/foreman_netbox/engine.rb +47 -40
- data/lib/foreman_netbox/version.rb +1 -1
- data/lib/tasks/foreman_netbox_tasks.rake +0 -50
- data/test/fixtures/netbox_device_raw_data.json +1 -1
- data/test/integration/foreman_netbox/sync_k8s_physical_host_test.rb +8 -8
- data/test/integration/foreman_netbox/sync_rhel_physical_host_test.rb +8 -8
- data/test/integration/foreman_netbox/sync_rhel_virtual_host_test.rb +8 -8
- data/test/interactors/foreman_netbox/sync_host/organizer_test.rb +9 -9
- data/test/interactors/foreman_netbox/sync_host/sync_device/create_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_device/save_netbox_url_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/create_test.rb +1 -1
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_role/find_test.rb +4 -4
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/create_test.rb +1 -1
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/find_test.rb +4 -4
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/create_test.rb +1 -1
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/find_test.rb +6 -6
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/update_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/create_test.rb +3 -3
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/delete_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/find_test.rb +4 -4
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/create_test.rb +5 -5
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/delete_test.rb +7 -7
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/find_test.rb +3 -3
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/update_test.rb +5 -5
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/update_test.rb +10 -10
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_site/create_test.rb +1 -1
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_site/find_test.rb +3 -3
- data/test/interactors/foreman_netbox/sync_host/sync_device/sync_site/update_test.rb +3 -3
- data/test/interactors/foreman_netbox/sync_host/sync_device/update_test.rb +11 -11
- data/test/interactors/foreman_netbox/sync_host/sync_tenant/create_test.rb +1 -1
- data/test/interactors/foreman_netbox/sync_host/sync_tenant/find_test.rb +3 -3
- data/test/interactors/foreman_netbox/sync_host/sync_tenant/update_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/create_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/save_netbox_url_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/create_test.rb +1 -1
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/find_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/sync_cluster_type/find_test.rb +4 -4
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_cluster/update_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/create_test.rb +3 -3
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/delete_test.rb +2 -2
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/find_test.rb +4 -4
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/create_test.rb +5 -5
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/delete_test.rb +7 -7
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/find_test.rb +3 -3
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/sync_ip_addresses/update_test.rb +7 -7
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/sync_interfaces/update_test.rb +9 -9
- data/test/interactors/foreman_netbox/sync_host/sync_virtual_machine/update_test.rb +10 -10
- data/test/models/foreman_netbox/netbox_facet_test.rb +1 -1
- data/test/models/foreman_netbox/nics/base_test.rb +1 -1
- data/test/services/foreman_netbox/netbox_attributes_test.rb +16 -16
- data/test/services/foreman_netbox/netbox_parameters_comparator_test.rb +31 -31
- data/test/test_plugin_helper.rb +1 -1
- data/test/unit/foreman_netbox/api_test.rb +52 -0
- metadata +88 -165
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2c91a8bd4a7bee1886c7d066161f77810c6cb11180feb3a10e559e317de1f57
|
4
|
+
data.tar.gz: a0cecb684f0a2b3c6866afa1cd0ec59809f9f9f24d8f9d8c4161f0b4ffb2d40c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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://
|
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::
|
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::
|
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}")
|
@@ -12,7 +12,7 @@ module ForemanNetbox
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
context.device = ForemanNetbox::
|
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::
|
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::
|
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::
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
@@ -12,7 +12,7 @@ module ForemanNetbox
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
context.device_role = ForemanNetbox::
|
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::
|
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}")
|
@@ -13,7 +13,7 @@ module ForemanNetbox
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
context.device_type = ForemanNetbox::
|
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::
|
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
|
-
|
16
|
-
|
17
|
-
|
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::
|
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}")
|
data/app/interactors/foreman_netbox/sync_host/sync_device/sync_device_type/sync_manufacturer/find.rb
CHANGED
@@ -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
|
-
|
15
|
-
|
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::
|
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::
|
32
|
+
ForemanNetbox::Api.client.dcim.manufacturers.find_by(params)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
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::
|
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::
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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::
|
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::
|
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
|
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
|
data/app/interactors/foreman_netbox/sync_host/sync_device/sync_interfaces/sync_ip_addresses/find.rb
CHANGED
@@ -9,7 +9,7 @@ module ForemanNetbox
|
|
9
9
|
include ::Interactor
|
10
10
|
|
11
11
|
def call
|
12
|
-
context.ip_addresses = ForemanNetbox::
|
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
|
-
|
17
|
-
|
18
|
-
|
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::
|
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::
|
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}")
|
@@ -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::
|
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::
|
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
|
-
|
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::
|
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::
|
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}")
|
@@ -12,7 +12,7 @@ module ForemanNetbox
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
context.virtual_machine = ForemanNetbox::
|
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::
|
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::
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
@@ -13,7 +13,7 @@ module ForemanNetbox
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
context.cluster = ForemanNetbox::
|
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::
|
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}")
|
@@ -13,7 +13,7 @@ module ForemanNetbox
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
context.cluster_type = ForemanNetbox::
|
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::
|
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}")
|