NAPALM is another tool for network automation. It is built on netmiko.
#!/usr/bin/env python
from napalm import get_network_driver
from jinja2 import Environment,FileSystemLoader
from yaml import safe_load
def main():
#this is important, read the file into structured data
with open("host.yml","r") as handle:
host_root = safe_load(handle)
for host in host_root["host_list"]:
print(f"Getting {host['platform']} driver")
driver = get_network_driver(host["platform"])
conn = driver(hostname = host["name"],username="pyuser",password="pypass"])
#open the connection and get the real model ID
conn.open()
facts = conn.get_facts()
print(facts)
print(f"{host['name']} model type: {facts['model']}")