├── libraries ├── robot │ ├── __init__.py │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── virl.yaml │ └── README.md ├── solutions │ ├── __init__.py │ ├── solution1 │ │ ├── run1 │ │ │ └── nx-osv-1 │ │ ├── run2 │ │ │ └── nx-osv-1 │ │ └── testbed.yaml │ └── solution2 │ │ ├── nx-osv-1-run1 │ │ ├── nx-osv-1-run2 │ │ └── testbed.yaml ├── advance_robot │ ├── __init__.py │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── virl.yaml │ └── README.md ├── pyats_conf_ops │ ├── __init__.py │ ├── job │ │ ├── __init__.py │ │ └── demo8_pyats_conf_ops_job.py │ ├── recording │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── datafile.yaml │ ├── README.md │ └── virl.yaml ├── context_comparator │ ├── __init__.py │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── job │ │ └── demo9_context_comparator_job.py │ ├── virl.yaml │ └── README.md ├── harness_custom_trigger │ ├── __init__.py │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── trigger_datafile_demo.yaml │ ├── virl.yaml │ ├── demo4_harness_custom_trigger_job.py │ ├── README.md │ └── trigger.py ├── config_ops │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── virl.yaml │ └── README.md ├── explore │ ├── mocked_devices │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── run_mocked_devices │ │ ├── csr1000v-1 │ │ └── nx-osv-1 │ ├── connection_nx-osv-1.txt │ ├── explore-1 │ │ ├── connection_nx-osv-1.txt │ │ ├── nx-osv-1_show-version_parsed.txt │ │ └── nx-osv-1_show-version_console.txt │ └── testbed.yaml ├── harness_cluster │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── trigger_datafile.yaml │ ├── demo11_harness_cluster_job.py │ ├── virl.yaml │ └── README.md ├── harness_triggers │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── virl.yaml │ ├── harness_triggers_result.yaml │ ├── demo2_harness_triggers_job.py │ └── README.md ├── harness_telemetry │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── telemetry.yaml │ ├── virl.yaml │ ├── demo3_harness_telemetry_job.py │ └── README.md ├── trigger_within_pyats │ ├── mock_device │ │ ├── nx-osv-1 │ │ └── csr1000v-1 │ ├── job │ │ └── demo7_trigger_within_pyats_job.py │ ├── trigger_within_pyats_result.yaml │ ├── README.md │ ├── cisco_live.yaml │ └── datafile.yaml ├── harness_simple │ ├── harness_simple_result.yaml │ ├── demo1_harness_simple_job.py │ ├── virl.yaml │ └── README.md └── README.md ├── comprehensive ├── libs │ ├── __init__.py │ └── local_library.py ├── testcases │ └── __init__.py └── data │ └── extended_datafile.yaml ├── GenieHarnessHelloWorld ├── __init__.py ├── subsection_datafile.yaml ├── trigger_datafile.yaml ├── HelloWorld.py ├── testbed.yaml └── Basic.py ├── .github └── CODEOWNERS ├── retry ├── retry_example_job.tem ├── results │ └── retry_example_result.yaml ├── retry_example_job.py └── retry_example_script.py ├── abstraction_example ├── abstracted_pkg │ ├── __init__.py │ ├── iosxe │ │ ├── __init__.py │ │ ├── asr1k │ │ │ ├── __init__.py │ │ │ └── polaris_dev │ │ │ │ ├── __init__.py │ │ │ │ ├── yang │ │ │ │ └── __init__.py │ │ │ │ └── some_module.py │ │ └── some_module.py │ ├── iosxr │ │ ├── __init__.py │ │ └── some_module.py │ ├── nxos │ │ ├── __init__.py │ │ ├── n7k │ │ │ ├── __init__.py │ │ │ └── some_module.py │ │ └── some_module.py │ └── some_module.py └── script.py ├── blitz └── config_interface │ ├── mapping_datafile.yaml │ ├── subsection_datafile.yaml │ ├── testbed.yaml │ ├── job.py │ ├── README.md │ └── blitz.yaml ├── connection ├── mock_device │ └── cat9500 ├── results │ ├── connection_example_result.yaml │ └── connection_example_result_ext.yaml ├── testbed.yaml └── connection_example_job.py ├── parsergen ├── pyAts │ ├── __init__.py │ ├── parsergen_demo_xrvr_job.py │ ├── parsergen_demo_enxr_job.py │ ├── parsergen_demo_enxr_job_conn_alias.py │ ├── parsergen_demo_aireos_job.py │ ├── parsergen_demo_aireos_job_conn_alias.py │ ├── parsergen_demo_vios_job.py │ ├── parsergen_demo_viosxe_job.py │ └── README ├── pyAtsStandaloneUt │ ├── __init__.py │ └── README └── demo │ ├── README.md │ ├── nontabular_example.py │ └── tabular_example.py ├── health ├── health_checks │ ├── mock_device │ │ └── R1_xe │ ├── mock_device_http │ │ └── R1_xe │ ├── health_check_results.yaml │ ├── health_check_results_ext.yaml │ └── README.md ├── cpu_memory_custom_check │ ├── README.md │ └── health_cpu_memory_custom.yaml └── README.md ├── datafiles ├── data │ ├── extended_data.yaml │ └── simple_data.yaml ├── lib │ └── processors.py └── job │ ├── results │ ├── datafile_job_result.yaml │ └── datafile_job_result_ext.yaml │ └── datafile_job.py ├── steps ├── job │ ├── results │ │ ├── steps_example_result.yaml │ │ └── steps_example_result_ext.yaml │ └── steps_example_job.py └── etc │ └── stepsDebug.yaml ├── clean ├── tftp_boot_device │ ├── README.md │ └── clean.yaml ├── ping_server │ ├── README.md │ └── clean.yaml ├── copy_files_to_device │ ├── README.md │ └── clean.yaml ├── verify_running_image │ ├── README.md │ └── clean.yaml ├── copy_files_to_server │ ├── README.md │ └── clean.yaml ├── write_erase_reload │ ├── README.md │ └── clean.yaml ├── delete_files_from_server │ ├── README.md │ └── clean.yaml ├── backup_files_on_device │ ├── README.md │ └── clean.yaml ├── change_boot_vars_reload │ ├── README.md │ └── clean.yaml ├── reload_apply_config │ ├── README.md │ └── clean.yaml ├── reload_apply_config_file │ ├── README.md │ └── clean.yaml ├── remove_config_load_new_config │ ├── README.md │ └── clean.yaml ├── clean │ ├── clean_mock.yaml │ └── testbed_cisco_live.yaml ├── clean_vWLC_aireos │ ├── clean_vWLC.yaml │ └── tb_vWLC.yaml ├── viptela │ └── full_clean_controllers │ │ ├── README.md │ │ ├── clean.yaml │ │ └── testbed.yaml ├── full_clean_n7k_nxos │ ├── README.md │ ├── testbed.yaml │ └── clean.yaml ├── full_clean_asr1k_iosxe │ ├── README.md │ ├── testbed.yaml │ └── clean.yaml ├── full_clean_cat9k_iosxe │ ├── README.md │ ├── testbed.yaml │ └── clean.yaml ├── full_clean_isr4k_iosxe │ ├── README.md │ ├── testbed.yaml │ └── clean.yaml ├── full_clean_csr1000v_iosxe │ ├── README.md │ ├── testbed.yaml │ └── clean.yaml ├── full_clean_n9kv_nxos │ ├── README.md │ ├── testbed.yaml │ └── clean.yaml ├── full_clean_n9k_nxos │ ├── README.md │ ├── testbed.yaml │ └── clean.yaml ├── iosxe │ └── sdwan │ │ └── full_clean_cedge │ │ ├── README.md │ │ └── testbed.yaml ├── full_clean_ncs540_xr7_iosxr │ ├── testbed.yaml │ └── clean.yaml ├── full_clean_multi_os │ └── README.md ├── README.md ├── full_clean_ie5000_ios │ └── ie5000_tb.yaml ├── full_clean_C3560CX_ios │ └── c3560cx_tb.yaml └── full_clean_ie4000_ios │ └── ie4000_tb.yaml ├── basic ├── results │ ├── basic_example_result.yaml │ └── basic_example_result_ext.yaml └── basic_example_job.py ├── loop └── loop_example_job.py ├── metaparser ├── README.md ├── demo_metaparser_iosxe.py └── demo_metaparser_nxos.py ├── tasks ├── results │ ├── task_example_result.yaml │ └── task_example_result_ext.yaml ├── task_example_job.py └── task_example.py ├── feature ├── results │ ├── features_example_result.yaml │ └── features_example_result_ext.yaml └── features_example_job.py ├── script_parameters ├── job │ └── script_parameters_example_job.py ├── etc │ └── connection_example_conf.yaml └── script_parameters_example_script.py ├── metadata ├── metadata_example_job.py └── metadata_example.py ├── README.md ├── .gitignore ├── groups └── group_example_job.py └── uids └── uids_example_job.py /libraries/robot/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /comprehensive/libs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/solutions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /GenieHarnessHelloWorld/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /comprehensive/testcases/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/advance_robot/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/context_comparator/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/job/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @CiscoTestAutomation/pyats-genie-devs -------------------------------------------------------------------------------- /retry/retry_example_job.tem: -------------------------------------------------------------------------------- 1 | version: 1 2 | 3 | type: easypy 4 | 5 | arguments: 6 | no-mail: True 7 | -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_package(__name__) -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxe/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_token(__name__) -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxr/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_token(__name__) -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/nxos/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_token(__name__) -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/nxos/n7k/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_token(__name__) -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxe/asr1k/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_token(__name__) -------------------------------------------------------------------------------- /blitz/config_interface/mapping_datafile.yaml: -------------------------------------------------------------------------------- 1 | devices: 2 | R1_xe: 3 | context: cli 4 | mapping: 5 | cli: cli 6 | -------------------------------------------------------------------------------- /connection/mock_device/cat9500: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/connection/mock_device/cat9500 -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxe/asr1k/polaris_dev/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_token(__name__) -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxe/asr1k/polaris_dev/yang/__init__.py: -------------------------------------------------------------------------------- 1 | from genie import abstract 2 | abstract.declare_token(__name__) -------------------------------------------------------------------------------- /libraries/robot/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/robot/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /parsergen/pyAts/__init__.py: -------------------------------------------------------------------------------- 1 | # placeholder __init__ file to enable the use of this folder 2 | # as a python module. 3 | 4 | # do not modify -------------------------------------------------------------------------------- /health/health_checks/mock_device/R1_xe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/health/health_checks/mock_device/R1_xe -------------------------------------------------------------------------------- /libraries/robot/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/robot/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/config_ops/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/config_ops/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/explore/mocked_devices/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/explore/mocked_devices/nx-osv-1 -------------------------------------------------------------------------------- /health/health_checks/mock_device_http/R1_xe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/health/health_checks/mock_device_http/R1_xe -------------------------------------------------------------------------------- /libraries/advance_robot/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/advance_robot/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/config_ops/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/config_ops/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/explore/mocked_devices/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/explore/mocked_devices/csr1000v-1 -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/recording/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/pyats_conf_ops/recording/nx-osv-1 -------------------------------------------------------------------------------- /libraries/solutions/solution1/run1/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/solutions/solution1/run1/nx-osv-1 -------------------------------------------------------------------------------- /libraries/solutions/solution1/run2/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/solutions/solution1/run2/nx-osv-1 -------------------------------------------------------------------------------- /libraries/solutions/solution2/nx-osv-1-run1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/solutions/solution2/nx-osv-1-run1 -------------------------------------------------------------------------------- /libraries/solutions/solution2/nx-osv-1-run2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/solutions/solution2/nx-osv-1-run2 -------------------------------------------------------------------------------- /parsergen/pyAtsStandaloneUt/__init__.py: -------------------------------------------------------------------------------- 1 | # placeholder __init__ file to enable the use of this folder 2 | # as a python module. 3 | 4 | # do not modify -------------------------------------------------------------------------------- /libraries/advance_robot/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/advance_robot/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/explore/run_mocked_devices/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/explore/run_mocked_devices/csr1000v-1 -------------------------------------------------------------------------------- /libraries/explore/run_mocked_devices/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/explore/run_mocked_devices/nx-osv-1 -------------------------------------------------------------------------------- /libraries/harness_cluster/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_cluster/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/harness_triggers/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_triggers/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/recording/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/pyats_conf_ops/recording/csr1000v-1 -------------------------------------------------------------------------------- /libraries/context_comparator/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/context_comparator/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/harness_cluster/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_cluster/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/harness_telemetry/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_telemetry/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/harness_triggers/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_triggers/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/context_comparator/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/context_comparator/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/harness_telemetry/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_telemetry/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/trigger_within_pyats/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/trigger_within_pyats/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/mock_device/nx-osv-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_custom_trigger/mock_device/nx-osv-1 -------------------------------------------------------------------------------- /libraries/trigger_within_pyats/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/trigger_within_pyats/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/mock_device/csr1000v-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoTestAutomation/examples/HEAD/libraries/harness_custom_trigger/mock_device/csr1000v-1 -------------------------------------------------------------------------------- /libraries/explore/connection_nx-osv-1.txt: -------------------------------------------------------------------------------- 1 | [2019-02-21 13:13:22,883] +++ nx-osv-1 logfile ./connection_nx-osv-1.txt +++ 2 | [2019-02-21 13:13:22,883] +++ Unicon plugin nxos +++ 3 | -------------------------------------------------------------------------------- /libraries/explore/explore-1/connection_nx-osv-1.txt: -------------------------------------------------------------------------------- 1 | [2019-02-21 12:07:08,440] +++ nx-osv-1 logfile explore-1/connection_nx-osv-1.txt +++ 2 | [2019-02-21 12:07:08,441] +++ Unicon plugin nxos +++ 3 | -------------------------------------------------------------------------------- /retry/results/retry_example_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | testcases: 3 | - name: MyTestcase_1 4 | result: PASSX 5 | testscript: /scratch/pyats_install_test/examples/retry/retry_example_script.py 6 | -------------------------------------------------------------------------------- /blitz/config_interface/subsection_datafile.yaml: -------------------------------------------------------------------------------- 1 | setup: 2 | sections: 3 | connect: 4 | method: genie.harness.commons.connect 5 | 6 | order: ['connect'] 7 | cleanup: 8 | sections: 9 | order: [] -------------------------------------------------------------------------------- /blitz/config_interface/testbed.yaml: -------------------------------------------------------------------------------- 1 | 2 | devices: 3 | R1_xe: 4 | os: iosxe 5 | connections: 6 | cli: 7 | command: mock_device_cli --os iosxe --mock_data_dir ../../blitz/config_interface/mock_data --state connect --hostname R1_xe 8 | -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/nxos/some_module.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class SomeClass(object): 4 | 5 | def some_method(self): 6 | print('SomeClass.some_method implementation for nxos') 7 | 8 | some_var = dict(location = 'nxos') 9 | 10 | def some_function(): 11 | print('some_function for nxos') -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxr/some_module.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class SomeClass(object): 4 | 5 | def some_method(self): 6 | print('SomeClass.some_method implementation for iosxr') 7 | 8 | some_var = dict(location = 'iosxr') 9 | 10 | def some_function(): 11 | print('some_function for iosxr') -------------------------------------------------------------------------------- /datafiles/data/extended_data.yaml: -------------------------------------------------------------------------------- 1 | extends: simple_data.yaml 2 | 3 | processors: 4 | pre: [lib.processors.log_enter] 5 | post: [lib.processors.log_exit] 6 | 7 | module_var_b: overwrite from extended file 8 | 9 | 10 | testcases: 11 | MyTestcase: 12 | parameters: 13 | tc_param_a: Over Nine Thousand! -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/trigger_datafile_demo.yaml: -------------------------------------------------------------------------------- 1 | extends: "%CALLABLE{genie.libs.sdk.genie_yamls.datafile(trigger,nxos)}" 2 | 3 | TriggerClearArpVrfAllForceDelete: 4 | source: 5 | class: examples.libraries.harness_custom_trigger.trigger.TriggerClearArpVrfAllForceDelete 6 | devices: ['uut'] 7 | sleep: 10 8 | -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxe/some_module.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class SomeClass(object): 4 | 5 | def some_method(self): 6 | print('SomeClass.some_method implementation for generic iosxe') 7 | 8 | some_var = dict(location = 'iosxe') 9 | 10 | def some_function(): 11 | print('some_function for generic iosxe') -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/nxos/n7k/some_module.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class SomeClass(object): 4 | 5 | def some_method(self): 6 | print('SomeClass.some_method implementation for nxos/n7k') 7 | 8 | some_var = dict(location = 'nxos/n7k') 9 | 10 | def some_function(): 11 | print('some_function for nxos/n7k') -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/some_module.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class SomeClass(object): 4 | 5 | def some_method(self): 6 | print('the default SomeClass.some_method implementation for no token') 7 | 8 | some_var = dict(location = 'default') 9 | 10 | def some_function(): 11 | print('default some_function with no token') -------------------------------------------------------------------------------- /steps/job/results/steps_example_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: tc_one 10 | result: FAILED 11 | testscript: /scratch/pyats_install_test/examples/steps/steps_example_script.py 12 | -------------------------------------------------------------------------------- /clean/tftp_boot_device/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | TFTP Boot device 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - TFTP boot a device with a given image 6 | 7 | The above would run _prior_ to executing any pyATS testcases or scripts. 8 | 9 | Note: Using CSR1000v device for the example. -------------------------------------------------------------------------------- /steps/job/results/steps_example_result_ext.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: tc_one 10 | result: FAILED 11 | testscript: /scratch/pyats_ext_install_test/examples/steps/steps_example_script.py 12 | -------------------------------------------------------------------------------- /clean/ping_server/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Ping server from device 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - Ping a specified server from the UUT device 6 | 7 | The above would run _prior_ to executing any pyATS testcases or scripts. 8 | 9 | Note: Using ASR1K device for the example. -------------------------------------------------------------------------------- /datafiles/lib/processors.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logger = logging.getLogger(__name__) 4 | 5 | def log_enter(section): 6 | '''processor to print enter section''' 7 | 8 | logger.info('---> %s' % section.uid) 9 | 10 | def log_exit(section): 11 | '''processor to print exit section''' 12 | 13 | logger.info('<--- %s' % section.uid) 14 | 15 | -------------------------------------------------------------------------------- /clean/copy_files_to_device/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Copy files to device 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - copy files (image/config etc) to the device 6 | 7 | The above would run _prior_ to executing any pyATS testcases or scripts. 8 | 9 | Note: Using ASR1K device for the example. -------------------------------------------------------------------------------- /connection/results/connection_example_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: test_up_interface 10 | result: PASSED 11 | testscript: /scratch/pyats_install_test/examples/connection/connection_example_script.py 12 | -------------------------------------------------------------------------------- /clean/verify_running_image/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Verify running image on device 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - Verify the current running image on device 6 | 7 | The above would run _prior_ to executing any pyATS testcases or scripts. 8 | 9 | Note: Using CSR1000v device for the example. -------------------------------------------------------------------------------- /GenieHarnessHelloWorld/subsection_datafile.yaml: -------------------------------------------------------------------------------- 1 | # This file define what to run before running any Trigger 2 | # They are part of the Common Setup and Common Cleanup 3 | # 4 | # In this case we only want to connect to the device 5 | setup: 6 | sections: 7 | connect: 8 | method: genie.harness.commons.connect 9 | order: ['connect'] 10 | 11 | cleanup: {} 12 | -------------------------------------------------------------------------------- /clean/copy_files_to_server/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Copy files to linux server 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - copy files (image/config etc) to a given linux server 6 | 7 | The above would run _prior_ to executing any pyATS testcases or scripts. 8 | 9 | Note: Using ASR1K device for the example. -------------------------------------------------------------------------------- /connection/results/connection_example_result_ext.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: test_up_interface 10 | result: PASSED 11 | testscript: /scratch/pyats_ext_install_test/examples/connection/connection_example_script.py 12 | -------------------------------------------------------------------------------- /basic/results/basic_example_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: tc_one 10 | result: PASSED 11 | - name: tc_two 12 | result: FAILED 13 | testscript: /scratch/pyats_install_test/examples/basic/basic_example_script.py 14 | -------------------------------------------------------------------------------- /clean/write_erase_reload/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Write erase and reload the device 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - Execute 'write erase' 6 | - Reload the device 7 | 8 | The above would run _prior_ to executing any pyATS testcases or scripts. 9 | 10 | Note: Using ASR1K device for the example. -------------------------------------------------------------------------------- /health/health_checks/health_check_results.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: config_interface.R1_xe 10 | result: PASSED 11 | testscript: /scratch/pyats_install_test/lib/python3.10/site-packages/genie/harness/genie_testscript.py 12 | -------------------------------------------------------------------------------- /libraries/harness_simple/harness_simple_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSX 8 | testcases: 9 | - name: TriggerSleep.uut 10 | result: PASSED 11 | testscript: /scratch/pyats_install_test/lib/python3.6/site-packages/genie/harness/genie_testscript.py 12 | -------------------------------------------------------------------------------- /abstraction_example/abstracted_pkg/iosxe/asr1k/polaris_dev/some_module.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class SomeClass(object): 4 | 5 | def some_method(self): 6 | print('SomeClass.some_method implementation in iosxe/asr1k/polaris_dev') 7 | 8 | some_var = dict(location = 'iosxe/asr1k/polaris_dev') 9 | 10 | def some_function(): 11 | print('some_function in iosxe/asr1k/polaris_dev') -------------------------------------------------------------------------------- /clean/delete_files_from_server/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Delete files from linux server 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - Delete files (image/config etc) from a given linux server 6 | 7 | The above would run _prior_ to executing any pyATS testcases or scripts. 8 | 9 | Note: Using ASR1K device for the example. -------------------------------------------------------------------------------- /basic/results/basic_example_result_ext.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: tc_one 10 | result: PASSED 11 | - name: tc_two 12 | result: FAILED 13 | testscript: /scratch/pyats_ext_install_test/examples/basic/basic_example_script.py 14 | -------------------------------------------------------------------------------- /clean/backup_files_on_device/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Backup files present on the device 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - Backup files present on the device with prefix 'backup_' 6 | 7 | The above would run _prior_ to executing any pyATS testcases or scripts. 8 | 9 | Note: Using ASR1K device for the example. -------------------------------------------------------------------------------- /clean/change_boot_vars_reload/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Change boot variables & reload device 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - change boot variables and 6 | - reload the device 7 | 8 | The above would run _prior_ to executing any pyATS testcases or scripts. 9 | 10 | Note: Using N7700 device for the example. -------------------------------------------------------------------------------- /health/health_checks/health_check_results_ext.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: config_interface.R1_xe 10 | result: PASSED 11 | testscript: /scratch/pyats_ext_install_test/venv/lib/python3.10/site-packages/genie/harness/genie_testscript.py 12 | -------------------------------------------------------------------------------- /libraries/harness_telemetry/telemetry.yaml: -------------------------------------------------------------------------------- 1 | plugins: 2 | crashdumps: 3 | interval: 30 4 | enabled: True 5 | module: genie.libs.telemetry.plugins.crashdumps 6 | devices: ['csr1000v-1'] 7 | tracebackcheck: 8 | interval: 30 9 | enabled: True 10 | module: genie.libs.telemetry.plugins.tracebackcheck 11 | devices: ['csr1000v-1'] 12 | -------------------------------------------------------------------------------- /clean/verify_running_image/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [csr-1000v-1] 5 | 6 | devices: 7 | csr-1000v-1: 8 | 9 | connect: 10 | 11 | verify_running_image: 12 | images: 13 | - bootflash:csr1000v-universalk9.03.10.00.S.153-3.S-ext.SPA.bin 14 | 15 | order: 16 | - 'connect' 17 | - 'verify_running_image' 18 | -------------------------------------------------------------------------------- /libraries/context_comparator/job/demo9_context_comparator_job.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # Needed for logic 4 | from pyats.datastructures.logic import And, Not, Or 5 | 6 | from genie.harness.main import gRun 7 | 8 | def main(): 9 | 10 | test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 11 | 12 | gRun(trigger_datafile=os.path.join(test_path, 'trigger_datafile_demo.yaml')) 13 | -------------------------------------------------------------------------------- /clean/backup_files_on_device/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [asr1000] 5 | 6 | devices: 7 | asr1000: 8 | 9 | connect: 10 | 11 | backup_file_on_device: 12 | copy_dir: 'bootflash:/' 13 | copy_file: 'asr1000_mpls_config.cfg' 14 | overwrite: False 15 | 16 | order: 17 | - 'connect' 18 | - 'backup_file_on_device' 19 | -------------------------------------------------------------------------------- /clean/reload_apply_config/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Reload device & apply raw configuration 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - Reload a given device 6 | - Apply raw configuration strings to the device 7 | 8 | The above would run _prior_ to executing any pyATS testcases or scripts. 9 | 10 | Note: Using N9K device for the example. -------------------------------------------------------------------------------- /clean/ping_server/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [asr1000] 5 | 6 | devices: 7 | asr1000: 8 | 9 | connect: 10 | 11 | ping_server: 12 | server: 10.81.116.4 13 | vrf: Mgmt-intf 14 | timeout: 60 15 | min_success_rate: 80 16 | max_attempts: 5 17 | interval: 30 18 | 19 | order: 20 | - 'connect' 21 | - 'ping_server' 22 | -------------------------------------------------------------------------------- /clean/reload_apply_config_file/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Reload device & apply configuration from a file 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | - Reload a given device 6 | - Apply configuration from a given file to the device 7 | 8 | The above would run _prior_ to executing any pyATS testcases or scripts. 9 | 10 | Note: Using N9K device for the example. -------------------------------------------------------------------------------- /clean/remove_config_load_new_config/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean | Remove existing config & load new config without reload 2 | 3 | This clean YAML demonstrates the simplicity of using the pyATS Clean library as 4 | a pre-execution step to: 5 | 6 | - Remove existing config on the device 7 | - Load new configs on the device 8 | 9 | The above would run _prior_ to executing any pyATS testcases or scripts. 10 | 11 | Note: Using N9K device for the example. -------------------------------------------------------------------------------- /clean/write_erase_reload/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [csr-1000v-1] 5 | 6 | devices: 7 | csr-1000v-1: 8 | 9 | connect: 10 | 11 | write_erase: 12 | timeout: 300 13 | 14 | reload: 15 | sleep_after_reload: 300 16 | module_timeout: 180 17 | module_interval: 60 18 | 19 | order: 20 | - 'connect' 21 | - 'write_erase' 22 | - 'reload' 23 | -------------------------------------------------------------------------------- /parsergen/demo/README.md: -------------------------------------------------------------------------------- 1 | # Parsergen demo on Virl device 2 | 3 | # Introduction 4 | 5 | Example of parsergen on real device 6 | 1) Once with tabular 7 | 2) once without tabular structure 8 | 9 | # Execution 10 | 11 | ``` 12 | python nontabular_example.py -testbed_file virl.yaml 13 | python tabular_example.py -testbed_file virl.yaml 14 | ``` 15 | 16 | # Output 17 | 18 | Example output in: 19 | nontabular_output 20 | tabular_output 21 | -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/datafile.yaml: -------------------------------------------------------------------------------- 1 | # Datafile Schema 2 | # --------------- 3 | 4 | common_setup: 5 | ospf_1: '100' 6 | ospf_2: '200' 7 | area_id: '0.0.0.0' 8 | verify_timer_1: 90 9 | verify_timer_2: 90 10 | log_adjacency_changes: True 11 | nsf: 'cisco' 12 | nsr: True 13 | auto_cost_ref_bw: 1000 14 | vrf_name: 'test' 15 | 16 | testcases: 17 | Modify: 18 | ospf_2: '200' 19 | auto_cost_ref_bw: 10 20 | -------------------------------------------------------------------------------- /GenieHarnessHelloWorld/trigger_datafile.yaml: -------------------------------------------------------------------------------- 1 | # Hello World Testcase 2 | HelloWorld: 3 | source: 4 | # Python path 5 | # Directory.file.ClassName 6 | class: examples.GenieHarnessHelloWorld.HelloWorld.HelloWorld 7 | devices: ['uut'] 8 | 9 | # Basic testcase 10 | Basic: 11 | source: 12 | # Python path 13 | # Directory.file.ClassName 14 | class: examples.GenieHarnessHelloWorld.Basic.Basic 15 | devices: ['uut'] 16 | 17 | -------------------------------------------------------------------------------- /loop/loop_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job loop_example_job.py 3 | # Description: This example shows looping and variants in pyats 4 | 5 | import os 6 | from pyats.easypy import run 7 | 8 | def main(): 9 | # Find the location of the script in relation to the job file 10 | test_path = os.path.dirname(os.path.abspath(__file__)) 11 | testscript = os.path.join(test_path, 'loop_example_script.py') 12 | 13 | run(testscript=testscript) 14 | -------------------------------------------------------------------------------- /metaparser/README.md: -------------------------------------------------------------------------------- 1 | # Metaparssser demo on Virl device 2 | 3 | # Introduction 4 | Example of Metaparser on real device 5 | 1) Once with ISOXE device 6 | 2) once without NXOS device 7 | 8 | # Execution 9 | 10 | ``` 11 | python demo_metaparser_iosxe.py -testbed_file virl.yaml 12 | python demo_metaparser_nxos.py -testbed_file virl.yaml 13 | ``` 14 | # Output 15 | 16 | Example output in: 17 | demo_metaparser_iosxe_output 18 | demo_metaparser_nxos_output 19 | -------------------------------------------------------------------------------- /retry/retry_example_job.py: -------------------------------------------------------------------------------- 1 | """ 2 | To run the job: 3 | pyats run job retry_example_job.py 4 | Description: This example shows retry and variants in pyats 5 | """ 6 | 7 | import os 8 | from pyats.easypy import run 9 | 10 | def main(): 11 | # Find the location of the script in relation to the job file 12 | test_path = os.path.dirname(os.path.abspath(__file__)) 13 | testscript = os.path.join(test_path, 'retry_example_script.py') 14 | 15 | run(testscript=testscript) 16 | 17 | -------------------------------------------------------------------------------- /clean/change_boot_vars_reload/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [N7700-1] 5 | 6 | devices: 7 | N7700-1: 8 | 9 | connect: 10 | 11 | change_boot_variable: 12 | copy_vdc_all: True 13 | images: 14 | system: 'bootflash:/n7700-s2-dk9.6.2.10.bin' 15 | kickstart: 'bootflash:/n7000-s2-kickstart.6.2.10.bin' 16 | 17 | reload: 18 | 19 | order: 20 | - 'connect' 21 | - 'change_boot_variable' 22 | - 'reload' 23 | -------------------------------------------------------------------------------- /GenieHarnessHelloWorld/HelloWorld.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from pyats import aetest 3 | from genie.harness.base import Trigger 4 | 5 | log = logging.getLogger() 6 | 7 | 8 | class HelloWorld(Trigger): 9 | '''Just print Hello World''' 10 | 11 | @aetest.test 12 | def print_hello1(self, uut): 13 | '''Print Hello World''' 14 | log.info('Hello World') 15 | 16 | @aetest.test 17 | def print_hello2(self, uut): 18 | '''Why not do it again?''' 19 | log.info('Yes Yes, Hello World') 20 | 21 | -------------------------------------------------------------------------------- /blitz/config_interface/job.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from pyats import aetest 4 | 5 | # Needed for logic 6 | from pyats.datastructures.logic import And, Not, Or 7 | from genie.harness.main import gRun 8 | 9 | def main(): 10 | test_path = os.path.dirname(os.path.abspath(__file__)) 11 | gRun( 12 | trigger_datafile=test_path+'/blitz.yaml', 13 | subsection_datafile=test_path+'/subsection_datafile.yaml', 14 | mapping_datafile=test_path+'/mapping_datafile.yaml', 15 | trigger_groups=And('all'), 16 | ) 17 | -------------------------------------------------------------------------------- /clean/delete_files_from_server/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [asr1000] 5 | 6 | devices: 7 | asr1000: 8 | 9 | connect: 10 | 11 | delete_files_from_server: 12 | server: 10.81.116.4 13 | protocol: 'sftp' 14 | files: 15 | - /auto/release/path/vmlinux.bin 16 | - /auto/configs/asr1000_ospf_config.cfg 17 | - /auto/configs/asr1000_bgp_config.cfg 18 | 19 | order: 20 | - 'connect' 21 | - 'delete_files_from_server' 22 | -------------------------------------------------------------------------------- /clean/tftp_boot_device/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [csr-1000v-1] 5 | 6 | devices: 7 | csr-1000v-1: 8 | 9 | connect: 10 | 11 | tftp_boot: 12 | image: 13 | - /auto/release/path/csr1000v-universalk9.03.10.00.S.153-3.S-ext.SPA.bin 14 | ip_address: [10.1.2.64] 15 | gateway: 10.1.2.1 16 | subnet_mask: 255.255.255.0 17 | tftp_server: 10.81.116.4 18 | timeout: 30000 19 | 20 | order: 21 | - 'connect' 22 | - 'tftp_boot' 23 | -------------------------------------------------------------------------------- /blitz/config_interface/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Blitz Configure Interface Description 3 | 4 | This folder contains following blitz file 5 | 6 | - blitz.yaml (trigger_datafile with Blitz style) 7 | 8 | What this Blitz yaml does is: 9 | - access to R1_xe (iosxe) device 10 | - default interface on both Gi2 and Gi3 11 | - configure interface description `configure by pyATS` on both Gi2 and Gi3 12 | - check the interface description is configured as expected 13 | 14 | ### How to use: 15 | ``` 16 | pyats run job job.py --testbed-file testbed.yaml 17 | ``` 18 | -------------------------------------------------------------------------------- /libraries/harness_cluster/trigger_datafile.yaml: -------------------------------------------------------------------------------- 1 | extends: "%CALLABLE{genie.libs.sdk.genie_yamls.datafile(trigger,nxos)}" 2 | 3 | TriggerCluster: 4 | sub_verifications: ['Verify_BgpVrfAllAll'] 5 | sub_triggers: [ 'TriggerSleep', 'TriggerShutNoShutBgp'] 6 | sub_order: ['TriggerSleep', 'Verify_BgpVrfAllAll', 'TriggerSleep', 'TriggerShutNoShutBgp', 'Verify_BgpVrfAllAll'] 7 | devices: ['uut'] 8 | 9 | TriggerCluster2: 10 | sub_verifications: ['Verify_BgpVrfAllAll'] 11 | sub_triggers: [ 'TriggerSleep', 'TriggerShutNoShutBgp'] 12 | devices: ['uut'] 13 | -------------------------------------------------------------------------------- /connection/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: c9000 3 | 4 | devices: 5 | cat9500: 6 | os: iosxe 7 | type: c9500 8 | platform: c9500 9 | credentials: 10 | default: 11 | password: password 12 | username: admin 13 | enable: 14 | password: password 15 | username: admin 16 | connections: 17 | defaults: 18 | class: unicon.Unicon 19 | cli: 20 | protocol: telnet 21 | ip: 172.27.101.31 22 | port: 6052 23 | service_attributes: 24 | execute: 25 | timeout: 600 26 | 27 | -------------------------------------------------------------------------------- /datafiles/data/simple_data.yaml: -------------------------------------------------------------------------------- 1 | module_var_a: some string value 2 | module_var_b: 99999 3 | 4 | parameters: 5 | script_param_a: 3.1415926 6 | script_param_b: 2016-01-01 7 | 8 | common_setup: 9 | parameters: 10 | cc_param_a: 3 11 | cc_param_b: 4 12 | 13 | testcases: 14 | MyTestcase: 15 | uid: customized_id_from_datafile 16 | groups: [demo, datafile, awesomeness] 17 | 18 | parameters: 19 | tc_param_a: 300 20 | tc_param_b: 400 21 | 22 | class_var_a: [1,2,3,4,5] 23 | class_var_b: datafile feature is just that awesome -------------------------------------------------------------------------------- /clean/clean/clean_mock.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | PyatsDeviceClean: 3 | module: genie.libs.clean 4 | devices: [uut] 5 | 6 | devices: 7 | uut: 8 | 9 | images: 10 | - bootflash:packages.conf 11 | 12 | connect: 13 | 14 | apply_configuration: 15 | configuration: 'hostname testing' 16 | 17 | change_boot_variable: 18 | 19 | reload: 20 | 21 | apply_configuration__1: 22 | configuration: 'hostname csr1000v-1' 23 | 24 | order: 25 | - connect 26 | - apply_configuration 27 | - change_boot_variable 28 | - reload 29 | - apply_configuration__1 30 | -------------------------------------------------------------------------------- /clean/reload_apply_config_file/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [N9500-1] 5 | 6 | devices: 7 | N9500-1: 8 | 9 | connect: 10 | 11 | reload: 12 | sleep_after_reload: 300 13 | module_timeout: 180 14 | module_interval: 60 15 | 16 | apply_configuration: 17 | file: 'bootflash:n9500_golden_config.cfg' 18 | config_timeout: 60 19 | max_time: 180 20 | check_interval: 60 21 | config_stable_time: 120 22 | 23 | order: 24 | - 'connect' 25 | - 'reload' 26 | - 'apply_configuration' 27 | -------------------------------------------------------------------------------- /tasks/results/task_example_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: tc_one 10 | result: PASSED 11 | testscript: /scratch/pyats_install_test/examples/tasks/task_example.py 12 | Task-2: 13 | commonCleanup: 14 | name: common_cleanup 15 | result: PASSED 16 | commonSetup: 17 | name: common_setup 18 | result: PASSED 19 | testcases: 20 | - name: tc_one 21 | result: PASSED 22 | testscript: /scratch/pyats_install_test/examples/tasks/task_example.py 23 | -------------------------------------------------------------------------------- /clean/clean_vWLC_aireos/clean_vWLC.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [vWLC] 5 | 6 | devices: 7 | vWLC: 8 | connect: 9 | 10 | cli_boot: 11 | filename: 'AIR-CTVM-K9-8-8-130-0.aes' 12 | timeout: 1000 13 | username: rcpuser 14 | password: 123rcp! 15 | protocol: ftp 16 | tftp_server: 10.2.5.5 17 | path: "/auto/tftp-ssr/golden/" 18 | 19 | ping_server: 20 | interval: 60 21 | server: 10.2.5.5 22 | timeout: 120 23 | vrf: '' 24 | 25 | order: 26 | - connect 27 | - ping_server 28 | - cli_boot -------------------------------------------------------------------------------- /basic/basic_example_job.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | """ 4 | # To run the job: 5 | # pyats run job basic_example_job.py 6 | # Description: This example shows the basic functionality of pyats 7 | # with few passing tests 8 | 9 | import os 10 | from pyats.easypy import run 11 | 12 | # All run() must be inside a main function 13 | def main(): 14 | # Find the location of the script in relation to the job file 15 | test_path = os.path.dirname(os.path.abspath(__file__)) 16 | testscript = os.path.join(test_path, 'basic_example_script.py') 17 | 18 | # Execute the testscript 19 | run(testscript=testscript) 20 | -------------------------------------------------------------------------------- /tasks/results/task_example_result_ext.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: tc_one 10 | result: PASSED 11 | testscript: /scratch/pyats_ext_install_test/examples/tasks/task_example.py 12 | Task-2: 13 | commonCleanup: 14 | name: common_cleanup 15 | result: PASSED 16 | commonSetup: 17 | name: common_setup 18 | result: PASSED 19 | testcases: 20 | - name: tc_one 21 | result: PASSED 22 | testscript: /scratch/pyats_ext_install_test/examples/tasks/task_example.py 23 | -------------------------------------------------------------------------------- /parsergen/pyAtsStandaloneUt/README: -------------------------------------------------------------------------------- 1 | Description: 2 | ------------ 3 | This directory contains a number of standalone scripts that show how 4 | scripts may be written to test parsergen against hardcoded router output. 5 | 6 | A mocking infrastructure is set up that "fools" pyAts into "thinking" that 7 | it is talking to a real device, when in reality it is just talking to 8 | a mocked-up stub whose behavior is under the user's complete control. 9 | 10 | Since these tests may be run extremely quickly, it is easier than ever to 11 | do quick and iterative parser development. 12 | 13 | Example: 14 | python cli_command_formatting_example.py 15 | -------------------------------------------------------------------------------- /feature/results/features_example_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: my_passing_tc 10 | result: PASSED 11 | - name: my_failed_testcase 12 | result: FAILED 13 | - name: loop1 14 | result: PASSED 15 | - name: loop2 16 | result: PASSED 17 | - name: my_looped_testcase_variant[variants=1] 18 | result: PASSED 19 | - name: my_looped_testcase_variant[variants=2] 20 | result: PASSED 21 | testscript: /scratch/pyats_install_test/examples/feature/features_example_script.py 22 | -------------------------------------------------------------------------------- /feature/results/features_example_result_ext.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: my_passing_tc 10 | result: PASSED 11 | - name: my_failed_testcase 12 | result: FAILED 13 | - name: loop1 14 | result: PASSED 15 | - name: loop2 16 | result: PASSED 17 | - name: my_looped_testcase_variant[variants=1] 18 | result: PASSED 19 | - name: my_looped_testcase_variant[variants=2] 20 | result: PASSED 21 | testscript: /scratch/pyats_ext_install_test/examples/feature/features_example_script.py 22 | -------------------------------------------------------------------------------- /health/cpu_memory_custom_check/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Health for cpu/memory custom check 2 | 3 | This folder contains following pyATS health yaml file: 4 | 5 | - health_cpu_memory_custom.yaml 6 | 7 | The file can be used as a template to create custom pyATS Health Check. 8 | In this example, having monitor/check a cpu load and memory usage on devices in health yaml. 9 | 10 | Please adjust some parameters such as device, threshold and etc to your testbed/job before use. 11 | 12 | ### How to use 13 | 14 | ``` 15 | pyats run job ../../blitz/config_interface/job.py --testbed-file ../../blitz/config_interface/testbed.yaml --health-file health_cpu_memory_custom.yaml 16 | ``` -------------------------------------------------------------------------------- /script_parameters/job/script_parameters_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job $VIRTUAL_ENV/examples/script_args/job/script_args_example_job.py 3 | # Description: This example shows how to pass script args from the job file 4 | # (and then how to read/set them from the script) 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | def main(): 10 | # Find the location of the script in relation to the job file 11 | test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 12 | testscript = os.path.join(test_path, 'script_parameters_example_script.py') 13 | 14 | run(testscript=testscript, x=1, y=2) 15 | -------------------------------------------------------------------------------- /steps/job/steps_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job $VIRTUAL_ENV/examples/steps/job/steps_example_job.py 3 | # Description: This example shows the basic functionality of pyats 4 | # with few passing tests 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | def main(): 10 | # Find the location of the script in relation to the job file 11 | test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 12 | testscript = os.path.join(test_path, 'steps_example_script.py') 13 | stepDebug = os.path.join(test_path, 'etc','stepsDebug.yaml') 14 | 15 | run(testscript=testscript, 16 | step_debug=stepDebug) 17 | -------------------------------------------------------------------------------- /libraries/harness_simple/demo1_harness_simple_job.py: -------------------------------------------------------------------------------- 1 | '''demo1_genie_harness_job.py 2 | 3 | Please read the README file. 4 | ''' 5 | 6 | # 7 | # optional author information 8 | # 9 | __author__ = 'Cisco Systems Inc.' 10 | __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' 11 | __contact__ = ['pyats-support-ext@cisco.com'] 12 | __date__= 'April 2018' 13 | 14 | # 15 | # import block 16 | # 17 | import os 18 | 19 | from genie.harness.main import gRun 20 | 21 | def main(): 22 | test_path = os.path.dirname(os.path.abspath(__file__)) 23 | 24 | # mapping_datafile is mandatory 25 | # trigger_uids limit which test to execute 26 | gRun(trigger_uids=['TriggerSleep']) 27 | -------------------------------------------------------------------------------- /clean/viptela/full_clean_controllers/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for Cisco SDWAN Controllers (Viptela) 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for Cisco SDWAN Controllers (Viptela) 6 | - testbed.yaml file for Cisco SDWAN Controllers (Viptela) 7 | 8 | These files can be used as a template to execute a full end-to-end clean on Cisco SDWAN Controllers (Viptela). It performs the following steps in order: 9 | 10 | - connects to Cisco SDWAN Controllers (Viptela) 11 | - install software via ftp 12 | - activate software and reload 13 | 14 | Please substitute your device IP addresses, credentials and image directories in the templates provided before use. 15 | -------------------------------------------------------------------------------- /libraries/trigger_within_pyats/job/demo7_trigger_within_pyats_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job $VIRTUAL_ENV/examples/basic/job/basic_example_job.py 3 | # Description: This example shows the basic functionality of pyats 4 | # with few passing tests 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | # All run() must be inside a main function 10 | def main(): 11 | # Find the location of the script in relation to the job file 12 | test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 13 | testscript = os.path.join(test_path, 'demo7_trigger_within_pyats.py') 14 | 15 | # Execute the testscript 16 | run(testscript=testscript) 17 | -------------------------------------------------------------------------------- /clean/copy_files_to_server/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [asr1000] 5 | 6 | devices: 7 | asr1000: 8 | 9 | connect: 10 | 11 | copy_to_linux: 12 | origin: 13 | files: 14 | - /auto/release/path/vmlinux.bin 15 | - /auto/configs/asr1000_ospf_config.cfg 16 | - /auto/configs/asr1000_bgp_config.cfg 17 | destination: 18 | directory: /nobackup/pyats_files/ 19 | hostname: 10.81.117.4 20 | protocol: sftp 21 | overwrite: True 22 | append_hostname: True 23 | check_file_stability: True 24 | 25 | order: 26 | - 'connect' 27 | - 'copy_to_linux' 28 | -------------------------------------------------------------------------------- /metadata/metadata_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job basic_example_metadata_job.py 3 | # Description: This example shows the basic functionality of pyats 4 | # with few passing tests 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | # All run() must be inside a main function 10 | def main(runtime): 11 | # Find the location of the script in relation to the job file 12 | test_path = os.path.dirname(os.path.abspath(__file__)) 13 | testscript = os.path.join(test_path, 'metadata_example.py') 14 | 15 | 16 | runtime.job.release = "1.2.3" 17 | runtime.job.image = "image1" 18 | run(testscript=testscript) 19 | run(testscript=testscript) 20 | -------------------------------------------------------------------------------- /libraries/trigger_within_pyats/trigger_within_pyats_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: tc_one 10 | result: PASSED 11 | - name: tc_genie_trigger 12 | result: ERRORED 13 | - name: tc_pyats_genie 14 | result: ERRORED 15 | - name: tc_pyats_and_genie_trigger 16 | result: ERRORED 17 | - name: Verify_bgp 18 | result: ERRORED 19 | - name: TriggerSleep 20 | result: ERRORED 21 | - name: Trigger_verification_mix 22 | result: ERRORED 23 | testscript: /scratch/pyats_install_test/examples/libraries/trigger_within_pyats/demo7_trigger_within_pyats.py 24 | -------------------------------------------------------------------------------- /datafiles/job/results/datafile_job_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonSetup: 3 | name: common_setup 4 | result: PASSED 5 | testcases: 6 | - name: MyTestcase 7 | result: ERRORED 8 | testscript: /scratch/pyats_install_test/examples/datafiles/testscript.py 9 | Task-2: 10 | commonSetup: 11 | name: common_setup 12 | result: PASSED 13 | testcases: 14 | - name: customized_id_from_datafile 15 | result: PASSED 16 | testscript: /scratch/pyats_install_test/examples/datafiles/testscript.py 17 | Task-3: 18 | commonSetup: 19 | name: common_setup 20 | result: PASSED 21 | testcases: 22 | - name: customized_id_from_datafile 23 | result: PASSED 24 | testscript: /scratch/pyats_install_test/examples/datafiles/testscript.py 25 | -------------------------------------------------------------------------------- /feature/features_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job features_example_job.py 3 | # Description: This example shows an overview of the different features/flows 4 | # that pyATS supports like skipping testcases, looping, variants, 5 | # in addition to basic usage (passing/failing/etc) 6 | 7 | import os 8 | from pyats.easypy import run 9 | from pyats.datastructures.logic import Not 10 | 11 | def main(): 12 | # Find the location of the script in relation to the job file 13 | test_path = os.path.dirname(os.path.abspath(__file__)) 14 | testscript = os.path.join(test_path, 'features_example_script.py') 15 | 16 | run(testscript=testscript, 17 | uids = Not("my_skipped_testcase1", "my_skipped_testcase2"),) 18 | -------------------------------------------------------------------------------- /clean/copy_files_to_device/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [asr1000] 5 | 6 | devices: 7 | asr1000: 8 | 9 | connect: 10 | 11 | copy_to_device: 12 | origin: 13 | files: 14 | - /auto/release/path/vmlinux.bin 15 | - /auto/configs/asr1000_ospf_config.cfg 16 | - /auto/configs/asr1000_bgp_config.cfg 17 | hostname: 10.81.116.4 18 | destination: 19 | directory: 'bootflash:/' 20 | protocol: ftp 21 | overwrite: True 22 | copy_attempts: 3 23 | min_free_space_percent: 30 24 | protected_files: 25 | - golden_config.cfg 26 | - (base.*) 27 | 28 | order: 29 | - 'connect' 30 | - 'copy_to_device' 31 | -------------------------------------------------------------------------------- /datafiles/job/results/datafile_job_result_ext.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonSetup: 3 | name: common_setup 4 | result: PASSED 5 | testcases: 6 | - name: MyTestcase 7 | result: ERRORED 8 | testscript: /scratch/pyats_ext_install_test/examples/datafiles/testscript.py 9 | Task-2: 10 | commonSetup: 11 | name: common_setup 12 | result: PASSED 13 | testcases: 14 | - name: customized_id_from_datafile 15 | result: PASSED 16 | testscript: /scratch/pyats_ext_install_test/examples/datafiles/testscript.py 17 | Task-3: 18 | commonSetup: 19 | name: common_setup 20 | result: PASSED 21 | testcases: 22 | - name: customized_id_from_datafile 23 | result: PASSED 24 | testscript: /scratch/pyats_ext_install_test/examples/datafiles/testscript.py 25 | -------------------------------------------------------------------------------- /connection/connection_example_job.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pyats.easypy import run 3 | 4 | # To run the job: 5 | # pyats run job $VIRTUAL_ENV/examples/connection/job/connection_example_job.py \ 6 | # --testbed-file 7 | # 8 | # Description: This example uses a sample testbed, connects to a device 9 | # which name is passed from the job file, 10 | # and executes some commands. 11 | 12 | # All run() must be inside a main function 13 | def main(): 14 | # Find the location of the script in relation to the job file 15 | test_path = os.path.dirname(os.path.abspath(__file__)) 16 | testscript = os.path.join(test_path, 'connection_example_script.py') 17 | 18 | # Execute the testscript 19 | run(testscript=testscript) 20 | -------------------------------------------------------------------------------- /health/cpu_memory_custom_check/health_cpu_memory_custom.yaml: -------------------------------------------------------------------------------- 1 | pyats_health_processors: 2 | groups: ["test"] 3 | source: 4 | pkg: genie.libs.health 5 | class: health.Health 6 | test_sections: 7 | - cpu: 8 | - api: 9 | device: R1_xe 10 | function: health_cpu 11 | arguments: 12 | command: show processes cpu 13 | processes: ['BGP I/O'] 14 | include: 15 | - sum_value_operator('value', '<', 90) 16 | - memory: 17 | - api: 18 | device: R1_xe 19 | function: health_memory 20 | arguments: 21 | command: show processes memory 22 | processes: ['\*Init\*'] 23 | include: 24 | - sum_value_operator('value', '<', 90) -------------------------------------------------------------------------------- /libraries/robot/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: admin 12 | password: admin 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: cisco 25 | password: cisco 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /libraries/config_ops/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: admin 12 | password: admin 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: cisco 25 | password: cisco 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /libraries/advance_robot/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: admin 12 | password: admin 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: cisco 25 | password: cisco 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /libraries/harness_cluster/demo11_harness_cluster_job.py: -------------------------------------------------------------------------------- 1 | '''demo11_harness_cluster_job.py 2 | 3 | Please read the README file. 4 | ''' 5 | 6 | # 7 | # optional author information 8 | # 9 | __author__ = 'Cisco Systems Inc.' 10 | __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' 11 | __contact__ = ['pyats-support-ext@cisco.com'] 12 | __date__= 'April 2019' 13 | 14 | # 15 | # import block 16 | # 17 | import os 18 | 19 | from genie.harness.main import gRun 20 | 21 | def main(): 22 | test_path = os.path.dirname(os.path.abspath(__file__)) 23 | 24 | # mapping_datafile is mandatory 25 | # trigger_uids limit which test to execute 26 | gRun(trigger_uids=['TriggerCluster'], 27 | verification_uids=['Verify_BgpVrfAllAll', 'Verify_Interface'], 28 | trigger_datafile='trigger_datafile.yaml') 29 | -------------------------------------------------------------------------------- /libraries/context_comparator/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: admin 12 | password: admin 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: cisco 25 | password: cisco 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /libraries/harness_telemetry/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: admin 12 | password: admin 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: cisco 25 | password: cisco 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /libraries/harness_triggers/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: admin 12 | password: admin 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: cisco 25 | password: cisco 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /libraries/harness_cluster/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: root 12 | password: D_Vay!_10& 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: root 25 | password: D_Vay!_10& 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: root 12 | password: D_Vay!_10& 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: 172.25.192.90 17 | port: 17023 18 | csr1000v-1: 19 | type: asr1k 20 | os: "iosxe" 21 | alias: helper 22 | credentials: 23 | default: 24 | username: root 25 | password: D_Vay!_10& 26 | connections: 27 | a: 28 | protocol: telnet 29 | ip: 172.25.192.90 30 | port: 17021 -------------------------------------------------------------------------------- /tasks/task_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job task_example_job.py 3 | # Description: This example demonstrate how tasks in easypy jobfiles are 4 | # created and handled. 5 | 6 | import os 7 | from pyats.easypy import Task 8 | 9 | def main(): 10 | # Find the location of the script in relation to the job file 11 | test_path = os.path.dirname(os.path.abspath(__file__)) 12 | testscript = os.path.join(test_path, 'task_example.py') 13 | 14 | # create two tasks. for simplicity's sake, we'll reuse the same script 15 | task_1 = Task(testscript = testscript) 16 | task_2 = Task(testscript = testscript) 17 | 18 | # start both tasks together (async execution) 19 | task_1.start() 20 | task_2.start() 21 | 22 | # wait for tasks to finish before terminating 23 | task_1.wait() 24 | task_2.wait() 25 | -------------------------------------------------------------------------------- /datafiles/job/datafile_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job $VIRTUAL_ENV/examples/datafile/job/datafile_job.py 3 | # Description: This example demonstrates how datafiles work in AEtest 4 | 5 | import os 6 | from pyats.easypy import run 7 | 8 | def main(): 9 | # Find the location of the script in relation to the job file 10 | test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 11 | testscript = os.path.join(test_path, 'testscript.py') 12 | 13 | # Execute the testscript with no datafile 14 | run(testscript=testscript) 15 | 16 | # run with simple datafile 17 | run(testscript=testscript, 18 | datafile = os.path.join(test_path, 'data', 'simple_data.yaml')) 19 | 20 | # run with extended datafile 21 | run(testscript=testscript, 22 | datafile = os.path.join(test_path, 'data', 'extended_data.yaml')) 23 | -------------------------------------------------------------------------------- /GenieHarnessHelloWorld/testbed.yaml: -------------------------------------------------------------------------------- 1 | devices: 2 | nx-osv-1: 3 | type: 'router' 4 | os: 'nxos' 5 | alias: 'uut' 6 | credentials: 7 | default: 8 | username: admin 9 | password: admin 10 | enable: 11 | password: admin 12 | connections: 13 | defaults: 14 | class: 'unicon.Unicon' 15 | cli: 16 | protocol: telnet 17 | ip: "172.25.192.90" 18 | port: 17064 19 | 20 | csr1000v-1: 21 | type: 'router' 22 | os: "iosxe" 23 | alias: 'helper' 24 | credentials: 25 | default: 26 | username: cisco 27 | password: cisco 28 | enable: 29 | password: cisco 30 | connections: 31 | defaults: 32 | class: 'unicon.Unicon' 33 | cli: 34 | protocol: telnet 35 | ip: "172.25.192.90" 36 | port: 17062 37 | -------------------------------------------------------------------------------- /clean/remove_config_load_new_config/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [N9500-1] 5 | 6 | devices: 7 | N9500-1: 8 | 9 | connect: 10 | 11 | write_erase: 12 | timeout: 30 13 | 14 | apply_configuration: 15 | configuration: | 16 | switchname N9500-1 17 | power redundancy-mode combined force 18 | username admin password lalala role network-admin 19 | no password strength-check 20 | interface mgmt0 21 | ip address X.X.X.X 255.255.255.0 22 | no shutdown 23 | vrf context management 24 | ip route 0.0.0.0/0 10.X.X.X 25 | line console 26 | exec-timeout 0 27 | no ip domain-lookup 28 | feature telnet 29 | config_timeout: 60 30 | max_time: 180 31 | check_interval: 60 32 | config_stable_time: 120 33 | 34 | order: 35 | - 'connect' 36 | - write_erase’ 37 | - 'apply_configuration' 38 | -------------------------------------------------------------------------------- /libraries/harness_triggers/harness_triggers_result.yaml: -------------------------------------------------------------------------------- 1 | Task-1: 2 | commonCleanup: 3 | name: common_cleanup 4 | result: PASSED 5 | commonSetup: 6 | name: common_setup 7 | result: PASSED 8 | testcases: 9 | - name: Verifications.TriggerUnconfigConfigBgp.uut 10 | result: PASSED 11 | - name: TriggerUnconfigConfigBgp.uut 12 | result: FAILED 13 | - name: Verifications.TriggerShutNoShutBgpNeighbors.uut 14 | result: BLOCKED 15 | - name: TriggerShutNoShutBgpNeighbors.uut 16 | result: PASSED 17 | - name: Verifications.TriggerModifyLoopbackInterfaceIp.uut 18 | result: PASSED 19 | - name: TriggerModifyLoopbackInterfaceIp.uut 20 | result: FAILED 21 | - name: Verifications.TriggerShutNoShutEthernetInterface.uut 22 | result: BLOCKED 23 | - name: TriggerShutNoShutEthernetInterface.uut 24 | result: PASSED 25 | - name: Verifications.post 26 | result: PASSED 27 | testscript: /scratch/pyats_install_test/lib/python3.10/site-packages/genie/harness/genie_testscript.py 28 | -------------------------------------------------------------------------------- /libraries/harness_telemetry/demo3_harness_telemetry_job.py: -------------------------------------------------------------------------------- 1 | '''demo3_harness_telemetry_job.py 2 | 3 | Please read the README file. 4 | ''' 5 | 6 | # 7 | # optional author information 8 | # 9 | __author__ = 'Cisco Systems Inc.' 10 | __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' 11 | __contact__ = ['pyats-support-ext@cisco.com'] 12 | __date__= 'April 2018' 13 | 14 | # 15 | # import block 16 | # 17 | import os 18 | 19 | from genie.harness.main import gRun 20 | 21 | def main(): 22 | test_path = os.path.dirname(os.path.abspath(__file__)) 23 | 24 | # pts_features mentions to Genie which feature to learn in CommonSetup, and then compare at the CommonCleanup 25 | # trigger_uids and verification_uids limit which test to execute 26 | gRun(pts_features=['platform', 'bgp', 'interface'], 27 | verification_uids=['Verify_IpInterfaceBrief', 'Verify_IpRoute_vrf_all'], 28 | trigger_uids=['TriggerUnconfigConfigBgp', 'TriggerShutNoShutBgpNeighbors', 'TriggerModifyLoopbackInterfaceIp', 'TriggerShutNoShutEthernetInterface']) 29 | -------------------------------------------------------------------------------- /libraries/harness_triggers/demo2_harness_triggers_job.py: -------------------------------------------------------------------------------- 1 | '''demo2_harness_triggers_job.py 2 | 3 | Please read the README file. 4 | ''' 5 | 6 | # 7 | # optional author information 8 | # 9 | __author__ = 'Cisco Systems Inc.' 10 | __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' 11 | __contact__ = ['pyats-support-ext@cisco.com'] 12 | __date__= 'April 2018' 13 | 14 | # 15 | # import block 16 | # 17 | import os 18 | 19 | from genie.harness.main import gRun 20 | 21 | def main(): 22 | test_path = os.path.dirname(os.path.abspath(__file__)) 23 | 24 | # pts_features mentions to Genie which feature to learn in CommonSetup, and then compare at the CommonCleanup 25 | # trigger_uids and verification_uids limit which test to execute 26 | gRun(pts_features=['platform', 'bgp', 'interface'], 27 | verification_uids=['Verify_IpInterfaceBrief', 'Verify_IpRoute_vrf_all'], 28 | trigger_uids=['TriggerUnconfigConfigBgp', 'TriggerShutNoShutBgpNeighbors', 'TriggerModifyLoopbackInterfaceIp', 'TriggerShutNoShutEthernetInterface']) 29 | -------------------------------------------------------------------------------- /clean/reload_apply_config/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [N9500-1] 5 | 6 | devices: 7 | N9500-1: 8 | 9 | connect: 10 | 11 | reload: 12 | sleep_after_reload: 300 13 | module_timeout: 180 14 | module_interval: 60 15 | 16 | apply_configuration: 17 | configuration: | 18 | switchname N9500-1 19 | power redundancy-mode combined force 20 | username admin password lalala role network-admin 21 | no password strength-check 22 | interface mgmt0 23 | ip address X.X.X.X 255.255.255.0 24 | no shutdown 25 | vrf context management 26 | ip route 0.0.0.0/0 10.X.X.X 27 | line console 28 | exec-timeout 0 29 | no ip domain-lookup 30 | feature telnet 31 | config_timeout: 60 32 | max_time: 180 33 | check_interval: 60 34 | config_stable_time: 120 35 | 36 | order: 37 | - 'connect' 38 | - 'reload' 39 | - 'apply_configuration' 40 | -------------------------------------------------------------------------------- /libraries/harness_cluster/README.md: -------------------------------------------------------------------------------- 1 | ## demo11_harness_cluster 2 | 3 | # Introduction 4 | 5 | This script demonstrate how to run multiple triggers and verifications within 1 6 | trigger; a Cluster trigger 7 | 8 | # Execution 9 | 10 | This demo requires devices. There is 3 options on how to run this demo: 11 | 12 | 1) Use mock devices. We have used the Unicon playback feature to record all 13 | interactions with the device so you can use it smoothly without connecting 14 | to real devices as below. 15 | 16 | ``` 17 | pyats run job demo11_harness_cluster_job.py --testbed-file virl.yaml --replay mock_device 18 | ``` 19 | 20 | 2) This demo is ready to be used with the VIRL devices. Follow the guide 21 | on how to boot the virtual devices. 22 | 23 | 3) Use your own devices. Modify the testbed file with the devices' 24 | names and the corresponding IP addresses. 25 | 26 | ``` 27 | pyats run job demo11_harness_cluster_job.py --testbed-file virl.yaml 28 | ``` 29 | 30 | # Output 31 | 32 | The log can be viewed in the file `TaskLog.html`. 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pyATS | Library Examples 2 | 3 | This repository contains pyATS and its library's usage examples. The purpose 4 | of these examples is not to perform _real testing_, but rather to: 5 | 6 | - demonstrate **the various features and functionalities** of the 7 | framework using examples and comments 8 | 9 | - and demonstrating **how to use the libraries** with example scripts 10 | using mock devices in `libraries/` folder 11 | 12 | ## Getting Started 13 | 14 | ```bash 15 | 16 | # 1. make sure pyATS is installed (including the libraries) 17 | bash$ pip install pyats[full] 18 | 19 | # 2. clone this repository into your environment 20 | bash$ git clone https://github.com/CiscoTestAutomation/examples 21 | 22 | ``` 23 | 24 | ## General Information 25 | 26 | - Website: https://developer.cisco.com/pyats/ 27 | - Documentation: https://developer.cisco.com/docs/pyats/ 28 | - Support: pyats-support-ext@cisco.com 29 | 30 | 31 | # Contribution 32 | 33 | Feel free to open PR against this repository for any enhancements or bug fixes 34 | you wish to add. 35 | -------------------------------------------------------------------------------- /libraries/explore/explore-1/nx-osv-1_show-version_parsed.txt: -------------------------------------------------------------------------------- 1 | { 2 | "_meta_class": "ShowVersion", 3 | "_meta_module": "show_platform", 4 | "_meta_os": "nxos", 5 | "platform": { 6 | "hardware": { 7 | "bootflash": "3184776 kB", 8 | "chassis": "NX-OSv Supervisor Module", 9 | "device_name": "nx-osv-1", 10 | "model": "NX-OSv", 11 | "processor_board_id": "TM00010000B", 12 | "slots": "None" 13 | }, 14 | "kernel_uptime": { 15 | "days": 6, 16 | "hours": 1, 17 | "minutes": 12, 18 | "seconds": 30 19 | }, 20 | "name": "Nexus", 21 | "os": "NX-OS", 22 | "software": { 23 | "kickstart_compile_time": "1/11/2016 16:00:00 [02/11/2016 10:30:12]", 24 | "kickstart_image_file": "bootflash:///titanium-d1-kickstart.7.3.0.D1.1.bin", 25 | "kickstart_version": "7.3(0)D1(1)", 26 | "system_compile_time": "1/11/2016 16:00:00 [02/11/2016 13:08:11]", 27 | "system_image_file": "bootflash:///titanium-d1.7.3.0.D1.1.bin", 28 | "system_version": "7.3(0)D1(1)" 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /libraries/harness_simple/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | credentials: 10 | default: 11 | username: admin 12 | password: admin 13 | connections: 14 | a: 15 | command: mock_device_cli --os nxos --state connect --mock_data_dir mock_device/nxos --hostname nx-osv-1 16 | protocol: telnet 17 | ip: 172.25.192.90 18 | port: 17023 19 | csr1000v-1: 20 | type: asr1k 21 | os: "iosxe" 22 | alias: helper 23 | credentials: 24 | default: 25 | username: cisco 26 | password: cisco 27 | connections: 28 | a: 29 | command: mock_device_cli --os iosxe --state connect --mock_data_dir mock_device/iosxe --hostname csr1000v-1 30 | protocol: telnet 31 | ip: 172.25.192.90 32 | port: 17021 33 | -------------------------------------------------------------------------------- /libraries/explore/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'new_tb' 3 | devices: 4 | nx-osv-1: 5 | type: 'Nexus' 6 | os: 'nxos' 7 | alias: 'uut' 8 | tacacs: 9 | login_prompt: "login:" 10 | password_prompt: "Password:" 11 | username: "admin" 12 | passwords: 13 | tacacs: Cisc0123 14 | enable: admin 15 | line: admin 16 | connections: 17 | defaults: 18 | class: 'unicon.Unicon' 19 | a: 20 | protocol: telnet 21 | ip: "172.25.192.90" 22 | port: 17028 23 | csr1000v-1: 24 | type: asr1k 25 | os: "iosxe" 26 | alias: 'helper' 27 | tacacs: 28 | login_prompt: 'login:' 29 | password_prompt: 'Password:' 30 | username: cisco 31 | passwords: 32 | tacacs: cisco 33 | enable: cisco 34 | line: cisco 35 | connections: 36 | defaults: 37 | class: 'unicon.Unicon' 38 | a: 39 | protocol: telnet 40 | ip: "172.25.192.90" 41 | port: 17002 42 | -------------------------------------------------------------------------------- /clean/full_clean_n7k_nxos/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for NXOS N7K 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for NXOS N7K platform 6 | - testbed.yaml file for NXOS N7K platform 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | NXOS N7K device. It performs the following steps in order: 10 | 11 | - connects to NXOS N7K device 12 | - (Optional) pings execution servers to verify connectivity 13 | - (Optional) copies necessary images to intermediate server 14 | - copies images to device 15 | - changes boot variables 16 | - executes 'write erase' 17 | - reload device 18 | - apply base configuration after reload 19 | - verifies the running image matches what was specified 20 | 21 | If the devices are not in stable state at the time of execution, pyATS Clean 22 | provides a built-in recovery mechanism, where it attempts to bring the device 23 | back to stable state by powercycling the device and then rebooting it from 24 | rommon with a known stable (golden) image. 25 | 26 | Please substitute your device IP addresses, credentials and image directories in 27 | the templates provided before use. 28 | -------------------------------------------------------------------------------- /clean/full_clean_asr1k_iosxe/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for IOSXE ASR1K 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for IOSXE ASR1K platform 6 | - testbed.yaml file for IOSXE ASR1K platform 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | IOSXE ASR1K device. It performs the following steps in order: 10 | 11 | - connects to IOSXE ASR1K device 12 | - (Optional) pings execution servers to verify connectivity 13 | - (Optional) copies necessary images to intermediate server 14 | - copies images to device 15 | - changes boot variables 16 | - executes 'write erase' 17 | - reload device 18 | - apply base configuration after reload 19 | - verifies the running image matches what was provided 20 | 21 | If the devices are not in stable state at the time of execution, pyATS Clean 22 | provides a built-in recovery mechanism, where it attempts to bring the device 23 | back to stable state by powercycling the device and then rebooting it from 24 | rommon with a known stable (golden) image. 25 | 26 | Please substitute your device IP addresses, credentials and image directories in 27 | the templates provided before use. 28 | -------------------------------------------------------------------------------- /libraries/README.md: -------------------------------------------------------------------------------- 1 | # Genie Examples 2 | 3 | Genie is both a library framework and a test harness that facilitates rapid 4 | development, encourage re-usable and simplify writing test automation. Genie bundled with 5 | the modular architecture of pyATS framework accelerates and simplifies test 6 | automation leveraging all the perks of the Python programming language in an 7 | object-orienting fashion. 8 | 9 | Genie was initially developed internally in Cisco, and is now available to the 10 | general public starting early 2018 through **Cisco DevNet**. Visit the Genie 11 | home page at https://developer.cisco.com/site/pyats/ 12 | 13 | 14 | ## Requirements 15 | 16 | Genie currently supports Python 3.4+ on Linux & Mac systems. Windows platforms 17 | are not yet supported. 18 | 19 | 20 | ## Examples List 21 | 22 | There are various examples of Genie under the directory `examples/libraries`. 23 | 1. harness_simple 24 | 2. harness_triggers 25 | 3. harness_telemetry 26 | 4. harness_custom_trigger 27 | 5. robot 28 | 6. config_ops 29 | 7. trigger_within_pyats 30 | 8. pyats_conf_ops 31 | 9. context_comparator 32 | 10. advance_robot 33 | 11. harness_cluster 34 | 12. explore 35 | 13. solutions -------------------------------------------------------------------------------- /clean/full_clean_cat9k_iosxe/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for IOSXE CAT9K 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for IOSXE CAT9K platform 6 | - testbed.yaml file for IOSXE CAT9K platform 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | IOSXE CAT9K device. It performs the following steps in order: 10 | 11 | - connects to IOSXE CAT9K device 12 | - (Optional) pings execution servers to verify connectivity 13 | - (Optional) copies necessary images to intermediate server 14 | - copies images to device 15 | - changes boot variables 16 | - executes 'write erase' 17 | - reload device 18 | - apply base configuration after reload 19 | - verifies the running image matches what was specified 20 | 21 | If the devices are not in stable state at the time of execution, pyATS Clean 22 | provides a built-in recovery mechanism, where it attempts to bring the device 23 | back to stable state by powercycling the device and then rebooting it from 24 | rommon with a known stable (golden) image. 25 | 26 | Please substitute your device IP addresses, credentials and image directories in 27 | the templates provided before use. 28 | -------------------------------------------------------------------------------- /clean/full_clean_isr4k_iosxe/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for IOSXE ISR4K 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for IOSXE ISR4K platform 6 | - testbed.yaml file for IOSXE ISR4K platform 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | IOSXE ISR4K device. It performs the following steps in order: 10 | 11 | - connects to IOSXE ISR4K device 12 | - (Optional) pings execution servers to verify connectivity 13 | - (Optional) copies necessary images to intermediate server 14 | - copies images to device 15 | - changes boot variables 16 | - executes 'write erase' 17 | - reload device 18 | - apply base configuration after reload 19 | - verifies the running image matches what was specified 20 | 21 | If the devices are not in stable state at the time of execution, pyATS Clean 22 | provides a built-in recovery mechanism, where it attempts to bring the device 23 | back to stable state by powercycling the device and then rebooting it from 24 | rommon with a known stable (golden) image. 25 | 26 | Please substitute your device IP addresses, credentials and image directories in 27 | the templates provided before use. 28 | -------------------------------------------------------------------------------- /clean/full_clean_csr1000v_iosxe/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for IOSXE CSR1000v 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for IOSXE CSR1000v platform 6 | - testbed.yaml file for IOSXE CSR1000v platform 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | IOSXE CSR1000v device. It performs the following steps in order: 10 | 11 | - connects to IOSXE CSR1000v device 12 | - (Optional) pings execution servers to verify connectivity 13 | - (Optional) copies necessary images to intermediate server 14 | - copies images to device 15 | - changes boot variables 16 | - executes 'write erase' 17 | - reload device 18 | - apply base configuration after reload 19 | - verifies the running image matches what was specified 20 | 21 | If the devices are not in stable state at the time of execution, pyATS Clean 22 | provides a built-in recovery mechanism, where it attempts to bring the device 23 | back to stable state by powercycling the device and then rebooting it from 24 | rommon with a known stable (golden) image. 25 | 26 | Please substitute your device IP addresses, credentials and image directories in 27 | the templates provided before use. 28 | -------------------------------------------------------------------------------- /libraries/context_comparator/README.md: -------------------------------------------------------------------------------- 1 | ## demo9_context_comparator 2 | 3 | # Introduction 4 | 5 | This script demonstrates how to compare show commands information between two 6 | contexts (cli/xml). It first sends a show command with cli, then do the same 7 | with xml, and compares the fields to make sure they are equal. 8 | 9 | # Execution 10 | 11 | This demo requires devices. There is 3 options on how to run this demo: 12 | 13 | 1) Use mock devices. We have used the Unicon playback feature to record all 14 | interactions with the device so you can use it smoothly without connecting 15 | to real devices as below. 16 | 17 | ``` 18 | pyats run job job/demo9_context_comparator_job.py --testbed-file virl.yaml --replay mock_device 19 | ``` 20 | 21 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 22 | on how to boot the virtual devices. 23 | 24 | 3) Use your own devices. Please modify the testbed file with the devices' 25 | names and the corresponding IP addresses. 26 | 27 | ``` 28 | pyats run job job/demo9_context_comparator_job.py --testbed-file virl.yaml 29 | ``` 30 | 31 | # Output 32 | 33 | The log can be viewed in the file `TaskLog.html`. 34 | -------------------------------------------------------------------------------- /clean/full_clean_n9kv_nxos/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for NXOS N9K Virtual 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for NXOS N9K virtual platform 6 | - testbed.yaml file for NXOS N9K virtual platform 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | NXOS N9K virtual device. It performs the following steps in order: 10 | 11 | - connects to NXOS N9K virtual device 12 | - (Optional) pings execution servers to verify connectivity 13 | - (Optional) copies necessary images to intermediate server 14 | - copies images to device 15 | - changes boot variables 16 | - executes 'write erase' 17 | - reload device 18 | - apply base configuration after reload 19 | - verifies the running image matches what was specified 20 | 21 | If the devices are not in stable state at the time of execution, pyATS Clean 22 | provides a built-in recovery mechanism, where it attempts to bring the device 23 | back to stable state by powercycling the device and then rebooting it from 24 | rommon with a known stable (golden) image. 25 | 26 | Please substitute your device IP addresses, credentials and image directories in 27 | the templates provided before use. 28 | -------------------------------------------------------------------------------- /clean/full_clean_n9k_nxos/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for NXOS N9K Hardware 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for NXOS N9K hardware platform 6 | - testbed.yaml file for NXOS N9K hardware platform 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | NXOS N9K hardware device. It performs the following steps in order: 10 | 11 | - connects to NXOS N9K hardware device 12 | - (Optional) pings execution servers to verify connectivity 13 | - (Optional) copies necessary images to intermediate server 14 | - copies images to device 15 | - changes boot variables 16 | - executes 'write erase' 17 | - reload device 18 | - apply base configuration after reload 19 | - verifies the running image matches what was specified 20 | 21 | If the devices are not in stable state at the time of execution, pyATS Clean 22 | provides a built-in recovery mechanism, where it attempts to bring the device 23 | back to stable state by powercycling the device and then rebooting it from 24 | rommon with a known stable (golden) image. 25 | 26 | Please substitute your device IP addresses, credentials and image directories in 27 | the templates provided before use. 28 | -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/README.md: -------------------------------------------------------------------------------- 1 | ## demo8_pyats_conf_ops 2 | 3 | # Introduction 4 | 5 | This script carries the knowledge of demo6. This time, it is uses within a 6 | pyATS script. This script is a pyATS scripts, which uses those objects to 7 | configuration and make sure the devices are configured correctly. This script 8 | works on all platform. 9 | 10 | This scripts requires the device to not be configured, as the configuration 11 | is done by the script. Make sure you are using the unconfigured virl devices. 12 | 13 | # Execution 14 | 15 | This demo requires devices. There is 2 options on how to run this demo: 16 | 17 | 1) This demo is ready to be used with the VIRL devices. Please follow the guide 18 | on how to boot the virtual devices. Make sure to use the VIRL file which 19 | does not configure both devices as the configuration is done within the script. 20 | 21 | 2) Use your own devices. Please modify the testbed file with the devices' 22 | names and the corresponding IP addresses. 23 | 24 | ``` 25 | pyats run job job/demo8_pyats_conf_ops_job.py --testbed-file virl.yaml --datafile datafile.yaml 26 | ``` 27 | 28 | # Output 29 | 30 | The log can be viewed in the file `logviewer`. 31 | -------------------------------------------------------------------------------- /steps/etc/stepsDebug.yaml: -------------------------------------------------------------------------------- 1 | myStep1: 2 | - when: ['start'] 3 | device: ['ott-tb1-n7k3'] 4 | cmd: ['show bgp'] 5 | - when: ['start'] 6 | device: ['myDevice2'] 7 | cmd: ['show ospf'] 8 | - when: ['passed'] 9 | device: ['ott-tb1-n7k3'] 10 | cmd: ['show int br'] 11 | - when: ['passed'] 12 | device: ['myDevice1'] 13 | cmd: ['show interface','show bgp'] 14 | - when: ['start', 'end'] 15 | device: ['ott-tb1-n7k3'] 16 | cmd: ['anyFirst'] 17 | - when: ['start', 'end'] 18 | device: ['myDevice1'] 19 | cmd: ['anySecond','show bgp'] 20 | 21 | First step is awesome: 22 | - when: ['start'] 23 | device: ['ott-tb1-n7k3'] 24 | cmd: ['show clock', 'show banana'] 25 | - when: ['passed', 'failed'] 26 | device: ['ott-tb1-n7k3'] 27 | cmd: ['show clock', 'show int'] 28 | - when: ['passed', 'failed'] 29 | device: ['ott-tb1-n7k2'] 30 | cmd: ['show int br'] 31 | - when: ['start', 'end'] 32 | device: ['ott-tb1-n7k3'] 33 | cmd: ['show ospf','show int'] 34 | 35 | .*: 36 | - when: ['start', 'end'] 37 | device: ['ott-tb1-n7k3'] 38 | cmd: ['show wrong command', 'show rip', 'any mpls'] -------------------------------------------------------------------------------- /clean/iosxe/sdwan/full_clean_cedge/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for IOSXE SDWAN (cEdge) devices 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for IOSXE SDWAN (cEdge) devices 6 | - testbed.yaml file for IOSXE SDWAN (cEdge) devices 7 | 8 | These files can be used as a template to execute a full end-to-end clean on IOSXE SDWAN (cEdge) It performs the following steps in order: 9 | 10 | - connects to IOSXE SDWAN devices 11 | - let device goes into ROMMON mode and boot from ROMMON as autonomous mode 12 | - apply bootstrap configuration for image copy 13 | - (Optional) pings execution servers to verify connectivity 14 | - copies images to device 15 | - expand .bin image as install mode 16 | - change mode to controller mode from autonomous mode and reload 17 | - apply bootstrap configuration 18 | 19 | If the devices are not in stable state at the time of execution, pyATS Clean 20 | provides a built-in recovery mechanism, where it attempts to bring the device 21 | back to stable state by powercycling the device and then rebooting it from 22 | rommon with a known stable (golden) image. 23 | 24 | Please substitute your device IP addresses, credentials and image directories in the templates provided before use. 25 | -------------------------------------------------------------------------------- /clean/full_clean_ncs540_xr7_iosxr/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: ncs540 3 | passwords: 4 | tacacs: xxx 5 | enable: xxx 6 | servers: 7 | ftp: 8 | address: 10.x.x.x 9 | credentials: 10 | default: 11 | username: xxxx 12 | password: xxxx 13 | 14 | tftp: 15 | address: 10.x.x.x 16 | credentials: 17 | default: 18 | username: xxxx 19 | password: xxxx 20 | 21 | devices: 22 | ncs540: 23 | alias: uut1 24 | os: iosxr 25 | type: iosxr 26 | platform: ncs540 27 | connections: 28 | defaults: 29 | class: unicon.Unicon 30 | via: peer_1 31 | peer_1: 32 | protocol: telnet 33 | ip: 10.x.x.x 34 | port: 2020 35 | member: 1 36 | service_attributes: 37 | execute: 38 | timeout: 600 39 | configure: 40 | timeout: 600 41 | peer_2: 42 | protocol: telnet 43 | ip: 10.x.x.x 44 | port: 2011 45 | member: 2 46 | custom: 47 | abstraction: 48 | order: [os, platform] 49 | -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/demo4_harness_custom_trigger_job.py: -------------------------------------------------------------------------------- 1 | '''demo4_harness_custom_trigger_job.py 2 | 3 | Please read the README file. 4 | ''' 5 | 6 | # 7 | # optional author information 8 | # 9 | __author__ = 'Cisco Systems Inc.' 10 | __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' 11 | __contact__ = ['pyats-support-ext@cisco.com'] 12 | __date__= 'April 2018' 13 | 14 | # 15 | # import block 16 | # 17 | import os 18 | 19 | from genie.harness.main import gRun 20 | 21 | def main(): 22 | test_path = os.path.dirname(os.path.abspath(__file__)) 23 | 24 | # the trigger_datafile is custom created by the user for a newly developed trigger 25 | # pts_features mentions to Genie which feature to learn in CommonSetup, and then compare at the CommonCleanup 26 | # trigger_uids and verification_uids limit which test to execute 27 | gRun(trigger_datafile=os.path.join(test_path, 'trigger_datafile_demo.yaml'), 28 | pts_features=['platform', 'bgp', 'interface'], 29 | verification_uids=['Verify_IpInterfaceBrief', 'Verify_IpRoute_vrf_all'], 30 | trigger_uids=['TriggerUnconfigConfigBgp', 'TriggerShutNoShutBgpNeighbors', 'TriggerModifyLoopbackInterfaceIp', 'TriggerShutNoShutEthernetInterface', 'TriggerClearArpVrfAllForceDelete']) 31 | -------------------------------------------------------------------------------- /clean/clean/testbed_cisco_live.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: example_testbed 3 | devices: 4 | csr1000v-1: 5 | alias: uut 6 | os: iosxe 7 | type: router 8 | credentials: 9 | default: 10 | username: admin 11 | password: password 12 | connections: 13 | defaults: 14 | class: unicon.Unicon 15 | a: 16 | command: mock_device_cli --os iosxe --mock_data_dir clean_recording --state connect 17 | nx-osv-1: 18 | alias: helper 19 | os: nxos 20 | type: switch 21 | credentials: 22 | default: 23 | username: admin 24 | password: password 25 | connections: 26 | defaults: 27 | class: unicon.Unicon 28 | a: 29 | protocol: telnet 30 | ip: ::1 31 | port: 9002 32 | topology: 33 | csr1000v-1: 34 | interfaces: 35 | GigabitEthernet1: 36 | type: ethernet 37 | GigabitEthernet2: 38 | link: l0 39 | type: ethernet 40 | GigabitEthernet3: 41 | link: l1 42 | type: ethernet 43 | nx-osv-1: 44 | interfaces: 45 | mgmt0: 46 | type: ethernet 47 | Ethernet2/1: 48 | link: l0 49 | type: ethernet 50 | Ethernet2/2: 51 | link: l1 52 | type: ethernet 53 | -------------------------------------------------------------------------------- /metadata/metadata_example.py: -------------------------------------------------------------------------------- 1 | ''' 2 | This is a metadata script demonstrating how various data, eg, __version__, can 3 | be set by the engine. 4 | ''' 5 | 6 | from pyats import aetest 7 | 8 | __version__ = '99.99.0' 9 | 10 | class CommonSetup(aetest.CommonSetup): 11 | 12 | @aetest.subsection 13 | def subsection_1(self, section): 14 | section.uid = 'subsection_one' 15 | 16 | @aetest.loop(var=[1,2,3]) 17 | @aetest.subsection 18 | def subsection_2(self, section): 19 | pass 20 | 21 | 22 | class TestcaseOne(aetest.Testcase): 23 | 24 | uid = 'testcase_one' 25 | name = 'an alternative name for testcase one' 26 | swversion = 'version string' 27 | hwversion = 'version string' 28 | fwversion = 'version string' 29 | tstversion = 'version string' 30 | 31 | @aetest.setup 32 | def setup(self): 33 | pass 34 | 35 | @aetest.test 36 | def test(self, section): 37 | section.uid = 'testcase_one_test' 38 | 39 | @aetest.loop(var=[10,20,30]) 40 | class TestcaseTwo(aetest.Testcase): 41 | 42 | @aetest.setup 43 | def setup(self): 44 | pass 45 | 46 | @aetest.test 47 | def test(self, section): 48 | pass 49 | 50 | -------------------------------------------------------------------------------- /tasks/task_example.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from pyats import aetest 4 | 5 | logger = logging.getLogger(__name__) 6 | 7 | class common_setup(aetest.CommonSetup): 8 | 9 | @aetest.subsection 10 | def sample_subsection_1(self): 11 | logger.info("Aetest Common Setup ") 12 | 13 | @aetest.subsection 14 | def sample_subsection_2(self, section): 15 | logger.info("Inside %s" % (section)) 16 | 17 | logger.info("Inside class %s" % (self.uid)) 18 | 19 | class tc_one(aetest.Testcase): 20 | 21 | @aetest.setup 22 | def prepare_testcase(self, section): 23 | logger.info("Preparing the test") 24 | logger.info(section) 25 | 26 | @aetest.test 27 | def simple_test_1(self): 28 | logger.info("First test section ") 29 | 30 | # Second test section 31 | @aetest.test 32 | def simple_test_2(self): 33 | logger.info("Second test section ") 34 | 35 | @aetest.cleanup 36 | def clean_testcase(self): 37 | logger.info("Pass testcase cleanup") 38 | 39 | 40 | class common_cleanup(aetest.CommonCleanup): 41 | 42 | @aetest.subsection 43 | def clean_everything(self): 44 | logger.info("Aetest Common Cleanup ") 45 | 46 | if __name__ == '__main__': # pragma: no cover 47 | aetest.main() 48 | -------------------------------------------------------------------------------- /clean/full_clean_multi_os/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Clean for multiple platform / multiple OS testbed 2 | 3 | This folder contains the following sample files: 4 | 5 | - clean.yaml file for a testbed containing multiple platforms and OS's 6 | - testbed.yaml file for a testbed containing multiple platforms and OS's 7 | 8 | These files can be used as a template to execute a full end-to-end clean on an 9 | multi-platform, multi-OS testbed. 10 | 11 | For each device in the testbed, it performs the following steps in order: 12 | 13 | - connects to device 14 | - (Optional) pings execution servers to verify connectivity 15 | - (Optional) copies necessary images to intermediate server 16 | - copies images to device 17 | - changes boot variables 18 | - executes 'write erase' 19 | - reload device 20 | - apply base configuration after reload 21 | - verifies the running image matches what was provided 22 | 23 | If the devices are not in stable state at the time of execution, pyATS Clean 24 | provides a built-in recovery mechanism, where it attempts to bring the device 25 | back to stable state by powercycling the device and then rebooting it from 26 | rommon with a known stable (golden) image. 27 | 28 | Please substitute your device IP addresses, credentials and image directories in 29 | the templates provided before use. 30 | -------------------------------------------------------------------------------- /clean/full_clean_n7k_nxos/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SAMPLE-TESTBED 3 | servers: 4 | tftp: 5 | server: the-tftp-server 6 | address: 10.81.116.4 7 | credentials: 8 | default: 9 | username: user 10 | password: "%ENC{w5zDmsOD}" 11 | path: /auto/path/images/ 12 | scp: 13 | server: the-tftp-server 14 | address: 10.81.116.4 15 | credentials: 16 | default: 17 | username: user 18 | password: "%ENC{w5zDmsOD}" 19 | path: /auto/path/images/ 20 | 21 | devices: 22 | N7700-1: 23 | alias: uut 24 | os: nxos 25 | type: n7k 26 | platform: n7k 27 | credentials: 28 | default: 29 | password: "%ENC{w5zDmsOD}" 30 | username: admin 31 | enable: 32 | password: "%ENC{w5zDmsOD}" 33 | username: admin 34 | connections: 35 | defaults: 36 | class: unicon.Unicon 37 | vty: 38 | protocol: telnet 39 | ip: 1.1.1.1 40 | cli: 41 | protocol: telnet 42 | ip: 2.2.2.2 43 | port: 2001 44 | a: 45 | protocol: telnet 46 | ip: 2.2.2.2 47 | port: 2001 48 | custom: 49 | execute_timeout: 600 50 | configure_timeout: 250 51 | abstraction: 52 | order: [os, platform] 53 | -------------------------------------------------------------------------------- /clean/full_clean_n9k_nxos/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SAMPLE-TESTBED 3 | servers: 4 | tftp: 5 | server: the-tftp-server 6 | address: 10.81.116.4 7 | credentials: 8 | default: 9 | username: user 10 | password: "%ENC{w5zDmsOD}" 11 | path: /auto/path/images/ 12 | scp: 13 | server: the-tftp-server 14 | address: 10.81.116.4 15 | credentials: 16 | default: 17 | username: user 18 | password: "%ENC{w5zDmsOD}" 19 | path: /auto/path/images/ 20 | 21 | devices: 22 | N9500-1: 23 | alias: uut 24 | os: nxos 25 | type: n9k 26 | platform: n9k 27 | credentials: 28 | default: 29 | password: "%ENC{w5zDmsOD}" 30 | username: admin 31 | enable: 32 | password: "%ENC{w5zDmsOD}" 33 | username: admin 34 | connections: 35 | defaults: 36 | class: unicon.Unicon 37 | vty: 38 | protocol: telnet 39 | ip: 1.1.1.1 40 | cli: 41 | protocol: telnet 42 | ip: 2.2.2.2 43 | port: 2001 44 | a: 45 | protocol: telnet 46 | ip: 2.2.2.2 47 | port: 2001 48 | custom: 49 | execute_timeout: 600 50 | configure_timeout: 250 51 | abstraction: 52 | order: [os, platform] 53 | -------------------------------------------------------------------------------- /clean/full_clean_n9kv_nxos/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SAMPLE-TESTBED 3 | servers: 4 | tftp: 5 | server: the-tftp-server 6 | address: 10.81.116.4 7 | credentials: 8 | default: 9 | username: user 10 | password: "%ENC{w5zDmsOD}" 11 | path: /auto/path/images/ 12 | scp: 13 | server: the-tftp-server 14 | address: 10.81.116.4 15 | credentials: 16 | default: 17 | username: user 18 | password: "%ENC{w5zDmsOD}" 19 | path: /auto/path/images/ 20 | 21 | devices: 22 | N9500v-1: 23 | alias: uut 24 | os: nxos 25 | type: n9k 26 | platform: n9k 27 | credentials: 28 | default: 29 | password: "%ENC{w5zDmsOD}" 30 | username: admin 31 | enable: 32 | password: "%ENC{w5zDmsOD}" 33 | username: admin 34 | connections: 35 | defaults: 36 | class: unicon.Unicon 37 | vty: 38 | protocol: telnet 39 | ip: 1.1.1.1 40 | cli: 41 | protocol: telnet 42 | ip: 2.2.2.2 43 | port: 2001 44 | a: 45 | protocol: telnet 46 | ip: 2.2.2.2 47 | port: 2001 48 | custom: 49 | execute_timeout: 600 50 | configure_timeout: 250 51 | abstraction: 52 | order: [os, platform] 53 | -------------------------------------------------------------------------------- /clean/full_clean_cat9k_iosxe/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SAMPLE-TESTBED 3 | servers: 4 | tftp: 5 | server: the-tftp-server 6 | address: 10.81.116.4 7 | credentials: 8 | default: 9 | username: user 10 | password: "%ENC{w5zDmsOD}" 11 | path: /auto/path/images/ 12 | scp: 13 | server: the-tftp-server 14 | address: 10.81.116.4 15 | credentials: 16 | default: 17 | username: user 18 | password: "%ENC{w5zDmsOD}" 19 | path: /auto/path/images/ 20 | 21 | devices: 22 | cat-9300-1: 23 | alias: uut 24 | os: iosxe 25 | type: cat9k 26 | platform: cat9k 27 | credentials: 28 | default: 29 | password: "%ENC{w5zDmsOD}" 30 | username: admin 31 | enable: 32 | password: "%ENC{w5zDmsOD}" 33 | username: admin 34 | connections: 35 | defaults: 36 | class: unicon.Unicon 37 | vty: 38 | protocol: telnet 39 | ip: 1.1.1.1 40 | cli: 41 | protocol: telnet 42 | ip: 2.2.2.2 43 | port: 2001 44 | a: 45 | protocol: telnet 46 | ip: 2.2.2.2 47 | port: 2001 48 | custom: 49 | execute_timeout: 600 50 | configure_timeout: 250 51 | abstraction: 52 | order: [os, platform] 53 | -------------------------------------------------------------------------------- /clean/full_clean_isr4k_iosxe/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SAMPLE-TESTBED 3 | servers: 4 | tftp: 5 | server: the-tftp-server 6 | address: 10.81.116.4 7 | credentials: 8 | default: 9 | username: user 10 | password: "%ENC{w5zDmsOD}" 11 | path: /auto/path/images/ 12 | scp: 13 | server: the-tftp-server 14 | address: 10.81.116.4 15 | credentials: 16 | default: 17 | username: user 18 | password: "%ENC{w5zDmsOD}" 19 | path: /auto/path/images/ 20 | 21 | devices: 22 | isr-4400-1: 23 | alias: uut 24 | os: iosxe 25 | type: isr 26 | platform: isr4000 27 | credentials: 28 | default: 29 | password: "%ENC{w5zDmsOD}" 30 | username: admin 31 | enable: 32 | password: "%ENC{w5zDmsOD}" 33 | username: admin 34 | connections: 35 | defaults: 36 | class: unicon.Unicon 37 | vty: 38 | protocol: telnet 39 | ip: 1.1.1.1 40 | cli: 41 | protocol: telnet 42 | ip: 2.2.2.2 43 | port: 2001 44 | a: 45 | protocol: telnet 46 | ip: 2.2.2.2 47 | port: 2001 48 | custom: 49 | execute_timeout: 600 50 | configure_timeout: 250 51 | abstraction: 52 | order: [os, platform] 53 | -------------------------------------------------------------------------------- /clean/full_clean_csr1000v_iosxe/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SAMPLE-TESTBED 3 | servers: 4 | tftp: 5 | server: the-tftp-server 6 | address: 10.81.116.4 7 | credentials: 8 | default: 9 | username: user 10 | password: "%ENC{w5zDmsOD}" 11 | path: /auto/path/images/ 12 | scp: 13 | server: the-tftp-server 14 | address: 10.81.116.4 15 | credentials: 16 | default: 17 | username: user 18 | password: "%ENC{w5zDmsOD}" 19 | path: /auto/path/images/ 20 | 21 | devices: 22 | csr-1000v-1: 23 | alias: uut 24 | os: iosxe 25 | type: csr1000v 26 | platform: csr1000v 27 | credentials: 28 | default: 29 | password: "%ENC{w5zDmsOD}" 30 | username: admin 31 | enable: 32 | password: "%ENC{w5zDmsOD}" 33 | username: admin 34 | connections: 35 | defaults: 36 | class: unicon.Unicon 37 | vty: 38 | protocol: telnet 39 | ip: 1.1.1.1 40 | cli: 41 | protocol: telnet 42 | ip: 2.2.2.2 43 | port: 2001 44 | a: 45 | protocol: telnet 46 | ip: 2.2.2.2 47 | port: 2001 48 | custom: 49 | execute_timeout: 600 50 | configure_timeout: 250 51 | abstraction: 52 | order: [os, platform] 53 | -------------------------------------------------------------------------------- /comprehensive/data/extended_datafile.yaml: -------------------------------------------------------------------------------- 1 | #******************************************************************************* 2 | #* EXTENSION DATAFILE 3 | #* 4 | #* The content of this file is no different than that of base_datafile.yaml, 5 | #* except that it "extends" it: the base_datafile.yaml values for the basis 6 | #* for this datafile to build on top of. 7 | #* 8 | #* Keep in mind that datafile extensions are done using recursive dictionary 9 | #* updates. 10 | #* 11 | #* To run the script with this datafile: 12 | #* bash$ python base_example.py -datafile=data/base_datafile.yaml 13 | #******************************************************************************* 14 | 15 | #**************************************** 16 | #* Extend More Datafiles 17 | #* 18 | #* each datafile may extend one or more datafiles. 19 | #* the value to 'extends' may be a single file or a list of files. 20 | extends: base_datafile.yaml 21 | 22 | parameters: 23 | parameter_A: datafile extended A 24 | 25 | testcases: 26 | 27 | ExampleTestcase: 28 | uid: 'ExampleTestcaseDatafileID_Extended!' 29 | groups: [group_A, group_B, group_C, group_D, group_E] 30 | 31 | parameters: 32 | local_B: datafile extended B 33 | 34 | data_A: attribute extended A 35 | 36 | LoopedTestcase: 37 | groups: [ha, sanity] 38 | -------------------------------------------------------------------------------- /libraries/trigger_within_pyats/README.md: -------------------------------------------------------------------------------- 1 | ## demo7_trigger_within_pyats 2 | 3 | # Introduction 4 | 5 | This script demonstrates how to include `Genie` Triggers and Verifications 6 | within any existing `pyATS` script. 7 | 8 | Make sure to read https://pubhub.devnetcloud.com/media/genie-docs/docs/userguide/harness/user/pyats.html for more details! 9 | 10 | # Execution 11 | 12 | This demo requires devices. There is 3 options on how to run this demo: 13 | 14 | 1) Use mock devices. We have used the Unicon playback feature to record all 15 | interactions with the device so you can use it smoothly without connecting 16 | to real devices as below. 17 | 18 | ``` 19 | pyats run job job/demo7_trigger_within_pyats_job.py --testbed-file cisco_live.yaml --replay mock_device 20 | ``` 21 | 22 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 23 | on how to boot the virtual devices. 24 | 25 | 3) Use your own devices. Please modify the testbed file with the devices' 26 | names and the corresponding IP addresses. 27 | 28 | ``` 29 | pyats run job job/demo7_trigger_within_pyats_job.py --testbed-file virl.yaml 30 | ``` 31 | 32 | # Output 33 | 34 | The log can be viewed in the file `TaskLog.html`. 35 | 36 | # What's next? 37 | 38 | Go ahead and add to your existing pyATS script any Genie Triggers for better coverage! 39 | -------------------------------------------------------------------------------- /libraries/solutions/solution1/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | tacacs: 10 | login_prompt: 'login:' 11 | password_prompt: 'Password:' 12 | username: admin 13 | passwords: 14 | tacacs: admin 15 | enable: admin 16 | line: admin 17 | connections: 18 | defaults: 19 | class: 'unicon.Unicon' 20 | a: 21 | protocol: telnet 22 | ip: 172.25.192.90 23 | port: 17023 24 | custom: 25 | abstraction: 26 | order: [os] 27 | csr1000v-1: 28 | type: asr1k 29 | os: "iosxe" 30 | alias: helper 31 | tacacs: 32 | login_prompt: 'login:' 33 | password_prompt: 'Password:' 34 | username: cisco 35 | passwords: 36 | tacacs: cisco 37 | enable: cisco 38 | line: cisco 39 | connections: 40 | defaults: 41 | class: 'unicon.Unicon' 42 | a: 43 | protocol: telnet 44 | ip: 172.25.192.90 45 | port: 17021 46 | custom: 47 | abstraction: 48 | order: [os] -------------------------------------------------------------------------------- /libraries/solutions/solution2/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: uut 9 | tacacs: 10 | login_prompt: 'login:' 11 | password_prompt: 'Password:' 12 | username: admin 13 | passwords: 14 | tacacs: admin 15 | enable: admin 16 | line: admin 17 | connections: 18 | defaults: 19 | class: 'unicon.Unicon' 20 | a: 21 | protocol: telnet 22 | ip: 172.25.192.90 23 | port: 17023 24 | custom: 25 | abstraction: 26 | order: [os] 27 | csr1000v-1: 28 | type: asr1k 29 | os: "iosxe" 30 | alias: helper 31 | tacacs: 32 | login_prompt: 'login:' 33 | password_prompt: 'Password:' 34 | username: cisco 35 | passwords: 36 | tacacs: cisco 37 | enable: cisco 38 | line: cisco 39 | connections: 40 | defaults: 41 | class: 'unicon.Unicon' 42 | a: 43 | protocol: telnet 44 | ip: 172.25.192.90 45 | port: 17021 46 | custom: 47 | abstraction: 48 | order: [os] -------------------------------------------------------------------------------- /libraries/trigger_within_pyats/cisco_live.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'virl' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: "NX-OSv 9000" 7 | os: "nxos" 8 | alias: two 9 | tacacs: 10 | login_prompt: 'login:' 11 | password_prompt: 'Password:' 12 | username: admin 13 | passwords: 14 | tacacs: admin 15 | enable: admin 16 | line: admin 17 | connections: 18 | defaults: 19 | class: 'unicon.Unicon' 20 | a: 21 | protocol: telnet 22 | ip: 172.25.192.90 23 | port: 17023 24 | custom: 25 | abstraction: 26 | order: [os] 27 | csr1000v-1: 28 | type: asr1k 29 | os: "iosxe" 30 | alias: helper 31 | tacacs: 32 | login_prompt: 'login:' 33 | password_prompt: 'Password:' 34 | username: cisco 35 | passwords: 36 | tacacs: cisco 37 | enable: cisco 38 | line: cisco 39 | connections: 40 | defaults: 41 | class: 'unicon.Unicon' 42 | a: 43 | protocol: telnet 44 | ip: 172.25.192.90 45 | port: 17021 46 | custom: 47 | abstraction: 48 | order: [os] 49 | -------------------------------------------------------------------------------- /metaparser/demo_metaparser_iosxe.py: -------------------------------------------------------------------------------- 1 | # 2 | # imports 3 | # 4 | import pprint 5 | import argparse 6 | 7 | from pyats.topology import loader 8 | from genie.libs.parser.iosxe.show_interface import ShowInterfaces 9 | 10 | 11 | def load(testbed, device_name): 12 | tb = loader.load(testbed) 13 | try: 14 | return tb.devices[device_name] 15 | except KeyError as e: 16 | raise KeyError("Could not find '{d}' within " 17 | "testbed '{tb}'".format(d=device, tb=testbed)) 18 | 19 | def parse(device): 20 | return ShowInterfaces(device).parse() 21 | 22 | 23 | if __name__ == '__main__': 24 | parser = argparse.ArgumentParser(description='Arguments for ' 25 | 'demo8_metaparser') 26 | parser.add_argument('-testbed_file', 27 | help='Location of the testbed file', 28 | default = 'virl.yaml') 29 | 30 | parser.add_argument('-device', 31 | help='Name or alias of the device to parse on', 32 | default = 'helper') 33 | 34 | custom_args = parser.parse_known_args()[0] 35 | testbed_file = custom_args.testbed_file 36 | device_name = custom_args.device 37 | 38 | device = load(testbed_file, device_name) 39 | device.connect() 40 | 41 | parsed = parse(device) 42 | pprint.pprint(parsed) 43 | -------------------------------------------------------------------------------- /libraries/harness_simple/README.md: -------------------------------------------------------------------------------- 1 | ## demo1_harness_simple 2 | 3 | # Introduction 4 | 5 | This script is an introduction to `Genie`. It does the following: 6 | 7 | * Connect to the devices defined in the testbed file. 8 | * Execute a Sleep Trigger. Will sleep for 5 seconds. This time can be modified 9 | in the Triggerdatafile (Location provided in the job file). 10 | * Terminate the run 11 | 12 | # Execution 13 | 14 | This demo requires devices. There is 3 options on how to run this demo: 15 | 16 | 1) Use mock devices. We have used the Unicon playback feature to record all 17 | interactions with the device so you can use it smoothly without connecting 18 | to real devices as below. 19 | 20 | ``` 21 | pyats run job demo1_harness_simple_job.py --testbed-file virl.yaml --replay mock_device 22 | ``` 23 | 24 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 25 | on how to boot the virtual devices. 26 | 27 | 3) Use your own devices. Please modify the testbed file with the devices' 28 | names and the corresponding IP addresses. 29 | 30 | ``` 31 | pyats run job demo1_harness_simple_job.py --testbed-file virl.yaml 32 | ``` 33 | 34 | # Output 35 | 36 | The log can be viewed in the file `TaskLog.html`. 37 | 38 | # What's next? 39 | 40 | Move on to the next demo `demo2_harness_triggers` to add useful `Triggers` and 41 | `Verifications` to your testing! 42 | -------------------------------------------------------------------------------- /libraries/config_ops/README.md: -------------------------------------------------------------------------------- 1 | ## demo6_config_ops 2 | 3 | # Introduction 4 | 5 | Genie uses Configuration and Operational objects to drive its configuration and 6 | operation state. The configuraiton object, `conf`, are object that once some 7 | variable are set, configuration is build and apply on the device. Those objects 8 | follow Models (Ietf, openstack, Cisco Models) to make them OS agnostic. 9 | 10 | Models are available here: 11 | 12 | 1) Connect to a list of devices 13 | 2) Retrieve the operational state for each device 14 | 3) Apply Ospf configuration 15 | 4) Retrieve the operational state for each device and compare with step 2 16 | 5) Unconfig Ospf configuration 17 | 18 | # Execution 19 | 20 | This demo requires devices. There is 2 options on how to run this demo: 21 | 22 | 1) This demo is ready to be used with the VIRL devices. Please follow the guide 23 | on how to boot the virtual devices. 24 | 25 | 2) Use your own devices. Please modify the testbed file with the devices' 26 | names and the corresponding IP addresses. 27 | 28 | ``` 29 | python demo6_config_ops.py --testbed-file virl.yaml 30 | ``` 31 | 32 | # Output 33 | 34 | The log can be viewed in the file `output`. 35 | 36 | # What's next? 37 | 38 | Move on to the next demo `demo7_trigger_within_pyats` to learn how to run 39 | a trigger directly from within pyATS framework. 40 | 41 | Try Demo8, it uses all demo6 concepts into a pyATS script. 42 | -------------------------------------------------------------------------------- /parsergen/pyAts/parsergen_demo_xrvr_job.py: -------------------------------------------------------------------------------- 1 | # Description: This example connects to a previous set-up XRVR router, 2 | # executes some show commands and parses via cAAs/TCL and 3 | # parsergen/Python, with differences in the parse results 4 | # shown. 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | def main(): 10 | # Find the examples/tests directory where the test script exists 11 | test_path = (os.path.dirname(os.path.abspath(__file__))) 12 | # Do some logic here to determine which devices to use 13 | # and pass these device names as script arguments 14 | # ... 15 | chosen_uut_device = 'VM-2' 16 | stdby_device = 'notreallyadevice' 17 | if_name = 'MgmtEth0/0/CPU0/0' 18 | mtu = 1514 19 | header_fields= [ "Address", 20 | "Age", 21 | "Hardware Addr", 22 | "State", 23 | "Type", 24 | "Interface" ] 25 | show_arp_table_parse_index = [0, 5] 26 | show_arp_table_title_pattern = r"^(\d+/\d+/CPU\d+)" 27 | 28 | 29 | run(testscript=test_path + '/parsergen_demo.py', 30 | uut_name=chosen_uut_device, 31 | stdby_name=stdby_device, if_name=if_name, mtu=mtu, 32 | show_arp_header_fields=header_fields, 33 | show_arp_table_parse_index=show_arp_table_parse_index, 34 | show_arp_table_title_pattern=show_arp_table_title_pattern) 35 | -------------------------------------------------------------------------------- /parsergen/pyAts/parsergen_demo_enxr_job.py: -------------------------------------------------------------------------------- 1 | # 2 | # Description: This example brings up a previously built EnXR router, 3 | # executes some show commands and parses via cAAs/TCL and 4 | # parsergen/Python, with differences in the parse results 5 | # shown. 6 | 7 | import os 8 | from pyats.easypy import run 9 | 10 | def main(): 11 | # Find the examples/tests directory where the test script exists 12 | test_path = (os.path.dirname(os.path.abspath(__file__))) 13 | # Do some logic here to determine which devices to use 14 | # and pass these device names as script arguments 15 | # ... 16 | chosen_uut_device = 'r1' 17 | stdby_device = 'notreallyadevice' 18 | if_name = 'GigabitEthernet0/2/0/0' 19 | mtu = 1514 20 | header_fields= [ "Address", 21 | "Age", 22 | "Hardware Addr", 23 | "State", 24 | "Type", 25 | "Interface" ] 26 | show_arp_table_parse_index = [0, 5] 27 | show_arp_table_title_pattern = r"^(\d+/\d+/CPU\d+)" 28 | 29 | 30 | run(testscript=test_path + '/parsergen_demo.py', 31 | uut_name=chosen_uut_device, 32 | stdby_name=stdby_device, if_name=if_name, mtu=mtu, 33 | show_arp_header_fields=header_fields, 34 | show_arp_table_parse_index=show_arp_table_parse_index, 35 | show_arp_table_title_pattern=show_arp_table_title_pattern) 36 | -------------------------------------------------------------------------------- /parsergen/pyAts/parsergen_demo_enxr_job_conn_alias.py: -------------------------------------------------------------------------------- 1 | # 2 | # Description: This example brings up a previously built EnXR router, 3 | # executes some show commands and parses via cAAs/TCL and 4 | # parsergen/Python, with differences in the parse results 5 | # shown. 6 | 7 | import os 8 | from pyats.easypy import run 9 | 10 | def main(): 11 | # Find the examples/tests directory where the test script exists 12 | test_path = (os.path.dirname(os.path.abspath(__file__))) 13 | # Do some logic here to determine which devices to use 14 | # and pass these device names as script arguments 15 | # ... 16 | chosen_uut_device = 'r1' 17 | stdby_device = 'notreallyadevice' 18 | if_name = 'GigabitEthernet0/2/0/0' 19 | mtu = 1514 20 | header_fields= [ "Address", 21 | "Age", 22 | "Hardware Addr", 23 | "State", 24 | "Type", 25 | "Interface" ] 26 | show_arp_table_parse_index = [0, 5] 27 | show_arp_table_title_pattern = r"^(\d+/\d+/CPU\d+)" 28 | 29 | 30 | run(testscript=test_path + '/parsergen_demo_conn_alias.py', 31 | uut_name=chosen_uut_device, 32 | stdby_name=stdby_device, if_name=if_name, mtu=mtu, 33 | show_arp_header_fields=header_fields, 34 | show_arp_table_parse_index=show_arp_table_parse_index, 35 | show_arp_table_title_pattern=show_arp_table_title_pattern) 36 | -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/job/demo8_pyats_conf_ops_job.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | from pyats.easypy import run 4 | 5 | parser = argparse.ArgumentParser() 6 | 7 | parser.add_argument('--context', 8 | help='Type agnostic to execute the script with', 9 | choices=['cli', 'yang', 'xml'], 10 | default = 'cli') 11 | parser.add_argument('--pool_num', 12 | help='Number of connections to used in the pool', 13 | type=int, default=1) 14 | parser.add_argument('--uut_alias', 15 | help='Alias name for the uut device', 16 | type=str, default='uut') 17 | parser.add_argument('--helper_alias', 18 | help='Alias name for the helper device', 19 | type=str, default='helper') 20 | 21 | # All run() must be inside a main function 22 | def main(): 23 | # Find the location of the script in relation to the job file 24 | custom_args = parser.parse_known_args()[0] 25 | test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 26 | testscript = os.path.join(test_path, 'demo8_pyats_conf_ops.py') 27 | datafile = os.path.join(test_path, 'datafile.yaml') 28 | 29 | # Execute the testscript 30 | run(testscript=testscript, 31 | uut_alias=custom_args.uut_alias, 32 | helper_alias=custom_args.helper_alias, 33 | context=custom_args.context, 34 | datafile=datafile, 35 | pool_num=custom_args.pool_num) 36 | -------------------------------------------------------------------------------- /libraries/pyats_conf_ops/virl.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: 'MyTestbed' 3 | 4 | devices: 5 | nx-osv-1: 6 | type: 'router' 7 | os: 'nxos' 8 | alias: 'uut' 9 | credentials: 10 | default: 11 | password: admin 12 | username: admin 13 | connections: 14 | a: 15 | protocol: telnet 16 | ip: "172.25.192.90" 17 | port: 17086 18 | 19 | csr1000v-1: 20 | type: 'router' 21 | os: "iosxe" 22 | alias: 'helper' 23 | credentials: 24 | default: 25 | password: cisco 26 | username: cisco 27 | connections: 28 | a: 29 | protocol: telnet 30 | ip: "172.25.192.90" 31 | port: 17084 32 | 33 | topology: 34 | csr1000v-1: 35 | interfaces: 36 | GigabitEthernet2: 37 | alias: device1-intf1 38 | link: rtr1-rtr2-1 39 | type: ethernet 40 | GigabitEthernet3: 41 | alias: device1-intf2 42 | link: rtr1-rtr2-2 43 | type: ethernet 44 | Loopback0: 45 | alias: device1-intf3 46 | link: rtr1-rtr2-3 47 | type: loopback 48 | 49 | nx-osv-1: 50 | interfaces: 51 | Ethernet2/1: 52 | alias: device2-intf1 53 | link: rtr1-rtr2-1 54 | type: ethernet 55 | Ethernet2/2: 56 | alias: device2-intf2 57 | link: rtr1-rtr2-2 58 | type: ethernet 59 | Loopback0: 60 | alias: device2-intf3 61 | link: rtr1-rtr2-3 62 | type: loopback 63 | -------------------------------------------------------------------------------- /parsergen/pyAts/parsergen_demo_aireos_job.py: -------------------------------------------------------------------------------- 1 | # Description: This example connects to a previous set-up XRVR router, 2 | # executes some show commands and parses via cAAs/TCL and 3 | # parsergen/Python, with differences in the parse results 4 | # shown. 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | def main(): 10 | # Find the examples/tests directory where the test script exists 11 | test_path = (os.path.dirname(os.path.abspath(__file__))) 12 | # Do some logic here to determine which devices to use 13 | # and pass these device names as script arguments 14 | # ... 15 | chosen_uut_device = 'ASIM2' 16 | stdby_device = 'notreallyadevice' 17 | if_name = 'management' 18 | mtu = 1500 19 | 20 | 21 | show_arp_header_fields= [ "IP address", 22 | "HW type", 23 | "Flags", 24 | "HW address", 25 | "Mask", 26 | "Device" ] 27 | show_arp_table_parse_index = [0, 5] 28 | show_arp_table_title_pattern = None 29 | 30 | 31 | run(testscript=test_path + '/parsergen_demo_aireos.py', 32 | uut_name=chosen_uut_device, 33 | stdby_name=stdby_device, if_name=if_name, 34 | show_arp_header_fields=show_arp_header_fields, 35 | show_arp_table_parse_index=show_arp_table_parse_index, 36 | show_arp_table_title_pattern=show_arp_table_title_pattern) 37 | -------------------------------------------------------------------------------- /GenieHarnessHelloWorld/Basic.py: -------------------------------------------------------------------------------- 1 | import pprint 2 | import logging 3 | from pyats import aetest 4 | from genie.harness.base import Trigger 5 | 6 | log = logging.getLogger() 7 | 8 | 9 | class Basic(Trigger): 10 | '''Just print Hello World''' 11 | 12 | @aetest.test 13 | def parse_example(self, uut): 14 | '''Parse example''' 15 | output = uut.parse('show version') 16 | # Output now contains a dictionary, you can do any logic you want here 17 | log.info('The dictionary returned by show version is:\n{}'.format(output)) 18 | 19 | # The following device action can be used 20 | # device.parse('show version') <-- Call a parser and returns a dictionary datastructure 21 | # device.execute('show version') <-- Send command to the device and return string from the device 22 | # device.configure('interface ethernet2/2\nshutdown') <-- Go to conf t and send configuration to the device 23 | # device.api.get_interface_mtu_size('Ethernet2/2') <-- Call any of our apis 24 | # device.learn('bgp') <-- OS Agnostic model for specific feature. The object returned has a .info which gi ves a dictionary which is identical between all OS. 25 | 26 | @aetest.test 27 | def execute_example(self, uut): 28 | '''Why not do it again?''' 29 | output = uut.execute('show clock') 30 | # Output now contains the string which was returned by the device 31 | log.info('The string returned by show clock is:\n{}'.format(output)) 32 | 33 | -------------------------------------------------------------------------------- /parsergen/pyAts/parsergen_demo_aireos_job_conn_alias.py: -------------------------------------------------------------------------------- 1 | # Description: This example connects to a previous set-up XRVR router, 2 | # executes some show commands and parses via cAAs/TCL and 3 | # parsergen/Python, with differences in the parse results 4 | # shown. 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | def main(): 10 | # Find the examples/tests directory where the test script exists 11 | test_path = (os.path.dirname(os.path.abspath(__file__))) 12 | # Do some logic here to determine which devices to use 13 | # and pass these device names as script arguments 14 | # ... 15 | chosen_uut_device = 'ASIM2' 16 | stdby_device = 'notreallyadevice' 17 | if_name = 'management' 18 | mtu = 1500 19 | 20 | 21 | show_arp_header_fields= [ "IP address", 22 | "HW type", 23 | "Flags", 24 | "HW address", 25 | "Mask", 26 | "Device" ] 27 | show_arp_table_parse_index = [0, 5] 28 | show_arp_table_title_pattern = None 29 | 30 | 31 | run(testscript=test_path + '/parsergen_demo_aireos_conn_alias.py', 32 | uut_name=chosen_uut_device, 33 | stdby_name=stdby_device, if_name=if_name, 34 | show_arp_header_fields=show_arp_header_fields, 35 | show_arp_table_parse_index=show_arp_table_parse_index, 36 | show_arp_table_title_pattern=show_arp_table_title_pattern) 37 | -------------------------------------------------------------------------------- /clean/viptela/full_clean_controllers/clean.yaml: -------------------------------------------------------------------------------- 1 | # Notes: 2 | # - vManage/vBond/vSmart should be already running as VMs on ESXi 3 | # - only upgrade is supported. Please don't do downgrade 4 | # - only on-premise (VMs on ESXi) is supported. 5 | # - only ftp is supported in software_install stage 6 | # - vManage/vBond/vSmart need to have console access to VMs 7 | # - configuration on controllers will remain 8 | 9 | cleaners: 10 | DeviceClean: 11 | module: genie.libs.clean 12 | devices: [vmanage, vbond, vsmart] 13 | 14 | devices: 15 | vmanage: 16 | images: 17 | - vmanage-20.3.4-x86_64.tar.gz 18 | 19 | connect: &connect 20 | 21 | software_install: 22 | origin: 23 | files: 24 | - vmanage-20.3.4-x86_64.tar.gz 25 | hostname: 172.16.192.90 26 | protocol: ftp # only ftp is supported 27 | vpn: 512 28 | timeout: 180 29 | 30 | order: &order 31 | - 'connect' 32 | - 'software_install' 33 | 34 | vbond: 35 | images: &image_viptela 36 | - viptela-20.3.4-x86_64.tar.gz 37 | 38 | connect: *connect 39 | 40 | software_install: &install_viptela 41 | origin: 42 | files: 43 | - viptela-20.3.4-x86_64.tar.gz 44 | hostname: 172.16.192.90 45 | protocol: ftp 46 | vpn: 512 47 | timeout: 180 48 | 49 | order: *order 50 | 51 | vsmart: 52 | images: *image_viptela 53 | 54 | connect: *connect 55 | 56 | software_install: *install_viptela 57 | 58 | order: *order 59 | -------------------------------------------------------------------------------- /clean/iosxe/sdwan/full_clean_cedge/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: iosxe_sdwan 3 | servers: 4 | tftp: 5 | address: 172.25.192.90 6 | credentials: 7 | default: 8 | username: cisco 9 | password: pass123 10 | scp: 11 | address: 172.25.192.90 12 | credentials: 13 | default: 14 | username: cisco 15 | password: pass123 16 | 17 | devices: 18 | ASR1001-X: 19 | alias: asr1001x 20 | os: iosxe 21 | platform: sdwan 22 | credentials: 23 | default: 24 | password: pass123 25 | username: admin 26 | enable_password: pass123 27 | connections: 28 | defaults: 29 | class: unicon.Unicon 30 | via: cli 31 | cli: 32 | protocol: telnet 33 | ip: 192.168.1.1 34 | port: 2003 35 | settings: 36 | PROMPT_RECOVERY_COMMANDS: ['\r','\r','\r','\r','\r'] 37 | PROMPT_RECOVERY_INTERVAL: 5 38 | PROMPT_RECOVERY_RETRIES: 3 39 | service_attributes: 40 | execute: 41 | timeout: 600 42 | configure: 43 | timeout: 250 44 | custom: 45 | abstraction: 46 | order: [os, platform] 47 | peripherals: 48 | terminal_server: 49 | "192.168.1.1": [3] 50 | power_cycler: 51 | type: raritan-px2 52 | connection_type: snmp 53 | host: 192.168.1.23 54 | read_community: public 55 | write_community: private 56 | outlets: [18] -------------------------------------------------------------------------------- /clean/README.md: -------------------------------------------------------------------------------- 1 | # pyATS | Clean Examples 2 | 3 | This repository contains usage examples for the pyATS clean library. These are 4 | not working examples, but rather: 5 | 6 | - showcase **the various features and functionalities** of the pyATS clean 7 | framework 8 | 9 | - demonstrate **how to use the pyATS clean libraries** 10 | 11 | pyATS Clean is broken down into several 'stages' which are executed in the 'order' 12 | specified within the clean YAML and is therefore highly customizable. 13 | 14 | The usecases and examples provided in this section can be merged or combined 15 | to generate your custom order or sequence of pyATS Clean stages. 16 | 17 | 18 | ## Getting Started 19 | 20 | ```bash 21 | 22 | # 1. make sure pyATS is installed (including the libraries) 23 | bash$ pip install pyats[full] 24 | 25 | # Cisco Internal only 26 | bash$ pip install ats[full] 27 | 28 | # 2. ensure the pyATS clean library is installed 29 | bash$ pip list | grep genie.libs.clean 30 | 31 | # 3. clone this repository into your environment 32 | bash$ git clone https://github.com/CiscoTestAutomation/examples 33 | 34 | ``` 35 | 36 | ## General Information 37 | 38 | - pyATS Clean Documentation: https://pubhub.devnetcloud.com/media/genie-docs/docs/clean/index.html 39 | - Website: https://developer.cisco.com/pyats/ 40 | - Documentation: https://developer.cisco.com/docs/pyats/ 41 | - Support: pyats-support-ext@cisco.com 42 | 43 | 44 | # Contribution 45 | 46 | Feel free to open PR against this repository for any enhancements or bug fixes 47 | you wish to add. 48 | -------------------------------------------------------------------------------- /blitz/config_interface/blitz.yaml: -------------------------------------------------------------------------------- 1 | variables: 2 | device: R1_xe 3 | interfaces: 4 | - GigabitEthernet2 5 | - GigabitEthernet3 6 | description: configured by pyATS 7 | 8 | config_interface: 9 | groups: ["all", "config", "interface"] 10 | source: 11 | pkg: genie.libs.sdk 12 | class: triggers.blitz.blitz.Blitz 13 | test_sections: 14 | - default_interfaces: 15 | - loop: 16 | loop_variable_name: intfs 17 | value: "%{variables.interfaces}" 18 | actions: 19 | - configure: 20 | device: "%{variables.device}" 21 | command: | 22 | default interface %VARIABLES{intfs} 23 | - configure_interfaces: 24 | - loop: 25 | loop_variable_name: intfs 26 | value: "%{variables.interfaces}" 27 | actions: 28 | - configure: 29 | device: "%{variables.device}" 30 | command: | 31 | interface %VARIABLES{intfs} 32 | description %{variables.description} 33 | - verify_configuration: 34 | - loop: 35 | loop_variable_name: intfs 36 | value: "%{variables.interfaces}" 37 | actions: 38 | - parse: 39 | device: "%{variables.device}" 40 | command: show interfaces description 41 | include: 42 | - contains("%VARIABLES{intfs}").contains_key_value('description', "%{variables.description}") 43 | -------------------------------------------------------------------------------- /clean/full_clean_ncs540_xr7_iosxr/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | # This means to use the cleaner class `PyatsDeviceClean` 3 | PyatsDeviceClean: 4 | # The module is where the cleaner class above can be found 5 | module: genie.libs.clean 6 | # You can define many devices within the Clean YAML. 7 | # Any that are not in this list are not cleaned even if they are defined below. 8 | devices: [ncs540] 9 | 10 | devices: 11 | ncs540: 12 | connect: 13 | timeout: 100 14 | 15 | copy_to_device: 16 | origin: 17 | files: 18 | - /path/test_config.cfg 19 | hostname: 10.x.x.x 20 | destination: 21 | directory: 'harddisk:/' 22 | protocol: tftp 23 | vrf: 'default' 24 | check_file_stability: False 25 | 26 | reload: 27 | check_modules: 28 | check: false 29 | reload_service_args: 30 | timeout: 900 31 | prompt_recovery: False 32 | 33 | install_image: 34 | image: 35 | - /harddisk:/path/ncs540l-golden-x86_64-7.8.1.20I-PROD_BUILD_7_8_1_20I_DT_IMAGE.iso 36 | install_timeout: 1500 37 | commit_sleep: 200 38 | #server: 10.10.10.10 39 | 40 | verify_running_image: 41 | images: 42 | - 7.8.1.20I 43 | 44 | order: 45 | - connect 46 | - copy_to_device 47 | - reload 48 | - install_image 49 | - verify_running_image 50 | 51 | -------------------------------------------------------------------------------- /libraries/explore/explore-1/nx-osv-1_show-version_console.txt: -------------------------------------------------------------------------------- 1 | nx-osv-1# 2 | +++ nx-osv-1: execute command 'show version' +++ 3 | show version 4 | Cisco Nexus Operating System (NX-OS) Software 5 | TAC support: http://www.cisco.com/tac 6 | Documents: http://www.cisco.com/en/US/products/ps9372/tsd_products_support_series_home.html 7 | Copyright (c) 2002-2016, Cisco Systems, Inc. All rights reserved. 8 | The copyrights to certain works contained herein are owned by 9 | other third parties and are used and distributed under license. 10 | Some parts of this software are covered under the GNU Public 11 | License. A copy of the license is available at 12 | http://www.gnu.org/licenses/gpl.html. 13 | 14 | NX-OSv is a demo version of the Nexus Operating System 15 | 16 | Software 17 | loader: version N/A 18 | kickstart: version 7.3(0)D1(1) 19 | system: version 7.3(0)D1(1) 20 | kickstart image file is: bootflash:///titanium-d1-kickstart.7.3.0.D1.1.bin 21 | kickstart compile time: 1/11/2016 16:00:00 [02/11/2016 10:30:12] 22 | system image file is: bootflash:///titanium-d1.7.3.0.D1.1.bin 23 | system compile time: 1/11/2016 16:00:00 [02/11/2016 13:08:11] 24 | 25 | 26 | Hardware 27 | cisco NX-OSv Chassis ("NX-OSv Supervisor Module") 28 | QEMU Virtual CPU version 2.5 with 3064740 kB of memory. 29 | Processor Board ID TM00010000B 30 | 31 | Device name: nx-osv-1 32 | bootflash: 3184776 kB 33 | 34 | Kernel uptime is 6 day(s), 1 hour(s), 12 minute(s), 30 second(s) 35 | 36 | 37 | plugin 38 | Core Plugin, Ethernet Plugin 39 | 40 | Active Package(s) 41 | -------------------------------------------------------------------------------- /health/README.md: -------------------------------------------------------------------------------- 1 | # pyATS Health Examples 2 | 3 | This repository contains usage examples for the pyATS Health library. These are 4 | not working examples, but rather: 5 | 6 | - showcase **the various features and functionalities** of the pyATS health 7 | 8 | - demonstrate **how to use the pyATS Health libraries** 9 | 10 | pyATS Health leverages Quick Trigger (Blitz) YAML format. So, can develop what you want to monitor and collect with Blitz and easily migrate from `Blitz` to `pyATS Health`. 11 | 12 | The usecases and examples provided in this repository can be tried with your pyATS job. 13 | But some of parameters such as device, threshold and etc might need to be adjusted for your env/job. 14 | 15 | ## Getting Started 16 | 17 | ```bash 18 | 19 | # 1. make sure pyATS is installed (including the libraries) 20 | bash$ pip install pyats[full] 21 | 22 | # Cisco Internal only 23 | bash$ pip install ats[full] 24 | 25 | # 2. ensure the pyATS clean library is installed 26 | bash$ pip list | grep genie.libs.health 27 | 28 | # 3. clone this repository into your environment 29 | bash$ git clone https://github.com/CiscoTestAutomation/examples 30 | 31 | ``` 32 | 33 | ## General Information 34 | 35 | - pyATS Clean Documentation: https://pubhub.devnetcloud.com/media/genie-docs/docs/health/index.html 36 | - Website: https://developer.cisco.com/pyats/ 37 | - Documentation: https://developer.cisco.com/docs/pyats/ 38 | - Support: pyats-support-ext@cisco.com 39 | 40 | 41 | # Contribution 42 | 43 | Feel free to open PR against this repository for any example of pyATS health emal, any enhancements or bug fixes you wish to add. -------------------------------------------------------------------------------- /libraries/advance_robot/README.md: -------------------------------------------------------------------------------- 1 | ## demo10_robot 2 | 3 | # Introduction 4 | 5 | `RobotFramework` is an opensource test automation framework which provides automation, 6 | without having to write code. It is `Keyword` driven. Libraries provide 7 | Keywords to interact. `Genie` and `pyATS` provide keywords, to execute 8 | Triggers and Testcases, parse commands, learn device features and many more. It also uses 9 | `Genie` `Operational` object, to verify if we have a right amount of Routes, up 10 | interfaces, etc. 11 | 12 | This demo is an advance version of Demo 5. 13 | 14 | # Execution 15 | 16 | This demo requires devices. There is 3 options on how to run this demo: 17 | 18 | Make sure you have robotframework installed 19 | ``` 20 | pip install robotframework 21 | ``` 22 | 23 | 1) Use mock devices. We have used the Unicon playback feature to record all 24 | interactions with the device so you can use it smoothly without connecting 25 | to real devices as below. 26 | 27 | ``` 28 | export unicon_replay=mock_device 29 | robot demo10_nxos.robot 30 | ``` 31 | 32 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 33 | on how to boot the virtual devices. 34 | 35 | 3) Use your own devices. Please modify the testbed file with the devices' 36 | names and the corresponding IP addresses. 37 | 38 | ``` 39 | 40 | robot demo10_nxos.robot 41 | ``` 42 | 43 | ** demo10_iosxr.robot & demo10_iosxe.robot can be run the same way ** 44 | 45 | # Output 46 | 47 | The log can be viewed in the log.html -------------------------------------------------------------------------------- /retry/retry_example_script.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ################################################################### 3 | # retry_example_script.py 4 | # The purpose of the sample test script is to test the retry 5 | # functionality on testcases and testsections 6 | ################################################################### 7 | 8 | import logging 9 | from pyats import aetest 10 | 11 | logger = logging.getLogger(__name__) 12 | 13 | # retry feature can be enabled by @aetest.retry() 14 | # It takes in args 15 | # retries - Number of retries 16 | # retry_wait - wait time between retries 17 | 18 | @aetest.retry(retries=2, retry_wait=2) 19 | class MyTestcase_1(aetest.Testcase): 20 | 21 | # define setup section 22 | @aetest.setup 23 | def testcase_setup(self): 24 | pass 25 | 26 | # In this section there is an intentional failure. When 27 | # the retry_count is 2 we mark the testsection as [passed]. 28 | # Here retry and retry_count are optional parameters, that 29 | # can be used in the script 30 | # retry(bool) - To check if the section is retried 31 | # retry_count(int) - To keep in track of retry count 32 | 33 | @aetest.retry(retries=2, retry_wait=2) 34 | @aetest.test 35 | def connect_testcase(self, steps, retry, retry_count): 36 | if retry_count==2: 37 | self.passed() 38 | self.failed('This is an intentional failure from connect_testcase') 39 | 40 | @aetest.retry(retries=2, retry_wait=2) 41 | @aetest.test 42 | def testcase_test(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | aetest.main() 48 | 49 | -------------------------------------------------------------------------------- /libraries/robot/README.md: -------------------------------------------------------------------------------- 1 | ## demo5_robot 2 | 3 | # Introduction 4 | 5 | `RobotFramework` is an opensource test automation framework which provides automation, 6 | without having to write code. It is `Keyword` driven. Libraries provide 7 | Keywords to interact. `Genie` and `pyATS` provide keywords, to execute 8 | Triggers and Testcases, parse commands, learn device features and many more. It also uses 9 | `Genie` `Operational` object, to verify if we have a right amount of Routes, up 10 | interfaces, etc. 11 | 12 | # Execution 13 | 14 | This demo requires devices. There is 3 options on how to run this demo: 15 | 16 | Make sure you have robotframework installed 17 | ``` 18 | pip install robotframework 19 | ``` 20 | 21 | 1) Use mock devices. We have used the Unicon playback feature to record all 22 | interactions with the device so you can use it smoothly without connecting 23 | to real devices as below. 24 | 25 | 26 | ``` 27 | export unicon_replay=mock_device 28 | robot demo5.robot 29 | ``` 30 | 31 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 32 | on how to boot the virtual devices. 33 | 34 | 3) Use your own devices. Please modify the testbed file with the devices' 35 | names and the corresponding IP addresses. 36 | 37 | ``` 38 | 39 | robot demo5.robot 40 | ``` 41 | 42 | # Output 43 | 44 | The log can be viewed in the log.html 45 | 46 | # What's next? 47 | 48 | Move on to the next demo `demo6_config_ops` to learn how Genie use 49 | Configuration and Operational objects to drive the device configuration and 50 | operational state. 51 | -------------------------------------------------------------------------------- /libraries/harness_telemetry/README.md: -------------------------------------------------------------------------------- 1 | ## demo3_harness_telemetry 2 | 3 | # Introduction 4 | 5 | This script demonstrates the Triggers and Verifications with Healthcheck. 6 | The Healthcheck is called `Genie Telemetry`. It allows to collect any kind of 7 | information in the execution, act on it and create a report at 8 | the end of the run. For example, verify if any core was created 9 | after each trigger, verify cpu usage, traceback, etc. 10 | 11 | The execution flow will be the same as demo2_harness_triggers, with the 12 | following addition: 13 | 14 | * At the end of CommonSetup, all Triggers and at the begining of CommonCleanup, 15 | it is verified if there is any core on the device and any traceback. 16 | 17 | # Execution 18 | 19 | This demo requires devices. There is 3 options on how to run this demo: 20 | 21 | 1) Use mock devices. We have used the Unicon playback feature to record all 22 | interactions with the device so you can use it smoothly without connecting 23 | to real devices as below. 24 | 25 | ``` 26 | pyats run job demo3_harness_telemetry_job.py --testbed-file virl.yaml --replay mock_device 27 | ``` 28 | 29 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 30 | on how to boot the virtual devices. 31 | 32 | 3) Use your own devices. Please modify the testbed file with the devices' 33 | names and the corresponding IP addresses. 34 | 35 | ``` 36 | pyats run job demo3_harness_telemetry_job.py --testbed-file virl.yaml --genietelemetry telemetry.yaml 37 | ``` 38 | 39 | # Output 40 | 41 | The log can be viewed in the file `TaskLog.html`. 42 | 43 | # What's next? 44 | 45 | Move on to the next demo `demo4_harness_custom_trigger` to add your own 46 | Triggers! 47 | -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/README.md: -------------------------------------------------------------------------------- 1 | ## demo4_harness_custom_trigger 2 | 3 | # Introduction 4 | 5 | This script demonstrates how to add your own `Trigger` to execute with existing 6 | triggers. A trigger is a pyATS testcase which test some specific action. Look 7 | inside the file `trigger.py`. Once created, the python path of the trigger must 8 | be added to the `trigger_datafile_demo.yaml`. Lastly, the 9 | `demo4_harness_custom_trigger_job.py` was modified to add the new trigger to the 10 | `trigger_uids`. 11 | 12 | Please note this demo is for NXOS devices only 13 | 14 | # Execution 15 | 16 | This demo requires devices. There is 3 options on how to run this demo: 17 | 18 | 1) Use mock devices. We have used the Unicon playback feature to record all 19 | interactions with the device so you can use it smoothly without connecting 20 | to real devices as below. 21 | 22 | ``` 23 | pyats run job demo4_harness_custom_trigger_job.py --testbed-file virl.yaml --replay mock_device 24 | ``` 25 | 26 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 27 | on how to boot the virtual devices. 28 | 29 | 3) Use your own devices. Please modify the testbed file with the devices' 30 | names and the corresponding IP addresses. 31 | 32 | ``` 33 | pyats run job demo4_harness_custom_trigger_job.py --testbed-file virl.yaml 34 | ``` 35 | 36 | # Output 37 | 38 | The log can be viewed in the file `TaskLog.html`. 39 | 40 | # What's next? 41 | 42 | After these 4 demos, you are now ready to run on your own Testbed, select a 43 | combination of triggers and verificaitons and start your testing! 44 | 45 | Move on to the next demo `demo5_robot` to learn how to use Genie and pyATS with 46 | RobotFramework! 47 | -------------------------------------------------------------------------------- /comprehensive/libs/local_library.py: -------------------------------------------------------------------------------- 1 | '''local_library.py 2 | 3 | This is a local library file that lives with the testscript. Local libraries 4 | contains functions, classes & methods local to a testscript only. Because they 5 | are local and are not shared with other scripts/modules, the use of them should 6 | be minimized (not used if possible). Common code/libraries should be shared with 7 | the testing community in repositories such as xbu_shared. 8 | 9 | Note: 10 | Any comments with "#*" in front of them (like this entire comment box) are 11 | for example/infrastructure clarifications only. 12 | 13 | Author: 14 | Siming Yuan, Cisco Systems Inc. 15 | 16 | Support: 17 | pyats-support-ext@cisco.com 18 | 19 | ''' 20 | 21 | # 22 | # import statements 23 | # 24 | import logging 25 | 26 | # 27 | # create a logger for this module 28 | # 29 | logger = logging.getLogger(__name__) 30 | 31 | #********************************** 32 | #* Function & Class Defitions 33 | #* 34 | def function_supporting_step(step): 35 | '''function_supporting_step 36 | 37 | This function demonstrate the use of steps within function APIs. This 38 | enables smaller breakdown of functions into smaller steps, and thus provides 39 | finer granuality in your testscript logs. 40 | 41 | Arguments 42 | --------- 43 | steps (obj): the step object to be passed in from the testscript 44 | 45 | ''' 46 | 47 | with step.start('function step one'): 48 | # do some meaningful testing 49 | pass 50 | 51 | with step.start('function step two'): 52 | # do some meaningful testing 53 | pass 54 | 55 | with step.start('function step three'): 56 | # do some meaningful testing 57 | pass 58 | 59 | return -------------------------------------------------------------------------------- /clean/viptela/full_clean_controllers/testbed.yaml: -------------------------------------------------------------------------------- 1 | # Notes: 2 | # - Controllers such as vManage/vBond/vSmart need to have console access to its VMs 3 | 4 | testbed: 5 | name: iosxe_sdwan 6 | servers: 7 | ftp: 8 | address: 172.16.192.90 9 | credentials: 10 | default: 11 | username: user 12 | password: pass123 13 | 14 | devices: 15 | vmanage: 16 | alias: vmanage 17 | os: viptela 18 | platform: viptela 19 | credentials: 20 | default: 21 | password: admin 22 | username: admin 23 | connections: 24 | defaults: 25 | class: unicon.Unicon 26 | via: cli 27 | debug: True 28 | cli: 29 | protocol: telnet 30 | ip: 10.1.1.132 31 | port: 5001 32 | custom: 33 | abstraction: 34 | order: [os, platform] 35 | 36 | vbond: 37 | alias: vbond 38 | os: viptela 39 | platform: viptela 40 | credentials: 41 | default: 42 | password: admin 43 | username: admin 44 | connections: 45 | defaults: 46 | class: unicon.Unicon 47 | via: cli 48 | debug: True 49 | cli: 50 | protocol: telnet 51 | ip: 10.1.1.132 52 | port: 5002 53 | custom: 54 | abstraction: 55 | order: [os, platform] 56 | 57 | vsmart: 58 | alias: vsmart 59 | os: viptela 60 | platform: viptela 61 | credentials: 62 | default: 63 | password: admin 64 | username: admin 65 | connections: 66 | defaults: 67 | class: unicon.Unicon 68 | via: cli 69 | debug: True 70 | cli: 71 | protocol: telnet 72 | ip: 10.1.1.132 73 | port: 5003 74 | custom: 75 | abstraction: 76 | order: [os, platform] 77 | -------------------------------------------------------------------------------- /parsergen/pyAts/parsergen_demo_vios_job.py: -------------------------------------------------------------------------------- 1 | # Description: This example connects to a previous set-up XRVR router, 2 | # executes some show commands and parses via cAAs/TCL and 3 | # parsergen/Python, with differences in the parse results 4 | # shown. 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | def main(): 10 | # Find the examples/tests directory where the test script exists 11 | test_path = (os.path.dirname(os.path.abspath(__file__))) 12 | # Do some logic here to determine which devices to use 13 | # and pass these device names as script arguments 14 | # ... 15 | chosen_uut_device = 'VM-1' 16 | stdby_device = 'notreallyadevice' 17 | if_name = 'GigabitEthernet0/0' 18 | mtu = 1500 19 | 20 | # 21 | # NOTE: The tabular parse will fail on vIOS platform, because 22 | # one of the colums is right-justified while the rest are 23 | # left-justified. The tabular parser only supports a 24 | # consistent justification setting for all columns in the table. 25 | # 26 | show_arp_header_fields= [ "Protocol", 27 | "Address", 28 | "Age \(min\)", 29 | "Hardware Addr", 30 | "Type", 31 | "Interface" ] 32 | show_arp_table_parse_index = [1, 5] 33 | show_arp_table_title_pattern = None 34 | 35 | 36 | run(testscript=test_path + '/parsergen_demo.py', 37 | uut_name=chosen_uut_device, 38 | stdby_name=stdby_device, if_name=if_name, mtu=mtu, 39 | show_arp_header_fields=show_arp_header_fields, 40 | show_arp_table_parse_index=show_arp_table_parse_index, 41 | show_arp_table_title_pattern=show_arp_table_title_pattern) 42 | -------------------------------------------------------------------------------- /parsergen/pyAts/parsergen_demo_viosxe_job.py: -------------------------------------------------------------------------------- 1 | # Description: This example connects to a previous set-up XRVR router, 2 | # executes some show commands and parses via cAAs/TCL and 3 | # parsergen/Python, with differences in the parse results 4 | # shown. 5 | 6 | import os 7 | from pyats.easypy import run 8 | 9 | def main(): 10 | # Find the examples/tests directory where the test script exists 11 | test_path = (os.path.dirname(os.path.abspath(__file__))) 12 | # Do some logic here to determine which devices to use 13 | # and pass these device names as script arguments 14 | # ... 15 | chosen_uut_device = 'VM-3' 16 | stdby_device = 'notreallyadevice' 17 | if_name = 'GigabitEthernet1' 18 | mtu = 1500 19 | 20 | # 21 | # NOTE: The tabular parse will fail on vIOS platform, because 22 | # one of the colums is right-justified while the rest are 23 | # left-justified. The tabular parser only supports a 24 | # consistent justification setting for all columns in the table. 25 | # 26 | show_arp_header_fields= [ "Protocol", 27 | "Address", 28 | "Age \(min\)", 29 | "Hardware Addr", 30 | "Type", 31 | "Interface" ] 32 | show_arp_table_parse_index = [1, 5] 33 | show_arp_table_title_pattern = None 34 | 35 | 36 | run(testscript=test_path + '/parsergen_demo.py', 37 | uut_name=chosen_uut_device, 38 | stdby_name=stdby_device, if_name=if_name, mtu=mtu, 39 | show_arp_header_fields=show_arp_header_fields, 40 | show_arp_table_parse_index=show_arp_table_parse_index, 41 | show_arp_table_title_pattern=show_arp_table_title_pattern) 42 | -------------------------------------------------------------------------------- /parsergen/demo/nontabular_example.py: -------------------------------------------------------------------------------- 1 | # 2 | # imports 3 | # 4 | import pprint 5 | import argparse 6 | 7 | from pyats.topology import loader 8 | 9 | from genie import parsergen 10 | import nontabular_markup 11 | 12 | 13 | def load(testbed, device_name): 14 | tb = loader.load(testbed) 15 | try: 16 | return tb.devices[device_name] 17 | except KeyError as e: 18 | raise KeyError("Could not find '{d}' within " 19 | "testbed '{tb}'".format(d=device, tb=testbed)) 20 | 21 | def parse_cli(device): 22 | output = device.execute('show interface brief') 23 | 24 | attrValPairsToParse = [ 25 | ('show.intf.if_name', 'mgmt0'), 26 | ] 27 | 28 | pgfill = parsergen.oper_fill ( 29 | device, 30 | ('show_interface_', [], {'ifname':'mgmt0'}), 31 | attrValPairsToParse, 32 | refresh_cache=True, regex_tag_fill_pattern='show\.intf') 33 | 34 | result = pgfill.parse() 35 | return parsergen.ext_dictio[device.name] 36 | 37 | 38 | if __name__ == '__main__': 39 | parser = argparse.ArgumentParser(description='Arguments for ' 40 | 'demo10_parsergen') 41 | parser.add_argument('-testbed_file', 42 | help='Location of the testbed file', 43 | default = 'virl.yaml') 44 | 45 | parser.add_argument('-device', 46 | help='Name or alias of the device to parse on', 47 | default = 'uut') 48 | 49 | custom_args = parser.parse_known_args()[0] 50 | testbed_file = custom_args.testbed_file 51 | device_name = custom_args.device 52 | 53 | device = load(testbed_file, device_name) 54 | device.connect() 55 | 56 | cli_parsed = parse_cli(device) 57 | pprint.pprint(cli_parsed) 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # .vscode 107 | .vscode 108 | .history -------------------------------------------------------------------------------- /libraries/harness_triggers/README.md: -------------------------------------------------------------------------------- 1 | ## demo2_harness_triggers 2 | 3 | # Introduction 4 | 5 | This script demonstrates the Triggers and Verifications concept in Genie. 6 | Triggers and verifications are plug and play Testcase to create any combination 7 | of tests. 8 | 9 | The list of triggers and verifications can be found here: 10 | 11 | * Connect to the devices defined in the testbed file. 12 | * Execute the first round of `verifications`. These verifications take a snapshot 13 | of the state of these commands. Future round of verifications is compared with 14 | these initial snapshot. 15 | * Execute the first trigger `TriggerClearCountersInterfaceAll`. 16 | * Execute the second round of verifications. Those are compared with the first round. 17 | * Execute the second trigger `TriggerShutNoShutBgpNeighbors`. 18 | * Repeat until all triggers are executed. 19 | * Terminate the run 20 | 21 | # Execution 22 | 23 | This demo requires devices. There is 3 options on how to run this demo: 24 | 25 | 1) Use mock devices. We have used the Unicon playback feature to record all 26 | interactions with the device so you can use it smoothly without connecting 27 | to real devices as below. 28 | 29 | ``` 30 | pyats run job demo2_harness_triggers_job.py --testbed-file virl.yaml --replay mock_device 31 | ``` 32 | 33 | 2) This demo is ready to be used with the VIRL devices. Please follow the guide 34 | on how to boot the virtual devices. 35 | 36 | 3) Use your own devices. Please modify the testbed file with the devices' 37 | names and the corresponding IP addresses. 38 | 39 | ``` 40 | pyats run job demo2_harness_triggers_job.py --testbed-file virl.yaml 41 | ``` 42 | 43 | # Output 44 | 45 | The log can be viewed in the file `TaskLog.html`. 46 | 47 | # What's next? 48 | 49 | Move on to the next demo `demo3_harness_telemetry` to add healthcheck 50 | capabilities to your testing! 51 | -------------------------------------------------------------------------------- /clean/full_clean_asr1k_iosxe/testbed.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SAMPLE-TESTBED 3 | servers: 4 | tftp: 5 | server: the-tftp-server 6 | address: 10.81.116.4 7 | credentials: 8 | default: 9 | username: user 10 | password: "%ENC{w5zDmsOD}" 11 | path: /auto/path/images/ 12 | scp: 13 | server: the-tftp-server 14 | address: 10.81.116.4 15 | credentials: 16 | default: 17 | username: user 18 | password: "%ENC{w5zDmsOD}" 19 | path: /auto/path/images/ 20 | 21 | 22 | devices: 23 | asr1000: 24 | alias: uut 25 | os: iosxe 26 | type: asr1k 27 | platform: asr1k 28 | credentials: 29 | default: 30 | password: "%ENC{w5zDmsOD}" 31 | username: admin 32 | enable: 33 | password: "%ENC{w5zDmsOD}" 34 | username: admin 35 | connections: 36 | defaults: 37 | class: unicon.Unicon 38 | vty: 39 | protocol: telnet 40 | ip: 1.1.1.1 41 | cli: 42 | protocol: telnet 43 | ip: 2.2.2.2 44 | port: 2001 45 | a: 46 | protocol: telnet 47 | ip: 2.2.2.2 48 | port: 2001 49 | custom: 50 | execute_timeout: 600 51 | configure_timeout: 250 52 | abstraction: 53 | order: [os, platform] 54 | peripherals: 55 | terminal_server: 56 | the-terminal-server: [41] 57 | power_cycler: 58 | type: dualcomm 59 | connection_type: snmp 60 | host: 6.6.6.6 61 | read_community: public 62 | write_community: public 63 | outlets: [1, 2] 64 | 65 | the-terminal-server: 66 | connections: 67 | a: 68 | ip: 3.3.3.3 69 | protocol: telnet 70 | credentials: 71 | default: 72 | password: lab 73 | enable: 74 | password: lab 75 | os: ios 76 | type: ios 77 | -------------------------------------------------------------------------------- /clean/full_clean_asr1k_iosxe/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [asr1000] 5 | 6 | devices: 7 | asr1000: 8 | images: 9 | - /auto/release/path/vmlinux.bin 10 | 11 | device_recovery: 12 | break_count: 5 13 | console_activity_pattern: "\\.\\.\\.\\." 14 | timeout: 600 15 | recovery_password: "%ENC{w5zDmsOD}" 16 | golden_image: 17 | - bootflash:/golden_image.bin 18 | 19 | connect: 20 | 21 | ping_server: 22 | server: the-tftp-server 23 | vrf: Mgmt-intf 24 | 25 | copy_to_linux: 26 | destination: 27 | directory: /auto/path/images/ 28 | overwrite: True 29 | copy_attempts: 3 30 | append_hostname: True 31 | 32 | copy_to_device: 33 | origin: 34 | hostname: the-tftp-server 35 | destination: 36 | directory: 'harddisk:/' 37 | protocol: ftp 38 | overwrite: True 39 | verify_num_images: False 40 | check_file_stability: True 41 | min_free_space_percent: 50 42 | 43 | change_boot_variable: 44 | 45 | write_erase: 46 | 47 | reload: 48 | 49 | apply_configuration: 50 | configuration: | 51 | hostname asr1000 52 | enable password banana 53 | interface GigabitEthernet0 54 | ip address X.X.X.X 255.255.255.0 55 | no shut 56 | line console 0 57 | exec-timeout 0 0 58 | logging synchronous 59 | line vty 0 4 60 | password lab 61 | config_timeout: 30 62 | config_stable_time: 120 63 | 64 | verify_running_image: 65 | 66 | order: 67 | - 'connect' 68 | - 'ping_server' 69 | - 'copy_to_linux' 70 | - 'copy_to_device' 71 | - 'change_boot_variable' 72 | - 'write_erase' 73 | - 'reload' 74 | - 'apply_configuration' 75 | - 'verify_running_image' 76 | -------------------------------------------------------------------------------- /metaparser/demo_metaparser_nxos.py: -------------------------------------------------------------------------------- 1 | # 2 | # imports 3 | # 4 | import pprint 5 | import argparse 6 | 7 | from pyats.topology import loader 8 | from genie.libs.parser.nxos.show_bgp import ShowBgpProcessVrfAll 9 | 10 | 11 | def load(testbed, device_name): 12 | tb = loader.load(testbed) 13 | try: 14 | return tb.devices[device_name] 15 | except KeyError as e: 16 | raise KeyError("Could not find '{d}' within " 17 | "testbed '{tb}'".format(d=device, tb=testbed)) 18 | 19 | def parse_cli(device): 20 | # By the default it will take cli 21 | return ShowBgpProcessVrfAll(device).parse() 22 | 23 | def parse_xml(device): 24 | return ShowBgpProcessVrfAll(device, context=['xml']).parse() 25 | 26 | def parse_xml_cli(device): 27 | # Parse Xml, and if any key is missing, complete it with cli output 28 | return ShowBgpProcessVrfAll(device, context=['xml', 'cli']).parse() 29 | 30 | 31 | if __name__ == '__main__': 32 | parser = argparse.ArgumentParser(description='Arguments for ' 33 | 'demo8_metaparser') 34 | parser.add_argument('-testbed_file', 35 | help='Location of the testbed file', 36 | default = 'virl.yaml') 37 | 38 | parser.add_argument('-device', 39 | help='Name or alias of the device to parse on', 40 | default = 'uut') 41 | 42 | custom_args = parser.parse_known_args()[0] 43 | testbed_file = custom_args.testbed_file 44 | device_name = custom_args.device 45 | 46 | device = load(testbed_file, device_name) 47 | device.connect() 48 | 49 | cli_parsed = parse_cli(device) 50 | pprint.pprint(cli_parsed) 51 | 52 | xml_parsed = parse_xml(device) 53 | pprint.pprint(xml_parsed) 54 | 55 | xml_cli_parsed = parse_xml_cli(device) 56 | pprint.pprint(xml_cli_parsed) 57 | -------------------------------------------------------------------------------- /parsergen/demo/tabular_example.py: -------------------------------------------------------------------------------- 1 | # 2 | # imports 3 | # 4 | import pprint 5 | import argparse 6 | 7 | from genie import parsergen 8 | from pyats.topology import loader 9 | 10 | 11 | def load(testbed, device_name): 12 | tb = loader.load(testbed) 13 | try: 14 | return tb.devices[device_name] 15 | except KeyError as e: 16 | raise KeyError("Could not find '{d}' within " 17 | "testbed '{tb}'".format(d=device, tb=testbed)) 18 | 19 | def parse_cli(device): 20 | # By the default it will take cli 21 | output = device.execute('show interface brief') 22 | result = parsergen.oper_fill_tabular( 23 | device_output= output, 24 | device_os= 'nxos', 25 | header_fields= [['Ethernet', 'VLAN', 'Type', 'Mode', 'Status', 'Reason', 'Speed', 'Port'], 26 | ['Interface', '', '', '', '', '', '', 'Ch \#']], 27 | label_fields=['Ethernet Interface', 'VLAN', 'Type', 28 | 'Mode', 'Status', 'Reason', 'Speed', 'Port'], 29 | index= [0]) 30 | 31 | return result 32 | 33 | 34 | if __name__ == '__main__': 35 | parser = argparse.ArgumentParser(description='Arguments for ' 36 | 'demo_parsergen') 37 | parser.add_argument('-testbed_file', 38 | help='Location of the testbed file', 39 | default = 'virl.yaml') 40 | 41 | parser.add_argument('-device', 42 | help='Name or alias of the device to parse on', 43 | default = 'uut') 44 | 45 | custom_args = parser.parse_known_args()[0] 46 | testbed_file = custom_args.testbed_file 47 | device_name = custom_args.device 48 | 49 | device = load(testbed_file, device_name) 50 | device.connect() 51 | 52 | cli_parsed = parse_cli(device) 53 | pprint.pprint(cli_parsed.entries) 54 | -------------------------------------------------------------------------------- /parsergen/pyAts/README: -------------------------------------------------------------------------------- 1 | Description: 2 | ------------ 3 | This README file is located in examples/parsergen/pyAts. 4 | 5 | These sample pyATS jobs log into a router you specify on a testbed that you 6 | specify, runs "show interface" and parses the output using cAAS/TCL and 7 | re-runs the command and this time parses the output using parsergen/Python. 8 | 9 | A comparison between the parsed results is then done, with results shown 10 | in the log. 11 | 12 | A parsergen comparison test is then run, where only user-selected parts of 13 | the output are parsed and compared to expected values. 14 | 15 | A show command producing tabular output is then run, and outputs parsed. 16 | 17 | Either csccon or unicon connection providers are supported. 18 | 19 | The following demo jobs are provided on various reference platforms: 20 | 21 | parsergen_demo_vios_job.py 22 | parsergen_demo_viosxe_job.py 23 | parsergen_demo_vnxos_job.py 24 | parsergen_demo_xrvr_job.py 25 | parsergen_demo_aireos_job.py 26 | parsergen_demo_enxr_job.py 27 | 28 | The following jobs invoke tests that use non-default connection aliases: 29 | 30 | parsergen_demo_aireos_job_conn_alias.py 31 | parsergen_demo_enxr_job_conn_alias.py 32 | 33 | 34 | To launch this sample pyATS job: 35 | -------------------------------- 36 | 37 | 1. Pick a testbed to run the job against and identify the YAML file 38 | 39 | 2. Substitute in parsergen_demo_job.py your UUT name, as per your YAML file, 40 | as chosen_uut_device. 41 | 42 | 3. Launch the job. 43 | easypy parsergen_demo__job.py -testbed_file /path/to/your_testbed.yaml 44 | 45 | 46 | To launch the EnXR sample pyATS job: 47 | ------------------------------------ 48 | 49 | 1. pip install dyntopo 50 | 51 | 2. cd examples 52 | 53 | 3. easypy parsergen/pyAts/parsergen_demo_enxr_job.py -logical_testbed_file dyntopo_xrut/yaml/ios_enxr_ping_test_config.yaml -clean_file dyntopo_xrut/yaml/ios_enxr_ping_bringup_config.yaml 54 | 55 | -------------------------------------------------------------------------------- /clean/full_clean_cat9k_iosxe/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [cat-9300-1] 5 | 6 | devices: 7 | cat-9300-1: 8 | images: 9 | - /auto/release/path/cat9k_iosxe.16.05.01a.SPA.bin 10 | 11 | device_recovery: 12 | break_count: 5 13 | console_activity_pattern: "\\.\\.\\.\\." 14 | timeout: 600 15 | recovery_password: "%ENC{w5zDmsOD}" 16 | golden_image: 17 | - bootflash:/golden_image.bin 18 | 19 | connect: 20 | 21 | ping_server: 22 | server: the-tftp-server 23 | vrf: Mgmt-intf 24 | 25 | copy_to_linux: 26 | destination: 27 | directory: /auto/path/images/ 28 | overwrite: True 29 | copy_attempts: 3 30 | append_hostname: True 31 | 32 | copy_to_device: 33 | origin: 34 | hostname: the-tftp-server 35 | destination: 36 | directory: 'bootflash:' 37 | protocol: ftp 38 | overwrite: True 39 | verify_num_images: False 40 | check_file_stability: True 41 | min_free_space_percent: 50 42 | 43 | change_boot_variable: 44 | 45 | write_erase: 46 | 47 | reload: 48 | 49 | apply_configuration: 50 | configuration: | 51 | hostname cat-9300-1 52 | enable password banana 53 | interface GigabitEthernet0 54 | ip address X.X.X.X 255.255.255.0 55 | no shut 56 | line console 0 57 | exec-timeout 0 0 58 | logging synchronous 59 | line vty 0 4 60 | transport input all 61 | config_timeout: 30 62 | config_stable_time: 120 63 | 64 | verify_running_image: 65 | 66 | order: 67 | - 'connect' 68 | - 'ping_server' 69 | - 'copy_to_linux' 70 | - 'copy_to_device' 71 | - 'change_boot_variable' 72 | - 'write_erase' 73 | - 'reload' 74 | - 'apply_configuration' 75 | - 'verify_running_image' 76 | -------------------------------------------------------------------------------- /clean/full_clean_isr4k_iosxe/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [isr-4400-1] 5 | 6 | devices: 7 | isr-4400-1: 8 | images: 9 | - /auto/release/path/isr4400-universalk9.164422SSA.bin 10 | 11 | device_recovery: 12 | break_count: 5 13 | console_activity_pattern: "\\.\\.\\.\\." 14 | timeout: 600 15 | recovery_password: "%ENC{w5zDmsOD}" 16 | golden_image: 17 | - bootflash:/golden_image.bin 18 | 19 | connect: 20 | 21 | ping_server: 22 | server: the-tftp-server 23 | vrf: Mgmt-intf 24 | 25 | copy_to_linux: 26 | destination: 27 | directory: /auto/path/images/ 28 | overwrite: True 29 | copy_attempts: 3 30 | append_hostname: True 31 | 32 | copy_to_device: 33 | origin: 34 | hostname: the-tftp-server 35 | destination: 36 | directory: 'bootflash:' 37 | protocol: ftp 38 | overwrite: True 39 | verify_num_images: False 40 | check_file_stability: True 41 | min_free_space_percent: 50 42 | 43 | change_boot_variable: 44 | 45 | write_erase: 46 | 47 | reload: 48 | 49 | apply_configuration: 50 | configuration: | 51 | hostname isr-4400-1 52 | enable password banana 53 | interface GigabitEthernet0 54 | ip address X.X.X.X 255.255.255.0 55 | no shut 56 | line console 0 57 | exec-timeout 0 0 58 | logging synchronous 59 | line vty 0 4 60 | transport input all 61 | config_timeout: 30 62 | config_stable_time: 120 63 | 64 | verify_running_image: 65 | 66 | order: 67 | - 'connect' 68 | - 'ping_server' 69 | - 'copy_to_linux' 70 | - 'copy_to_device' 71 | - 'change_boot_variable' 72 | - 'write_erase' 73 | - 'reload' 74 | - 'apply_configuration' 75 | - 'verify_running_image' 76 | -------------------------------------------------------------------------------- /abstraction_example/script.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Abstraction demonstraction test-script. 3 | 4 | Run with: 5 | python script.py --testbed tb.yaml 6 | python script.py --testbed tb.yaml --release polaris_dev 7 | 8 | Feel free to make changes to the tb.yaml file and see how lookup behavior change 9 | ''' 10 | 11 | from genie import abstract 12 | 13 | from pyats import aetest 14 | 15 | import abstracted_pkg 16 | 17 | class CommonSetup(aetest.CommonSetup): 18 | 19 | @aetest.subsection 20 | def create_lookup_object(self, testbed, release, yang): 21 | for device in testbed.devices.values(): 22 | device.lib = genie.abstract.Lookup(device.os, device.type, release, yang) 23 | 24 | class LookupTestcase(aetest.Testcase): 25 | 26 | @aetest.test 27 | def device_lookup(self, testbed): 28 | for name, device in sorted(testbed.devices.items()): 29 | 30 | print('operating on device: %s' % name) 31 | print('device os:', device.os) 32 | print('device type:', device.type) 33 | 34 | # lookup class 35 | obj = device.lib.abstracted_pkg.some_module.SomeClass() 36 | obj.some_method() 37 | 38 | # lookup function 39 | device.lib.abstracted_pkg.some_module.some_function() 40 | 41 | # lookup varibale 42 | print(device.lib.abstracted_pkg.some_module.some_var) 43 | 44 | print() 45 | 46 | if __name__ == '__main__': 47 | 48 | import argparse 49 | from pyats import topology 50 | 51 | parser = argparse.ArgumentParser() 52 | parser.add_argument('--testbed', type = topology.loader.load) 53 | parser.add_argument('--release', type = str, default = None) 54 | parser.add_argument('--yang', action = 'store_true', default = None) 55 | 56 | args, _ = parser.parse_known_args() 57 | aetest.main(**vars(args)) 58 | -------------------------------------------------------------------------------- /clean/full_clean_ie5000_ios/ie5000_tb.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: IE5000-tb 3 | servers: 4 | ftp: 5 | address: 10.15.19.10 6 | credentials: 7 | default: 8 | username: admin 9 | password: C1sco123 10 | path: /mypath/ 11 | tftp: 12 | address: 172.2.11.12 13 | credentials: 14 | default: 15 | username: rcpuser 16 | password: 123rcp! 17 | devices: 18 | ie5000: 19 | alias: uut 20 | os: ios 21 | type: ie5k 22 | platform: ie5k 23 | credentials: 24 | default: 25 | password: C1sco123 26 | username: admin 27 | enable: 28 | password: "C1sco123" 29 | username: admin 30 | connections: 31 | defaults: 32 | class: unicon.Unicon 33 | cli: 34 | protocol: telnet 35 | ip: 10.15.27.18 36 | port: 6029 37 | a: 38 | protocol: telnet 39 | ip: 10.15.27.18 40 | port: 6029 41 | custom: 42 | abstraction: 43 | order: [os, platform] 44 | peripherals: 45 | terminal_server: 46 | "10.15.27.18": [29] 47 | power_cycler: 48 | type: raritan-px2 49 | connection_type: snmp 50 | host: 172.2.21.11 51 | read_community: public 52 | write_community: private 53 | outlets: [2] 54 | "10.15.27.18": 55 | os: iosxe 56 | type: iosxe 57 | platform: isr4k 58 | connections: 59 | a: 60 | ip: 10.15.27.18 61 | protocol: telnet 62 | credentials: 63 | default: 64 | password: Lablab123 65 | enable: 66 | password: C1sc0123 -------------------------------------------------------------------------------- /clean/full_clean_C3560CX_ios/c3560cx_tb.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: c3560cx 3 | servers: 4 | ftp: 5 | address: 10.10.19.10 6 | credentials: 7 | default: 8 | username: admin 9 | password: cisco123 10 | path: /mypath/ 11 | 12 | tftp: 13 | address: 172.2.11.12 14 | credentials: 15 | default: 16 | username: rcpuser 17 | password: 123rcp! 18 | 19 | devices: 20 | 3560cx: 21 | alias: uut 22 | os: ios 23 | type: cat3k 24 | platform: cat3k 25 | credentials: 26 | default: 27 | password: C1sco123 28 | username: admin 29 | enable: 30 | password: "C1sco123" 31 | username: admin 32 | connections: 33 | defaults: 34 | class: unicon.Unicon 35 | cli: 36 | protocol: telnet 37 | ip: 10.15.27.37 38 | port: 6020 39 | a: 40 | protocol: telnet 41 | ip: 10.15.27.37 42 | port: 6020 43 | custom: 44 | abstraction: 45 | order: [os, platform] 46 | peripherals: 47 | terminal_server: 48 | "10.15.27.37": [20] 49 | power_cycler: 50 | type: raritan-px2 51 | connection_type: snmp 52 | host: 172.2.21.2 53 | read_community: public 54 | write_community: private 55 | outlets: [12] 56 | "10.15.27.37": 57 | os: iosxe 58 | type: iosxe 59 | platform: isr4k 60 | connections: 61 | a: 62 | ip: 10.15.27.7 63 | protocol: telnet 64 | credentials: 65 | default: 66 | password: cisco123 67 | enable: 68 | password: cisco123 69 | -------------------------------------------------------------------------------- /clean/full_clean_csr1000v_iosxe/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [csr-1000v-1] 5 | 6 | devices: 7 | csr-1000v-1: 8 | images: 9 | - /auto/release/path/csr1000v-universalk9.03.10.00.S.153-3.S-ext.SPA.bin 10 | 11 | device_recovery: 12 | break_count: 5 13 | console_activity_pattern: "\\.\\.\\.\\." 14 | timeout: 600 15 | recovery_password: "%ENC{w5zDmsOD}" 16 | golden_image: 17 | - bootflash:/golden_image.bin 18 | 19 | connect: 20 | 21 | ping_server: 22 | server: the-tftp-server 23 | max_attempts: 2 24 | 25 | copy_to_linux: 26 | destination: 27 | directory: /auto/path/images/ 28 | overwrite: True 29 | copy_attempts: 3 30 | append_hostname: True 31 | 32 | copy_to_device: 33 | origin: 34 | hostname: the-tftp-server 35 | destination: 36 | directory: 'bootflash:' 37 | protocol: ftp 38 | overwrite: True 39 | verify_num_images: False 40 | check_file_stability: True 41 | min_free_space_percent: 50 42 | 43 | change_boot_variable: 44 | write_memory: True 45 | 46 | write_erase: 47 | 48 | reload: 49 | 50 | apply_configuration: 51 | configuration: | 52 | hostname csr-1000v-1 53 | enable password banana 54 | interface GigabitEthernet1 55 | ip address X.X.X.X 255.255.255.0 56 | negotiation auto 57 | no shut 58 | line console 0 59 | exec-timeout 0 0 60 | logging synchronous 61 | line vty 0 4 62 | password lab 63 | transport input all 64 | config_timeout: 30 65 | config_stable_time: 120 66 | 67 | verify_running_image: 68 | 69 | order: 70 | - 'connect' 71 | - 'ping_server' 72 | - 'copy_to_linux' 73 | - 'copy_to_device' 74 | - 'change_boot_variable' 75 | - 'write_erase' 76 | - 'reload' 77 | - 'apply_configuration' 78 | - 'verify_running_image' 79 | -------------------------------------------------------------------------------- /clean/full_clean_ie4000_ios/ie4000_tb.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: SOL-IE4000-thai 3 | servers: 4 | ftp: 5 | address: 10.195.189.100 6 | credentials: 7 | default: 8 | username: admin 9 | password: C1sco123 10 | path: /thaing/ 11 | tftp: 12 | address: 172.27.115.127 13 | credentials: 14 | default: 15 | username: rcpuser 16 | password: 123rcp! 17 | devices: 18 | MEX-X-4000: 19 | alias: uut 20 | os: ios 21 | type: ie4k 22 | platform: ie4k 23 | credentials: 24 | default: 25 | password: C1sco123 26 | username: admin 27 | enable: 28 | password: "C1sco123" 29 | username: admin 30 | connections: 31 | defaults: 32 | class: unicon.Unicon 33 | cli: 34 | protocol: telnet 35 | ip: 10.195.247.37 36 | port: 6057 37 | a: 38 | protocol: telnet 39 | ip: 10.195.247.37 40 | port: 6057 41 | custom: 42 | abstraction: 43 | order: [os, platform] 44 | peripherals: 45 | terminal_server: 46 | "10.195.247.37": [57] 47 | power_cycler: 48 | type: raritan-px2 49 | connection_type: snmp 50 | host: 172.23.241.22 51 | read_community: public 52 | write_community: private 53 | outlets: [9] 54 | "10.195.247.37": 55 | os: iosxe 56 | type: iosxe 57 | platform: isr4k 58 | connections: 59 | a: 60 | ip: 10.195.247.37 61 | protocol: telnet 62 | credentials: 63 | default: 64 | password: Lablab123 65 | enable: 66 | password: C1sco123 -------------------------------------------------------------------------------- /groups/group_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job group_example_job.py 3 | # Description: This example shows looping and variants in pyats 4 | 5 | import os 6 | 7 | from pyats.easypy import run 8 | # Data structure used to mentions that to execute 9 | from pyats.datastructures.logic import And, Or, Not 10 | 11 | def main(): 12 | # Find the location of the script in relation to the job file 13 | test_path = os.path.dirname(os.path.abspath(__file__)) 14 | testscript = os.path.join(test_path, 'group_example_script.py') 15 | 16 | #Task-1 17 | # Execution Group by itself 18 | # Only execute group1 19 | run(testscript=testscript, 20 | groups=Or('group1')) 21 | 22 | #Task-2 23 | # Execute testcases that are member of group1 and group2 24 | # We expect only the common_ to be executed, no testcase 25 | run(testscript=testscript, 26 | groups=And('group1', 'group2')) 27 | 28 | #Task-3 29 | # Execute testcases that are member of group1 and group3 30 | # We expect tc_two to be executed 31 | run(testscript=testscript, 32 | groups=And('group2', 'group3')) 33 | 34 | #Task-4 35 | # Combine groups and ids. 36 | # Execute testcase part of Group 1 or Group2 , and not tc_two 37 | # We expect everything except tc_two to be executed 38 | run(testscript=testscript, 39 | groups=Or('group1', 'group2'), 40 | uids=Not('tc_two')) 41 | 42 | # Create a function that tests for testcases group 43 | # this api tests that a testcase belongs to group 1 but not group 2 44 | # The argument must be stared 45 | def group1_not_group2(*groups): 46 | # Groups is evaluated on run time, will be replaced by the groups of 47 | # the testcase 48 | # Return True/False 49 | # if True the testcase will execute 50 | return 'group1' in groups and 'group2' not in groups 51 | 52 | #Task-5 53 | # Use the above function as group callable 54 | # we expect everything except tc_two to be executed 55 | run(testscript=testscript, 56 | groups=group1_not_group2) 57 | -------------------------------------------------------------------------------- /script_parameters/etc/connection_example_conf.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: tbd1 3 | servers: 4 | tftp: 5 | server: "ott2lab-tftp1" 6 | address: "223.255.254.254" 7 | path: "" 8 | username: "rcpuser" 9 | password: "123rcp!" 10 | ntp: 11 | server: 102.0.0.102 12 | devices: 13 | ott-tb1-n7k3: 14 | type: 'router' 15 | tacacs: 16 | login_prompt: "login:" 17 | password_prompt: "Password:" 18 | username: "admin" 19 | passwords: 20 | tacacs: CSCO12345^ 21 | enable: CSCO12345^ 22 | line: CSCO12345^ 23 | connections: 24 | a: 25 | protocol: telnet 26 | ip: "10.85.87.25" 27 | port: 2003 28 | b: 29 | protocol: telnet 30 | ip: "10.85.87.25" 31 | port: 2004 32 | alt: 33 | protocol : telnet 34 | ip : "5.25.25.3" 35 | clean: 36 | pre_clean: | 37 | switchname %{self} 38 | license grace-period 39 | feature telnet 40 | interface mgmt0 41 | ip addr %{self.connections.alt.ip}/24 42 | no shut 43 | vrf context management 44 | ip route 101.0.0.0/24 5.19.27.251 45 | ip route 102.0.0.0/24 5.19.27.251 46 | post_clean: | 47 | switchname %{self} 48 | license grace-period 49 | feature telnet 50 | interface mgmt0 51 | ip addr %{self.connections.alt.ip}/24 52 | no shut 53 | vrf context management 54 | ip route 101.0.0.0/24 5.19.27.251 55 | ip route 102.0.0.0/24 5.19.27.251 56 | 57 | topology: 58 | ott-tb1-n7k3: 59 | interfaces: 60 | Ethernet3/1: 61 | link: link-1 62 | type: ethernet 63 | loopback0: 64 | link: link-2 65 | type: loopback 66 | -------------------------------------------------------------------------------- /clean/full_clean_n9k_nxos/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [N9500-1] 5 | 6 | devices: 7 | N9500-1: 8 | images: 9 | system: 10 | - /auto/release/path/nxos.7.0.3.I7.1.bin 11 | 12 | device_recovery: 13 | break_count: 5 14 | console_activity_pattern: "\\.\\.\\.\\." 15 | timeout: 600 16 | recovery_password: "%ENC{w5zDmsOD}" 17 | golden_image: 18 | system: bootflash:/golden_system_image.bin 19 | 20 | connect: 21 | 22 | ping_server: 23 | server: the-tftp-server 24 | vrf: management 25 | 26 | copy_to_linux: 27 | destination: 28 | directory: /auto/path/images/ 29 | overwrite: True 30 | copy_attempts: 3 31 | append_hostname: True 32 | 33 | copy_to_device: 34 | origin: 35 | hostname: the-tftp-server 36 | destination: 37 | directory: 'bootflash:' 38 | protocol: ftp 39 | vrf: management 40 | overwrite: True 41 | verify_num_images: False 42 | check_file_stability: True 43 | min_free_space_percent: 50 44 | 45 | change_boot_variable: 46 | copy_vdc_all: True 47 | 48 | write_erase: 49 | 50 | reload: 51 | 52 | apply_configuration: 53 | configuration: | 54 | switchname N9500-1 55 | power redundancy-mode combined force 56 | username admin password lalala role network-admin 57 | no password strength-check 58 | interface mgmt0 59 | ip address X.X.X.X 255.255.255.0 60 | no shutdown 61 | vrf context management 62 | ip route 0.0.0.0/0 10.X.X.X 63 | line console 64 | exec-timeout 0 65 | no ip domain-lookup 66 | feature telnet 67 | config_timeout: 30 68 | config_stable_time: 120 69 | 70 | verify_running_image: 71 | 72 | order: 73 | - 'connect' 74 | - 'ping_server' 75 | - 'copy_to_linux' 76 | - 'copy_to_device' 77 | - 'change_boot_variable' 78 | - 'write_erase' 79 | - 'reload' 80 | - 'apply_configuration' 81 | - 'verify_running_image' 82 | -------------------------------------------------------------------------------- /clean/full_clean_n9kv_nxos/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [N9500v-1] 5 | 6 | devices: 7 | N9500v-1: 8 | images: 9 | system: 10 | - /auto/release/path/nxos.7.0.3.I7.1.bin 11 | 12 | device_recovery: 13 | break_count: 5 14 | console_activity_pattern: "\\.\\.\\.\\." 15 | timeout: 600 16 | recovery_password: "%ENC{w5zDmsOD}" 17 | golden_image: 18 | system: bootflash:/golden_system_image.bin 19 | 20 | connect: 21 | 22 | ping_server: 23 | server: the-tftp-server 24 | vrf: management 25 | 26 | copy_to_linux: 27 | destination: 28 | directory: /auto/path/images/ 29 | overwrite: True 30 | copy_attempts: 3 31 | append_hostname: True 32 | 33 | copy_to_device: 34 | origin: 35 | hostname: the-tftp-server 36 | destination: 37 | directory: 'bootflash:' 38 | protocol: ftp 39 | vrf: management 40 | overwrite: True 41 | verify_num_images: False 42 | check_file_stability: True 43 | min_free_space_percent: 50 44 | 45 | change_boot_variable: 46 | copy_vdc_all: True 47 | 48 | write_erase: 49 | 50 | reload: 51 | 52 | apply_configuration: 53 | configuration: | 54 | switchname N9500v-1 55 | power redundancy-mode combined force 56 | username admin password lalala role network-admin 57 | no password strength-check 58 | interface mgmt0 59 | ip address X.X.X.X 255.255.255.0 60 | no shutdown 61 | vrf context management 62 | ip route 0.0.0.0/0 10.X.X.X 63 | line console 64 | exec-timeout 0 65 | no ip domain-lookup 66 | feature telnet 67 | config_timeout: 30 68 | config_stable_time: 120 69 | 70 | verify_running_image: 71 | 72 | order: 73 | - 'connect' 74 | - 'ping_server' 75 | - 'copy_to_linux' 76 | - 'copy_to_device' 77 | - 'change_boot_variable' 78 | - 'write_erase' 79 | - 'reload' 80 | - 'apply_configuration' 81 | - 'verify_running_image' 82 | -------------------------------------------------------------------------------- /libraries/trigger_within_pyats/datafile.yaml: -------------------------------------------------------------------------------- 1 | ##################################################### 2 | # Datafile driving pyATS Testcases # 3 | # and driving the Genie Triggers and Verifications # 4 | ##################################################### 5 | 6 | testcases: 7 | # Trigger name, has to match the one in the testscript 8 | TriggerSleep: 9 | # Giving it a group (Optional) 10 | groups: ['sleep'] 11 | # Those are the parameters needed for the trigger. 12 | # To know which one are needed 13 | # Take a look in the Trigger_datafile provided with 14 | # Genie. 15 | parameters: 16 | sleep_time: 5 17 | message_time: 3 18 | 19 | # Verification name, has to match the one in the testscript 20 | Verify_BgpVrfAllAll_1: 21 | # As we are using Template for verification we only need to mention 22 | # which parser or Ops object we want to use via parameters 23 | parameters: 24 | source: 25 | class: genie.harness.base.Template 26 | cmd: 27 | pkg: genie.libs.parser 28 | class: show_bgp.ShowBgpProcessVrfAll 29 | 30 | # Verification name, has to match the one in the testscript 31 | Verify_BgpVrfAllAll_2: 32 | # As we are using Template for verification we only need to mention 33 | # which parser or Ops object we want to use via parameters 34 | parameters: 35 | source: 36 | class: genie.harness.base.Template 37 | cmd: 38 | pkg: genie.libs.parser 39 | class: show_bgp.ShowBgpProcessVrfAll 40 | 41 | # Verification name, has to match the one in the testscript 42 | Verify_BgpVrfAllAll_3: 43 | # As we are using Template for verification we only need to mention 44 | # which parser or Ops object we want to use via parameters 45 | parameters: 46 | source: 47 | class: genie.harness.base.Template 48 | cmd: 49 | pkg: genie.libs.parser 50 | class: show_bgp.ShowBgpProcessVrfAll 51 | 52 | TriggerShutNoShutBgp: 53 | parameters: 54 | timeout: 55 | max_time: 180 56 | interval: 10 57 | tgn_timeout: 300 58 | tgn_delay: 10 59 | tgn_max_outage: 120 60 | -------------------------------------------------------------------------------- /libraries/harness_custom_trigger/trigger.py: -------------------------------------------------------------------------------- 1 | # Python 2 | import time 3 | import logging 4 | 5 | # pyATS 6 | from pyats import aetest 7 | 8 | # Genie 9 | from genie.harness.base import Trigger 10 | 11 | # Parser 12 | from genie.libs.parser.nxos.show_arp import ShowIpArp 13 | 14 | # Metaparser exception 15 | from genie.metaparser.util.exceptions import SchemaEmptyParserError 16 | 17 | log = logging.getLogger(__name__) 18 | 19 | # Steps in this Trigger 20 | # Take snapshot of existing arp 21 | # clear ip arp vrf all force-delete 22 | # Verify they all came back - And uptime was reduced 23 | 24 | class TriggerClearArpVrfAllForceDelete(Trigger): 25 | 26 | @aetest.setup 27 | def verify_prerequisite(self, uut): 28 | ''' ''' 29 | 30 | # Perform init steps here 31 | # Call our parser 32 | parser = ShowIpArp(device=uut) 33 | output = parser.parse() 34 | self.initial_output = {} 35 | 36 | for addr, value in output.items(): 37 | if 'age' in value: 38 | self.initial_output[addr] = {} 39 | self.initial_output[addr]['age'] = value['age'] 40 | 41 | @aetest.test 42 | def clear(self, uut): 43 | 44 | log.info('Send Clear cmd') 45 | uut.execute('clear ip arp vrf all force-delete') 46 | 47 | @aetest.test 48 | def verify_clear(self, uut, sleep): 49 | 50 | time.sleep(sleep) 51 | # Call our parser 52 | parser = ShowIpArp(device=uut) 53 | try: 54 | after_output = parser.parse() 55 | except SchemaEmptyParserError: 56 | # If only 1 arp, then it will return empty, which is perfectly fine 57 | pass 58 | 59 | for addr, value in self.initial_output.items(): 60 | if addr not in after_output: 61 | # Lost an arp! 62 | self.failed('Lost {addr}'.format(addr=addr)) 63 | 64 | 65 | # Make sure uptime is less than 30 sec 66 | if not after_output[addr]['Age'] == '-' and\ 67 | after_output[addr]['Age'] > 30 or\ 68 | after_output[addr]['Age'] > self.initial_output[addr]['Age']: 69 | self.failed('{addr} was not reseted'.format(addr=addr)) 70 | -------------------------------------------------------------------------------- /script_parameters/script_parameters_example_script.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import logging 3 | from pyats import aetest 4 | from pyats.log.utils import banner 5 | 6 | log = logging.getLogger(__name__) 7 | log.setLevel(logging.DEBUG) 8 | 9 | ################################################################### 10 | ### COMMON SETUP SECTION ### 11 | ################################################################### 12 | 13 | # As a simple example, we don't do much here except printing some 14 | # log messages. 15 | 16 | class common_setup(aetest.CommonSetup): 17 | """ Common Setup section """ 18 | @aetest.subsection 19 | def common_setup_subsection(self, x, y): 20 | """ Common Setup subsection """ 21 | log.info(banner(" Aetest Common Setup ")) 22 | # Use script args from aetest 23 | print("Script args from common setup") 24 | print(x) 25 | assert x == 1 26 | 27 | ################################################################### 28 | ### TESTCASES SECTION ### 29 | ################################################################### 30 | 31 | class tc_one(aetest.Testcase): 32 | """ This is user Testcases section """ 33 | @aetest.setup 34 | def tc_one_setup(self, x): 35 | """ Testcase Setup section """ 36 | log.info(banner(" Aetest Testcase Execution ")) 37 | print("Script args from testcase") 38 | assert x == 1 39 | 40 | @aetest.test 41 | def tc_one_test(self): 42 | pass 43 | 44 | @aetest.cleanup 45 | def tc_one_cleanup(self): 46 | """ Testcase cleanup section """ 47 | log.info("Pass testcase cleanup") 48 | ##################################################################### 49 | #### COMMON CLEANUP SECTION ### 50 | ##################################################################### 51 | 52 | class common_cleanup(aetest.CommonCleanup): 53 | """ Common Cleanup for Sample Test """ 54 | @aetest.subsection 55 | def common_cleanup_subsection(self): 56 | """ Common Cleanup Subsection """ 57 | log.info(banner(" Aetest Common Cleanup ")) 58 | 59 | if __name__ == '__main__': # pragma: no cover 60 | aetest.main() 61 | -------------------------------------------------------------------------------- /health/health_checks/README.md: -------------------------------------------------------------------------------- 1 | ## pyATS Health for cpu/memory average check 2 | 3 | This folder contains no yaml file. pyATS Health Check has pre-defined checks for `cpu`, `memory`, `logging` and `core`. 4 | 5 | But of course, you need to have pyATS job where you want to run pyATS Health Check. So, we will use Blitz example (config_interface) here. 6 | 7 | [blitz/config_interface](https://github.com/CiscoTestAutomation/examples/tree/master/blitz/config_interface) 8 | 9 | Please find the detail what the Blitz does from above example. 10 | 11 | ### How to use: 12 | ``` 13 | pyats run job ../../blitz/config_interface/job.py --testbed-file ../../blitz/config_interface/testbed.yaml --health-checks cpu memory logging core --replay mock_device 14 | ``` 15 | NOTE: above use `--replay` (mock device). so you don't need to have device to run. 16 | 17 | As you can see above, what you need to do is just adding health check names such as `cpu`, `memory`, `logging` and `core`. These checks will run as post processor per testcase. 18 | 19 | Here are some information about what each check does: 20 | 21 | | health check | description | 22 | |--------------|-------------| 23 | | cpu | cpu load check. check total of cpu load with threshold 90% by default. | 24 | | memory | memory usage check. check total of memory usage with threshold 90% by default. | 25 | | logging | keyword check in show logging output. default keywords are traceback, Traceback, TRACEBACK | 26 | | core | check if core file is generated on device. just check by default. Please use `--health-remote-device` to copy the core file to remote server. | 27 | 28 | By default, `core` check only detects if core file is generated or not. in case you want to save/copy the generated core file to remote server. please use `--health-remote-device` argument. If copying core file is successful, the copied core file will be deleted from device. 29 | 30 | ``` 31 | pyats run job ../../blitz/config_interface/job.py --testbed-file ../../blitz/config_interface/testbed.yaml --health-checks cpu memory logging core --health-remote-device name:myserver path:/tmp/ protocol:http --health-mgmt-vrf iosxe:None --replay mock_device_http 32 | ``` 33 | NOTE: default VRF will be used for `protocol:http`. so, specifying `--health-mgmt-vrf iosxe:None` 34 | 35 | 36 | -------------------------------------------------------------------------------- /clean/full_clean_n7k_nxos/clean.yaml: -------------------------------------------------------------------------------- 1 | cleaners: 2 | DeviceClean: 3 | module: genie.libs.clean 4 | devices: [N7700-1] 5 | 6 | devices: 7 | N7700-1: 8 | images: 9 | system: 10 | - /auto/release/path/n7700-s2-dk9.6.2.10.bin 11 | kickstart: 12 | - /auto/release/path/n7000-s2-kickstart.6.2.10.bin 13 | 14 | device_recovery: 15 | break_count: 5 16 | console_activity_pattern: "\\.\\.\\.\\." 17 | timeout: 600 18 | recovery_password: "%ENC{w5zDmsOD}" 19 | golden_image: 20 | system: bootflash:/golden_system_image.bin 21 | kickstart: bootflash:/golden_kickstart_image.bin 22 | 23 | connect: 24 | 25 | ping_server: 26 | server: the-tftp-server 27 | vrf: management 28 | 29 | copy_to_linux: 30 | destination: 31 | directory: /auto/path/images/ 32 | overwrite: True 33 | copy_attempts: 3 34 | append_hostname: True 35 | 36 | copy_to_device: 37 | origin: 38 | hostname: the-tftp-server 39 | destination: 40 | directory: 'bootflash:' 41 | protocol: ftp 42 | vrf: management 43 | overwrite: True 44 | verify_num_images: False 45 | check_file_stability: True 46 | min_free_space_percent: 50 47 | 48 | change_boot_variable: 49 | copy_vdc_all: True 50 | 51 | write_erase: 52 | 53 | reload: 54 | 55 | apply_configuration: 56 | configuration: | 57 | switchname N7700-1 58 | power redundancy-mode combined force 59 | username admin password lalala role network-admin 60 | no password strength-check 61 | interface mgmt0 62 | ip address X.X.X.X 255.255.255.0 63 | no shutdown 64 | vrf context management 65 | ip route 0.0.0.0/0 10.X.X.X 66 | line console 67 | exec-timeout 0 68 | no ip domain-lookup 69 | feature telnet 70 | config_timeout: 30 71 | config_stable_time: 120 72 | 73 | verify_running_image: 74 | 75 | order: 76 | - 'connect' 77 | - 'ping_server' 78 | - 'copy_to_linux' 79 | - 'copy_to_device' 80 | - 'change_boot_variable' 81 | - 'write_erase' 82 | - 'reload' 83 | - 'apply_configuration' 84 | - 'verify_running_image' 85 | -------------------------------------------------------------------------------- /uids/uids_example_job.py: -------------------------------------------------------------------------------- 1 | # To run the job: 2 | # pyats run job uids_example_ids_job.py 3 | # Description: This example shows looping and variants in pyats 4 | 5 | import os 6 | 7 | from pyats.easypy import run 8 | # Data structure used to mentions that to execute 9 | from pyats.datastructures.logic import And, Or, Not 10 | 11 | def main(): 12 | 13 | # Find the location of the script in relation to the job file 14 | test_path = os.path.dirname(os.path.abspath(__file__)) 15 | testscript = os.path.join(test_path, 'uids_example_script.py') 16 | 17 | ##### 18 | # Skip Example 19 | ##### 20 | 21 | #Task-1 22 | # Skip Container/Section that match tc_two and my_looped_testcase 23 | run(testscript=testscript, 24 | uids=Not('tc_two','my_looped_testcase')) 25 | 26 | #Task-2 27 | # Skip Container/Section that match common_setup 28 | run(testscript=testscript, 29 | uids=Not('common_setup')) 30 | 31 | 32 | # Skip Container/Section that match common_setup, and also skip 33 | # Container/Section that begins with loop2 34 | 35 | #Task-3 36 | # ^loop2 will match a loop of a testcase section. 37 | # It also demonstrate that regex can be used 38 | run(testscript=testscript, 39 | uids=Not('common_setup','^loop2$')) 40 | 41 | ##### 42 | # Execute Example 43 | ##### 44 | 45 | #Task-4 46 | # Execute Container/Section that match common_setup 47 | run(testscript=testscript, 48 | uids=And('common_setup')) 49 | 50 | #Task-5 51 | # Execute Container/Section that match tc_two or my_looped_testcase 52 | run(testscript=testscript, 53 | uids=Or('tc_two','my_looped_testcase')) 54 | 55 | #Task-6 56 | # Execute Container/Section that match common_setup or test_two, or begins 57 | # with loop2 58 | run(testscript=testscript, 59 | uids=Or('common_setup','^loop2','test_two')) 60 | 61 | ##### 62 | # Skip and Execute Example 63 | ##### 64 | 65 | #Task-7 66 | # Skip loop1, and execute tc_two, my_looped_testcase 67 | run(testscript=testscript, 68 | uids=And(Not('loop1'), Or('tc_two','my_looped_testcase'))) 69 | 70 | ##### 71 | # Default behavior 72 | ##### 73 | 74 | #Task-8 75 | # By default everything will be executed, as no uids is specified. 76 | run(testscript=testscript) 77 | -------------------------------------------------------------------------------- /clean/clean_vWLC_aireos/tb_vWLC.yaml: -------------------------------------------------------------------------------- 1 | testbed: 2 | name: vWLC 3 | servers: 4 | ftp: 5 | address: 10.2.5.5 6 | credentials: 7 | default: 8 | username: rcpuser 9 | password: 123rcp! 10 | path: /auto/your-tftp/path 11 | tftp: 12 | address: 10.2.5.5 13 | credentials: 14 | default: 15 | username: rcpuser 16 | password: 123rcp! 17 | devices: 18 | vWLC: 19 | alias: uut 20 | os: aireos 21 | type: ap 22 | platform: single_rp 23 | credentials: 24 | default: 25 | password: Cisco123$ 26 | username: admin 27 | enable: 28 | password: "Cisco123$" 29 | username: admin 30 | connections: 31 | defaults: 32 | class: unicon.Unicon 33 | cli: 34 | protocol: telnet 35 | ip: 10.2.5.5 36 | port: 6000 37 | service_attributes: 38 | execute: 39 | timeout: 600 40 | configure: 41 | timeout: 600 42 | a: 43 | protocol: telnet 44 | ip: 10.2.5.5 45 | port: 6000 46 | service_attributes: 47 | execute: 48 | timeout: 600 49 | configure: 50 | timeout: 600 51 | custom: 52 | abstraction: 53 | order: [os, platform] 54 | peripherals: 55 | terminal_server: 56 | "10.2.5.5": [6000] 57 | power_cycler: 58 | type: raritan-px2 59 | connection_type: snmp 60 | host: 10.2.5.5 61 | read_community: public 62 | write_community: private 63 | outlets: [9] 64 | 65 | "10.2.5.5": 66 | os: ios 67 | type: ios 68 | platform: isr4k 69 | connections: 70 | a: 71 | ip: 10.2.5.5 72 | protocol: telnet 73 | credentials: 74 | default: 75 | password: Lablab123 76 | enable: 77 | password: C1sco123 78 | --------------------------------------------------------------------------------