-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type hints for napalm.base and napalm.nxos #1434
Conversation
…e checking for nxapi_plumbing
* Add IOSXR NETCONF driver boilerplate * Add base implementation for IOSXRNETCONFDriver class Implemented class initialization and open methods. In addition, added implementation for private lock and unlock methods. Remaining methods return NotImplementedError. Class makes use of the NETCONF implementation in the ncclient package. The open method establishes a connection using password based authentication and automatically locks the candidate datastore. * Add get_interfaces implementation Implement get interfaces using the operational data in Cisco-IOS-XR-pfi-im-cmd-oper YANG model. In addition, implement private _find_txt method to retrieve data leaves taking into account the data model namespace. The RPC filter and namespace strings added in constants.py. * Add get_interfaces_counters implementation Implement get interface counters using the operational data in Cisco-IOS-XR-pfi-im-cmd-oper YANG model. The RPC filter string is different from the filter used for get_interfaces method. Each method relies on data from different subtrees of the same operational data model. * Add get_facts implementation Implement get facts using the operational data in Cisco-IOS-XR-shellutil-oper, Cisco-IOS-XR-pfi-im-cmd-oper and Cisco-IOS-XR-invmgr-oper YANG models. Uses an explicit RPC string with multiple subtree filters to retrieve data from multiple data models in a single call. The RPC and namespace strings added in constants.py. * Add get_ntp_peers implementation Implement get NTP peers using the configuration data in Cisco-IOS-XR-ip-ntp-cfg YANG model. The RPC filter and namespace string added in constants.py. * Add get_ntp_servers implementation Implement get NTP servers using the configuration data in Cisco-IOS-XR-ip-ntp-cfg YANG model. * Add get_ntp_stats implementation Implement get NTP statistics using the operational data in Cisco-IOS-XR-ip-ntp-oper YANG model. The RPC filter and namespace string added in constants.py. * Add get_lldp_neighbors implementation Implement get LLDP neighbors using the operational data in Cisco-IOS-XR-ethernet-lldp-oper YANG model. The RPC filter and namespace string added in constants.py. * Add convert to text_type * Add get_bgp_neighbors implementation Implement get BGP neighbors using the operational data in Cisco-IOS-XR-ipv4-bgp-oper YANG model. The method uses a helper method (get_neighbors) to gather the neighbors of the default(global) VRF first and then the neighbors of the other VRFs. All the required operational data is retrieved from the device in a single RPC call. The RPC filter and namespace string added in constants.py. * Add get_bgp_config implementation Implement get BGP configuration using the configuration data in Cisco-IOS-XR-ipv4-bgp-cfg YANG model. The RPC filter and namespace string added in constants.py. * Add get_bgp_neighbors_detail implementation Implement get BGP neighbors detail using the operational data in Cisco-IOS-XR-ipv4-bgp-oper YANG model. The method uses a helper method (get_vrf_neighbors_detail) to gather the neighbors of the default(global) VRF first and then the neighbors of the other VRFs. All the required operational data is retrieved from the device in a single RPC call. * Add get_mac_address_table implementation Implement get MAC address table using the operational data in Cisco-IOS-XR-l2vpn-oper YANG model. The RPC filter and namespace string added in constants.py. * Add get_interfaces_ip implementation Implement get IP interfaces using the operational data in Cisco-IOS-XR-ipv4-io-oper and Cisco-IOS-XR-ipv6-ma-oper YANG models. Uses an explicit RPC string with multiple subtree filters to retrieve data from multiple data models in a single call. The RPC and namespace strings added in constants.py. * Add get_snmp_information implementation Implement get SNMP information using the configuration data in Cisco-IOS-XR-snmp-agent-cfg YANG model. The RPC and namespace strings added in constants.py. The ipv4 and ipv6 ACL data is now included in the result. The data was missing in the implementation of the IOSXR driver. * Add get_users implementation Implement get users using the configuration data in Cisco-IOS-XR-aaa-lib-cfg and Cisco-IOS-XR-aaa-locald-cfg YANG models. The RPC and namespace strings added in constants.py. * Add is_alive implementation Return false if the connection is not instantiated or not open. Otherwise, return true. * Add get_config implementation Return device running and/or candidate configurations. The `full` argument ignored as `with-default` capability is not supported. * Fix lock check during initialization * Add `close` implementation Close NETCONF session. Unlock candidate datastore if currently locked. * Add load_merge_candidate implementation Load and merge candidate configuration from a file or string. This method relies on a private method (_load_candidate_config) to read the configuration and issue an edit-config RPC with rollback-on-error error-option. If an error is detected on client or server side, a MergeConfigException is raised. * Add load_replace_candidate implementation Load and replace candidate configuration from a file or string. This method relies on a private method (_load_candidate_config) to read the configuration and issue an edit-config RPC with rollback-on-error error-option. If an error is detected on client or server side, a ReplaceConfigException is raised. * Add commit_config implementation Commit candidate configuration by issuing a NETCONF commit RPC. * Add discard_config implementation Discard the candidate configuration by issuing a NETCONF discard-changes RPC. * Add rollback implementation Roll back the last commit to the running configuration by issuing a roll-back-configuration-last RPC as defined in Cisco-IOS-XR-cfgmgr-rollback-act data model. * Remove legacy PY2 compatibility * Fix arguement typo in _find_txt * Fix load_replace_candidate to replace entire config Reimplement load replace candidate method to use copy-config RPC instead of edit-config RPC. This implementation guarantees an entire replacement of the configuration once a commit RPC is issued on the device. These changes slightly modified the load_merge_candidate implementation, but they don't alter its behaviour. * Add compare_config implementation Compare candidate and running datastores. The output is styled as a diff file. The XML strings for candidate and running configurations are parsed as etrees and re-encoded as strings to make the comparison more reliable. * Rework _find_txt implementation Improve handling of YANG-modeled data. The new implementation now differentiates between a path match (returns a string) and a non-match (returns None unless a default is specified). In case a path matches a tag without a value, an empty string is returned. While this implementation is not truly YANG-aware, it facilitates the handling of any presence containers or empty leafs. * Add get_lldp_neighbors_detail implementation Implement get LLDP neighbors detail using the operational data in Cisco-IOS-XR-ethernet-lldp-oper YANG model. No new RPC filter or namespace is being introduced. * Add get_arp_table implementation Implement get ARP table using the operational data in Cisco-IOS-XR-ipv4-arp-oper YANG model. The RPC filter and namespace string added in constants.py. * Add get_probes_config implementation Implement get probe configuration using the data in Cisco-IOS-XR-man-ipsla-cfg YANG model. The RPC filter and namespace string added in constants.py. * Add get_probes_results implementation Implement get probe results using the operational data in Cisco-IOS-XR-man-ipsla-oper YANG model. The RPC filter and namespace string added in constants.py. * Add get_route_to implementation Implement get route to using the operational data in Cisco-IOS-XR-ip-rib-ipv4-oper and Cisco-IOS-XR-ip-rib-ipv6-oper YANG models. The RPC filter and namespace string added in constants.py. * Refactor session attribute Rename 'self.netconf_ssh' as 'self.device' to make it consistent with other drivers and support pytest framework. * Fix get_route_to for an address without a mask Use a prefix length (mask) of zero when the method gets invoked without one. Using this default value guarantees a correct longest prefix match. * Add empty counters for subinterfaces and bundles Subinterfaces and bundles are now included in the interface counters dictionary. All counters for those interfaces are shown empty. Loopback interfaces are excluded from the dictionary. These changes make the result backward compatible with the `iosxr` driver. * Remove redundant bgp neighbor key check * Add traceroute implementation Implement trace route using the RPC in Cisco-IOS-XR-traceroute-act YANG models. The RPC and namespace strings added in constants.py. * Add support for key-based authentication * Add get_environment implementation Implement get environment using the operational data in environment monitoring, system monitoring and memory summary models. The environment monitoring data (power, fans, temperature) is retrieved from Cisco-IOS-XR-sysadmin-asr9k-envmon-ui, Cisco-IOS-XR-sysadmin-envmon-ui and Cisco-IOS-XR-sysadmin-fretta-envmon-ui YANG models. The system monitoring data (CPU) is retrieved from Cisco-IOS-XR-wdsysmon-fd-oper YANG model. The memory summary data (memory) is retrieved from Cisco-IOS-XR-nto-misc-oper YANG model. The current implementation supports ASR9000 (64 bit), NCS5500 and XRv 9000. The RPC filters and namespace strings added in constants.py. * Add base pytest implementation for get methods Create the child class `PatchedIOSXRNETCONFDriver` that uses a `FakeIOSXRNETCONFDevice` object as device driver. The device relies on mocked data stored in XML files. The data is returned by the device methods (dispatch, get, get_config) as objects of the `FakeRPCReply` class. * Add mocked data for test_is_alive File with expected results for the `is_alive` method in the patched driver. * Add support for temperature `Control Sensor` Read platform temperature from logical `Control Sensor` if present. This sensor provides an average of the physical temperature sensors. * Expand platform support for get_facts Retrieve basic attribute platforms from `Rack 0` entity for greater platform support. * Add explicit default to _find_txt invocations An empty string ("") is used as default to emulate the behaviour of napalm.base.helpers.find_txt. That function returns an empty string both when xml tag has no value and when xml tag doesn't exist. * Remove redundant lock checks * Black cleanup * Linting cleanup * Add mock data to test get_facts Mock data resides in per-platform directories. Each directory includes a version.md file with the software version of the device. This file exists for documentation purpose only. * Add mock data to test get_environment Mock data resides in per-platform directories. Each directory includes a version.md file with the software version of the device. This file exists for documentation purpose only. * Add logging support * Add mock data to test get_facts & get_environment (napalm-automation#1210) * Add 4-byte AS support for get_bgp_config * Fix is_enabled key in get_bgp_neighbors * Add logging support (napalm-automation#1217) * Remove RPC reply tag in get_config * Add optional argument for config encoding Define new optional argument (config_encoding) to specify the expected encoding in load_merge_config and load_replace_config. When not specified, the encoding defaults to "cli". A ValueError exception is raised if an invalid encoding is specified. * Add CLI support for load_replace_config Load replace config now supports both CLI and XML format based on config encoding attribute. * Add CLI support for load_merge_config Load merge config now supports both CLI and XML format based on config encoding attribute. * Add encoding support for get_config The get_config method now accepts an encoding argument that can be set to "xml" or "cli". The argument defaults to "cli". An exception is raised if an unsupported encoding value is provided. * Add encoding support for compare_config The compare_config method now accepts an encoding argument that can be set to "xml" or "cli". The argument defaults to "cli". An exception is raised if an unsupported encoding value is provided. * Linting cleanup * Add config filter for XR-only module set Retrieval of configuration in XML format is limited to models in the XR-only module set. All the other models are filtered out. Both get_config and compare_config make use of this filtering. * Add config filter for XR-only module set Retrieval of configuration in XML format is limited to models in the XR-only module set. All the other models are filtered out. Both get_config and compare_config make use of this filtering. The RPC filter and namespace string added in constants.py. The models in the module set are determined using the YANG library model. If a device doesn't support the YANG library model, no filtering is performed. * Add config filter for XR-only module set Retrieval of configuration in XML format is limited to models in the XR-only module set. All the other models are filtered out. Both get_config and compare_config make use of this filtering. The models in the module set are determined using the YANG library model. If a device doesn't support the YANG library model, explicit filtering is performed. * Linting cleanup * Bump black version in tox.ini to match requirements-dev.txt * Update constants with optimized snmp filter * Fix numeric defaults in probe getters * Rename get_environment mock data The mock data files now uniquely identify the set of model names and model roots they use. This naming convention applies to all mock data files. * Rename get_facts mock data * Add mock data to test get_facts on Cisco 8000 * Add mock data to test get_arp_table * Add mock data to test get_bgp_config * Add mock data to test get_bgp_neighbors * Add mock data to test get_bgp_neighbors_detail * Add mock data to test get_interfaces * Add mock data to test get_interfaces_counters * Add mock data to test get_interfaces_ip * Add mock data to test get_lldp_neighbors * Add mock data to test get_lldp_neighbors_detail * Add mock data to test get_mac_address_table * Add mock data to test get_ntp_peers * Add mock data to test get_ntp_servers * Add mock data to test get_ntp_stats * Add mock data to test get_probes_config * Add mock data to test get_probes_results * Add mock data to test get_route_to * Add mock data to test get_snmp_information * Add mock data to test get_users * Add mock data to test traceroute * Add mock data to test get_config * Fix mock data to test get_config * Refactor naming convention for mock data files The mock data files now uniquely identify the set of model names and model roots they use. This naming convention applies to all mock data files. For configuration getter methods, the datastore name (running, candidate) is appended as the suffix in the mock data file name. * Linting cleanup * Add support for new password encryption types Extends CISCO_SANITIZE_FILTERS to support 2-digit password encryption types. Previous regex supported only 1-digit password encryption types. * Add support for sanitized arg in get_config * Add mock data to test get_config (sanitized) * Add documentation for iosxr_netconf driver * Black * Fixing issues with tests; using object attribute for encoding * Black * Update black version * Fixing f-strings * Adding robust code * Black * Improving IOS-XR diff * Unifying strip_config_header such that code is shared * Adding ncclient as a direct dependency for IOS-XR NETCONF * Updating some of the docs * Minor doc update * Minor doc updates * Linting issue * XML config is experimental Co-authored-by: Neelima Parakala <[email protected]> Co-authored-by: Mircea Ulinic <[email protected]> Co-authored-by: Santiago Alvarez <[email protected]>
…terface Add source_interface argument to ping
change the function cli when result is xml object
I think we should just move forward with this and not hold off for discussions on #1441 (i.e. once conflicts are fixed, then we should just merge this PR). |
Alright. I will get the checks passing later and let you know. |
…e checking for nxapi_plumbing
I must admit that I don't have a clue as to what exactly is failing here. JunOS tests are reporting a missing |
Re-iterated upon in #1476. Something weird happened with this one, I don't know. The failing tests are running properly in that PR. Sorry for the mess! |
Supersede #1433, #1412 taking into account the newly added
napalm.iosxr_netconf
.