def get_hostname(device): device_type = "" if "xrv" in device.get("hostname"): device_type = "iosxr" if "IOS" in device.get("hostname"): device_type = "ios" tn = Telnet("172.20.0.1", port=device.get("port"), device_type=device_type, debug=True) tn.config_hostname(device.get("hostname"))
'password': '******', "mgt_ip": "172.20.3.119" }, { 'port': 33300, 'hostname': 'vIOS20', 'username': '******', 'password': '******', "mgt_ip": "172.20.3.120" }, { 'port': 33301, 'hostname': 'vIOS21', 'username': '******', 'password': '******', "mgt_ip": "172.20.3.121" }, ] for d in devices_info: device_type = "" if "xrv" in d.get("hostname"): device_type = "iosxr" if "IOS" in d.get("hostname"): device_type = "ios" tn = Telnet(host="172.20.0.1", port=d.get("port"), device_type=device_type, debug=True) tn.config_hostname(d.get("hostname"))