Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions module/sources/check_redfish/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ def __init__(self):
syncing.""",
default_value=False),

ConfigOption("skip_os_reported_ips",
bool,
description="""define if IP addresses which the BMC reports for the ports of the server
itself are skipped. Some BMCs (i.e. HPE iLO with AMS) report the IP addresses of the
operating system on the physical NICs. If the operating system is synced by another
source (i.e. VMware ESXi hosts) these IPs would be moved back and forth between
interfaces. If True only the IP addresses of the BMC ports are synced.""",
default_value=False),

ConfigOption(**config_option_ip_tenant_inheritance_order_definition),
]

Expand Down
3 changes: 3 additions & 0 deletions module/sources/check_redfish/import_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,9 @@ def update_network_interface(self):

# collect ip addresses
nic_ips[port_name] = list()
if self.settings.skip_os_reported_ips is True and mgmt_only is False:
continue

for ipv4_address in grab(nic_port, "ipv4_addresses", fallback=list()):
if self.settings.permitted_subnets.permitted(ipv4_address, interface_name=port_name) is False:
continue
Expand Down
7 changes: 7 additions & 0 deletions settings-example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,13 @@ inventory_file_path = /full/path/to/inventory/files
; incorrect syncing.
;skip_fhrp_group_ips = False

; define if IP addresses which the BMC reports for the ports of the server itself are
; skipped. Some BMCs (i.e. HPE iLO with AMS) report the IP addresses of the operating
; system on the physical NICs. If the operating system is synced by another source (i.e.
; VMware ESXi hosts) these IPs would be moved back and forth between interfaces. If True
; only the IP addresses of the BMC ports are synced.
;skip_os_reported_ips = False

; define in which order the IP address tenant will be assigned if tenant is undefined.
; possible values:
; * device : host or VM tenant will be assigned to the IP address
Expand Down
50 changes: 50 additions & 0 deletions tests/test_check_redfish_interface_ips.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
NBIPAddress objects.
"""

from module.common.misc import grab
from module.netbox.object_classes import NBInterface, NBIPAddress
from module.sources.common.permitted_subnets import PermittedSubnets


def seed_interface_with_ip(context, name="pnet0", address="172.10.10.12/24"):
Expand Down Expand Up @@ -71,3 +73,51 @@ def test_ip_is_still_removed_when_the_discovered_ips_are_unusable(check_redfish_
keep_undiscovered_ips=True)

assert "assigned_object_id" in ip.unset_items


def run_network_interface_sync(check_redfish_source, **settings):
"""Sync a server NIC port and a BMC port which both report IP addresses, like an HPE iLO
with AMS which reports the IPs of the operating system on the physical NICs."""

context = check_redfish_source(**settings)
source = context.source
context.inventory.netbox_api_version = "4.2.0"
source.interface_adapter_type_dict = {}
source.manager_name = "iLO 5"
source.settings.permitted_subnets = PermittedSubnets("10.0.0.0/8")
source.settings.ip_tenant_inheritance_order = []

source.inventory_file_content = {
"inventory": {
"network_port": [
{"id": "2.2", "addresses": ["8C:DC:D4:0F:D7:84"],
"operation_status": "Enabled", "link_status": "Up", "manager_ids": [],
"ipv4_addresses": ["10.40.232.163/22"], "ipv6_addresses": []},
{"id": "1:1", "name": "Manager Dedicated Network Interface",
"addresses": ["08:F1:EA:93:F3:D6"], "operation_status": "Enabled",
"link_status": "Up", "manager_ids": ["1"],
"ipv4_addresses": ["10.44.102.102/22"], "ipv6_addresses": []},
],
}
}

source.update_network_interface()

return {grab(ip, "data.assigned_object_id.data.name"): str(grab(ip, "data.address"))
for ip in context.inventory.get_all_items(NBIPAddress)}


def test_os_reported_ips_are_synced_by_default(check_redfish_source):
"""Without skip_os_reported_ips the IPs of all ports are synced, as before."""

assigned_ips = run_network_interface_sync(check_redfish_source)

assert assigned_ips == {"2.2": "10.40.232.163/22", "iLO 5 (1:1)": "10.44.102.102/22"}


def test_os_reported_ips_are_skipped(check_redfish_source):
"""With skip_os_reported_ips only the IPs of the BMC ports are synced."""

assigned_ips = run_network_interface_sync(check_redfish_source, skip_os_reported_ips=True)

assert assigned_ips == {"iLO 5 (1:1)": "10.44.102.102/22"}
Loading