Skip to content

Commit d09d883

Browse files
khackworthcardoe
andcommitted
feat(ironic): add PAN-OS inspect and management interfaces
Give the panos hardware type its own inspect and management interfaces that talk to the appliance over the PAN-OS XML API at driver_info['management_ip'], keeping the netdev no-op interfaces as fallbacks. Inspection logs in using the [netdev_panos] credentials, trying the standard, preconfig, then factory password so it works at any point in an appliance's setup, and records the model, serial, and firmware version from show system info. Model and serial set by enroll-fw are not overwritten. LLDP port discovery, HA peer discovery, initial configuration, and the cleaning steps are stubbed with their intended behavior documented. The initial configuration verify step only logs so enrollment isn't blocked; the manual clean steps fail rather than report work that wasn't done. Co-Authored-By: Doug Goldstein <doug.goldstein@rackspace.com>
1 parent ff8601a commit d09d883

13 files changed

Lines changed: 629 additions & 10 deletions

File tree

‎components/ironic/values.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ conf:
6161
enabled_console_interfaces: redfish-graphical,no-console
6262
enabled_deploy_interfaces: direct,ramdisk,noop
6363
enabled_firmware_interfaces: redfish,no-firmware
64-
enabled_inspect_interfaces: redfish,idrac-redfish,agent,no-inspect
65-
enabled_management_interfaces: redfish,idrac-redfish,noop
64+
enabled_inspect_interfaces: redfish,idrac-redfish,agent,panos,no-inspect
65+
enabled_management_interfaces: redfish,idrac-redfish,panos,noop
6666
enabled_network_interfaces: neutron,noop
6767
# remove fake once there is a noop that the ManualManagement uses, which netdev is derived from
6868
enabled_power_interfaces: redfish,idrac-redfish,fake

‎docs/design-guide/ironic.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,30 @@ bindings.
2020

2121
To use it, add `netdev` to `enabled_hardware_types` in `ironic.conf` and
2222
ensure `noop` deploy and `neutron` network interfaces are also enabled.
23+
24+
### panos
25+
26+
The `panos` hardware type is a `netdev` for PAN-OS (Palo Alto) firewalls, so
27+
these appliances can be told apart by their `driver`. It replaces the `netdev`
28+
inspect and management interfaces with `panos` ones, which talk to the
29+
appliance's XML API at `driver_info['management_ip']`. The no-op interfaces
30+
remain available as fallbacks.
31+
32+
- **inspect** logs in and records the model and serial (only when enroll-fw
33+
hasn't already set them) and `firmware_version`. LLDP-based port
34+
discovery and HA peer discovery are not implemented yet.
35+
- **management** has a `setup_initial_configuration` verify step, which
36+
currently only logs, and the manual clean steps `reset_to_factory_defaults`
37+
and `clear_configuration`. Those clean steps fail with "not implemented"
38+
instead of reporting success.
39+
40+
Credentials come from the `[netdev_panos]` oslo.config group. Login tries the
41+
standard password first, then preconfig, then factory, so it works with
42+
appliances at any point in their setup. `[netdev_panos] verify_ssl`
43+
(default off) controls TLS verification.
44+
45+
To use it, add `panos` to `enabled_hardware_types`, `enabled_inspect_interfaces`,
46+
and `enabled_management_interfaces`. Nodes enrolled before the `panos`
47+
interfaces existed keep their stored `no-inspect` and `noop` interfaces until
48+
they are switched with
49+
`openstack baremetal node set --inspect-interface panos --management-interface panos`.

‎python/ironic-understack/ironic_understack/conf/__init__.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def setup_conf():
4646
help="PAN-OS factory password",
4747
),
4848
cfg.StrOpt("panorama_master_key", secret=True, help="Panorama master key"),
49+
cfg.BoolOpt(
50+
"verify_ssl",
51+
default=False,
52+
help="Verify the TLS certificate of the PAN-OS XML API. Off by "
53+
"default because appliances ship with self-signed certificates.",
54+
),
4955
]
5056
panos_grp = cfg.OptGroup("netdev_panos", title="PAN-OS Credentials")
5157
cfg.CONF.register_group(panos_grp)
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1+
from ironic.drivers.modules import noop
2+
from ironic.drivers.modules import noop_mgmt
3+
14
from ironic_understack.drivers.netdev_hardware import NetdevHardware
5+
from ironic_understack.drivers.panos_inspect import PanosInspect
6+
from ironic_understack.drivers.panos_management import PanosManagement
27

38

