Skip to content

NETCONF Get Capabilities¤

List capabilities advertised by device NETCONF sessions using ncclient or Scrapli. Use netconf_get_capabilities to check protocol features and advertised YANG modules.

Output¤

Each host has a server_capabilities list of capability URIs. A capability filter with no matches returns an empty list. add_details=True includes metadata and to_dict=False returns serialized records. Connection errors mark hosts as failed.

Examples¤

nf# nornir netconf get-capabilities plugin ncclient FC spine
nf# nornir netconf get-capabilities plugin scrapli capab-filter *candidate* FC leaf
from norfab.core.nfapi import NorFab

with NorFab(inventory="inventory.yaml") as nf:
    client = nf.make_client()
    result = client.run_job(
        "nornir", "netconf_get_capabilities",
        kwargs={"plugin": "scrapli", "capab_filter": "*candidate*", "FC": "leaf"},
    )
    print(result)

Notes¤

  • capab_filter is a case-sensitive glob. Omit it to retrieve all capability URIs.
  • Host filters select devices. The capability filter selects URIs within each reply.
  • Capabilities describe the session. Use YANG Library or NETCONF monitoring for a fuller module inventory. Retrieve module source with get-schema.
  • Configure the backend using the NETCONF inventory.

Troubleshooting¤

Check NETCONF connectivity and credentials for connection errors. An empty filtered list means no advertised URI matched. It does not indicate a failed RPC.

Task Command Shell Reference¤

nf#man tree nornir.netconf.get_capabilities

R - required field, M - supports multiline input, D - dynamic key

root
└── nornir:    Nornir service
    └── netconf:    Manage devices using NETCONF
        └── get-capabilities:    List NETCONF capabilities
            ├── timeout:    Job timeout
            ├── workers:    Filter workers to target, default 'all'
            ├── verbose-result:    Control output details, default 'False'
            ├── nowait:    Do not wait for job to complete, default 'False'
            ├── FO:    Filter hosts using a Nornir-Salt Filter Object
            ├── FB:    Filter hosts by name using glob patterns
            ├── FH:    Filter hosts by hostname
            ├── FC:    Filter hosts by name containment pattern
            ├── FR:    Filter hosts by name using regular expressions
            ├── FG:    Filter hosts by group
            ├── FP:    Filter hosts by hostname using IP prefix
            ├── FL:    Filter hosts by names list
            ├── FM:    Filter hosts by platform
            ├── FX:    Exclude hosts by name
            ├── FN:    Negate the host filter match
            ├── on-failed:    Run task on hosts currently marked as failed by Nornir, default 'False'
            ├── to-dict:    Return task results as a dictionary keyed by host, default 'True'
            ├── add-details:    Add Nornir task execution details to results, default 'False'
            ├── progress:    Emit progress events during task execution, default 'True'
            ├── num-workers:    RetryRunner number of threads for task execution
            ├── num-connectors:    RetryRunner number of threads for device connections
            ├── connect-retry:    RetryRunner number of connection attempts
            ├── task-retry:    RetryRunner number of attempts to run each task
            ├── reconnect-on-fail:    RetryRunner reconnects to a host after task failure
            ├── connect-check:    RetryRunner tests TCP connectivity before opening connection
            ├── connect-timeout:    RetryRunner TCP connection check timeout in seconds
            ├── creds-retry:    RetryRunner connection credentials and parameters to retry
            ├── tf:    File group name to save task results on the worker
            ├── tf-skip-failed:    Skip failed task results when saving to file
            ├── diff:    File group name to diff task results against
            ├── diff-last:    Previous saved file version to diff against
            ├── plugin:    NETCONF backend, default 'NetconfPlugin.ncclient'
            └── capab-filter:    Capability glob filter
nf#

Common host filters and job options apply.

Python API Reference¤

List NETCONF capabilities advertised by devices.

Parameters:

Name Type Description Default
job Job

NorFab job metadata.

required
plugin str

Backend name: ncclient (default) or scrapli.

'ncclient'
capab_filter str

Optional case-sensitive glob pattern to filter capability URIs. Omit to return all capabilities advertised for the session.

None
**kwargs Any

Common host filters, retries and serialization options.

{}

Returns:

Name Type Description
Result Result

Capability URI lists under each host's server_capabilities key, or serialized records with to_dict=False. An unmatched capability filter returns an empty list. Unmatched host filters return status no_match. Connection errors mark hosts as failed. Capabilities describe the current session and do not necessarily provide a complete inventory of available YANG modules.

Source code in norfab\workers\nornir_worker\netconf_task.py
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
@Task(
    fastapi={"methods": ["POST"]},
    input=NetconfGetCapabilitiesInput,
    output=NetconfResult,
    mcp={
        "annotations": {
            "title": "NETCONF Get Capabilities",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True,
        }
    },
)
def netconf_get_capabilities(
    self,
    job: Job,
    plugin: str = "ncclient",
    capab_filter: str = None,
    **kwargs: Any,
) -> Result:
    """List NETCONF capabilities advertised by devices.

    Args:
        job: NorFab job metadata.
        plugin: Backend name: ncclient (default) or scrapli.
        capab_filter: Optional case-sensitive glob pattern to filter capability
            URIs. Omit to return all capabilities advertised for the session.
        **kwargs: Common host filters, retries and serialization options.

    Returns:
        Result: Capability URI lists under each host's server_capabilities
            key, or serialized records with to_dict=False. An unmatched
            capability filter returns an empty list. Unmatched host filters
            return status no_match. Connection errors mark hosts as failed.
            Capabilities describe the current session and do not necessarily
            provide a complete inventory of available YANG modules.
    """
    return self._run_netconf(
        job,
        call="server_capabilities",
        plugin=plugin,
        capab_filter=capab_filter,
        **kwargs,
    )