Skip to content

Instantly share code, notes, and snippets.

@sulrich
Created March 26, 2024 01:35
Show Gist options
  • Save sulrich/354fdd48fbe29d1b0cc41518889f9c13 to your computer and use it in GitHub Desktop.
Save sulrich/354fdd48fbe29d1b0cc41518889f9c13 to your computer and use it in GitHub Desktop.
netconf capabilities dump
#!/usr/bin/env python3
from ncclient import manager
import argparse
NETCONF_PORT = "830"
def parseCliArgs():
"""parse command line options and CLI flag dependencies.
parameters: none
returns:
type: argparse object
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"-host",
"--hostname",
dest="hostname",
help="switch hostname",
required=True,
action="store",
)
parser.add_argument(
"-u",
"--username",
dest="username",
help="username for authentication",
required=True,
action="store",
)
parser.add_argument(
"-p",
"--password",
dest="password",
help="password for authentication",
required=True,
action="store",
)
args = parser.parse_args()
return args
def main():
args = parseCliArgs()
eos = manager.connect(
host=args.hostname,
port=NETCONF_PORT,
timeout=30,
username=args.username,
password=args.password,
hostkey_verify=False,
)
for item in eos.server_capabilities:
print(item)
eos.close_session()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment