Cisco automation/PyATS notes
1 Network automation from Cisco's automation/PyATS docker image
Cisco develops pyats. cs.co/pyats maps to developer.cisco.com/pyats
First the actual source of these notes is mostly from: hub.docker.com
2 pyATS
pyATS ir just a test framework
. A tool for writing and running test cases.
It features multiple packages and modules that make writing network-related
tests very easy.
You need python 3.5.x, 3.6.x, or 3.7.x (not 3.9). So will need to run it in a virutalenv. It does run on Linux and MacOSX
2.1 Out of box features:
See devnetcloud.com for pyats packages.
2.2 Simple example learning ospf
pyats learn ospf interface --testbed-file mytestbed.yaml --output ospf-today pyats diff ospf-today /ospf-yesterday
2.3 Simple example learning entire cml setup
A simple command-line call of pyats can get you to learn an entire cml lab and save the state (baseline) into a directory. Here is what I ran on my c8host under the pyats venv:
pyats learn all --testbed-file yaml/testbed.yml --output baseline/zintis-cml
Using the default YAML encoding key since no key was specified in configuration. THIS IS A SHARED KEY AND IS NOT SECURE, PLEASE RUN `pyats secret keygen` AND ADD TO YOUR pyats.conf FILE BEFORE ENCODING ANY VALUES. Learning '['acl', 'arp', 'bgp', 'dot1x', 'eigrp', 'fdb', 'hsrp', 'igmp', 'interface', 'isis', 'lag', 'lisp', 'lldp', 'mcast', 'mld', 'msdp', 'nd', 'ntp', 'ospf', 'pim', 'platform', 'prefix_list', 'rip', 'route_policy', 'routing', 'static_routing', 'stp', 'utils', 'vlan', 'vrf', 'vxlan', 'config']' on devices '['r0', 'r1', 'r2', 'r3', 'r4', 'r5']
This results in quite a long list of baseline files that can be then later used in a revision control system, such as git to compare changes. My system had six routers, so that generated a total of 372 files. 62 per router. Here the full list of what was tested:
+==============================================================================+ | Genie Learn Summary for device r0 | +==============================================================================+ | Connected to r0 | | - Log: baseline/zintis-cml/connection_r0.txt | |------------------------------------------------------------------------------| | Learnt feature 'acl' | | - Ops structure: baseline/zintis-cml/acl_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/acl_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'arp' | | - Ops structure: baseline/zintis-cml/arp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/arp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'bgp' | | - Ops structure: baseline/zintis-cml/bgp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/bgp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'dot1x' | | - Ops structure: baseline/zintis-cml/dot1x_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/dot1x_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'eigrp' | | - Ops structure: baseline/zintis-cml/eigrp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/eigrp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'fdb' | | - Ops structure: baseline/zintis-cml/fdb_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/fdb_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'hsrp' | | - Ops structure: baseline/zintis-cml/hsrp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/hsrp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'igmp' | | - Ops structure: baseline/zintis-cml/igmp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/igmp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'interface' | | - Ops structure: baseline/zintis-cml/interface_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/interface_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'isis' | | - Ops structure: baseline/zintis-cml/isis_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/isis_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lag' | | - Ops structure: baseline/zintis-cml/lag_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/lag_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lisp' | | - Ops structure: baseline/zintis-cml/lisp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/lisp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lldp' | | - Ops structure: baseline/zintis-cml/lldp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/lldp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mcast' | | - Ops structure: baseline/zintis-cml/mcast_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/mcast_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mld' | | - Ops structure: baseline/zintis-cml/mld_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/mld_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'msdp' | | - Ops structure: baseline/zintis-cml/msdp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/msdp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'nd' | | - Exception: baseline/zintis-cml/nd_ios_r0_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'ntp' | | - Ops structure: baseline/zintis-cml/ntp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/ntp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'ospf' | | - Ops structure: baseline/zintis-cml/ospf_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/ospf_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'pim' | | - Ops structure: baseline/zintis-cml/pim_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/pim_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'platform' | | - Ops structure: baseline/zintis-cml/platform_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/platform_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'prefix_list' | | - Ops structure: baseline/zintis-cml/prefix_list_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/prefix_list_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'rip' | | - Ops structure: baseline/zintis-cml/rip_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/rip_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'route_policy' | | - Ops structure: baseline/zintis-cml/route_policy_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/route_policy_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'routing' | | - Ops structure: baseline/zintis-cml/routing_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/routing_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'static_routing' | | - Ops structure: baseline/zintis-cml/static_routing_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/static_routing_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'stp' | | - Ops structure: baseline/zintis-cml/stp_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/stp_ios_r0_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'utils' | | - Exception: baseline/zintis-cml/utils_ios_r0_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'vlan' | | - Ops structure: baseline/zintis-cml/vlan_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/vlan_ios_r0_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'vrf' | | - Ops structure: baseline/zintis-cml/vrf_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/vrf_ios_r0_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'vxlan' | | - Exception: baseline/zintis-cml/vxlan_ios_r0_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'config' | | - Ops structure: baseline/zintis-cml/config_ios_r0_ops.txt | | - Device Console: baseline/zintis-cml/config_ios_r0_console.txt | |==============================================================================| +==============================================================================+ | Genie Learn Summary for device r1 | +==============================================================================+ | Connected to r1 | | - Log: baseline/zintis-cml/connection_r1.txt | |------------------------------------------------------------------------------| | Learnt feature 'acl' | | - Ops structure: baseline/zintis-cml/acl_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/acl_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'arp' | | - Ops structure: baseline/zintis-cml/arp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/arp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'bgp' | | - Ops structure: baseline/zintis-cml/bgp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/bgp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'dot1x' | | - Ops structure: baseline/zintis-cml/dot1x_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/dot1x_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'eigrp' | | - Ops structure: baseline/zintis-cml/eigrp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/eigrp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'fdb' | | - Ops structure: baseline/zintis-cml/fdb_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/fdb_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'hsrp' | | - Ops structure: baseline/zintis-cml/hsrp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/hsrp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'igmp' | | - Ops structure: baseline/zintis-cml/igmp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/igmp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'interface' | | - Ops structure: baseline/zintis-cml/interface_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/interface_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'isis' | | - Ops structure: baseline/zintis-cml/isis_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/isis_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lag' | | - Ops structure: baseline/zintis-cml/lag_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/lag_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lisp' | | - Ops structure: baseline/zintis-cml/lisp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/lisp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lldp' | | - Ops structure: baseline/zintis-cml/lldp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/lldp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mcast' | | - Ops structure: baseline/zintis-cml/mcast_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/mcast_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mld' | | - Ops structure: baseline/zintis-cml/mld_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/mld_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'msdp' | | - Ops structure: baseline/zintis-cml/msdp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/msdp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'nd' | | - Exception: baseline/zintis-cml/nd_ios_r1_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'ntp' | | - Ops structure: baseline/zintis-cml/ntp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/ntp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'ospf' | | - Ops structure: baseline/zintis-cml/ospf_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/ospf_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'pim' | | - Ops structure: baseline/zintis-cml/pim_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/pim_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'platform' | | - Ops structure: baseline/zintis-cml/platform_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/platform_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'prefix_list' | | - Ops structure: baseline/zintis-cml/prefix_list_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/prefix_list_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'rip' | | - Ops structure: baseline/zintis-cml/rip_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/rip_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'route_policy' | | - Ops structure: baseline/zintis-cml/route_policy_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/route_policy_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'routing' | | - Ops structure: baseline/zintis-cml/routing_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/routing_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'static_routing' | | - Ops structure: baseline/zintis-cml/static_routing_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/static_routing_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'stp' | | - Ops structure: baseline/zintis-cml/stp_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/stp_ios_r1_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'utils' | | - Exception: baseline/zintis-cml/utils_ios_r1_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'vlan' | | - Ops structure: baseline/zintis-cml/vlan_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/vlan_ios_r1_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'vrf' | | - Ops structure: baseline/zintis-cml/vrf_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/vrf_ios_r1_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'vxlan' | | - Exception: baseline/zintis-cml/vxlan_ios_r1_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'config' | | - Ops structure: baseline/zintis-cml/config_ios_r1_ops.txt | | - Device Console: baseline/zintis-cml/config_ios_r1_console.txt | |==============================================================================| +==============================================================================+ | Genie Learn Summary for device r2 | +==============================================================================+ | Connected to r2 | | - Log: baseline/zintis-cml/connection_r2.txt | |------------------------------------------------------------------------------| | Learnt feature 'acl' | | - Ops structure: baseline/zintis-cml/acl_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/acl_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'arp' | | - Ops structure: baseline/zintis-cml/arp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/arp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'bgp' | | - Ops structure: baseline/zintis-cml/bgp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/bgp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'dot1x' | | - Ops structure: baseline/zintis-cml/dot1x_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/dot1x_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'eigrp' | | - Ops structure: baseline/zintis-cml/eigrp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/eigrp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'fdb' | | - Ops structure: baseline/zintis-cml/fdb_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/fdb_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'hsrp' | | - Ops structure: baseline/zintis-cml/hsrp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/hsrp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'igmp' | | - Ops structure: baseline/zintis-cml/igmp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/igmp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'interface' | | - Ops structure: baseline/zintis-cml/interface_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/interface_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'isis' | | - Ops structure: baseline/zintis-cml/isis_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/isis_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lag' | | - Ops structure: baseline/zintis-cml/lag_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/lag_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lisp' | | - Ops structure: baseline/zintis-cml/lisp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/lisp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lldp' | | - Ops structure: baseline/zintis-cml/lldp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/lldp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mcast' | | - Ops structure: baseline/zintis-cml/mcast_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/mcast_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mld' | | - Ops structure: baseline/zintis-cml/mld_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/mld_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'msdp' | | - Ops structure: baseline/zintis-cml/msdp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/msdp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'nd' | | - Exception: baseline/zintis-cml/nd_ios_r2_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'ntp' | | - Ops structure: baseline/zintis-cml/ntp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/ntp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'ospf' | | - Ops structure: baseline/zintis-cml/ospf_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/ospf_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'pim' | | - Ops structure: baseline/zintis-cml/pim_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/pim_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'platform' | | - Ops structure: baseline/zintis-cml/platform_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/platform_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'prefix_list' | | - Ops structure: baseline/zintis-cml/prefix_list_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/prefix_list_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'rip' | | - Ops structure: baseline/zintis-cml/rip_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/rip_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'route_policy' | | - Ops structure: baseline/zintis-cml/route_policy_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/route_policy_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'routing' | | - Ops structure: baseline/zintis-cml/routing_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/routing_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'static_routing' | | - Ops structure: baseline/zintis-cml/static_routing_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/static_routing_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'stp' | | - Ops structure: baseline/zintis-cml/stp_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/stp_ios_r2_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'utils' | | - Exception: baseline/zintis-cml/utils_ios_r2_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'vlan' | | - Ops structure: baseline/zintis-cml/vlan_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/vlan_ios_r2_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'vrf' | | - Ops structure: baseline/zintis-cml/vrf_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/vrf_ios_r2_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'vxlan' | | - Exception: baseline/zintis-cml/vxlan_ios_r2_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'config' | | - Ops structure: baseline/zintis-cml/config_ios_r2_ops.txt | | - Device Console: baseline/zintis-cml/config_ios_r2_console.txt | |==============================================================================| +==============================================================================+ | Genie Learn Summary for device r3 | +==============================================================================+ | Connected to r3 | | - Log: baseline/zintis-cml/connection_r3.txt | |------------------------------------------------------------------------------| | Learnt feature 'acl' | | - Ops structure: baseline/zintis-cml/acl_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/acl_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'arp' | | - Ops structure: baseline/zintis-cml/arp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/arp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'bgp' | | - Ops structure: baseline/zintis-cml/bgp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/bgp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'dot1x' | | - Ops structure: baseline/zintis-cml/dot1x_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/dot1x_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'eigrp' | | - Ops structure: baseline/zintis-cml/eigrp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/eigrp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'fdb' | | - Ops structure: baseline/zintis-cml/fdb_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/fdb_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'hsrp' | | - Ops structure: baseline/zintis-cml/hsrp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/hsrp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'igmp' | | - Ops structure: baseline/zintis-cml/igmp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/igmp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'interface' | | - Ops structure: baseline/zintis-cml/interface_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/interface_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'isis' | | - Ops structure: baseline/zintis-cml/isis_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/isis_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lag' | | - Ops structure: baseline/zintis-cml/lag_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/lag_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lisp' | | - Ops structure: baseline/zintis-cml/lisp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/lisp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lldp' | | - Ops structure: baseline/zintis-cml/lldp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/lldp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mcast' | | - Ops structure: baseline/zintis-cml/mcast_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/mcast_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mld' | | - Ops structure: baseline/zintis-cml/mld_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/mld_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'msdp' | | - Ops structure: baseline/zintis-cml/msdp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/msdp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'nd' | | - Exception: baseline/zintis-cml/nd_ios_r3_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'ntp' | | - Ops structure: baseline/zintis-cml/ntp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/ntp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'ospf' | | - Ops structure: baseline/zintis-cml/ospf_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/ospf_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'pim' | | - Ops structure: baseline/zintis-cml/pim_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/pim_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'platform' | | - Ops structure: baseline/zintis-cml/platform_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/platform_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'prefix_list' | | - Ops structure: baseline/zintis-cml/prefix_list_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/prefix_list_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'rip' | | - Ops structure: baseline/zintis-cml/rip_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/rip_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'route_policy' | | - Ops structure: baseline/zintis-cml/route_policy_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/route_policy_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'routing' | | - Ops structure: baseline/zintis-cml/routing_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/routing_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'static_routing' | | - Ops structure: baseline/zintis-cml/static_routing_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/static_routing_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'stp' | | - Ops structure: baseline/zintis-cml/stp_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/stp_ios_r3_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'utils' | | - Exception: baseline/zintis-cml/utils_ios_r3_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'vlan' | | - Ops structure: baseline/zintis-cml/vlan_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/vlan_ios_r3_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'vrf' | | - Ops structure: baseline/zintis-cml/vrf_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/vrf_ios_r3_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'vxlan' | | - Exception: baseline/zintis-cml/vxlan_ios_r3_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'config' | | - Ops structure: baseline/zintis-cml/config_ios_r3_ops.txt | | - Device Console: baseline/zintis-cml/config_ios_r3_console.txt | |==============================================================================| +==============================================================================+ | Genie Learn Summary for device r4 | +==============================================================================+ | Connected to r4 | | - Log: baseline/zintis-cml/connection_r4.txt | |------------------------------------------------------------------------------| | Learnt feature 'acl' | | - Ops structure: baseline/zintis-cml/acl_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/acl_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'arp' | | - Ops structure: baseline/zintis-cml/arp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/arp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'bgp' | | - Ops structure: baseline/zintis-cml/bgp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/bgp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'dot1x' | | - Ops structure: baseline/zintis-cml/dot1x_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/dot1x_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'eigrp' | | - Ops structure: baseline/zintis-cml/eigrp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/eigrp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'fdb' | | - Ops structure: baseline/zintis-cml/fdb_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/fdb_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'hsrp' | | - Ops structure: baseline/zintis-cml/hsrp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/hsrp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'igmp' | | - Ops structure: baseline/zintis-cml/igmp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/igmp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'interface' | | - Ops structure: baseline/zintis-cml/interface_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/interface_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'isis' | | - Ops structure: baseline/zintis-cml/isis_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/isis_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lag' | | - Ops structure: baseline/zintis-cml/lag_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/lag_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lisp' | | - Ops structure: baseline/zintis-cml/lisp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/lisp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lldp' | | - Ops structure: baseline/zintis-cml/lldp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/lldp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mcast' | | - Ops structure: baseline/zintis-cml/mcast_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/mcast_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mld' | | - Ops structure: baseline/zintis-cml/mld_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/mld_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'msdp' | | - Ops structure: baseline/zintis-cml/msdp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/msdp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'nd' | | - Exception: baseline/zintis-cml/nd_ios_r4_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'ntp' | | - Ops structure: baseline/zintis-cml/ntp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/ntp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'ospf' | | - Ops structure: baseline/zintis-cml/ospf_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/ospf_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'pim' | | - Ops structure: baseline/zintis-cml/pim_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/pim_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'platform' | | - Ops structure: baseline/zintis-cml/platform_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/platform_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'prefix_list' | | - Ops structure: baseline/zintis-cml/prefix_list_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/prefix_list_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'rip' | | - Ops structure: baseline/zintis-cml/rip_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/rip_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'route_policy' | | - Ops structure: baseline/zintis-cml/route_policy_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/route_policy_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'routing' | | - Ops structure: baseline/zintis-cml/routing_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/routing_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'static_routing' | | - Ops structure: baseline/zintis-cml/static_routing_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/static_routing_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'stp' | | - Ops structure: baseline/zintis-cml/stp_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/stp_ios_r4_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'utils' | | - Exception: baseline/zintis-cml/utils_ios_r4_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'vlan' | | - Ops structure: baseline/zintis-cml/vlan_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/vlan_ios_r4_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'vrf' | | - Ops structure: baseline/zintis-cml/vrf_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/vrf_ios_r4_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'vxlan' | | - Exception: baseline/zintis-cml/vxlan_ios_r4_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'config' | | - Ops structure: baseline/zintis-cml/config_ios_r4_ops.txt | | - Device Console: baseline/zintis-cml/config_ios_r4_console.txt | |==============================================================================| +==============================================================================+ | Genie Learn Summary for device r5 | +==============================================================================+ | Connected to r5 | | - Log: baseline/zintis-cml/connection_r5.txt | |------------------------------------------------------------------------------| | Learnt feature 'acl' | | - Ops structure: baseline/zintis-cml/acl_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/acl_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'arp' | | - Ops structure: baseline/zintis-cml/arp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/arp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'bgp' | | - Ops structure: baseline/zintis-cml/bgp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/bgp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'dot1x' | | - Ops structure: baseline/zintis-cml/dot1x_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/dot1x_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'eigrp' | | - Ops structure: baseline/zintis-cml/eigrp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/eigrp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'fdb' | | - Ops structure: baseline/zintis-cml/fdb_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/fdb_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'hsrp' | | - Ops structure: baseline/zintis-cml/hsrp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/hsrp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'igmp' | | - Ops structure: baseline/zintis-cml/igmp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/igmp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'interface' | | - Ops structure: baseline/zintis-cml/interface_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/interface_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'isis' | | - Ops structure: baseline/zintis-cml/isis_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/isis_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lag' | | - Ops structure: baseline/zintis-cml/lag_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/lag_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lisp' | | - Ops structure: baseline/zintis-cml/lisp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/lisp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'lldp' | | - Ops structure: baseline/zintis-cml/lldp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/lldp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mcast' | | - Ops structure: baseline/zintis-cml/mcast_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/mcast_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'mld' | | - Ops structure: baseline/zintis-cml/mld_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/mld_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'msdp' | | - Ops structure: baseline/zintis-cml/msdp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/msdp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'nd' | | - Exception: baseline/zintis-cml/nd_ios_r5_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'ntp' | | - Ops structure: baseline/zintis-cml/ntp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/ntp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'ospf' | | - Ops structure: baseline/zintis-cml/ospf_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/ospf_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'pim' | | - Ops structure: baseline/zintis-cml/pim_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/pim_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'platform' | | - Ops structure: baseline/zintis-cml/platform_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/platform_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'prefix_list' | | - Ops structure: baseline/zintis-cml/prefix_list_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/prefix_list_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'rip' | | - Ops structure: baseline/zintis-cml/rip_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/rip_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'route_policy' | | - Ops structure: baseline/zintis-cml/route_policy_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/route_policy_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'routing' | | - Ops structure: baseline/zintis-cml/routing_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/routing_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'static_routing' | | - Ops structure: baseline/zintis-cml/static_routing_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/static_routing_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'stp' | | - Ops structure: baseline/zintis-cml/stp_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/stp_ios_r5_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'utils' | | - Exception: baseline/zintis-cml/utils_ios_r5_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'vlan' | | - Ops structure: baseline/zintis-cml/vlan_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/vlan_ios_r5_console.txt | |------------------------------------------------------------------------------| | Learnt feature 'vrf' | | - Ops structure: baseline/zintis-cml/vrf_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/vrf_ios_r5_console.txt | |------------------------------------------------------------------------------| | Could not learn feature 'vxlan' | | - Exception: baseline/zintis-cml/vxlan_ios_r5_exception.txt | | - Feature not yet developed for this os | |------------------------------------------------------------------------------| | Learnt feature 'config' | | - Ops structure: baseline/zintis-cml/config_ios_r5_ops.txt | | - Device Console: baseline/zintis-cml/config_ios_r5_console.txt | |==============================================================================| (pyats) zintis@c8host ~/bin/pyats[1064] $
cd into baseline and look at the individual files if you like, but the power is in running this again after a change so that you can see what has changed.
You will see though that the output is in a Windows format that has a bunch
of carriage return/ line feeds
i.e. ^M
which you can convert to unix test
that only has the line feeds using the usual methods:
For example:
3 Download
From pypi: https://pypi.org/project/pyats/ From docker: hub.docker.com
Downloading the pyATS image in a separate step is not strictly necessary, but is a good practise to ensure your local image is always kept up-to-date.
$ docker pull ciscotestautomation/pyats:latest
where the latest tag can be replacee with a specific version of pyATS you need
4 Run it (as a container)
The pyATS docker container defaults to starting in an interactive Python shell
$docker run -it ciscotestautomation/pyats:latest
But if you want to start in an interactive bash shell run:
$docker run -it ciscotestautomation/pyats:latest /bin/bash
The use the pyATS Sandbox at Cisco.
4.1 Exiting the container with C-D or C-d ?
4.2 Good examples built in:
$ docker run -it ciscotestautomation/pyats:latest /bin/bash [Entrypoint] Starting pyATS Docker Image ... [Entrypoint] Workspace Directory: /pyats [Entrypoint] Activating workspace root@0c832ac21322:/pyats# easypy examples/basic/job/basic_example_job.py
5 Customizing the PyATS container
Again, this is straight out of the online documentation on hub.docker.com
Starting the pyATS Container
The pyATS docker container defaults to starting in Python interactive shell.
$ docker run -it ciscotestautomation/pyats:latest [Entrypoint] Starting pyATS Docker Image ... [Entrypoint] Workspace Directory: /pyats [Entrypoint] Activating workspace Python 3.4.7 (default, Nov 4 2017, 22:21:42) [GCC 4.9.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
Alternatively, you can also start the container in shell,
$ docker run -it ciscotestautomation/pyats:latest /bin/bash [Entrypoint] Starting pyATS Docker Image ... [Entrypoint] Workspace Directory: /pyats [Entrypoint] Activating workspace root@0c832ac21322:/pyats# The pyATS virtual environment is sourced automatically, and your workspace is preset to be /pyats. Note that this workspace directory (virtual environment) is declared to be a docker volume, so its content will persist between container reloads.
To get out of the container, try CTRL-D.
5.1 Examples and Templates
Examples and templates are built into the image under /pyats default workspace to help users on getting started.
$ docker run -it ciscotestautomation/pyats:latest /bin/bash [Entrypoint] Starting pyATS Docker Image ... [Entrypoint] Workspace Directory: /pyats [Entrypoint] Activating workspace root@0c832ac21322:/pyats# easypy examples/basic/job/basic_example_job.py
6 Run it (natively on Linus or Mac OSX)
Run this from the virtual environment you have set up with pyATS. I did all
my pyATS install after running python3 -m virtualenv pyATS --python=python3.8
- pip install pyats # installs core framework ONLY.
- pip install pyats[library] # installs core and Genie library from pypi Genie is now known as pyats library.
- pip install pyats[robot] # for RobotFramework support + pyats.robot package
- pip install pyats[template] # for cookiecutter dependency is required for "pyats create project"
pip install pyats[full]
# install the core and all the options.
7 After installing on MAC, test of pyATS
Download the examples from github:
git clone https://github.com/CiscoTestAutomation/examples
Then run this to test if the examples were downloaded and if pyATS is setup
correctly:
pyats run job examples/basic/basic_example_job.py
pyats run job examples/basic/basic_example_job.py
pyats run job examples/basic/basic_example_job.py
this gave me errors, but examples/basic/basicexamplescript.py passed fine I fixed the errors (I had named a script "jinja2.py" somewhere in my path. This was conflicting with the real jinja2.py. A simple renamed fixed it)
The tests ran and passed (except the single expected failure that tested proper failure)
Next I installed additional libraries in the virtual env:
pip install xlrd xlwt xlsxwriter
Also please note that this basicexamplejob.py was run with NO pyats.conf file. If I tried to add that file to /etc directory, I got Traceback errors:
- ~pyats run job examples/basic/basic_example_job.py~ Traceback (most recent call last): File "/Users/zintis/bin/python/venv-pyats/bin/pyats", line 5, in <module> from pyats.cli.__main__ import main ...
7.1 Let pyATS generate my first testbed.yml
genie create testbed
is included in the pyATS install:
genie create testbed --output yaml/firsttestbed.yml --encode-password
genie create testbed --output yaml/firsttestbed.yml --encode-password
genie create testbed --output yaml/firsttestbed.yml --encode-password
genie create testbed --output yaml/firsttestbed.yml --encode-password
This is what I got:
$ genie create testbed interactive --output yaml/firsttestbed.yml --encode-password Start creating Testbed yaml file ... Do all of the devices have the same username? [y/n] y Common Username: admin Do all of the devices have the same default password? [y/n] y Common Default Password (leave blank if you want to enter on demand): Do all of the devices have the same enable password? [y/n] y Common Enable Password (leave blank if you want to enter on demand): Device hostname: ospf-r1 IP (ip, or ip:port): 192.168.255.205 Protocol (ssh, telnet, ...): telnet OS (iosxr, iosxe, ios, nxos, linux, ...): iosv More devices to add ? [y/n] y Device hostname: ospf-r2 IP (ip, or ip:port): 192.168.255.211 Protocol (ssh, telnet, ...): ssh OS (iosxr, iosxe, ios, nxos, linux, ...): iosv More devices to add ? [y/n] n Using the default encoding key since no key was specified in configuration. THIS IS A SHARED KEY AND IS NOT SECURE, PLEASE RUN `pyats secret keygen` AND ADD TO YOUR pyats.conf FILE BEFORE ENCODING ANY VALUES. Testbed file generated: yaml/firsttestbed.yml (venv-pyats) /Users/zintis/bin/python/venv-pyats[726]: $
So how close is that file to what CML Breakout produced in labs.yml ?
Here is the testbed.yml produced from the above interactive pyats command:
$ cat testbed.yml devices: ospf-r1: connections: cli: ip: 192.168.255.205 protocol: telnet credentials: default: password: '%ENC{w4DDrsOPw5_DpsOUw57CmsKd}' username: admin enable: password: '%ENC{w4DDrsOPw5_DpsOUw57CmsKd}' os: iosv type: iosv ospf-r2: connections: cli: ip: 192.168.255.211 protocol: telnet credentials: default: password: '%ENC{w4DDrsOPw5_DpsOUw57CmsKd}' username: admin enable: password: '%ENC{w4DDrsOPw5_DpsOUw57CmsKd}' os: iosv type: iosv
And here is the CML labs yaml that I downloaded from Breakout:
bcfd4e: enabled: true lab_description: "" lab_title: Route-redistribution-lab-zp.yaml nodes: n0: devices: - enabled: true listen_port: 9000 name: serial0 running: true status: TCP/9000 - enabled: false listen_port: 9001 name: serial1 running: false status: "" label: R5-EIGRP n1: devices: - enabled: true listen_port: 9002 name: serial0 running: true status: TCP/9002 - enabled: false listen_port: 9003 name: serial1 running: false status: "" label: R3-eigrp n2: devices: - enabled: true listen_port: 9004 name: serial0 running: true status: TCP/9004 - enabled: false listen_port: 9005 name: serial1 running: false status: "" label: R4-eigrp n3: devices: - enabled: true listen_port: 9006 name: serial0 running: true status: TCP/9006 - enabled: false listen_port: 9007 name: serial1 running: false status: "" label: R1-ospf n4: devices: - enabled: true listen_port: 9008 name: serial0 running: true status: TCP/9008 - enabled: false listen_port: 9009 name: serial1 running: false status: "" label: R2-ospf
As you can see it is not so close. So, I will run genie again and create a new testbed.yml file. First cd tino venv-pyats/yaml/ directory
genie create testbed –output yaml/firsttestbed.yml –encode-password
genie create testbed interactive --output yaml/firsttestbed.yml --encode-password
genie create testbed interactive --output yaml/firsttestbed.yml --encode-password
It has to be interactive or one of:
- ansible
- documentation
- file
- libs
- netbox
- template
- topology
See genie docs for more details.
8 pyATS Network Test Project Components
To run a pyATS test, you need 3 components
- Testbed
- AEtest Testscript
- Easypy Jobfile
8.1 1) Testbed
Is a yaml file that describes the network topology and credentials for each
node so it can be managed. You can edit it manually, or start with an easy
built-in genie script called genie create testbed interactive
(you could
also have the topology stored in a file somewhere and read that instead of
an interactive session.)
genie create testbed interactive --output yaml/firsttestbed.yml --encode-password
8.2 2) AEtest Testscripts
Automation Easy Test is AEtest. They are 1 or more python files that define test setup, test execution and test cleanup. You can have multiple of these for whatever you want to test in your environment.
8.3 3) Easypy Jobfiles
A python file that combines AEtest scripts and defines runtime, logging and archives.
8.4 4) Convenience commands
Not really part of the three above components, but worth mentioning. Built-in. Makes your life easier, when installing pyATS. So far I have:
pyats create testbed
pyats create project
9 genie commands
Genie is the library of network specific modules
that leverage the pyATS core
library
. Most of the commands you run will actually be genie commands? Let's
see:
- genie …
I have noticed that running genie parse
appears to have been replaced with
pyats parse
. Same for genie create
is now pyats create
I think? — check
this!!!
10 error re: encoding key
When I tried the above genie parse command I got this error:
(venv-pyats) /Users/zintis/bin/python/venv-pyats[553]: $ genie parse "show version" --testbed-file yaml/testbed.yml --devices R1-ospf Using the default encoding key since no key was specified in configuration. THIS IS A SHARED KEY AND IS NOT SECURE, PLEASE RUN `pyats secret keygen` AND ADD TO YOUR pyats.conf FILE BEFORE ENCODING ANY VALUES. Details: Could not find parser for 'show version' under ('iosv',) 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1.59it/s]
11 pyATS Genie run natively on Linux or Mac OSX
Several settings are needed to get pyATS working on a MAC.
11.1 /etc/pyats.conf or $VIRTUALENV/pyats.conf
the latter when inside a virtual environment, which should be almost always.
This file looks like this:
# # pyATS configuration file [email] smtp.host = mail.google.com smtp.port = 25 default_domain = gmail.com
12 Describe your testbed
Network automation expects to see testbeds where you describe your devices under the control of pyats. This description is in YAML format.
Example:
testbed: name: IOS_Testbed credentials: default: username: admin password: cisco enable: password: cisco devices: ios-1: # <----- must match to your device hostname in the prompt os: ios type: ios connections: a: protocol: telnet ip: 1.1.1.1 port: 11023 ios-2: os: ios type: ios connections: a: protocol: telnet ip: 1.1.1.2 port: 11024 vty: protocol: ssh ip: 5.5.5.5 topology: ios-1: interfaces: GigabitEthernet0/0: ipv4: 10.10.10.1/24 ipv6: '10:10:10::1/64' link: link-1 type: ethernet Loopback0: ipv4: 192.168.0.1/32 ipv6: '192::1/128' link: ios1_Loopback0 type: loopback ios-2: interfaces: GigabitEthernet0/0: ipv4: 10.10.10.2/24 ipv6: '10:10:10::2/64' link: link-1 type: ethernet Loopback0: ipv4: 192.168.0.2/32 ipv6: '192::2/128' link: ios2_Loopback0 type: loopback
13 Letting PyATS create your testbed
Various options exist, all of which are documented in devnetcloud.com and here pyats-getting-started
$ pyats create testbed interactive --output yaml my_testbed.yaml --encode-password Start creating Testbed yaml file ... Do all of the devices have the same username? [y/n] y Common Username: zintis Do all of the devices have the same default password? [y/n] y Common Default Password (leave blank if you want to enter on demand): Do all of the devices have the same enable password? [y/n] y Common Enable Password (leave blank if you want to enter on demand): Device hostname: ospf-R1 IP (ip, or ip:port): 192.168.128.106 Protocol (ssh, telnet, ...): ssh OS (iosxr, iosxe, ios, nxos, linux, ...): iosv More devices to add ? [y/n] y Device hostname: ospf-R2 IP (ip, or ip:port): 192.168.128.107 Protocol (ssh, telnet, ...): ssh OS (iosxr, iosxe, ios, nxos, linux, ...): iosv More devices to add ? [y/n] y Device hostname: eigrp-R3 IP (ip, or ip:port): 192.168.128.111 Protocol (ssh, telnet, ...): ssh OS (iosxr, iosxe, ios, nxos, linux, ...): iosv More devices to add ? [y/n] y Device hostname: eigrp-R4 IP (ip, or ip:port): 192.168.128.112 Protocol (ssh, telnet, ...): ssh OS (iosxr, iosxe, ios, nxos, linux, ...): iosv More devices to add ? [y/n] y Device hostname: eigrp-R5 IP (ip, or ip:port): 192.168.128.110 Protocol (ssh, telnet, ...): ssh OS (iosxr, iosxe, ios, nxos, linux, ...): iosv More devices to add ? [y/n] y Device hostname: Nexus-cli-champ IP (ip, or ip:port): 192.168.128.109 Protocol (ssh, telnet, ...): ssh OS (iosxr, iosxe, ios, nxos, linux, ...): nxos More devices to add ? [y/n] n Using the default encoding key since no key was specified in configuration. THIS IS A SHARED KEY AND IS NOT SECURE, PLEASE RUN `pyats secret keygen` AND ADD TO YOUR pyats.conf FILE BEFORE ENCODING ANY VALUES. Testbed file generated: yaml
14 PyATS parsers
PyATS comes with over 1000 parsers, and
the ability to create new parsers
of your own design. Here is the genie feature browser of parsers. This is
the official link to the available parsers: developer.cisco.com/docs/genie-docs
If you wanted to develop your own parser you would follow these three steps:
Once you create a new parser, don't forget to check 1, 2, and 3; if you only update the parser class without modifying/creating the schema, please check 2 and 3.
- make json
- cd tests; and execute python -m unittest -v
- create changelog for your pull request.
I ran pyats parse "show version" --testbed-file yaml/testbed.yaml
but got the error Could not find parser for 'show version' under ('iosv',)
And then realized that iosv is not a valid os: type:
I changed my
testbed.yaml
file to have os: ios
and type: ios
and then the command worked.
I also tried a specific call to just the nxos virtual device with this:
pyats parse "show interface brief" --testbed-file yaml/testbed.yaml --devices Nexus-cli-champ
But that got me this error: TypeError: device is not connected, output must be provided.
14.1 Issue to resolve around testbed
- what are my options for os: and type: and what is the difference?
- From the genie feature browser it looks like os: can be
any of these
Figure 2: PyATS Genie Parsers
- From the genie feature browser it looks like os: can be
any of these
15 Use API to manage the devices in the testbed.yml file
The best way to use the API is with python. Here is an example: Direct link: pyats-zp-load-testped.py and copied here as well:
# load the testbed files from pyats.topology import loader testbed = loader.load('ios_testbed.yaml') # access the devices testbed.devices # AttrDict({'ios-1': <Device ott-tb1-n7k4 at 0xf77190cc>, # 'ios-2': <Device ott-tb1-n7k5 at 0xf744e16c>}) ios_1 = testbed.devices['ios-1'] ios_2 = testbed.devices['ios-2'] # find links from one device to another for link in ios_1.find_links(ios_2): print(repr(link)) # <Link link-1 at 0xf744ef8c> # establish basic connectivity ios_1.connect() # issue commands print(ios_1.execute('show version')) ios_1.configure(''' interface GigabitEthernet0/0 ip address 10.10.10.1 255.255.255.0 ''') # establish multiple, simultaneous connections ios_2.connect(alias = 'console', via = 'a') ios_2.connect(alias = 'vty_1', via = 'vty') # issue commands through each connection separately ios_2.vty_1.execute('show running') ios_2.console.execute('reload') # creating connection pools ios_2.start_pool(alias = 'pool', size = 2) # use connection pool in multiprocessing paradigms # each process will be allocated a connection - whenever one is available def sleep(seconds): ios_2.pool.execute('sleep %s' % seconds) import multiprocessing p1 = multiprocessing.Process(target=sleep, args = (10, )) p2 = multiprocessing.Process(target=sleep, args = (10, )) p3 = multiprocessing.Process(target=sleep, args = (10, )) p1.start(); p2.start(); p3.start() p1.join(); p2.join(); p3.join()
?
16 pyATS Test scripts
testscripts are the main raison d'etre for pyATS.
pyATS is all about testing; and the absolute cornerstone in testing is the
actual testscript. In pyATS, test scripts are written and executed through
AEtest
Package.
Testscripts are python code files:
Here is an example: pyats-zp-testing-script.py