In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how python through the netconf protocol to obtain network element data, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
For network operation and maintenance (that is, network management), the unified management of the equipment in the network is the most important requirement, and the netconf protocol is born for this reason. Using netconf protocol, we can manage the network elements (that is, the computer units in the network) through the switch to improve the efficiency of network operation and maintenance.
[introduction to the principle]
Through NETCONF, network management can manage the devices in the network with visual interface, and it has high security, strong reliability and strong expansibility. As shown in the following figure, when a NETCONF session is established between the network manager and all the switches in the network, users can uniformly manage all the switches in the network on the visual interface provided by the network management, and improve the efficiency of network operation and maintenance.
The network manager manages the group network diagram of the equipment through NETCONF.
[introduction to the development process]
First, configure the network element and activate the configuration related to the netconf protocol, then write python to call the netconf module.
[network element configuration]
Log in to the management port of ne40e and configure it according to the following command. For configuration instructions, please see the network element configuration shown in the figure above.
System-viewaaalocal-user netconf001 password irreversible-cipher Root@123local-user netconf001 service-type sshlocal-user netconf001 user-group manage-ug ssh user netconf001ssh user netconf001 authentication-type passwordssh user netconf001 service-type allsnetconf server enable
The port of the default netconf is SSH port 22, or you can change it to another port with the following command:
Protocol inbound ssh port 830
[python code example]
It is recommended to use the third-party library ncclient to implement the call to netconf:
1. Install ncclient:
Pip install ncclient
2.Python references ncclient:
From ncclient import manager
3.Python obtains the interface status information of network elements through the get capability of netconf:
# establish a connection conn = manager.connect (host= "10.10.10.10", port=22, username= "netconf001", password= "Root@123", hostkey_verify=False, device_params= {'name':' huawei'}, allow_agent=False) Look_for_keys=False) # set to get the status information of the port (down or up) message =' '' # get calls ret = conn.get (("subtree") Message)) # print the returned information print (ret)
4. If you participate in the following example, you can see that the port GigabitEthernet0/0/0 is up:
GigabitEthernet0/0/0 up up above is all the contents of this article entitled "how python obtains the data of network elements through netconf protocol". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.