这是我的第一篇文章,所以我希望我在这里没有做错任何事情。
我从网站上获得了以下带有一些示例netmiko
脚本的代码。
预先感谢。
例如,我从一个站点复制了此脚本,并提供了一些netmiko
示例:
def render_to_file_and_deploy(self):
username, acc, password = \
netrc.netrc().authenticators(self._device.name)
device_data = {
'device_type': 'cisco_ios',
'ip': self._device.name,
'username': username,
'password': password,
}
f = NamedTemporaryFile(delete=False)
print('Stored temporary config at {}'.format(f.name))
f.write(self._device.rendered_config)
f.flush()
net_connect = ConnectHandler(**device_data)
output = net_connect.send_config_from_file(f.name)
print(output)
print('Config uploaded!')
f.close()
print('Done.')