nxos adapter¶
Features¶
The nxos module manages the configuration of Cisco NX-OS (Nexus) switches as declarative Inmanta resources. It
covers the common data-center switch configuration families, each exposed as its own submodule:
VLANs (
nxos::nxos_vlans)L2 interfaces (
nxos::nxos_interfaces) and L3 interfaces / IP addressing (nxos::nxos_l3_interfaces)VRFs — context, address-families and interface membership (
nxos::nxos_vrf_global,nxos::nxos_vrf_address_family,nxos::nxos_vrf_interfaces)BGP — global/router, per-address-family and per-neighbor address-family (
nxos::nxos_bgp_global,nxos::nxos_bgp_address_family,nxos::nxos_bgp_neighbor_address_family)Raw CLI escape hatch (
nxos::nxos_config)
Every family entity extends the shared base nxos::Module, so all families support create/update/purge. The DSL model
is generated (from the cisco.nxos Ansible collection argspecs; generated files are tagged # <IMF-GENERATED-FILE/>),
but deployment does not use Ansible at runtime: a native handler talks to the device over the NX-OS xmlagent SSH
subsystem (NETCONF via ncclient), reads show running-config | section, computes an ownership-aware CLI delta and
pushes CLI lines. This lets multiple resources co-manage a shared device object (e.g. router bgp, a shared
vrf context or interface) without clobbering each other.
Api configuration¶
Resources connect through a nxos::Connection entity:
Attribute |
Description |
|---|---|
|
Management address of the device; also used as the Inmanta agent name |
|
Login user for the |
|
Login password for the |
Every family resource carries a connection relation. Authentication is NETCONF over SSH (port 22) to the NX-OS
xmlagent subsystem, using plain username/password auth (no key auth). Because host is the agent name, all resources
targeting one device serialize on that device.
:bulb: The NETCONF timeout can be tuned with the
N7K_NETCONF_TIMEOUTenvironment variable on the agent (default60seconds). No config file is read; credentials live on theConnectionentity.
Usage example¶
The example connects to a device, creates a VLAN and configures the matching SVI interface and its IP address. Because
host is the agent name, these resources serialize per device; explicit requires order the config.
import nxos
import nxos::nxos_vlans
import nxos::nxos_vlans::config
import nxos::nxos_interfaces
import nxos::nxos_interfaces::config
import nxos::nxos_l3_interfaces
import nxos::nxos_l3_interfaces::config
import nxos::nxos_l3_interfaces::config::ipv4
conn = nxos::Connection(host="n7k-edge-01.example.com", username="admin", password="changeme")
# VLAN 446
vlan = nxos::nxos_vlans::Vlans(
name="vlan_446",
purged=false,
connection=conn,
config=[nxos::nxos_vlans::config::Config(vlan_id=446, name="ci-complex-446")],
)
# The SVI interface (Vlan446)
iface = nxos::nxos_interfaces::Interfaces(
name="iface_Vlan446",
purged=false,
connection=conn,
config=[
nxos::nxos_interfaces::config::Config(
name="Vlan446",
description="*** complex-site SVI ***",
enabled=true,
mtu="9100",
),
],
)
# The SVI IP address
l3 = nxos::nxos_l3_interfaces::L3Interfaces(
name="l3_Vlan446",
purged=false,
connection=conn,
config=[
nxos::nxos_l3_interfaces::config::Config(
name="Vlan446",
ipv4=[nxos::nxos_l3_interfaces::config::ipv4::Ipv4(address="10.99.46.1/29")],
redirects=false,
),
],
)
# Deploy order: vlan -> interface -> ip
iface.requires = [vlan]
l3.requires = [iface]
Setting purged=true on a resource tears down the config it owns. A full multi-family edge-router example (VRF +
route-targets + BGP global/neighbors/address-families + SVI + raw config) is available in examples/complex_site.cf.
Main entities¶
nxos::Connection— device host + SSH credentials, shared by all resources targeting one device; itshostis the agent name.nxos::Module— abstract base (extendsstd::PurgeableResource) for all family resources.nxos::nxos_vlans::Vlans(+config::Config) — manage VLANs.nxos::nxos_interfaces::Interfaces(+config::Config) — L2/physical/SVI interface settings.nxos::nxos_l3_interfaces::L3Interfaces(+config::Config,config::ipv4::Ipv4) — L3 interface IP addressing.nxos::nxos_vrf_global::VrfGlobal—vrf context(name, description, rd).nxos::nxos_vrf_address_family::VrfAddressFamily— per-VRF address-families and route-target import/export.nxos::nxos_vrf_interfaces::VrfInterfaces—vrf memberbinding of an interface to a VRF.nxos::nxos_bgp_global::BgpGlobal—router bgpAS, per-VRF local-as and neighbors.nxos::nxos_bgp_address_family::BgpAddressFamily— per-VRF-AFredistribute,maximum_paths.nxos::nxos_bgp_neighbor_address_family::BgpNeighborAddressFamily— per-neighbor address-family options.nxos::nxos_config::Config— raw CLI escape hatch (linesunderparents_contexts, plus config-management options).