49
class PanosHardware(NetdevHardware):
510
"""Hardware type for PAN-OS (Palo Alto) network appliances.
611
7-
Behaves exactly like :class:`NetdevHardware` today. It exists as a distinct
8-
hardware type so a PAN-OS appliance is identifiable from the node's
9-
``driver`` alone.
12+
A :class:`NetdevHardware` with PAN-OS inspect and management interfaces,
13+
which talk to the appliance over its XML API. The netdev no-op interfaces
14+
stay supported as fallbacks.
1015
"""
16+
17+
@property
18+
def supported_inspect_interfaces(self):
19+
return [PanosInspect, noop.NoInspect]
20+
21+
@property
22+
def supported_management_interfaces(self):
23+
return [PanosManagement, noop_mgmt.NoopManagement]
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
"""Inspect interface for PAN-OS (Palo Alto) appliances."""
2+
3+
from typing import ClassVar
4+
5+
import requests
6+
from ironic.common import exception
7+
from ironic.common import states
8+
from ironic.drivers import base
9+
from oslo_log import log
10+
11+
from ironic_understack.utils import panos_api
12+
13+
LOG = log.getLogger(__name__)
14+
15+
16+
class PanosInspect(base.InspectInterface):
17+
"""Inspect a PAN-OS appliance over its XML API.
18+
19+
No ramdisk is involved; everything goes over the management address in
20+
``driver_info['management_ip']``, which enroll-fw sets.
21+
"""
22+
23+
# A firewall has no memory_mb/local_gb/cpu_arch to report.
24+
ESSENTIAL_PROPERTIES: ClassVar[set] = set()
25+
26+
def get_properties(self):
27+
return {
28+
"management_ip": "Address of the appliance's management interface, "
29+
"used for the XML API. Required.",
30+
}
31+
32+
def validate(self, task):
33+
if not task.node.driver_info.get("management_ip"):
34+
raise exception.MissingParameterValue(
35+
f"Node {task.node.uuid} is missing driver_info management_ip"
36+
)
37+
38+
def inspect_hardware(self, task):
39+
node = task.node
40+
address = node.driver_info["management_ip"]
41+
client = panos_api.PanosClient(address)
42+
try:
43+
password = client.login()
44+
LOG.info(
45+
"[node:%s] Logged in to %s with the %s password",
46+
node.uuid,
47+
address,
48+
password,
49+
)
50+
system = client.system_info()
51+
except (panos_api.PanosApiError, requests.RequestException) as e:
52+
raise exception.HardwareInspectionFailure(
53+
error=f"PAN-OS {address}: {e}"
54+
) from e
55+
56+
_apply_system_info(node, system)
57+
58+
# TODO: discover data plane connectivity and create ports from it:
59+
# - show interface all, for the data plane interfaces and their MACs
60+
# - LLDP neighbors. Interfaces without config don't transmit LLDP, so
61+
# this needs to enable LLDP and a transmit-receive profile on them,
62+
# commit, wait for neighbors, collect them, then restore the
63+
# original config and commit again.
64+
# - an Ironic port per neighbor named "<node name>:<interface>", with
65+
# local_link_connection from the neighbor and the remote interface
66+
# as extra["bios_name"]
67+
# TODO: show high-availability all, recording the HA peer serial in
68+
# extra["mate_serial"] (which enroll-fw also sets) when HA is enabled.
69+
70+
node.save()
71+
return states.MANAGEABLE
72+
73+
74+
def _apply_system_info(node, system: dict[str, str]) -> None:
75+
"""Record what ``show system info`` reported on the node.
76+
77+
model and serial are also set by enroll-fw from Nautobot, so those are only
78+
filled in when missing; a disagreement is logged rather than overwritten.
79+
"""
80+
properties = dict(node.properties)
81+
extra = dict(node.extra)
82+
for target, key, field in (
83+
(properties, "model", "model"),
84+
(extra, "serial", "serial"),
85+
):
86+
found = system.get(field)
87+
if not found:
88+
continue
89+
if not target.get(key):
90+
target[key] = found
91+
elif target[key] != found:
92+
LOG.warning(
93+
"[node:%s] Appliance reports %s %r but the node has %r",
94+
node.uuid,
95+
key,
96+
found,
97+
target[key],
98+
)
99+
if system.get("sw-version"):
100+
properties["firmware_version"] = system["sw-version"]
101+
node.properties = properties
102+
node.extra = extra
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""Management interface for PAN-OS (Palo Alto) appliances."""
2+
3+
from ironic.common import exception
4+
from ironic.drivers import base
5+
from ironic.drivers.modules import noop_mgmt
6+
from oslo_log import log
7+
8+
LOG = log.getLogger(__name__)
9+
10+
11+
class PanosManagement(noop_mgmt.NoopManagement):
12+
"""Lifecycle steps for PAN-OS appliances.
13+
14+
Boot device methods don't apply to a firewall, so those are inherited from
15+
NoopManagement.
16+
"""
17+
18+
@base.verify_step(priority=10)
19+
def setup_initial_configuration(self, task):
20+
"""First-time setup of a factory-fresh appliance.
21+
22+
Runs on enroll -> manageable. It must be idempotent and skip an
23+
appliance that has already been set up. Planned steps, committed once
24+
at the end:
25+
26+
- management interface address, netmask, and gateway
27+
- remove the factory defaults that conflict with production use: the
28+
rule1 security rule, the trust and untrust zones, default-vwire, and
29+
the ethernet1/1 and ethernet1/2 config
30+
- jumbo frames
31+
- admin credentials, moving from the factory to the standard password
32+
- hostname from the node name
33+
"""
34+
# TODO: implement. Left as a no-op so enrollment isn't blocked on it.
35+
LOG.warning(
36+
"[node:%s] PAN-OS initial configuration is not implemented yet, skipping",
37+
task.node.uuid,
38+
)
39+
40+
@base.clean_step(priority=0, requires_ramdisk=False)
41+
def reset_to_factory_defaults(self, task):
42+
"""Factory reset the appliance, then rerun initial configuration."""
43+
# TODO: implement. Fails rather than reporting a reset that didn't happen.
44+
raise exception.NodeCleaningFailure(
45+
node=task.node.uuid, reason="PAN-OS factory reset is not implemented yet"
46+
)
47+
48+
@base.clean_step(priority=0, requires_ramdisk=False)
49+
def clear_configuration(self, task):
50+
"""Remove tenant configuration, without a full factory reset.
51+
52+
Removes security policies, NAT rules, and custom zones, interfaces,
53+
and routing. Keeps the management interface, admin credentials, and
54+
basic system settings.
55+
"""
56+
# TODO: implement. Fails rather than reporting a clean that didn't happen.
57+
raise exception.NodeCleaningFailure(
58+
node=task.node.uuid,
59+
reason="PAN-OS configuration cleanup is not implemented yet",
60+
)

0 commit comments

Comments
 (0)