Skip to content

feat(panos): add LLDP port discovery to PAN-OS inspect interface - #2564

Open
khackworth wants to merge 7 commits into
mainfrom
panos-inspect-lldp-ports
Open

khackworth wants to merge 7 commits into
mainfrom
panos-inspect-lldp-ports

Conversation

@khackworth

@khackworth khackworth commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements automatic LLDP neighbor discovery during PAN-OS device inspection to populate port MAC addresses and local_link_connection data.

Changes

  • panos_inspect.py: Add _discover_and_update_ports() to enable LLDP, wait for neighbor discovery, and update ports
  • panos_api.py: Add API methods for config management, commit operations, and LLDP neighbor retrieval

Testing

Draft PR to build container image for testing in dev environment with device PaloAlto-026701009584.

[dev-iad3] [k8s:uc_iad3_dev](panos-inspect-lldp-ports) khackwor understack % baremetal port list --node PaloAlto-026701009945 -f value -c UUID | xargs -I {} baremetal port delete {}

Deleted port 0e5f72bd-da52-47f7-984f-f71f3f0f0e2e
Deleted port 32734424-cefa-4ebc-b22f-f8693075418a
[dev-iad3] [k8s:uc_iad3_dev](panos-inspect-lldp-ports) khackwor understack %
[dev-iad3] [k8s:uc_iad3_dev](panos-inspect-lldp-ports) khackwor understack % openstack baremetal node inspect PaloAlto-026701009945

# waiting 2 or so minutes

[dev-iad3] [k8s:uc_iad3_dev](panos-inspect-lldp-ports) khackwor understack %
[dev-iad3] [k8s:uc_iad3_dev](panos-inspect-lldp-ports) khackwor understack % openstack baremetal port list --node  PaloAlto-026701009945 --long -f json | jq '.[] | {address, local_link_connection}'
{
  "address": "60:15:2b:62:4a:10",
  "local_link_connection": {
    "port_id": "Ethernet1/43",
    "switch_id": "c4:7e:e0:e4:03:37",
    "switch_info": "f20-3-2.iad3.rackspace.net"
  }
}
{
  "address": "60:15:2b:62:4a:11",
  "local_link_connection": {
    "port_id": "Ethernet1/44",
    "switch_id": "c4:7e:e0:e4:03:37",
    "switch_info": "f20-3-2.iad3.rackspace.net"
  }
}

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Python test results

466 tests   461 ✅  30s ⏱️
  1 suites    5 💤
  1 files      0 ❌

Results for commit 924db13.

♻️ This comment has been updated with latest results.

@khackworth
khackworth force-pushed the panos-inspect-lldp-ports branch from c1fc47f to 9e6c459 Compare October 23, 2026 15:13
@khackworth khackworth changed the title Add LLDP port discovery to PAN-OS inspect interface feat(panos): add LLDP port discovery to PAN-OS inspect interface Oct 23, 2026
@khackworth
khackworth force-pushed the panos-inspect-lldp-ports branch 4 times, most recently from 5632021 to d76ad65 Compare October 23, 2026 18:57
@khackworth
khackworth marked this pull request as ready for review October 23, 2026 19:04
@khackworth
khackworth enabled auto-merge October 23, 2026 19:04
Adds automatic network port discovery to PAN-OS firewalls during
inspection using LLDP neighbor discovery.

Implementation:
1. Removes factory default zone and virtual-wire configurations that
   would block interface configuration
2. Enables LLDP globally and configures it on all physical interfaces
3. Waits 30 seconds for LLDP neighbor discovery
4. Creates Ironic ports with local_link_connection metadata including:
   - switch_id (chassis ID)
   - port_id (remote port identifier)
   - switch_info (normalized FQDN switch name)
5. Derives VLAN groups from switch names using existing conventions
6. Removes temporary LLDP configuration to clean up

Port creation:
- Handles re-inspection gracefully by checking for existing ports
  by both MAC address and port name
- Normalizes switch names to FQDN format (adds .rackspace.net suffix)
  to match baremetal server port format
- Uses correct config group path for switch_name_vlan_group_mapping

IMPORTANT: This modifies device configuration and deletes factory
default settings. It should ONLY run during initial enrollment when
the device is in 'manageable' state, before any production
configuration exists. The inspect interface is only called during
enrollment, never on already-configured devices.
- Remove virtual-wire config from each interface before configuring as layer3
- Only commit factory cleanup if we actually deleted something
- Check commit return values and fail loudly with proper errors
- Include job details in commit failure error messages

This fixes inspection failures on devices with virtual-wire interfaces
configured, where commits were silently failing and code continued anyway.
Security rules reference zones, so they must be deleted first to avoid
validation errors when cleaning up factory/staging config for LLDP discovery.

This allows inspect to work on devices that have been through a staging
station that adds generic security rules.
Simplified LLDP discovery to configure all interfaces instead of trying
to detect which ones are already configured. Since the device must be in
manageable (not production) state, we can be destructive and just blast
through all interfaces.

This fixes the issue where ethernet1/1 and ethernet1/2 had virtual-wire
config that was detected as 'configured', causing them to be skipped,
which meant they never got LLDP enabled.
- Remove verbose DEBUG logs showing full XML responses and config operations from panos_api.py
- Remove per-interface deletion logs (22 lines per run)
- Add single summary log showing which factory configs were deleted
- Use contextlib.suppress for cleaner exception handling
- Keep essential INFO logs for key events (neighbor discovery, port creation)
Ruff S110 requires specific exception types instead of bare except Exception.
This also improves error handling by only catching the expected exception type.
@khackworth
khackworth force-pushed the panos-inspect-lldp-ports branch from d76ad65 to 924db13 Compare October 23, 2026 20:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant