From c414b3742a4f7c509ab0dbe10576a1e35b7fe729 Mon Sep 17 00:00:00 2001 From: Lukeman Hakkim Sheik Alavudeen Date: Mon, 25 Nov 2024 09:47:23 -0800 Subject: [PATCH] Releasing v24.11 --- pkgs/clean-pkg/changelog/2024/november.rst | 42 + .../sdk_generator/output/github_clean.json | 52 +- .../src/genie/libs/clean/__init__.py | 2 +- .../src/genie/libs/clean/recovery/recovery.py | 2 - .../genie/libs/clean/stages/apic/stages.py | 5 +- .../stages/apic/tests/test_copy_to_device.py | 128 +++ .../libs/clean/stages/iosxe/cat9k/stages.py | 39 +- .../iosxe/cat9k/tests/test_install_image.py | 5 +- .../cat9k/tests/test_install_image_reload.py | 53 ++ .../libs/clean/stages/iosxe/image_handler.py | 10 +- .../genie/libs/clean/stages/iosxe/stages.py | 85 +- .../stages/iosxe/tests/test_copy_to_device.py | 79 ++ .../stages/iosxe/tests/test_image_handler.py | 11 + .../stages/iosxe/tests/test_install_image.py | 88 +++ .../src/genie/libs/clean/stages/stages.py | 5 +- .../clean/stages/tests/test_copy_to_device.py | 79 ++ .../libs/clean/templates/iosxe/templates.py | 77 +- pkgs/conf-pkg/changelog/2024/november.rst | 27 + pkgs/conf-pkg/src/genie/libs/conf/__init__.py | 2 +- pkgs/conf-pkg/src/genie/libs/conf/bgp/bgp.py | 15 + .../src/genie/libs/conf/bgp/nxos/bgp.py | 13 + .../libs/conf/bgp/nxos/tests/test_bgp.py | 204 +++++ .../src/genie/libs/conf/interface/ipv6addr.py | 2 +- .../libs/conf/interface/nxos/ipv4addr.py | 20 +- .../interface/nxos/tests/test_interface.py | 12 +- .../conf/route_policy/nxos/route_policy.py | 7 + .../nxos/tests/test_route_policy.py | 15 + .../libs/conf/vlan/nxos/tests/test_vlan.py | 67 ++ .../src/genie/libs/conf/vlan/nxos/vlan.py | 10 + .../conf-pkg/src/genie/libs/conf/vlan/vlan.py | 6 + .../changelog/2024/november.rst | 0 .../genie/libs/filetransferutils/__init__.py | 2 +- pkgs/health-pkg/changelog/2024/november.rst | 0 .../src/genie/libs/health/__init__.py | 2 +- pkgs/ops-pkg/changelog/2024/november.rst | 0 pkgs/ops-pkg/src/genie/libs/ops/__init__.py | 2 +- pkgs/robot-pkg/changelog/2024/november.rst | 0 .../src/genie/libs/robot/__init__.py | 2 +- pkgs/sdk-pkg/changelog/2024/november.rst | 64 ++ .../sdk_generator/output/github_apis.json | 536 +++++++++---- .../sdk_generator/output/github_triggers.json | 12 +- pkgs/sdk-pkg/src/genie/libs/sdk/__init__.py | 2 +- .../libs/sdk/apis/api_unittest_generator.py | 635 +++++++++------ .../libs/sdk/apis/iosxe/aaa/configure.py | 6 +- .../libs/sdk/apis/iosxe/cts/configure.py | 18 + .../libs/sdk/apis/iosxe/debug/configure.py | 40 +- .../libs/sdk/apis/iosxe/dot1x/configure.py | 20 + .../libs/sdk/apis/iosxe/health/health.py | 54 +- .../libs/sdk/apis/iosxe/install/execute.py | 10 +- .../sdk/apis/iosxe/interface/configure.py | 21 +- .../libs/sdk/apis/iosxe/interface/execute.py | 74 +- .../libs/sdk/apis/iosxe/platform/execute.py | 82 ++ .../sdk/apis/iosxe/policy_map/configure.py | 84 ++ .../genie/libs/sdk/apis/iosxe/rommon/utils.py | 31 +- .../sdk/apis/iosxe/startup_config/verify.py | 9 +- .../sdk/apis/test_templates/test_api.py.jinja | 40 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...ion_accnt_attr_filter_spec_include_list.py | 32 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...sion_auth_attr_filter_spec_include_list.py | 37 +- ...t_api_configure_aaa_accounting_commands.py | 35 +- ...ccounting_exec_default_start_stop_group.py | 32 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 36 - ..._accounting_identity_default_start_stop.py | 31 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...est_api_configure_aaa_accounting_update.py | 31 +- .../__init__.py | 0 ...onfigure_aaa_accounting_update_periodic.py | 31 +- ...aaa_accounting_update_periodic_interval.py | 31 +- .../configure_aaa_auth_proxy/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 42 - .../test_api_configure_aaa_auth_proxy.py | 30 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...api_configure_aaa_authentication_enable.py | 31 +- .../mock_data/iosxe/mock_data.yaml | 36 - ..._api_configure_aaa_authentication_login.py | 31 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...pi_configure_aaa_authorization_commands.py | 31 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...onfigure_aaa_authorization_exec_default.py | 31 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...api_configure_aaa_authorization_network.py | 31 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 44 -- ...api_configure_aaa_default_group_methods.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 42 - .../test_api_configure_aaa_local_auth.py | 32 +- .../mock_data/iosxe/mock_data.yaml | 42 - ...nfigure_access_session_attr_filter_list.py | 38 +- .../aaa/configure/configure_coa/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 37 - .../configure_coa/test_api_configure_coa.py | 31 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 44 -- ...st_api_configure_common_criteria_policy.py | 73 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...configure_disable_config_key_encryption.py | 33 +- .../test_api_configure_dscp_global.py | 30 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 43 - ...st_api_configure_enable_policy_password.py | 35 +- .../mock_data/iosxe/mock_data.yaml | 43 + ...i_configure_masked_unmasked_credentials.py | 35 + .../configure_radius_attribute_25/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 36 - .../test_api_configure_radius_attribute_25.py | 30 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 36 - ...onfigure_radius_attribute_31_mac_format.py | 30 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 36 - ..._configure_radius_attribute_31_send_mac.py | 30 +- .../configure_radius_attribute_8/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 36 - .../test_api_configure_radius_attribute_8.py | 30 +- .../mock_data/iosxe/mock_data.yaml | 37 - .../test_api_configure_radius_group.py | 34 +- .../__init__.py | 0 ...i_configure_radius_server_dead_criteria.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...ure_radius_server_source_ports_extended.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 41 - ...i_configure_service_password_encryption.py | 33 +- .../mock_data/iosxe/mock_data.yaml | 37 - .../test_api_configure_username.py | 34 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 42 - ...st_api_configure_wired_radius_attribute.py | 33 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 36 - ...st_api_disable_aaa_authentication_login.py | 31 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 35 - ...st_api_disable_aaa_password_restriction.py | 31 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...i_disable_login_password_reuse_interval.py | 33 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...est_api_enable_aaa_authentication_login.py | 31 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...est_api_enable_aaa_password_restriction.py | 33 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...pi_enable_login_password_reuse_interval.py | 33 +- .../mock_data/iosxe/mock_data.yaml | 38 - ..._enable_radius_automate_tester_probe_on.py | 42 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...ion_accnt_attr_filter_spec_include_list.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 37 - ...sion_auth_attr_filter_spec_include_list.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...api_unconfigure_aaa_accounting_commands.py | 39 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...ccounting_exec_default_start_stop_group.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 39 - ..._accounting_identity_default_start_stop.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...t_api_unconfigure_aaa_accounting_update.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...aaa_accounting_update_periodic_interval.py | 34 +- .../unconfigure_aaa_auth_proxy/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 42 - .../test_api_unconfigure_aaa_auth_proxy.py | 33 +- .../mock_data/iosxe/mock_data.yaml | 35 - ...i_unconfigure_aaa_authentication_enable.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 36 - ..._unconfigure_aaa_authorization_commands.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 40 - .../test_api_unconfigure_aaa_local_auth.py | 35 +- .../unconfigure_aaa_new_model/__init__.py | 0 .../test_api_unconfigure_aaa_new_model.py | 33 +- .../mock_data/iosxe/mock_data.yaml | 36 - ...nfigure_access_session_attr_filter_list.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 42 - ...ccess_session_attr_filter_list_protocol.py | 48 +- .../aaa/configure/unconfigure_coa/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 35 - .../test_api_unconfigure_coa.py | 33 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 42 - ..._api_unconfigure_common_criteria_policy.py | 34 +- .../test_api_unconfigure_dscp_global.py | 35 +- ...test_api_unconfigure_dscp_radius_server.py | 44 +- .../mock_data/iosxe/mock_data.yaml | 37 - ...pi_unconfigure_dscp_radius_server_group.py | 44 +- .../unconfigure_enable_password/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 35 - .../test_api_unconfigure_enable_password.py | 46 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 42 - ..._api_unconfigure_enable_policy_password.py | 38 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 36 - ...unconfigure_radius_server_dead_criteria.py | 33 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 41 - ...unconfigure_service_password_encryption.py | 33 +- .../mock_data/iosxe/mock_data.yaml | 35 - .../test_api_unconfigure_tacacs_group.py | 34 +- .../mock_data/iosxe/mock_data.yaml | 35 - .../test_api_unconfigure_tacacs_server.py | 32 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 42 - ..._api_unconfigure_wired_radius_attribute.py | 33 +- ...t_api_execute_clear_aaa_counters_server.py | 31 +- .../test_api_set_platform_soft_trace_debug.py | 36 +- .../mock_data/iosxe/mock_data.yaml | 98 --- ...est_api_show_logging_smd_output_to_file.py | 32 +- .../verify/verify_enable_password/__init__.py | 0 .../test_api_verify_enable_password.py | 35 +- ...erify_login_credentials_enable_password.py | 38 +- .../mock_data/iosxe/mock_data.yaml | 35 - .../test_api_configure_autoboot.py | 34 +- .../remove_default_ipv6_sgacl/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 21 +- .../test_api_remove_default_ipv6_sgacl.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 14 +- ...test_api_debug_software_cpm_switch_pcap.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 23 +- ...t_api_set_platform_soft_trace_ptp_debug.py | 35 + .../unconfigure_ip_domain_lookup/__init__.py | 0 .../test_api_unconfigure_ip_domain_lookup.py | 11 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 25 +- ...pi_unconfigure_parameter_map_subscriber.py | 35 + .../health/health_cpu/test_api_health_cpu.py | 125 ++- .../mock_data/iosxe/mock_data.yaml | 60 -- .../test_api_execute_install_activate.py | 41 +- .../mock_data/iosxe/install_image_reload.txt | 137 ++++ .../mock_data/iosxe/mock_data.yaml | 110 ++- .../test_api_execute_install_one_shot.py | 37 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 23 +- ...test_api_configure_interface_speed_auto.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 29 +- ...api_execute_test_platform_hardware_cman.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 25 +- ...i_execute_test_sfp_port_lpn_fake_insert.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 39 + ...i_execute_test_sfp_port_lpn_fake_remove.py | 35 + .../get/get_interface_names/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 116 +-- .../test_api_get_interface_names.py | 65 +- .../mock_data/iosxe/mock_data.yaml | 39 - ...pi_unconfigure_lisp_enhanced_forwarding.py | 37 +- .../get/execute_clear_logging/__init__.py | 0 .../test_api_execute_clear_logging.py | 16 + .../mock_data/iosxe/mock_data.yaml | 42 - .../test_api_configure_crypto_pki_server.py | 32 +- .../configure_boot_manual/__init__.py | 0 .../test_api_configure_boot_manual.py | 32 +- .../test_api_configure_device_classifier.py | 45 +- ...api_configure_device_classifier_command.py | 39 +- .../configure_no_boot_manual/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 39 - .../test_api_configure_no_boot_manual.py | 32 +- .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 37 +- ...pi_execute_diagnostic_start_switch_port.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 25 +- ..._platform_hardware_fed_switch_phy_debug.py | 35 + .../request_platform_hardware_pfu/__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 24 +- .../test_api_request_platform_hardware_pfu.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 26 +- ...uest_platform_software_trace_rotate_all.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 25 +- ...est_api_configure_policy_map_parameters.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 42 + ...e_policy_map_with_police_cir_percentage.py | 35 + .../__init__.py | 0 .../mock_data/iosxe/mock_data.yaml | 23 +- ...nconfigure_policy_map_set_cos_cos_table.py | 35 + .../mock_data/iosxe/mock_data.yaml | 17 +- .../mock_data/iosxe/mock_data.yaml | 5 +- .../startup_config/verify/test_verify.py | 5 +- .../clear_counters/test_api_clear_counters.py | 47 +- .../get_show_output_line_count/__init__.py | 0 .../test_api_get_show_output_line_count.py | 27 + .../apis/tests/test_api_unittest_generator.py | 741 ++++++++---------- pkgs/sdk-pkg/src/genie/libs/sdk/apis/utils.py | 109 +-- 289 files changed, 4703 insertions(+), 5897 deletions(-) create mode 100644 pkgs/clean-pkg/changelog/2024/november.rst create mode 100644 pkgs/clean-pkg/src/genie/libs/clean/stages/apic/tests/test_copy_to_device.py create mode 100644 pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image_reload.py create mode 100644 pkgs/conf-pkg/changelog/2024/november.rst create mode 100644 pkgs/filetransferutils-pkg/changelog/2024/november.rst create mode 100644 pkgs/health-pkg/changelog/2024/november.rst create mode 100644 pkgs/ops-pkg/changelog/2024/november.rst create mode 100644 pkgs/robot-pkg/changelog/2024/november.rst create mode 100644 pkgs/sdk-pkg/changelog/2024/november.rst delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/__init__.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/test_api_configure_masked_unmasked_credentials.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_enable_password/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{platform/configure/configure_boot_manual => cts/configure/remove_default_ipv6_sgacl}/mock_data/iosxe/mock_data.yaml (67%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/test_api_remove_default_ipv6_sgacl.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{utils/clear_counters => debug/configure/debug_software_cpm_switch_pcap}/mock_data/iosxe/mock_data.yaml (74%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/test_api_debug_software_cpm_switch_pcap.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/execute/set_platform_soft_trace_debug => debug/configure/set_platform_soft_trace_ptp_debug}/mock_data/iosxe/mock_data.yaml (66%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/test_api_set_platform_soft_trace_ptp_debug.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dns/configure/unconfigure_ip_domain_lookup/__init__.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dns/configure/unconfigure_ip_domain_lookup/test_api_unconfigure_ip_domain_lookup.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/unconfigure_dscp_global => dot1x/configure/unconfigure_parameter_map_subscriber}/mock_data/iosxe/mock_data.yaml (51%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/test_api_unconfigure_parameter_map_subscriber.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/install_image_reload.txt create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/configure_radius_server_dead_criteria => interface/configure/configure_interface_speed_auto}/mock_data/iosxe/mock_data.yaml (64%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/test_api_configure_interface_speed_auto.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/execute/execute_clear_aaa_counters_server => interface/execute/execute_test_platform_hardware_cman}/mock_data/iosxe/mock_data.yaml (60%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/test_api_execute_test_platform_hardware_cman.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/configure_aaa_accounting_update_periodic => interface/execute/execute_test_sfp_port_lpn_fake_insert}/mock_data/iosxe/mock_data.yaml (61%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/test_api_execute_test_sfp_port_lpn_fake_insert.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/__init__.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/test_api_execute_test_sfp_port_lpn_fake_remove.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/logging/get/execute_clear_logging/__init__.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/logging/get/execute_clear_logging/test_api_execute_clear_logging.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/__init__.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/__init__.py delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/unconfigure_aaa_new_model => platform/execute/execute_diagnostic_start_switch_port}/mock_data/iosxe/mock_data.yaml (53%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/test_api_execute_diagnostic_start_switch_port.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/configure_dscp_global => platform/execute/platform_hardware_fed_switch_phy_debug}/mock_data/iosxe/mock_data.yaml (60%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/test_api_platform_hardware_fed_switch_phy_debug.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/configure_aaa_accounting_commands => platform/execute/request_platform_hardware_pfu}/mock_data/iosxe/mock_data.yaml (61%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/test_api_request_platform_hardware_pfu.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/unconfigure_dscp_radius_server => platform/execute/request_platform_software_trace_rotate_all}/mock_data/iosxe/mock_data.yaml (65%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/test_api_request_platform_software_trace_rotate_all.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/configure_aaa_accounting_exec_default_start_stop_group => policy_map/configure/configure_policy_map_parameters}/mock_data/iosxe/mock_data.yaml (56%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/test_api_configure_policy_map_parameters.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/__init__.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/mock_data/iosxe/mock_data.yaml create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/test_api_configure_policy_map_with_police_cir_percentage.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/__init__.py rename pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/{aaa/configure/configure_aaa_accounting_update_periodic_interval => policy_map/configure/unconfigure_policy_map_set_cos_cos_table}/mock_data/iosxe/mock_data.yaml (65%) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/test_api_unconfigure_policy_map_set_cos_cos_table.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/get_show_output_line_count/__init__.py create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/get_show_output_line_count/test_api_get_show_output_line_count.py diff --git a/pkgs/clean-pkg/changelog/2024/november.rst b/pkgs/clean-pkg/changelog/2024/november.rst new file mode 100644 index 000000000..dfb3a446e --- /dev/null +++ b/pkgs/clean-pkg/changelog/2024/november.rst @@ -0,0 +1,42 @@ +-------------------------------------------------------------------------------- + New +-------------------------------------------------------------------------------- + +* clean-pkg + * iosxe + * Added default `LOAD_IMAGE` template + * iosxe + * image_handler + * check if smu image is passed instead of base image in the image list + * Skip `install_image` if smu only image passed. + + +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* stages/iosxe + * install image + * Ensure startup config is verified if install image is skipped. + * install image + * Updated _check_for_member_config to handle install image stage. + +* iosxe + * Modified clean stages + * Fixed the usage of steps in the clean stages to ensure correct result rollup + * Modified copy_to_device + * Skip verifying free space on the device if skip_deletion is set to True + +* apic + * Modified copy_to_device + * Skip verifying free space on the device if skip_deletion is set to True + +* generic + * Modified copy_to_device + * Skip verifying free space on the device if skip_deletion is set to True + +* recovery + * Modified recovery_processor + * Removed unused params from docstring + + diff --git a/pkgs/clean-pkg/sdk_generator/output/github_clean.json b/pkgs/clean-pkg/sdk_generator/output/github_clean.json index 4c9b37dcd..f86ec5d74 100644 --- a/pkgs/clean-pkg/sdk_generator/output/github_clean.json +++ b/pkgs/clean-pkg/sdk_generator/output/github_clean.json @@ -10,7 +10,7 @@ "os": "apic" }, "uid": "ApplyConfiguration", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/stages.py#L1036" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/stages.py#L1037" }, "iosxe": { "folders": { @@ -43,7 +43,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "ApplyConfiguration", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1612" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1615" }, "ApplyGlobalConfiguration": { "folders": { @@ -107,7 +107,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "BackupFileOnDevice", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1940" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1943" }, "ChangeBootVariable": { "folders": { @@ -225,7 +225,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "ConfigureInterfaces", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2946" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2949" }, "ConfigureManagement": { "doc": "This stage configures the management IP settings on the device.\n\nStage Schema\n------------\nconfigure_management:\n\n address ('dict', optional): Address(es) to configure on the device (syntax: address/mask) (optional)\n ipv4 ('str') or ('list'): ipv4 address\n ipv6 ('str') or ('list'): ipv6 address\n\n gateway: (dict, optional) Gateway address(es) for default route\n ipv4 ('str') or ('list'): ipv4 gateway address\n ipv6 ('str') or ('list'): ipv6 gateway address\n\n vrf (str, optional): VRF to use for management interface\n\n interface (str, optional): Management interface to use\n\n routes ('dict', optional):\n ipv4 (list of 'dict'): ipv4 routes\n - subnet: (str) subnet including mask\n next_hop: (str) next_hop for this subnet\n ipv6 (list of 'dict'): ipv6 routes\n - subnet: (str) subnet including mask\n next_hop: (str) next_hop for this subnet\n\n dhcp_timeout ('int', optional): DHCP timeout in seconds (default: 30)\n\n protocols ('list', optional): [list of protocols]\n\n set_hostname (bool): Configure device hostname (default: True)\n alias_as_hostname (bool): When used with `set_hostname`, will use the\n alias as the hostname. (default: False)\n\n\nExample\n-------\nconfigure_management:\n vrf: Mgmt-vrf\n\n", @@ -233,7 +233,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "ConfigureManagement", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2849" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2852" }, "ConfigureReplace": { "folders": { @@ -245,7 +245,7 @@ "os": "iosxe" }, "uid": "ConfigureReplace", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3073" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3102" } } }, @@ -300,7 +300,7 @@ "os": "iosxe" }, "uid": "Connect", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3152" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3181" }, "linux": { "folders": { @@ -331,7 +331,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "CopyRunToFlash", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2799" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2802" }, "CopyToDevice": { "doc": "This stage will copy an image to a device from a networked location.\n\nStage Schema\n------------\ncopy_to_device:\n\n origin:\n\n files (list): Image files location on the server.\n\n hostname (str): Hostname or address of the server.\n\n destination:\n\n directory (str): Directory on the device to copy the images to.\n\n standby_directory (str, optional): Standby directory on the device\n to copy the images to. Defaults to None.\n\n protocol (str): Protocol used for copy operation.\n\n connection_alias (str): Connection alias to use\n\n verify_num_images (bool, optional): Verify number of images provided by\n user for clean is correct. Defaults to True.\n\n expected_num_images (int, optional): Number of images expected to be\n provided by user for clean. Defaults to 1.\n\n vrf (str, optional): Vrf used to copy. Defaults to an empty string.\n\n timeout (int, optional): Copy operation timeout in seconds. Defaults to 300.\n\n compact (bool, optional): Compact copy mode if supported by the device.\n Defaults to False.\n\n protected_files (list, optional): File patterns that should not be deleted.\n Defaults to None.\n\n overwrite (bool, optional): Overwrite the file if a file with the same\n name already exists. Defaults to False.\n\n skip_deletion (bool, optional): Do not delete any files even if there isn't\n any space on device. Defaults to False.\n\n copy_attempts (int, optional): Number of times to attempt copying image\n files. Defaults to 1 (no retry).\n\n copy_attempts_sleep (int, optional): Number of seconds to sleep between\n copy_attempts. Defaults to 30.\n\n check_file_stability (bool, optional): Verifies that the file size is not\n changing. This ensures the image is not actively being copied.\n Defaults to False.\n\n stability_check_tries (int, optional): Max number of checks that can be\n done when checking file stability. Defaults to 3.\n\n stability_check_delay (int, optional): Delay between tries when checking\n file stability in seconds. Defaults to 2.\n\n min_free_space_percent ('int', optional) : Percentage of total disk space\n that must be free. If specified the percentage is not free then the\n stage will attempt to delete unprotected files to reach the minimum\n percentage. Defaults to None.\n\n use_kstack (bool, optional): Use faster version of copy with limited options.\n Defaults to False.\n\n interface (str, optional): The interface to use for file transfers, may be needed\n for copying files on some IOSXE platforms, such as ASR1K when using a VRF\n Defaults to None\n\n unique_file_name (bool, optional): Appends a random six-digit number to\n the end of the image name. Defaults to False.\n\n unique_number: (int, optional): Appends the provided number to the end of\n the image name. Defaults to None. Requires unique_file_name is True\n to be applied.\n\n rename_images: (str, optional): Rename the image to the provided name.\n If multiple files exist then an incrementing number is also appended.\n Defaults to None\n\n prompt_recovery(bool, optional): Enable the prompt recovery when the execution\n command timeout. Defaults to False.\n\nExample\n-------\ncopy_to_device:\n origin:\n hostname: server-1\n files:\n - /home/cisco/asr1k.bin\n destination:\n directory: harddisk:/\n protocol: sftp\n timeout: 300\n", @@ -354,7 +354,7 @@ "os": "iosxe" }, "uid": "CopyToDevice", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L2175" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L2201" } }, "module_name": "stages.stages", @@ -376,7 +376,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "DeleteBackupFromDevice", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2035" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2038" }, "DeleteFiles": { "doc": "Delete files from the device.\n\nUses the `delete_files` device API.\n\nStage Schema\n------------\ndelete_files:\n\n files (list): List of files including location.\n\n regex (bool, optional): If regex is used in the file names, set to True. Default False.\n\nExample\n-------\ndelete_files:\n - flash:core/*.gz\n - crashinfo/*.tar.gz\n", @@ -384,7 +384,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "DeleteFiles", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2258" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2261" }, "DeleteFilesFromServer": { "doc": "This stage deletes files from a server.\n\nStage Schema\n------------\ndelete_files_from_server:\n\n server (str, optional): Hostname or address of the server. If not provided,\n uses the same server from copy_to_linux (if applicable).\n\n files (list, optional): List of files to delete. If not provided, uses the\n same files from copy_to_linux (if applicable).\n\n protocol (str, optional): Protocol used for deletion. Only ftp or sftp is\n supported. Defaults to sftp.\n\nExample\n-------\ndelete_files_from_server:\n server: 1.1.1.1\n files:\n - /home/cisco/kickstart.bin\n protocol: sftp\n\n", @@ -392,7 +392,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "DeleteFilesFromServer", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2159" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2162" }, "EraseApConfiguration": { "folders": { @@ -421,7 +421,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "ExecuteCommand", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1546" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1549" }, "ExpandImage": { "folders": { @@ -521,7 +521,7 @@ "os": "iosxe" }, "uid": "InstallImage", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L679" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L686" }, "iosxr": { "folders": { @@ -583,7 +583,7 @@ "os": "iosxe" }, "uid": "InstallPackages", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1437" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1463" } } }, @@ -611,7 +611,7 @@ "os": "iosxe" }, "uid": "InstallRemoveSmu", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1001" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1027" } } }, @@ -625,7 +625,7 @@ "os": "iosxe" }, "uid": "InstallSmu", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1234" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1260" } } }, @@ -692,7 +692,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "PowerCycle", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2695" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2698" }, "PrimeAp": { "folders": { @@ -726,13 +726,13 @@ "os": "iosxe" }, "uid": "Reload", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1535" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1561" } }, "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "Reload", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1369" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1372" }, "ResetConfiguration": { "folders": { @@ -744,7 +744,7 @@ "os": "iosxe" }, "uid": "ResetConfiguration", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3388" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3417" } } }, @@ -754,7 +754,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "RevertVmSnapshot", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2328" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L2331" }, "RommonBoot": { "folders": { @@ -778,7 +778,7 @@ "os": "iosxe" }, "uid": "RommonBoot", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1889" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1915" } } }, @@ -813,7 +813,7 @@ "os": "iosxe" }, "uid": "SetControllerMode", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3605" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L3634" } } }, @@ -1148,7 +1148,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "VerifyRunningImage", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1775" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1778" }, "VerifyWirelessProcess": { "folders": { @@ -1177,7 +1177,7 @@ "module_name": "stages.stages", "package": "genie.libs.clean", "uid": "WriteErase", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1325" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py#L1328" }, "token_order": [ "origin", diff --git a/pkgs/clean-pkg/src/genie/libs/clean/__init__.py b/pkgs/clean-pkg/src/genie/libs/clean/__init__.py index a49e5fb46..2695d0c57 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/__init__.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/__init__.py @@ -8,7 +8,7 @@ ''' # metadata -__version__ = '24.10' +__version__ = '24.11' __author__ = 'Cisco Systems Inc.' __contact__ = ['asg-genie-support@cisco.com', 'pyats-support-ext@cisco.com'] __copyright__ = 'Copyright (c) 2019, Cisco Systems Inc.' diff --git a/pkgs/clean-pkg/src/genie/libs/clean/recovery/recovery.py b/pkgs/clean-pkg/src/genie/libs/clean/recovery/recovery.py index 7fd2e03ca..92ab8b2a8 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/recovery/recovery.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/recovery/recovery.py @@ -198,8 +198,6 @@ def recovery_processor( grub_breakboot_char: timeout: recovery_password: - recovery_username: - recovery_en_password: powercycler: (Default: True) powercycler_delay: , 'int'> (Default: 30) reconnect_delay: , 'int'> (Default: 60) diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/stages.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/stages.py index 75bf66514..3876a8f0c 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/stages.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/stages.py @@ -945,6 +945,9 @@ def copy_to_device(self, steps, device, origin, destination, protocol, step.failed("Error while creating free space for " "image on device {} {}". format(device.name, dest)) + else: + step.skipped(f"Skip verifying free space on the device '{device.name}'" + " because skip_deletion is set to True") # Copy the file to the devices for file, file_data in files_to_copy.items(): @@ -1030,8 +1033,6 @@ def copy_to_device(self, steps, device, origin, destination, protocol, "Image file has been copied to device {} correctly" " but cannot verify file size".format(device.name)) - self.passed("Copy to device completed") - class ApplyConfiguration(BaseStage): """This stage executes the REST API against the device. diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/tests/test_copy_to_device.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/tests/test_copy_to_device.py new file mode 100644 index 000000000..f0c3fa801 --- /dev/null +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/apic/tests/test_copy_to_device.py @@ -0,0 +1,128 @@ +import unittest + +from unittest.mock import Mock, call, ANY + +from genie.libs.clean.stages.apic.stages import CopyToDevice +from genie.libs.clean.stages.tests.utils import create_test_device + +from pyats.aetest.steps import Steps +from pyats.results import Passed +from pyats.topology import Testbed +from pyats.datastructures import AttrDict + + +class VerifyCopyToDevice(unittest.TestCase): + + def setUp(self): + # Instantiate class object + self.cls = CopyToDevice() + self.cls.history = {'CopyToDevice': AttrDict({'parameters': {}})} + + # Instantiate device object. This also sets up commonly needed + # attributes and Mock objects associated with the device. + self.device = create_test_device('PE1', os='apic', via='cli') + + # And we want the connect method to be mocked. + # This simulates the pass case. + self.device.connect = Mock() + + + def test_copy_to_device_skip_deletion_true(self): + class MockExecute: + + def __init__(self, *args, **kwargs): + self.data = { + 'dir bootflash:': iter([ + ''' + Directory of bootflash:/ + 11 drwx 16384 Nov 25 2016 19:32:53 -07:00 lost+found + 12 -rw- 0 Dec 13 2016 11:36:36 -07:00 ds_stats.txt + 104417 drwx 4096 Apr 10 2017 09:09:11 -07:00 .prst_sync + 80321 drwx 4096 Nov 25 2016 19:40:38 -07:00 .rollback_timer + 64257 drwx 4096 Nov 25 2016 19:41:02 -07:00 .installer + 48193 drwx 4096 Nov 25 2016 19:41:14 -07:00 virtual-instance-stby-sync + 1940303872 bytes total (1036210176 bytes free) + ''', + f''' + Directory of bootflash:/ + 11 drwx 16384 Nov 25 2016 19:32:53 -07:00 lost+found + 12 -rw- 0 Dec 13 2016 11:36:36 -07:00 ds_stats.txt + 104417 drwx 4096 Apr 10 2017 09:09:11 -07:00 .prst_sync + 80321 drwx 4096 Nov 25 2016 19:40:38 -07:00 .rollback_timer + 64257 drwx 4096 Nov 25 2016 19:41:02 -07:00 .installer + 48193 drwx 4096 Nov 25 2016 19:41:14 -07:00 virtual-instance-stby-sync + 8033 drwx 4096 Nov 25 2016 18:42:07 -07:00 test.bin + 1940303872 bytes total (1036210176 bytes free) + ''' + ]), + 'scp None@127.0.0.1:/path/test.bin bootflash:/test.bin': iter(['Copied file']), + 'show version': iter([ + ''' + Role Pod Node Name Version + ---------- ---------- ---------- ------------------------ -------------------- + controller 1 1 msl-ifav205-ifc1 5.1(2e) + leaf 1 101 msl-ifav205-leaf1 n9000-15.1(2e) + spine 1 201 msl-ifav205-spine1 n9000-15.1(2e) + spine 1 202 msl-ifav205-spine2 n9000-14.2(2e) + ''' + ]), + 'ls -l bootflash:': iter([ + ''' + total 6894908 + lrwxrwxrwx 1 root root 12 Mar 23 23:36 aci -> /.aci/viewfs + -rw-r--r-- 1 admin admin 7060381696 Apr 7 01:41 aci-apic-dk9.5.1.2e.iso + lrwxrwxrwx 1 root root 13 Mar 23 23:36 debug -> /.aci/debugfs + lrwxrwxrwx 1 root root 11 Mar 23 23:36 mit -> /.aci/mitfs + lrwxrwxrwx 1 root root 11 Mar 23 2009 nonaci + ''' + ]) + } + + def __call__(self, cmd, *args, **kwargs): + output = next(self.data[cmd]) + return output + + mock_execute = MockExecute() + + # And we want the execute method to be mocked with device console output. + self.device.execute = Mock(side_effect=mock_execute) + + steps = Steps() + + testbed = Testbed('mytb', servers={ + 'server1': { + 'address': '127.0.0.1', + 'protocol': 'scp' + } + }) + + self.device.testbed = testbed + + # Call the method to be tested (clean step inside class) + with self.assertLogs(level='INFO') as log: + self.cls.copy_to_device( + steps=steps, device=self.device, + origin=dict( + files=[f'/path/test.bin'], + hostname='server1' + ), + destination=dict( + directory='bootflash:' + ), + protocol='scp', + verify_running_image=False, + skip_deletion=True + ) + self.assertIn(f"INFO:pyats.aetest.steps.implementation:Skipped reason: Skip verifying free space on the device '{self.device.name}' because skip_deletion is set to True", + log.output) + + # Check that the result is expected + self.assertEqual(Passed, steps.details[0].result) + self.device.execute.assert_has_calls([ + call('show version'), + call('ls -l bootflash:'), + call(f'scp None@127.0.0.1:/path/test.bin bootflash:/test.bin', + prompt_recovery=True, timeout=300, reply=ANY, + error_pattern=ANY), + call('dir bootflash:') + ]) diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/stages.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/stages.py index 8cc5bd718..bed6ebf71 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/stages.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/stages.py @@ -925,7 +925,7 @@ def _check_for_member_config(spawn, session): if not session.get('member_config'): raise StackMemberConfigException - dialog = Dialog([ + install_add_one_shot_dialog = Dialog([ Statement(pattern=r"Do you want to proceed\? \[y\/n\]", action='sendline(y)', loop_continue=True, @@ -943,31 +943,22 @@ def _check_for_member_config(spawn, session): loop_continue=True, continue_timer=False) ]) - if issu: - device.sendline('install add file {} activate issu commit'.format(images[0])) - else: - device.sendline('install add file {} activate commit'.format(images[0])) try: - dialog.process(device.spawn, - timeout = install_timeout, - context=device.context + reload_args.update( + {"timeout": install_timeout, "reply": install_add_one_shot_dialog} + ) + if issu: + device.reload("install add file {} activate issu commit".format( + images[0] + ), + **reload_args, + ) + else: + device.reload("install add file {} activate commit".format( + images[0] + ), + **reload_args, ) - except StackMemberConfigException as e: - log.debug("Expected exception continue with the stage") - log.info('Waiting for buffer to settle down') - post_reload_wait_time = reload_args.get('post_reload_wait', 15) - post_reload_timeout = reload_args.get('post_reload_timeout', 60) - start_time = current_time = datetime.now() - timeout_time = timedelta(seconds=post_reload_timeout) - settle_time = current_time = datetime.now() - while (current_time - settle_time) < timeout_time: - if buffer_settled(device.spawn, post_reload_wait_time): - log.info('Buffer settled, accessing device..') - break - current_time = datetime.now() - if (current_time - start_time) > timeout_time: - log.info('Time out, trying to acces device..') - break except Exception as e: step.failed("Failed to install the image", from_exception=e) diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image.py index 0316f5b7c..d99d871d2 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image.py @@ -26,7 +26,7 @@ def test_iosxe_install_image_pass(self): device = Mock() device.chassis_type = 'stack' - device.sendline = Mock() + device.reload = Mock() # device.api.get_running_image.return_value = 'sftp://server/image.bin' with patch( @@ -35,7 +35,7 @@ def test_iosxe_install_image_pass(self): "genie.libs.clean.stages.iosxe.cat9k.stages.Dialog") as dialog_mock: cls.install_image(steps=steps, device=device, images=['sftp://server/image.bin']) - device.sendline.assert_has_calls([ + device.reload([ call('install add file sftp://server/image.bin activate commit')]) self.assertEqual(Passed, steps.details[0].result) @@ -46,6 +46,7 @@ def test_iosxe_install_image_skip(self): device = Mock() device.chassis_type = 'stack' device.api.get_running_image.return_value = 'sftp://server/image.bin' + device.reload = Mock(side_effect=Exception) with self.assertRaises(TerminateStepSignal): with patch( "genie.libs.clean.stages.iosxe.cat9k.stages.StackUtils") as stack_mock: diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image_reload.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image_reload.py new file mode 100644 index 000000000..cc6a05371 --- /dev/null +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/cat9k/tests/test_install_image_reload.py @@ -0,0 +1,53 @@ +import logging +import unittest + +from unittest.mock import Mock, MagicMock, call, patch + +from genie.libs.clean.stages.iosxe.cat9k.stages import InstallImage + +from pyats.aetest.steps import Steps +from pyats.results import Passed, Failed +from pyats.aetest.signals import TerminateStepSignal + +logging.disable(logging.CRITICAL) + +class TestInstallImage(unittest.TestCase): + + def test_iosxe_install_image_reload_pass(self): + steps = Steps() + cls = InstallImage() + cls.history = MagicMock() + cls.new_boot_var = 'image.bin' + + device = Mock() + device.chassis_type = 'stack' + device.reload = Mock() + + with patch( + "genie.libs.clean.stages.iosxe.cat9k.stages.StackUtils") as stack_mock: + with patch( + "genie.libs.clean.stages.iosxe.cat9k.stages.Dialog") as dialog_mock: + cls.install_image(steps=steps, device=device, images=['sftp://server/image.bin']) + + device.reload([ + call('install add file sftp://server/image.bin activate commit')]) + self.assertEqual(Passed, steps.details[0].result) + + def test_iosxe_install_image_reload_fail(self): + steps = Steps() + cls = InstallImage() + cls.history = {} + + device = Mock() + device.chassis_type = 'stack' + device.reload = Mock(side_effect=Exception) + + with self.assertRaises(TerminateStepSignal): + with patch( + "genie.libs.clean.stages.iosxe.cat9k.stages.StackUtils") as stack_mock: + with patch( + "genie.libs.clean.stages.iosxe.cat9k.stages.Dialog.process") as dialog_mock: + dialog_mock.side_effect = Exception + cls.install_image(steps=steps, device=device, images=['sftp://server/image.bin']) + + self.assertEqual(Failed, steps.details[0].result) \ No newline at end of file diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/image_handler.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/image_handler.py index 7ccc1e14f..1f309abcd 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/image_handler.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/image_handler.py @@ -79,7 +79,10 @@ def valid_structure_1(self, images): return False if len(images) == 1: - setattr(self, "image", images) + if "smu" in images[0]: + setattr(self, "smu", images) + else: + setattr(self, "image", images) return True if len(images) >= 2: setattr(self, "image", images[:1]) @@ -162,6 +165,7 @@ class ImageHandler(BaseImageHandler, ImageLoader): def __init__(self, device, images, *args, **kwargs): # Set default + self.image = [] self.smu = [] self.packages = [] self.other = [] @@ -171,7 +175,7 @@ def __init__(self, device, images, *args, **kwargs): ImageLoader.load(self, images) # Temp workaround for XPRESSO - self.image = [self.image[0].replace("file://", "")] + self.image = [self.image[0].replace("file://", "")] if self.image else [] if hasattr(self, "smu"): self.smu = [x.replace("file://", "") for x in self.smu] @@ -182,7 +186,7 @@ def __init__(self, device, images, *args, **kwargs): if hasattr(self, "other"): self.other = [x.replace("file://", "") for x in self.other] - self.original_image = [self.image[0].replace("file://", "")] + self.original_image = [self.image[0].replace("file://", "")] if self.image else [] super().__init__(device, *args, **kwargs) diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py index aa637b267..c27ef4dff 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py @@ -627,6 +627,13 @@ class InstallRemoveInactive(BaseStage): # ============================== exec_order = ["remove_inactive_pkgs"] + def __call__(self, **parameters): + images = parameters.get('images') + if not images: + self.skipped('Base image not provided. Skipping install remove inactive') + return + super().__call__(**parameters) + def remove_inactive_pkgs( self, steps, device, images, timeout=TIMEOUT, force_remove=FORCE_REMOVE ): @@ -786,6 +793,13 @@ class InstallImage(BaseStage): "install_image", ] + def __call__(self, **parameters): + images = parameters.get('images') + if not images: + self.skipped('Base image not provided. Skipping the install image stage.') + return + super().__call__(**parameters) + def verify_running_image( self, steps, device, images, verify_running_image=VERIFY_RUNNING_IMAGE ): @@ -808,7 +822,7 @@ def verify_running_image( # If neither is found, fail to match the image xe_version = out.get("version", {}).get("xe_version", "") build_label = out.get("version", {}).get("build_label", "") - image_version = build_label or xe_version + image_version = xe_version or build_label image_match = re.search(image_version, images[0]) if image_match and image_match.group(): image_mapping = self.history[ @@ -816,10 +830,22 @@ def verify_running_image( ].parameters.setdefault("image_mapping", {}) system_image = device.api.get_running_image() image_mapping.update({images[0]: system_image}) - self.skipped( - f"The image file provided is same as the current running image {image_version} on the device.\n\ - Skipping the install image stage." - ) + + log.info(f'Unconfigure the ignore startup config on {device.name}') + try: + device.api.unconfigure_ignore_startup_config() + except Exception as e: + step.failed(f"Failed to unconfigure ignore startup config on the device {device.name}", + from_exception=e) + + log.info(f'Verify the ignore startup config') + if not device.api.verify_ignore_startup_config(): + step.failed(f"Failed to verify unconfigure the ignore startup config on {device.name}") + else: + self.skipped( + f"The image file provided is same as the current running image {image_version} on the device.\n\ + Skipping the install image stage." + ) def delete_boot_variable( self, steps, device, issu=ISSU, skip_boot_variable=SKIP_BOOT_VARIABLE @@ -1063,7 +1089,7 @@ def remove_smu_image( force_remove=FORCE_REMOVE, ): - with steps.start("Removing SMU image") as step: + with steps.start("Removing SMU image") as super_step: def _check_for_system_image( spawn, system_image=None, force_remove=None @@ -1095,7 +1121,7 @@ def _check_for_system_image( if reload_service_args: reload_args.update(reload_service_args) - with steps.start("Checking status of SMU image") as step: + with super_step.start("Checking status of SMU image") as step: try: output = device.parse("show install summary") location = list(output.get("location").keys())[0] @@ -1122,7 +1148,7 @@ def _check_for_system_image( step.skipped("No smu image to remove") if file_state == "C" and file_type == "SMU": - with steps.start(f"Deactivate the smu image '{image}'") as step: + with step.start(f"Deactivate the smu image '{image}'") as sub_step: try: install_smu_dialog = Dialog( [ @@ -1156,11 +1182,11 @@ def _check_for_system_image( ) device.parse("show install summary") except Exception as e: - step.failed( + sub_step.failed( "Failed to deactivate SMU image", from_exception=e ) - with steps.start("commit the smu image") as step: + with step.start("commit the smu image") as sub_step: try: output = device.parse("show install summary") location = list(output.get("location").keys())[0] @@ -1175,9 +1201,9 @@ def _check_for_system_image( device.execute("show install summary") log.info("The image is in inactivate state") except Exception as e: - step.failed("Failed to commit SMU image", from_exception=e) + sub_step.failed("Failed to commit SMU image", from_exception=e) - with steps.start("Remove inactive smu image") as step: + with step.start("Remove inactive smu image") as sub_step: try: install_remove_smu_inactive_dialog = Dialog( [ @@ -1196,18 +1222,18 @@ def _check_for_system_image( timeout=timeout, ) except Exception as e: - step.failed("Failed to remove inactive smu image", from_exception=e) + sub_step.failed("Failed to remove inactive smu image", from_exception=e) elif file_state == "D" and file_type == "SMU": - with steps.start("commit the smu image") as step: + with step.start("commit the smu image") as sub_step: try: device.execute("install commit") device.execute("show install summary") log.info("The image is in inactivate state") except Exception as e: - step.failed("Failed to commit SMU image", from_exception=e) + sub_step.failed("Failed to commit SMU image", from_exception=e) - with steps.start("Remove inactive smu image") as step: + with step.start("Remove inactive smu image") as sub_step: try: install_remove_smu_inactive_dialog = Dialog( [ @@ -1226,7 +1252,7 @@ def _check_for_system_image( timeout=timeout, ) except Exception as e: - step.failed("Failed to remove inactive packages", from_exception=e) + sub_step.failed("Failed to remove inactive packages", from_exception=e) else: step.skipped("SMU image is in inactive state") @@ -1327,12 +1353,12 @@ def install_smu( reload_service_args=None, ): - with steps.start("Installing smu image") as step: + with steps.start("Installing smu image") as super_step: if not images: - step.skipped("No smu image provided, skipping install_smu stage") + super_step.skipped("No smu image provided, skipping install_smu stage") if "smu" not in images[0]: - step.skipped("No smu image provided, skipping install_smu stage") + super_step.skipped("No smu image provided, skipping install_smu stage") # Set default reload args reload_args = self.RELOAD_SERVICE_ARGS.copy() @@ -1368,13 +1394,13 @@ def install_smu( ] ) - with steps.start(f"Add SMU image : '{images[0]}'") as step: + with super_step.start(f"Add SMU image : '{images[0]}'") as step: try: device.execute("install add file {}".format(images[0])) except Exception as e: step.failed("Failed to add SMU image", from_exception=e) - with steps.start("Verify SMU image is added successfully") as step: + with super_step.start("Verify SMU image is added successfully") as step: try: output = device.parse("show install summary") location = list(output.get("location").keys())[0] @@ -1393,7 +1419,7 @@ def install_smu( except Exception as e: step.failed("Failed to verify SMU image", from_exception=e) - with steps.start(f"Activate the SMU file with image '{images[0]}'") as step: + with super_step.start(f"Activate the SMU file with image '{images[0]}'") as step: try: reload_args.update( {"timeout": install_timeout, "reply": install_smu_dialog} @@ -1406,7 +1432,7 @@ def install_smu( except Exception as e: step.failed("Failed to activate SMU image", from_exception=e) - with steps.start("Commit the SMU file with image") as step: + with super_step.start("Commit the SMU file with image") as step: try: output = device.parse("show install active") location = list(output.get("location").keys())[0] @@ -1420,7 +1446,7 @@ def install_smu( except Exception as e: step.failed("Failed to activate SMU image", from_exception=e) - with steps.start("Check if SMU is applied succesfully") as step: + with super_step.start("Check if SMU is applied succesfully") as step: try: output = device.parse("show install summary") for pkg in output.get("location").get(location).get("pkg_state"): @@ -1688,7 +1714,7 @@ def break_reload(device): self.reload_service_args.update({"reply": reload_dialog}) - with steps.start(f"Reload {device.name}") as step: + with steps.start(f"Reload {device.name}") as super_step: try: device.reload(**self.reload_service_args) @@ -1722,7 +1748,7 @@ def break_reload(device): if con.role == "standby": con.context["boot_cmd"] = cmd - with steps.start(f"Reload using manual boot for {device.name}") as step: + with super_step.start(f"Reload using manual boot for {device.name}") as step: try: device.reload(reload_command=cmd) except Exception as e: @@ -1737,7 +1763,7 @@ def break_reload(device): device.api.execute_set_config_register(config_register=config_reg) except Exception as e: - step.failed( + super_step.failed( f"Failed to reload within {self.reload_service_args['timeout']} " f"seconds.", from_exception=e, @@ -2835,6 +2861,9 @@ def copy_to_device( device.name, dest ) ) + else: + step.skipped(f"Skip verifying free space on the device '{device.name}'" + " because skip_deletion is set to True") # Copy the file to the devices for file, file_data in files_to_copy.items(): diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_copy_to_device.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_copy_to_device.py index 3cd24f91d..f3b13b811 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_copy_to_device.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_copy_to_device.py @@ -472,3 +472,82 @@ def __call__(self, cmd, *args, **kwargs): self.assertEqual(Skipped, steps.details[1].result) self.assertEqual(skipped_reason, steps.details[1].result.reason) + + def test_copy_to_device_skip_deletion_true(self): + class MockExecute: + + def __init__(self, *args, **kwargs): + self.data = { + 'dir bootflash:': iter([ + ''' + Directory of bootflash:/ + 11 drwx 16384 Nov 25 2016 19:32:53 -07:00 lost+found + 12 -rw- 0 Dec 13 2016 11:36:36 -07:00 ds_stats.txt + 104417 drwx 4096 Apr 10 2017 09:09:11 -07:00 .prst_sync + 80321 drwx 4096 Nov 25 2016 19:40:38 -07:00 .rollback_timer + 64257 drwx 4096 Nov 25 2016 19:41:02 -07:00 .installer + 48193 drwx 4096 Nov 25 2016 19:41:14 -07:00 virtual-instance-stby-sync + 1940303872 bytes total (1036210176 bytes free) + ''', + f''' + Directory of bootflash:/ + 11 drwx 16384 Nov 25 2016 19:32:53 -07:00 lost+found + 12 -rw- 0 Dec 13 2016 11:36:36 -07:00 ds_stats.txt + 104417 drwx 4096 Apr 10 2017 09:09:11 -07:00 .prst_sync + 80321 drwx 4096 Nov 25 2016 19:40:38 -07:00 .rollback_timer + 64257 drwx 4096 Nov 25 2016 19:41:02 -07:00 .installer + 48193 drwx 4096 Nov 25 2016 19:41:14 -07:00 virtual-instance-stby-sync + 8033 drwx 4096 Nov 25 2016 18:42:07 -07:00 test.bin + 1940303872 bytes total (1036210176 bytes free) + ''' + ]), + 'copy scp://127.0.0.1//path/test.bin bootflash:/test.bin': iter(['Copied file']), + } + + def __call__(self, cmd, *args, **kwargs): + output = next(self.data[cmd]) + return output + + mock_execute = MockExecute() + + # And we want the execute method to be mocked with device console output. + self.device.execute = Mock(side_effect=mock_execute) + + steps = Steps() + + testbed = Testbed('mytb', servers={ + 'server1': { + 'address': '127.0.0.1', + 'protocol': 'scp' + } + }) + + self.device.testbed = testbed + + # Call the method to be tested (clean step inside class) + with self.assertLogs(level='INFO') as log: + self.cls.copy_to_device( + steps=steps, device=self.device, + origin=dict( + files=[f'/path/test.bin'], + hostname='server1' + ), + destination=dict( + directory='bootflash:' + ), + protocol='scp', + verify_running_image=False, + skip_deletion=True + ) + self.assertIn(f"INFO:pyats.aetest.steps.implementation:Skipped reason: Skip verifying free space on the device '{self.device.name}' because skip_deletion is set to True", + log.output) + + # Check that the result is expected + self.assertEqual(Passed, steps.details[0].result) + self.device.execute.assert_has_calls([ + call('dir bootflash:'), + call(f'copy scp://127.0.0.1//path/test.bin bootflash:/test.bin', + prompt_recovery=False, timeout=300, reply=ANY, + error_pattern=ANY), + call('dir bootflash:') + ]) diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_image_handler.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_image_handler.py index 3f2fcdf52..568630264 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_image_handler.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_image_handler.py @@ -183,6 +183,17 @@ def test_structure_3_with_packages(self): self.assertEqual(image_handler.smu, self.EXPECTED_SMU) self.assertEqual(image_handler.packages, self.EXPECTED_DOUBLE_PKG) + def test_image_handler_without_base_image(self): + images = [ + self.SMU + ] + + image_handler = ImageHandler(self.device, images) + # since the smu image is passed instead of base image + self.EXPECTED_IMAGE = [] + self.assertEqual(image_handler.image, self.EXPECTED_IMAGE) + self.assertEqual(image_handler.smu, self.EXPECTED_SMU) + class InvalidStructures(unittest.TestCase): def setUp(self): diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_install_image.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_install_image.py index 5241f3b7c..9a0df6383 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_install_image.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/tests/test_install_image.py @@ -415,6 +415,8 @@ def setUp(self): self.device = create_test_device('PE1', os='iosxe', platform='cat9k') def test_iosxe_verify_running_image_skipped(self): + self.device.api.unconfigure_ignore_startup_config = Mock() + self.device.api.verify_ignore_startup_config = Mock() class MockExecute: def __init__(self, *args, **kwargs): @@ -503,3 +505,89 @@ def __call__(self, cmd, *args, **kwargs): self.assertEqual(self.cls.history['InstallImage'].parameters['image_mapping'], {'/path/asr1000-universalk9.BLD_MCP_DEV_LATEST_20110615_044519.SSA.bin': 'flash:/asr1000-universalk9.BLD_MCP_DEV_LATEST_20110615_044519.SSA.bin'}) + + self.device.api.verify_ignore_startup_config.assert_called_once() + + def test_iosxe_verify_running_image_failed(self): + self.device.api.unconfigure_ignore_startup_config = Mock() + self.device.api.verify_ignore_startup_config = Mock() + class MockExecute: + def __init__(self, *args, **kwargs): + self.data = { + 'show version': ''' +Cisco IOS Software, IOS-XE Software (X86_64_LINUX_IOSD-ADVENTERPRISEK9-M), Experimental Version 15.2(20110615:055721) [mcp_dev-BLD-BLD_MCP_DEV_LATEST_20110615_044519-ios 143] +Copyright (c) 1986-2011 by Cisco Systems, Inc. +Compiled Wed 15-Jun-11 08:54 by mcpre + + +Cisco IOS-XE software, Copyright (c) 2005-2011 by cisco Systems, Inc. +All rights reserved. Certain components of Cisco IOS-XE software are +licensed under the GNU General Public License ("GPL") Version 2.0. The +software code licensed under GPL Version 2.0 is free software that comes +with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such +GPL code under the terms of GPL Version 2.0. For more details, see the +documentation or "License Notice" file accompanying the IOS-XE software, +or the applicable URL provided on the flyer accompanying the IOS-XE +software. + + +ROM: IOS-XE ROMMON +ROM: Cisco IOS Software, IOS-XE Software (X86_64_LINUX_IOSD-ADVENTERPRISEK9-M), Experimental Version 15.2(20110615:055721) [mcp_dev-BLD-BLD_MCP_DEV_LATEST_20110615_044519-ios 143] + +issu-asr-lns uptime is 1 hour, 16 minutes +Uptime for this control processor is 1 hour, 17 minutes +System returned to ROM by reload +System image file is "flash:/asr1000-universalk9.BLD_MCP_DEV_LATEST_20110615_044519.SSA.bin" +Last reload reason: Reload Command + + + +This product contains cryptographic features and is subject to United +States and local country laws governing import, export, transfer and +use. Delivery of Cisco cryptographic products does not imply +third-party authority to import, export, distribute or use encryption. +Importers, exporters, distributors and users are responsible for +compliance with U.S. and local country laws. By using this product you +agree to comply with applicable laws and regulations. If you are unable +to comply with U.S. and local laws, return this product immediately. + +A summary of U.S. laws governing Cisco cryptographic products may be found at: +http://www.cisco.com/wwl/export/crypto/tool/stqrg.html + +If you require further assistance please contact us by sending email to +export@cisco.com. + +cisco ASR1006 (RP2) processor with 4254354K/6147K bytes of memory. +3 ATM interfaces +32768K bytes of non-volatile configuration memory. +8388608K bytes of physical memory. +1826815K bytes of eUSB flash at bootflash:. +78085207K bytes of SATA hard disk at harddisk:. + +Configuration register is 0x1 + ''' + } + + def __call__(self, cmd, *args, **kwargs): + output = self.data.get(cmd) + return output + + + mock_execute = MockExecute() + self.device.execute = Mock(side_effect=mock_execute) + + steps = Steps() + + self.cls.history = OrderedDict() + self.cls.mock_value = OrderedDict() + setattr(self.cls.mock_value, 'parameters', {}) + self.cls.history.update({'InstallImage': self.cls.mock_value}) + self.cls.history['InstallImage'].parameters = OrderedDict() + + self.device.api.verify_ignore_startup_config.return_value = False + + with self.assertRaises(TerminateStepSignal): + self.cls.verify_running_image(steps=steps, + device=self.device, + images=['/path/asr1000-universalk9.BLD_MCP_DEV_LATEST_20110615_044519.SSA.bin'] + ) \ No newline at end of file diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py index 3295ce128..214d56f20 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py @@ -709,7 +709,7 @@ def copy_to_linux(self, steps, device, origin, destination, protocol=PROTOCOL, step.failed("File size is not the same on the origin" " and on the file server") else: - self.passed("File size is the same on the origin " + step.passed("File size is the same on the origin " "and on the file server") except Exception as e: step.failed("Failed to verify file. Error: {}".format( @@ -1162,6 +1162,9 @@ def copy_to_device(self, steps, device, origin, destination, step.failed("Error while creating free space for " "image on device {} {}".\ format(device.name, dest)) + else: + step.skipped(f"Skip verifying free space on the device '{device.name}'" + " because skip_deletion is set to True") # Copy the file to the devices for file, file_data in files_to_copy.items(): diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/tests/test_copy_to_device.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/tests/test_copy_to_device.py index 459744387..629009513 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/tests/test_copy_to_device.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/tests/test_copy_to_device.py @@ -330,3 +330,82 @@ def __call__(self, cmd, *args, **kwargs): error_pattern=ANY), call('dir bootflash:') ]) + + + def test_copy_to_device_skip_deletion_true(self): + class MockExecute: + + def __init__(self, *args, **kwargs): + self.data = { + 'dir bootflash:': iter([ + ''' + Directory of bootflash:/ + 11 drwx 16384 Nov 25 2016 19:32:53 -07:00 lost+found + 12 -rw- 0 Dec 13 2016 11:36:36 -07:00 ds_stats.txt + 104417 drwx 4096 Apr 10 2017 09:09:11 -07:00 .prst_sync + 80321 drwx 4096 Nov 25 2016 19:40:38 -07:00 .rollback_timer + 64257 drwx 4096 Nov 25 2016 19:41:02 -07:00 .installer + 48193 drwx 4096 Nov 25 2016 19:41:14 -07:00 virtual-instance-stby-sync + 1940303872 bytes total (1036210176 bytes free) + ''', + f''' + Directory of bootflash:/ + 11 drwx 16384 Nov 25 2016 19:32:53 -07:00 lost+found + 12 -rw- 0 Dec 13 2016 11:36:36 -07:00 ds_stats.txt + 104417 drwx 4096 Apr 10 2017 09:09:11 -07:00 .prst_sync + 80321 drwx 4096 Nov 25 2016 19:40:38 -07:00 .rollback_timer + 64257 drwx 4096 Nov 25 2016 19:41:02 -07:00 .installer + 48193 drwx 4096 Nov 25 2016 19:41:14 -07:00 virtual-instance-stby-sync + 8033 drwx 4096 Nov 25 2016 18:42:07 -07:00 test.bin + 1940303872 bytes total (1036210176 bytes free) + ''' + ]), + 'copy scp://127.0.0.1//path/test.bin bootflash:/test.bin': iter(['Copied file']), + } + + def __call__(self, cmd, *args, **kwargs): + output = next(self.data[cmd]) + return output + + mock_execute = MockExecute() + + # And we want the execute method to be mocked with device console output. + self.device.execute = Mock(side_effect=mock_execute) + + steps = Steps() + + testbed = Testbed('mytb', servers={ + 'server1': { + 'address': '127.0.0.1', + 'protocol': 'scp' + } + }) + + self.device.testbed = testbed + + # Call the method to be tested (clean step inside class) + with self.assertLogs(level='INFO') as log: + self.cls.copy_to_device( + steps=steps, device=self.device, + origin=dict( + files=[f'/path/test.bin'], + hostname='server1' + ), + destination=dict( + directory='bootflash:' + ), + protocol='scp', + skip_deletion=True + ) + self.assertIn(f"INFO:pyats.aetest.steps.implementation:Skipped reason: Skip verifying free space on the device '{self.device.name}' because skip_deletion is set to True", + log.output) + + # Check that the result is expected + self.assertEqual(Passed, steps.details[0].result) + self.device.execute.assert_has_calls([ + call('dir bootflash:'), + call(f'copy scp://127.0.0.1//path/test.bin bootflash:/test.bin', + prompt_recovery=False, timeout=300, reply=ANY, + error_pattern=ANY), + call('dir bootflash:') + ]) diff --git a/pkgs/clean-pkg/src/genie/libs/clean/templates/iosxe/templates.py b/pkgs/clean-pkg/src/genie/libs/clean/templates/iosxe/templates.py index 37ea6e417..06cf8fe21 100644 --- a/pkgs/clean-pkg/src/genie/libs/clean/templates/iosxe/templates.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/templates/iosxe/templates.py @@ -1,9 +1,80 @@ +from copy import deepcopy + DEFAULT = { 'connect': {}, - 'order': ['connect', - ] + 'reset_configuration': {}, + + 'apply_configuration': { + 'configuration': r"%CLEANARG{apply_configuration__configuration}", + }, + + 'install_remove_inactive': { + 'timeout': r"%CLEANARG{install_remove_inactive__timeout}" + }, + + 'install_remove_smu': { + 'timeout': r"%CLEANARG{install_remove_smu__timeout}" + }, + + 'configure_management': { + 'protocols': r"%CLEANARG{configure_management__protocols}", + }, + + 'copy_to_device': { + 'destination': { + 'directory': r"%CLEANARG{copy_to_device__destination_directory}", + }, + 'protocol': r"%CLEANARG{copy_to_device__protocol}", + 'overwrite': r"%CLEANARG{copy_to_device__overwrite}", + 'expected_num_images': r"%CLEANARG{copy_to_device__expected_num_images}", + 'timeout': r"%CLEANARG{copy_to_device__timeout}", + 'check_file_stability': r"%CLEANARG{copy_to_device__check_file_stability}" + }, + + 'install_image': { + 'install_timeout': r"%CLEANARG{install_image__install_timeout}", + 'reload_timeout': r"%CLEANARG{install_image__reload_timeout}", + }, + + 'install_smu': { + 'install_timeout': r"%CLEANARG{install_smu__install_timeout}", + 'reload_timeout': r"%CLEANARG{install_smu__reload_timeout}", + }, + + 'order': [ + 'connect', + 'reset_configuration', + 'install_remove_inactive', + 'install_remove_smu', + 'configure_management', + 'apply_configuration', + 'copy_to_device', + 'install_image', + 'install_smu' + ] } DEFAULT_ARGS = { -} \ No newline at end of file + "copy_to_device__destination_directory": "bootflash:", + "copy_to_device__timeout": 1800, + "copy_to_device__overwrite": False, + "copy_to_device__check_file_stability": False, + "configure_management__protocols": ['telnet', 'ssh', 'netconf', 'tftp', 'http'], + "install_image__install_timeout": 1800, + "install_image__reload_timeout": 1800, + "install_smu__install_timeout": 700, + "install_smu__reload_timeout": 700, + "install_remove_inactive__timeout": 180, + "install_remove_smu__timeout": 700, + "apply_configuration__configuration": "", + "copy_to_device__protocol": "http", + "copy_to_device__expected_num_images": 1, +} + + +# LOAD_IMAGE +LOAD_IMAGE = deepcopy(DEFAULT) +LOAD_IMAGE.pop('reset_configuration') +LOAD_IMAGE.get('order').remove('reset_configuration') +LOAD_IMAGE_ARGS = deepcopy(DEFAULT_ARGS) \ No newline at end of file diff --git a/pkgs/conf-pkg/changelog/2024/november.rst b/pkgs/conf-pkg/changelog/2024/november.rst new file mode 100644 index 000000000..bb97109f4 --- /dev/null +++ b/pkgs/conf-pkg/changelog/2024/november.rst @@ -0,0 +1,27 @@ +-------------------------------------------------------------------------------- + New +-------------------------------------------------------------------------------- + +* nxos + * Added + * neighbor \ bfd multihop + * Added associate_vrf_name attributes under vlan + * associate_vrf_name = 'vxlan-1001' + * Added + * enabled redistribute AM routes + * router bgp \ address-family ipv4|ipv6 unicast \ redistribute am route-map + + +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* nxos + * Modified ipv6addr.py + * changed route_tag type to str from bool to read the route_tag values + * Modified ipv4addr.py + * Modified 'tag' to 'route_tag' for configuring route_tag + * Modified route_policy.py + * Reading 'match_tag' for configuring match_tag under route policy + + diff --git a/pkgs/conf-pkg/src/genie/libs/conf/__init__.py b/pkgs/conf-pkg/src/genie/libs/conf/__init__.py index 917f591ad..43aeba77d 100644 --- a/pkgs/conf-pkg/src/genie/libs/conf/__init__.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/__init__.py @@ -12,7 +12,7 @@ ''' # metadata -__version__ = '24.10' +__version__ = '24.11' __author__ = 'Cisco Systems Inc.' __contact__ = ['pyats-support@cisco.com', 'pyats-support-ext@cisco.com'] __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' diff --git a/pkgs/conf-pkg/src/genie/libs/conf/bgp/bgp.py b/pkgs/conf-pkg/src/genie/libs/conf/bgp/bgp.py index a3228e9cb..0984b8d66 100644 --- a/pkgs/conf-pkg/src/genie/libs/conf/bgp/bgp.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/bgp/bgp.py @@ -634,6 +634,11 @@ class AF_LABEL_ALLOCATION_MODE(Enum): default=None, type=(None, managedattribute.test_istype(bool))) + af_redist_am = managedattribute( + name='af_redist_am', + default=None, + type=(None, managedattribute.test_istype(bool))) + af_redist_connected_metric = managedattribute( name='af_redist_connected_metric', default=None, @@ -644,6 +649,11 @@ class AF_LABEL_ALLOCATION_MODE(Enum): default=None, type=(None, managedattribute.test_istype(str))) + af_redist_am_route_policy = managedattribute( + name='af_redist_am_route_policy', + default=None, + type=(None, managedattribute.test_istype(str))) + af_v6_aggregate_address_ipv6_address = managedattribute( name='af_v6_aggregate_address_ipv6_address', default=None, @@ -755,6 +765,11 @@ class NBR_SEND_COMMUNITY(Enum): default=None, type=(None, managedattribute.test_istype(bool))) + nbr_fall_over_bfd_mh = managedattribute( + name='nbr_fall_over_bfd_mh', + default=None, + type=(None, managedattribute.test_istype(bool))) + nbr_suppress_four_byte_as_capability = managedattribute( name='nbr_suppress_four_byte_as_capability', default=None, diff --git a/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/bgp.py b/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/bgp.py index a6b961ef4..f10603654 100644 --- a/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/bgp.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/bgp.py @@ -652,6 +652,14 @@ def build_config(self, apply=True, attributes=None, 'redistribute direct route-map ' '{af_redist_connected_route_policy}')) + # nxos: address-family ipv4|ipv6 unicast/ + # redistribute am route-map + if attributes.value('af_redist_am'): + configurations.append_line( + attributes.format( + 'redistribute am route-map ' + '{af_redist_am_route_policy}')) + if attributes.value('af_default_metric'): configurations.append_line( attributes.format( @@ -881,6 +889,11 @@ def build_config(self, apply=True, attributes=None, configurations.append_line( attributes.format('bfd')) + # nxos: neighbor \ bfd multihop + if attributes.value('nbr_fall_over_bfd_mh'): + configurations.append_line( + attributes.format('bfd multihop')) + # nxos: neighbor \ # capability suppress 4-byte-as if attributes.value( diff --git a/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/tests/test_bgp.py b/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/tests/test_bgp.py index 99362ba7e..cf6344144 100755 --- a/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/tests/test_bgp.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/bgp/nxos/tests/test_bgp.py @@ -263,6 +263,8 @@ def test_cfg(self): bgp.device_attr[dev1].vrf_attr[None].neighbor_attr[neighbor_id] bgp.device_attr[dev1].vrf_attr[None].neighbor_attr[neighbor_id]. \ nbr_fall_over_bfd = True + bgp.device_attr[dev1].vrf_attr[None].neighbor_attr[neighbor_id].\ + nbr_fall_over_bfd_mh = True bgp.device_attr[dev1].vrf_attr[None].neighbor_attr[neighbor_id]. \ nbr_shutdown = True nbr_af_name = 'ipv4 unicast' @@ -284,6 +286,7 @@ def test_cfg(self): ' timers prefix-peer-timeout 10', ' neighbor 10.2.0.2', ' bfd', + ' bfd multihop', ' shutdown', ' address-family ipv4 unicast', ' allowas-in', @@ -488,6 +491,8 @@ def test_uncfg(self): bgp.device_attr[dev1].vrf_attr[vrf1].neighbor_attr[neighbor_id] bgp.device_attr[dev1].vrf_attr[vrf1].neighbor_attr[neighbor_id].\ nbr_fall_over_bfd = True + bgp.device_attr[dev1].vrf_attr[vrf1].neighbor_attr[neighbor_id].\ + nbr_fall_over_bfd_mh = True nbr_af_name = 'ipv4 unicast' bgp.device_attr[dev1].vrf_attr[vrf1].neighbor_attr[neighbor_id].\ address_family_attr[nbr_af_name] @@ -1027,6 +1032,205 @@ def test_cfg_bgp(self): ' exit', ' exit', ])) + + def test_cfg_am_redistribute(self): + self.maxDiff = None + Genie.testbed = testbed = Testbed() + dev1 = Device(testbed=testbed, name='PE1', os='nxos') + bgp = Bgp(bgp_id=35000) + + # Defining attributes + af_name = 'ipv4 unicast' + vrf = Vrf('srmpls-1012') + + self.assertIs(bgp.testbed, testbed) + dev1.add_feature(bgp) + + bgp.device_attr[dev1].vrf_attr[vrf].address_family_attr[af_name].\ + af_redist_am = True + bgp.device_attr[dev1].vrf_attr[vrf].address_family_attr[af_name].\ + af_redist_am_route_policy = 'permitall' + + bgp.device_attr[dev1] + + self.assertIs(bgp.testbed, testbed) + dev1.add_feature(bgp) + + cfgs = bgp.build_config(apply=False) + self.assertCountEqual(cfgs.keys(), [dev1.name]) + self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join( + ['router bgp 35000', + ' vrf srmpls-1012', + ' address-family ipv4 unicast', + ' redistribute am route-map permitall', + ' exit', + ' exit', + ' exit', + ])) + + # Defining attributes + af_name = 'ipv4 unicast' + vrf = Vrf('default') + neighbor_id='150.101.30.30' + bgp.device_attr[dev1].vrf_attr[vrf].bestpath_multipath_relax = True + bgp.device_attr[dev1].vrf_attr[vrf].address_family_attr[af_name].af_additional_paths_install_backup = True + bgp.device_attr[dev1].vrf_attr[vrf].address_family_attr[af_name].af_v4_allocate_label_all = True + bgp.device_attr[dev1].vrf_attr[vrf].address_family_attr['vpnv4 unicast'].af_allocate_label_option_b = True + bgp.device_attr[dev1].vrf_attr[vrf].address_family_attr['vpnv6 unicast'].af_allocate_label_option_b = True + bgp.device_attr[dev1].vrf_attr[vrf].neighbor_attr[neighbor_id] + bgp.device_attr[dev1].vrf_attr[vrf].neighbor_attr[neighbor_id].address_family_attr['l2vpn evpn'].nbr_af_encap_mpls = True + bgp.device_attr[dev1].vrf_attr[vrf].neighbor_attr[neighbor_id].address_family_attr['l2vpn evpn'].nbr_af_import_vpn_unicast_reoriginate = True + bgp.device_attr[dev1].vrf_attr[vrf].neighbor_attr[neighbor_id].address_family_attr['vpnv4 unicast'].nbr_af_import_l2vpn_evpn_reoriginate = True + bgp.device_attr[dev1].vrf_attr[vrf].neighbor_attr[neighbor_id].address_family_attr['vpnv6 unicast'].nbr_af_import_l2vpn_evpn_reoriginate = True + bgp.device_attr[dev1].vrf_attr['vrf8'].bestpath_multipath_relax = True + bgp.device_attr[dev1].vrf_attr['vrf8'].allocate_index = 80 + bgp.device_attr[dev1].vrf_attr['vrf8'].neighbor_attr['101.100.30.30'] + bgp.device_attr[dev1].vrf_attr['vrf8'].neighbor_attr['101.100.30.30'].address_family_attr[af_name].nbr_af_weight = 10 + + self.assertIs(bgp.testbed, testbed) + dev1.add_feature(bgp) + + cfgs = bgp.build_config(apply=False) + print(cfgs) + self.assertCountEqual(cfgs.keys(), [dev1.name]) + self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join( + ['router bgp 35000', + ' bestpath as-path multipath-relax', + ' neighbor 150.101.30.30', + ' address-family l2vpn evpn', + ' encapsulation mpls', + ' import vpn unicast reoriginate', + ' exit', + ' address-family vpnv4 unicast', + ' import l2vpn evpn reoriginate', + ' exit', + ' address-family vpnv6 unicast', + ' import l2vpn evpn reoriginate', + ' exit', + ' exit', + ' address-family ipv4 unicast', + ' allocate-label all', + ' additional-paths install backup', + ' exit', + ' address-family vpnv4 unicast', + ' allocate-label option-b', + ' exit', + ' address-family vpnv6 unicast', + ' allocate-label option-b', + ' exit', + ' vrf srmpls-1012', + ' address-family ipv4 unicast', + ' redistribute am route-map permitall', + ' exit', + ' exit', + ' vrf vrf8', + ' bestpath as-path multipath-relax', + ' allocate-index 80', + ' neighbor 101.100.30.30', + ' address-family ipv4 unicast', + ' weight 10', + ' exit', + ' exit', + ' exit', + ' exit', + ])) + print('cfg of bgp new args') + print(cfgs[dev1.name]) + uncfgs = bgp.build_unconfig( + apply=False, + attributes={ + 'device_attr': { + '*': { + 'vrf_attr': { + '*': { + 'bestpath_multipath_relax': None, # Unconfigure multipath relax + 'neighbor_attr': { + '150.101.30.30': { # Neighbor to be unconfigured + 'address_family_attr': { + 'l2vpn evpn': { # Address family for neighbor + 'nbr_af_encap_mpls': None, # Unconfigure MPLS encapsulation + 'nbr_af_import_vpn_unicast_reoriginate': None + }, + 'vpnv4 unicast': { + 'nbr_af_import_l2vpn_evpn_reoriginate': None, + }, + 'vpnv6 unicast': { + 'nbr_af_import_l2vpn_evpn_reoriginate': None, + }, + } + } + }, + 'address_family_attr': { + 'ipv4 unicast': { + 'af_additional_paths_install_backup': None, # Unconfigure additional paths + 'af_v4_allocate_label_all': None # Unconfigure label allocation + }, + 'vpnv4 unicast': { + 'af_allocate_label_option_b': None # Unconfigure label option for vpnv4 + }, + 'vpnv6 unicast': { + 'af_allocate_label_option_b': None # Unconfigure label option for vpnv6 + } + } + }, + 'vrf8': { + 'bestpath_multipath_relax': None, # Unconfigure multipath relax for vrf8 + 'allocate_index': 80, # Unconfigure specific allocate index + 'neighbor_attr': { + '101.100.30.30': { # Neighbor to be unconfigured + 'address_family_attr': { + 'ipv4 unicast': { # Address family for neighbor + 'nbr_af_weight': 10 # Unconfigure MPLS encapsulation + } + } + } + } + } + } + } + } + } + ) + print('ucfg of bgp args') + print(uncfgs[dev1.name]) + self.assertCountEqual(uncfgs.keys(), [dev1.name]) + self.maxDiff = None + self.assertMultiLineEqual(str(uncfgs[dev1.name]), '\n'.join( + ['router bgp 35000', + ' no bestpath as-path multipath-relax', + ' neighbor 150.101.30.30', + ' address-family l2vpn evpn', + ' no encapsulation mpls', + ' no import vpn unicast reoriginate', + ' exit', + ' address-family vpnv4 unicast', + ' no import l2vpn evpn reoriginate', + ' exit', + ' address-family vpnv6 unicast', + ' no import l2vpn evpn reoriginate', + ' exit', + ' exit', + ' address-family ipv4 unicast', + ' no allocate-label all', + ' no additional-paths install backup', + ' exit', + ' address-family vpnv4 unicast', + ' no allocate-label option-b', + ' exit', + ' address-family vpnv6 unicast', + ' no allocate-label option-b', + ' exit', + ' vrf vrf8', + ' no bestpath as-path multipath-relax', + ' no allocate-index 80', + ' neighbor 101.100.30.30', + ' address-family ipv4 unicast', + ' no weight 10', + ' exit', + ' exit', + ' exit', + ' exit', + ])) if __name__ == '__main__': unittest.main() diff --git a/pkgs/conf-pkg/src/genie/libs/conf/interface/ipv6addr.py b/pkgs/conf-pkg/src/genie/libs/conf/interface/ipv6addr.py index 1b8ea8d30..51fd16d99 100644 --- a/pkgs/conf-pkg/src/genie/libs/conf/interface/ipv6addr.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/interface/ipv6addr.py @@ -55,7 +55,7 @@ def device(self): ipv6_route_tag = managedattribute( name='ipv6_route_tag', default=None, - type=(None, managedattribute.test_istype(bool)), + type=(None, managedattribute.test_istype(str)), doc='Route-tag to be associated with this address') # ipv6 redirect diff --git a/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/ipv4addr.py b/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/ipv4addr.py index b51cd2950..317c4c5c6 100755 --- a/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/ipv4addr.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/ipv4addr.py @@ -30,18 +30,14 @@ def build_config(self, apply=True, attributes=None, unconfig=False, if attributes.value('ipv4') and attributes.value('prefix_length'): if attributes.value('ipv4_secondary'): - configurations.append_line('ip address' - ' {ipv4}/{prefix_length} secondary' - .format(ipv4=attributes.value('ipv4'), - prefix_length=attributes.value('prefix_length'))) - if attributes.value('tag'): - configurations.append_line('ip address' - ' {ipv4}/{prefix_length} secondary' - ' tag {route_tag}' - .format(ipv4=attributes.value('ipv4'), - prefix_length=attributes.value('prefix_length'), - route_tag=attributes.value('route_tag'))) - elif attributes.value('tag'): + cmd_line = 'ip address {ipv4}/{prefix_length} secondary'.format( + ipv4=attributes.value('ipv4'), + prefix_length=attributes.value('prefix_length')) + if attributes.value('route_tag'): + cmd_line += ' tag {route_tag}'.format( + route_tag=attributes.value('route_tag')) + configurations.append_line(cmd_line) + elif attributes.value('route_tag'): configurations.append_line('ip address' ' {ipv4}/{prefix_length}' ' tag {route_tag}' diff --git a/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/tests/test_interface.py b/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/tests/test_interface.py index 902899b8a..07ff594b2 100755 --- a/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/tests/test_interface.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/interface/nxos/tests/test_interface.py @@ -904,11 +904,13 @@ def test_ipv4_multiple_lines_confg(self): ipv4a = IPv4Addr(device=dev1) ipv4a.ipv4 = IPv4Address('192.168.1.1') ipv4a.prefix_length = '24' + ipv4a.route_tag = '10' intf1.add_ipv4addr(ipv4a) ipv4b = IPv4Addr(device=dev1) ipv4b.ipv4 = IPv4Address('192.168.1.2') ipv4b.prefix_length = '24' ipv4b.ipv4_secondary = True + ipv4b.route_tag = '5' ipv4b.redirect = False intf1.add_ipv4addr(ipv4b) intf1.shutdown = False @@ -925,9 +927,9 @@ def test_ipv4_multiple_lines_confg(self): ' description multiple lines config', ' no shutdown', ' no switchport', - ' ip address 192.168.1.1/24', + ' ip address 192.168.1.1/24 tag 10', ' no ip redirects', - ' ip address 192.168.1.2/24 secondary', + ' ip address 192.168.1.2/24 secondary tag 5', ' no ip redirects', ' exit' ])) @@ -968,10 +970,12 @@ def test_ipv6_multiple_lines_confg(self): ipv6a = IPv6Addr(device=dev1) ipv6a.ipv6 = IPv6Address('2001:db1:1::1') ipv6a.ipv6_prefix_length = '64' + ipv6a.ipv6_route_tag = '10' intf1.add_ipv6addr(ipv6a) ipv6b = IPv6Addr(device=dev1) ipv6b.ipv6 = IPv6Address('2001:db1:2::2') ipv6b.ipv6_prefix_length = '64' + ipv6b.ipv6_route_tag = '15' ipv6b.redirect = False intf1.add_ipv6addr(ipv6b) intf1.shutdown = False @@ -988,9 +992,9 @@ def test_ipv6_multiple_lines_confg(self): ' description multiple lines config', ' no shutdown', ' no switchport', - ' ipv6 address 2001:db1:1::1/64', + ' ipv6 address 2001:db1:1::1/64 tag 10', ' no ipv6 redirects', - ' ipv6 address 2001:db1:2::2/64', + ' ipv6 address 2001:db1:2::2/64 tag 15', ' no ipv6 redirects', ' exit' ])) diff --git a/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/route_policy.py b/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/route_policy.py index b9ba6f5ac..0d5789405 100644 --- a/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/route_policy.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/route_policy.py @@ -137,6 +137,13 @@ def build_config(self, apply=True, attributes=None, unconfig=False, attributes.format('match ipv6 address prefix-list ' '{match_prefix_list_v6}')) + # nxos: match tag + # + if attributes.value('match_tag'): + configurations.append_line( + attributes.format('match tag ' + '{match_tag}')) + # nxos: set origin if attributes.value('set_route_origin'): configurations.append_line( diff --git a/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/tests/test_route_policy.py b/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/tests/test_route_policy.py index 4f52ae12f..330dbb293 100755 --- a/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/tests/test_route_policy.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/route_policy/nxos/tests/test_route_policy.py @@ -62,6 +62,21 @@ def test_basic_cfg(self): " exit" ])) + rpl3 = RoutePolicy(policy_definition='rpl3', + route_disposition='permit') + dev1.add_feature(rpl3) + + rpl3.device_attr[dev1].statement_attr['10'] + rpl3.device_attr[dev1].statement_attr['10'].match_tag = 5 + + cfgs = rpl3.build_config(apply=False) + self.assertCountEqual(cfgs.keys(), [dev1.name]) + self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join( + ['route-map rpl3 permit 10', + ' match tag 5', + ' exit' + ])) + def test_basic_uncfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='nxos') diff --git a/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/tests/test_vlan.py b/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/tests/test_vlan.py index 11f3cb023..14fa5e67c 100755 --- a/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/tests/test_vlan.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/tests/test_vlan.py @@ -637,5 +637,72 @@ def test_enable_disable(self): 'no feature vn-segment-vlan-based', ])) + def test_cfg_with_vn_segment(self): + Genie.testbed = testbed = Testbed() + dev1 = Device(testbed=testbed, name='PE1', os='nxos') + + with self.assertNoWarnings(): + Genie.testbed = None + with self.assertRaises(TypeError): + vlan = Vlan() + Genie.testbed = testbed + + vlan = Vlan(vlan='102') + vlan.device_attr[dev1].vlan_attr['102'].name = 'vlan2' + vlan.device_attr[dev1].vlan_attr['102'].state = 'active' + vlan.device_attr[dev1].vlan_attr['102'].mode = 'ce' + vlan.device_attr[dev1].vlan_attr['102'].vn_segment_id = 100102 + vlan.device_attr[dev1].vlan_attr['102'].associate_vrf_name = 'vxlan-1001' + + vlan.device_attr[dev1].config_vlan_attr['102'].config_vlan_id = '102' + vlan.device_attr[dev1].config_vlan_attr['102'].ip_igmp_snooping = True + + self.assertIs(vlan.testbed, testbed) + + dev1.add_feature(vlan) + + cfgs = vlan.build_config(apply=False) + self.assertCountEqual(cfgs.keys(), [dev1.name]) + self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join([ + 'vlan 102', + ' name vlan2', + ' state active', + ' mode ce', + ' vn-segment 100102', + ' associate-vrf vxlan-1001', + ' exit', + 'vlan configuration 102', + ' ip igmp snooping', + ' exit' + ])) + + un_cfgs = vlan.build_unconfig(apply=False) + self.assertMultiLineEqual(str(un_cfgs[dev1.name]), '\n'.join([ + 'no vlan 102', + 'no vlan configuration 102', + ])) + + un_cfgs = vlan.build_unconfig(apply=False, + attributes={'device_attr': { + dev1: { + 'vlan_attr': { + '102': {"mode": None} + }, + 'config_vlan_attr': { + '102': {"ip_igmp_snooping": None} + } + } + } + }) + self.assertCountEqual(un_cfgs.keys(), [dev1.name]) + self.assertMultiLineEqual(str(un_cfgs[dev1.name]), '\n'.join([ + 'vlan 102', + ' no mode ce', + ' exit', + 'vlan configuration 102', + ' no ip igmp snooping', + ' exit', + ])) + if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/vlan.py b/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/vlan.py index 20b662a37..f2bcf8056 100644 --- a/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/vlan.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/vlan/nxos/vlan.py @@ -90,6 +90,11 @@ def build_config(self, apply=True, attributes=None, unconfig=False, configurations.append_line( attributes.format('vn-segment {vn_segment_id}')) + # nxos: vlan 1000 / associate-vrf vxlan-1001 + if attributes.value('associate_vrf_name'): + configurations.append_line( + attributes.format('associate-vrf {associate_vrf_name}')) + # nxos: vlan dot1q tag native # nxos: vlan dot1q tag native exclude control # nxos: vlan dot1q tag native fabricpath @@ -352,6 +357,11 @@ def build_config(self, devices=None, apply=True, attributes=None, configurations.append_line( attributes.format('vn-segment {vn_segment_id}')) + # associate_vrf_name + if attributes.value('associate_vrf_name'): + configurations.append_line( + attributes.format('associate-vrf {associate_vrf_name}')) + return str(configurations) class VlanConfigAttributes(ABC): diff --git a/pkgs/conf-pkg/src/genie/libs/conf/vlan/vlan.py b/pkgs/conf-pkg/src/genie/libs/conf/vlan/vlan.py index 155a566d1..154df8bbd 100644 --- a/pkgs/conf-pkg/src/genie/libs/conf/vlan/vlan.py +++ b/pkgs/conf-pkg/src/genie/libs/conf/vlan/vlan.py @@ -322,6 +322,12 @@ class State(Enum): type=(None, managedattribute.test_istype(int)), doc='Segment id') + associate_vrf_name = managedattribute( + name='associate_vrf_name', + default=None, + type=(None, managedattribute.test_istype(str)), + doc='associate-vrf name') + class Mode(Enum): CE = 'ce' FABRICPATH = 'fabricpath' diff --git a/pkgs/filetransferutils-pkg/changelog/2024/november.rst b/pkgs/filetransferutils-pkg/changelog/2024/november.rst new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/filetransferutils-pkg/src/genie/libs/filetransferutils/__init__.py b/pkgs/filetransferutils-pkg/src/genie/libs/filetransferutils/__init__.py index 3842fb6fd..5da6445b2 100644 --- a/pkgs/filetransferutils-pkg/src/genie/libs/filetransferutils/__init__.py +++ b/pkgs/filetransferutils-pkg/src/genie/libs/filetransferutils/__init__.py @@ -9,7 +9,7 @@ ''' -__version__ = '24.10' +__version__ = '24.11' __author__ = 'Cisco Systems Inc.' __contact__ = ['pyats-support@cisco.com', 'pyats-support-ext@cisco.com'] __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' diff --git a/pkgs/health-pkg/changelog/2024/november.rst b/pkgs/health-pkg/changelog/2024/november.rst new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/health-pkg/src/genie/libs/health/__init__.py b/pkgs/health-pkg/src/genie/libs/health/__init__.py index 96650ac18..db3431236 100644 --- a/pkgs/health-pkg/src/genie/libs/health/__init__.py +++ b/pkgs/health-pkg/src/genie/libs/health/__init__.py @@ -8,7 +8,7 @@ ''' # metadata -__version__ = '24.10' +__version__ = '24.11' __author__ = 'Cisco Systems Inc.' __contact__ = ['asg-genie-support@cisco.com', 'pyats-support-ext@cisco.com'] __copyright__ = 'Copyright (c) 2020, Cisco Systems Inc.' diff --git a/pkgs/ops-pkg/changelog/2024/november.rst b/pkgs/ops-pkg/changelog/2024/november.rst new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/ops-pkg/src/genie/libs/ops/__init__.py b/pkgs/ops-pkg/src/genie/libs/ops/__init__.py index a208f77f6..08458baa7 100644 --- a/pkgs/ops-pkg/src/genie/libs/ops/__init__.py +++ b/pkgs/ops-pkg/src/genie/libs/ops/__init__.py @@ -7,7 +7,7 @@ ''' # metadata -__version__ = '24.10' +__version__ = '24.11' __author__ = 'Cisco Systems Inc.' __contact__ = ['pyats-support@cisco.com', 'pyats-support-ext@cisco.com'] __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' diff --git a/pkgs/robot-pkg/changelog/2024/november.rst b/pkgs/robot-pkg/changelog/2024/november.rst new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/robot-pkg/src/genie/libs/robot/__init__.py b/pkgs/robot-pkg/src/genie/libs/robot/__init__.py index 84dfacf4e..60fae3cf4 100644 --- a/pkgs/robot-pkg/src/genie/libs/robot/__init__.py +++ b/pkgs/robot-pkg/src/genie/libs/robot/__init__.py @@ -8,7 +8,7 @@ ''' # metadata -__version__ = '24.10' +__version__ = '24.11' __author__ = 'Cisco Systems Inc.' __contact__ = ['pyats-support@cisco.com', 'pyats-support-ext@cisco.com'] __copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.' diff --git a/pkgs/sdk-pkg/changelog/2024/november.rst b/pkgs/sdk-pkg/changelog/2024/november.rst new file mode 100644 index 000000000..42fd99d5e --- /dev/null +++ b/pkgs/sdk-pkg/changelog/2024/november.rst @@ -0,0 +1,64 @@ +-------------------------------------------------------------------------------- + New +-------------------------------------------------------------------------------- + +* iosxe + * Added API execute_test_sfp_port_lpn_fake_insert + * Added API to execute_test_sfp_port_lpn_fake_insert + * Added API execute_test_sfp_port_lpn_fake_remove + * Added API platform_hardware_fed_switch_phy_debug + * Added API to platform_hardware_fed_switch_phy_debug + * Added API debug_software_cpm_switch_pcap + * Added API to enable disable software cpm switch + * Added API's to configure cli commands for policy-map. + * API to configure_policy_map_with_police_cir_percentage + * API to configure_policy_map_parameters + * Added API's to configure cli commands for speed auto. + * API for configure_interface_speed_auto + * Added execute_diagnostic_start_switch_port + * API to execute_diagnostic_start_switch_port + * Added execute_test_platform_hardware_cman + * API to execute_test_platform_hardware_cman + * Added request_platform_hardware_pfu + * API to request_platform_hardware_pfu + * Added remove_default_ipv6_sgacl + * API to clear default IPv6 SGACL + * Added API request_platform_software_trace_rotate_all + * Added request_platform_software_trace_rotate_all api + * Added set_platform_soft_trace_ptp_debug + * added api for set platform software trace fed active ptp_proto debug + * Added unconfigure_parameter_map_subscriber + * API to unconfigure "parameter-map type subscriber attribute-to-service {parameter_map_name}" + * Added unconfigure_policy_map_set_cos_cos_table + * New API to unconfigure policy map set cos cos table + +* added api to execute_test_sfp_port_lpn_fake_remove + + +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* api utils + * Modified api_unittest_generator + * Refactored code to streamline `configure` and `execute` API unit tests + * Removed dependency on mock data yaml files for `configure` and `execute` API unit tests + +* iosxe + * health cpu api + * Update the API to handle the scenario when the parser dont has the key + * Modified verify_ignore_startup_config + * fixed next_config_register Key Error + * Health + * Update the health cpu to include `show processes cpu platform` command + * Modified configure_masked_unmasked_credentials + * Added parameter view + * Modified + * Updated execute_install_one_shot to use reload service instead of execute + * Recovery + * Modified send_break_boot to send context with username, password and enable_password + +* sdk-pkg + * Update load_image api in utils.py + + diff --git a/pkgs/sdk-pkg/sdk_generator/output/github_apis.json b/pkgs/sdk-pkg/sdk_generator/output/github_apis.json index 0f1dee8d0..b2abeaa84 100644 --- a/pkgs/sdk-pkg/sdk_generator/output/github_apis.json +++ b/pkgs/sdk-pkg/sdk_generator/output/github_apis.json @@ -620,14 +620,14 @@ "clear_controllers_ethernet_controller": { "folders": { "iosxe": { - "doc": " API to clear controllers ethernet-controller\n Args:\n device ('obj'): Device object\n interface ('str', Optional): Interface name to clear controllers\n Returns:\n None\n Raises:\n SubCommandFailure\n ", - "module_name": "iosxe.controllers.clear", + "doc": " clear controllers ethernet-controller\n Args:\n device ('obj'): device to execute on\n Return:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.platform.utils", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "clear_controllers_ethernet_controller", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/controllers/clear.py#L7" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/utils.py#L505" } } }, @@ -725,7 +725,7 @@ "os": "iosxe" }, "uid": "clear_cts_counters", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L428" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L446" } } }, @@ -739,7 +739,7 @@ "os": "iosxe" }, "uid": "clear_cts_counters_ipv4", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1076" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1094" } } }, @@ -753,7 +753,7 @@ "os": "iosxe" }, "uid": "clear_cts_counters_ipv6", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1026" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1044" } } }, @@ -767,7 +767,7 @@ "os": "iosxe" }, "uid": "clear_cts_credentials", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L406" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L424" } } }, @@ -2227,7 +2227,7 @@ "os": "iosxe" }, "uid": "config_access_session_accnt_attr_filter_spec_include_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2551" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2555" } } }, @@ -2241,7 +2241,7 @@ "os": "iosxe" }, "uid": "config_access_session_auth_attr_filter_spec_include_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2489" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2493" } } }, @@ -3483,7 +3483,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_commands", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2180" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2184" } } }, @@ -3497,7 +3497,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_connection_default_start_stop_group_tacacs_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3107" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3111" } } }, @@ -3511,7 +3511,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_exec_default_start_stop_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2384" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2388" } } }, @@ -3525,7 +3525,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_identity_default_start_stop", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1937" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1941" } } }, @@ -3539,7 +3539,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_identity_default_start_stop_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2805" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2809" } } }, @@ -3553,7 +3553,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_network_default_start_stop_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2769" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2773" } } }, @@ -3567,7 +3567,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_system_default_start_stop_group_tacacs_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3124" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3128" } } }, @@ -3581,7 +3581,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_update", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2681" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2685" } } }, @@ -3595,7 +3595,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_update_periodic", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1921" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1925" } } }, @@ -3609,7 +3609,7 @@ "os": "iosxe" }, "uid": "configure_aaa_accounting_update_periodic_interval", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2735" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2739" } } }, @@ -3665,7 +3665,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authentication_enable", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2039" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2043" } } }, @@ -3679,7 +3679,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authentication_enable_default_group_enable", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2878" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2882" } } }, @@ -3693,7 +3693,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authentication_login", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1856" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1860" } } }, @@ -3707,7 +3707,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authentication_login_default_group_local", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2860" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2864" } } }, @@ -3721,7 +3721,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authorization_commands", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2101" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2105" } } }, @@ -3735,7 +3735,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authorization_config_commands", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3091" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3095" } } }, @@ -3749,7 +3749,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authorization_exec_default", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1902" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1906" } } }, @@ -3763,7 +3763,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authorization_exec_default_group_if_authenticated", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2896" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2900" } } }, @@ -3777,7 +3777,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authorization_network", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2312" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2316" } } }, @@ -3791,7 +3791,7 @@ "os": "iosxe" }, "uid": "configure_aaa_authorization_network_default_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2914" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2918" } } }, @@ -3819,7 +3819,7 @@ "os": "iosxe" }, "uid": "configure_aaa_default_group_methods", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1878" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1882" } } }, @@ -4015,7 +4015,7 @@ "os": "iosxe" }, "uid": "configure_access_session_attr_filter_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2592" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2596" } } }, @@ -6728,14 +6728,14 @@ "configure_crypto_pki_server": { "folders": { "iosxe": { - "doc": "Configures crypto pki server on device\n\n Args:\n device (`obj`): Device object\n domain_name ('str'): Name of the domain to be configured\n database_level ('str'): Database level to be configured\n issuer_name ('str'): Issuer name to be configured\n hash ('str'): Hash to be configured\n modulus_size ('str'): Modulus size to be configured\n Password ('str'): Password to be configured\n server_name ('str'): Name of the server to be configured\n\n Returns:\n None\n\n Raise:\n SubCommandFailure: Failed to configure crypto pki server on device\n ", - "module_name": "iosxe.eaptls.configure", + "doc": " \n Configure crypto pki server\n Args:\n device ('obj'): Device object\n server_name ('str'): Name for the pki server\n auto_rollover_time('str'): Auto rollover time \n cdp_url_server ('str') : cdp url server (http | ldap)\n cdp_url_ip_path ('str') : cdp url ip path \n database_archive_type ('str') : Database archive type either pem or pkcs12\n archive_password ('str') : Database archive password\n archive_encryption_type ('int') : Database archive encryption type (0-9)\n database_level ('str') : Database level (complete|minimum|names)\n database_url_server ('str') : Database server (http | ldap) \n database_ip_path ('str') : Exact path for database file\n database_url_storage_location ('str') : Database url storage location (cnm|crl|crt etc.)\n database_url_publish ('bool') : Database url publish option for cnm, crl,crt\n database_user ('str') : Database username\n eku_options ('str') : eku options that needs to be configured (1 or more)\n grant_mode ('str') : Grant request mode (auto | none | ra-auto)\n grant_rollover_cert ('str') : Grant auto rollover certificate (ca-cert | ra-cert)\n grant_tp_list ('str') : grant trustpoints (upto 5 trustpoints)\n grant_trustpoint ('str') : Label of trustpoint holding trusted CA cert\n hash_type ('str') : Hash algorithm type (md5, sha1, sha256, sha384, sha512)\n issuer_name ('str') : Issuer name to be configured\n ca_cert_life ('str') : Ca certificate lifetime in format or \n cert_life ('str') : Certificate lifetime in format or \n crl_life ('str') : crl lifetime in format or \n enrol_req_life ('str') : enrollment request lifetime in format or \n mode ('str') : Modes (ra|sub-cs)\n mode_ra_transparent ('bool') : True if want to enable transparent in ra mode\n serial_number ('str') : serial number of last issued ceritificate \n enrollment_ip ('str') : Ip address for CA server enrollment URL\n enrollment_path ('str') : Path for CA server enrollment URL\n revoke_chk ('str') : Type of revocation check (none|crl|ocsp)\n key_len ('int') : Key length for RSA keypair \n port ('int') : Port number for CA server enrollment\n Returns:\n True/False\n ", + "module_name": "iosxe.pki.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "configure_crypto_pki_server", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eaptls/configure.py#L159" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/pki/configure.py#L13" } } }, @@ -6763,7 +6763,7 @@ "os": "iosxe" }, "uid": "configure_cts_aaa_methods", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1040" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1058" } } }, @@ -6805,7 +6805,7 @@ "os": "iosxe" }, "uid": "configure_cts_enforcement_interface", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L889" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L907" } } }, @@ -6819,7 +6819,7 @@ "os": "iosxe" }, "uid": "configure_cts_enforcement_logging", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L992" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1010" } } }, @@ -6847,7 +6847,7 @@ "os": "iosxe" }, "uid": "configure_cts_role_based_monitor", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L829" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L847" } } }, @@ -6861,7 +6861,7 @@ "os": "iosxe" }, "uid": "configure_cts_role_based_permission", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L751" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L769" } } }, @@ -6875,7 +6875,7 @@ "os": "iosxe" }, "uid": "configure_cts_role_based_permission_default", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L792" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L810" } } }, @@ -7630,7 +7630,7 @@ "os": "iosxe" }, "uid": "configure_disable_config_key_encryption", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2461" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2465" } } }, @@ -7784,7 +7784,7 @@ "os": "iosxe" }, "uid": "configure_dscp_global", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2331" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2335" } } }, @@ -9105,7 +9105,7 @@ "os": "iosxe" }, "uid": "configure_host_ip_to_sgt_mapping", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L631" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L649" } } }, @@ -9724,7 +9724,7 @@ "os": "iosxe" }, "uid": "configure_interface_cts_role_based_sgt_map", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1126" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1144" } } }, @@ -10839,6 +10839,20 @@ } } }, + "configure_interface_speed_auto": { + "folders": { + "iosxe": { + "doc": " configure speed auto on interface\n Args:\n device ('obj'): Device object\n interface ('str'): Interface name\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.interface.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "configure_interface_speed_auto", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/configure.py#L10538" + } + } + }, "configure_interface_split_horizon_eigrp": { "folders": { "iosxe": { @@ -12316,14 +12330,14 @@ "configure_ip_multicast_routing_distributed": { "folders": { "iosxe": { - "doc": " configure ip multicast routing on device\n Args:\n device (`obj`): Device object\n Returns:\n None\n ", - "module_name": "iosxe.mcast.configure", + "doc": "Configure IP multicast routing\n Args:\n device (`obj`): Device object\n no_spd (): If True, turn off selective packet discard. Default False.\n punt_limit (`str` or `int`): Punt limit. Acceptable values are:\n integer (packets per second)\n default\n disable\n Return:\n None\n Raise:\n SubCommandFailure: Failure while configuring\n ", + "module_name": "iosxe.multicast.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "configure_ip_multicast_routing_distributed", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/mcast/configure.py#L48" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/multicast/configure.py#L450" } } }, @@ -12687,7 +12701,7 @@ "os": "iosxe" }, "uid": "configure_ip_role_based_acl", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L925" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L943" } } }, @@ -12939,7 +12953,7 @@ "os": "iosxe" }, "uid": "configure_ip_subnet_to_sgt_mapping_vrf", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L709" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L727" } } }, @@ -12967,7 +12981,7 @@ "os": "iosxe" }, "uid": "configure_ip_to_sgt_mapping_vrf", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L669" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L687" } } }, @@ -14101,7 +14115,7 @@ "os": "iosxe" }, "uid": "configure_ipv6_subnet_to_sgt_mapping", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L591" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L609" } } }, @@ -14115,7 +14129,7 @@ "os": "iosxe" }, "uid": "configure_ipv6_to_sgt_mapping", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L553" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L571" } } }, @@ -15317,7 +15331,7 @@ "os": "iosxe" }, "uid": "configure_mab_eap_on_switchport_mode_access_interface", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2842" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2846" } } }, @@ -15813,7 +15827,7 @@ "configure_masked_unmasked_credentials": { "folders": { "iosxe": { - "doc": " Configure masked or unmasked credentials with privilege,common criteria policy\n and encryption algorithm type.\n\n Args:\n device (`obj`): Device object\n username (`str`): username\n password (`str`): Password\n privilege('int',optional): specified privilege num else None\n ccp_name (`str`, optional): specified Common Criteria Policy else None\n algorithm_type ('str', optional): specified algorithm type else None\n masked ('bool'): masked secret if True else unmasked.\n secret ('bool'): secret if True else plain-text\n Return :\n None\n Raise:\n SubCommandFailure: Failed configuring\n ", + "doc": " Configure masked or unmasked credentials with privilege,common criteria policy\n and encryption algorithm type.\n\n Args:\n device (`obj`): Device object\n username (`str`): username\n password (`str`): Password\n privilege('int',optional): specified privilege num else None\n ccp_name (`str`, optional): specified Common Criteria Policy else None\n algorithm_type ('str', optional): specified algorithm type else None\n masked ('bool'): masked secret if True else unmasked.\n secret ('bool'): secret if True else plain-text\n view ('str', optional): specified CLI view else None\n Return :\n None\n Raise:\n SubCommandFailure: Failed configuring\n ", "module_name": "iosxe.aaa.configure", "package": "genie.libs.sdk.apis", "tokens": { @@ -15834,7 +15848,7 @@ "os": "iosxe" }, "uid": "configure_masked_unmasked_enable_secret_password", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1757" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1761" } } }, @@ -18178,14 +18192,14 @@ "configure_pki_authenticate_certificate": { "folders": { "iosxe": { - "doc": " Pastes certificate on device\n\n Args:\n device (`obj`): Device object\n certificate ('str'): Certificate to be pasted\n label_name ('str'): Label name\n\n Returns:\n None\n\n Raise:\n SubCommandFailure: Failed to paste certificate on device\n ", - "module_name": "iosxe.eaptls.configure", + "doc": " Pastes certificate on device\n Args:\n device (`obj`): Device object\n certificate ('str'): Certificate to be pasted\n label_name ('str'): Label name\n Returns:\n None\n Raise:\n SubCommandFailure: Failed to paste certificate on device\n ", + "module_name": "iosxe.pki.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "configure_pki_authenticate_certificate", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eaptls/configure.py#L38" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/pki/configure.py#L1019" } } }, @@ -18414,7 +18428,7 @@ "os": "iosxe" }, "uid": "configure_policy_map_class", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py#L1020" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py#L1047" } } }, @@ -18488,6 +18502,20 @@ } } }, + "configure_policy_map_parameters": { + "folders": { + "iosxe": { + "doc": " Configure policy-map parameters on device\n Args:\n device ('obj'): device to use\n policy_map_name('str'): Policy-map name\n class_name('str',optional) : Class-name \n priority_level('int',optional): value of priority queue from 0 to 7\n bandwidth_remaining_percent('int',optional) :bandwidth remaining percent\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.policy_map.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "configure_policy_map_parameters", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py#L1150" + } + } + }, "configure_policy_map_set_cos_cos_table": { "folders": { "iosxe": { @@ -18572,6 +18600,20 @@ } } }, + "configure_policy_map_with_police_cir_percentage": { + "folders": { + "iosxe": { + "doc": " Configure policy-map with police cir percentage\n Args:\n device ('obj'): device to use\n policy_map_name('str'): Policy-map name\n class_name('str',optional) : Class-name \n percent('int',optional) : police cir percentage \n action('str',optional) : exceed-action to do (drop/transmit)\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.policy_map.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "configure_policy_map_with_police_cir_percentage", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py#L1123" + } + } + }, "configure_policy_map_with_pps": { "folders": { "iosxe": { @@ -19254,7 +19296,7 @@ "os": "iosxe" }, "uid": "configure_radius_attribute_25", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1976" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1980" } } }, @@ -19268,7 +19310,7 @@ "os": "iosxe" }, "uid": "configure_radius_attribute_31_mac_format", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1996" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2000" } } }, @@ -19282,7 +19324,7 @@ "os": "iosxe" }, "uid": "configure_radius_attribute_31_send_mac", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2016" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2020" } } }, @@ -19310,7 +19352,7 @@ "os": "iosxe" }, "uid": "configure_radius_attribute_8", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1956" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1960" } } }, @@ -19324,7 +19366,7 @@ "os": "iosxe" }, "uid": "configure_radius_attribute_policy_name_globally", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2932" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2936" } } }, @@ -19338,7 +19380,7 @@ "os": "iosxe" }, "uid": "configure_radius_attribute_policy_name_under_server", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2974" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2978" } } }, @@ -19352,7 +19394,7 @@ "os": "iosxe" }, "uid": "configure_radius_attribute_policy_name_under_servergroup", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3025" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3029" } } }, @@ -19492,7 +19534,7 @@ "os": "iosxe" }, "uid": "configure_radius_server_source_ports_extended", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2536" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2540" } } }, @@ -20010,7 +20052,7 @@ "os": "iosxe" }, "uid": "configure_sap_pmk_on_cts", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L444" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L462" } } }, @@ -20381,14 +20423,14 @@ "configure_service_private_config_encryption": { "folders": { "iosxe": { - "doc": " \n service private-config-encryption\n Args:\n device ('obj'): Device object\n Returns:\n None\n Raises:\n SubCommandFailure exception\n ", - "module_name": "iosxe.csdl.configure", + "doc": " service private-config-encryption\n Args:\n device (`obj`): Device object\n Returns:\n None\n Raises:\n SubCommandFailure : Failed configuring device\n ", + "module_name": "iosxe.sudi.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "configure_service_private_config_encryption", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/csdl/configure.py#L33" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/sudi/configure.py#L42" } } }, @@ -22202,14 +22244,14 @@ "configure_switch_provision": { "folders": { "iosxe": { - "doc": " Configures switch provisioning / offline configuration\n Example : switch 3 provision c9300-24h\n\n Args:\n device ('obj'): device to use\n switch_number('int'): switch number (Range 1-16)\n sku_type('str'): type of switch\n\n Returns:\n None\n\n Raises: \n SubCommandFailure\n ", - "module_name": "iosxe.offline_provisioning.configure", + "doc": " Configure switch provision for switch\n Args:\n device ('obj'): Device object\n switch_number('int'): switch number\n model ('str'): switch model\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.platform.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "configure_switch_provision", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/offline_provisioning/configure.py#L11" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/configure.py#L555" } } }, @@ -23116,14 +23158,14 @@ "configure_udld_message_time": { "folders": { "iosxe": { - "doc": " Configures udld message time\n Example : udld message time 30\n Args:\n device ('obj'): device to use\n time ('int'): Time in seconds between sending of messages in steady state\n Returns:\n None\n Raises:\n SubCommandFailure\n ", - "module_name": "iosxe.platform.configure", + "doc": " Configures UDLD Message Time on Target Device globally \n Args:\n device ('obj') : device to use\n message_time ('int') : Time in seconds between sending of messages 1-90\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.udld.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "configure_udld_message_time", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/configure.py#L2498" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/udld/configure.py#L95" } } }, @@ -24218,7 +24260,7 @@ "os": "iosxe" }, "uid": "cts_refresh_environment_data", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L521" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L539" } } }, @@ -24232,7 +24274,7 @@ "os": "iosxe" }, "uid": "cts_refresh_pac", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L537" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L555" } } }, @@ -24246,7 +24288,7 @@ "os": "iosxe" }, "uid": "cts_refresh_policy", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L488" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L506" } } }, @@ -24348,6 +24390,20 @@ } } }, + "debug_software_cpm_switch_pcap": { + "folders": { + "iosxe": { + "doc": " debug software cpm switch pcap\n Args:\n device ('obj'): device to use\n mode ('str'): active/standby\n enable_disable('str'): enable or disable\n Returns\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.debug.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "debug_software_cpm_switch_pcap", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/debug/configure.py#L493" + } + } + }, "debug_vdsl_controller_slot_dump_internal": { "folders": { "iosxe": { @@ -24753,7 +24809,7 @@ "os": "iosxe" }, "uid": "device_rommon_boot", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py#L14" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py#L18" } } }, @@ -24929,7 +24985,7 @@ "os": "iosxe" }, "uid": "disable_cts_enforcement_vlan_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1108" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1126" } } }, @@ -25512,7 +25568,7 @@ "os": "iosxe" }, "uid": "enable_cts_enforcement_vlan_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1090" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1108" } } }, @@ -26439,7 +26495,7 @@ "os": "iosxe" }, "uid": "execute_clear_install_label", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L615" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L620" } } }, @@ -26453,7 +26509,7 @@ "os": "iosxe" }, "uid": "execute_clear_install_state", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L541" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L546" } } }, @@ -26835,7 +26891,7 @@ "os": "iosxe" }, "uid": "execute_create_rollback_description", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L515" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L520" } } }, @@ -26849,7 +26905,7 @@ "os": "iosxe" }, "uid": "execute_create_rollback_label", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L489" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L494" } } }, @@ -27032,6 +27088,20 @@ } } }, + "execute_diagnostic_start_switch_port": { + "folders": { + "iosxe": { + "doc": " execute diagnostic start switch 1 test\n Args:\n device ('obj'): Device object\n test_id ('str'): Test ID list (e.g. 1,3-6) or Test Name or minimal or complete\n Interface port number WORD Port number list (e.g. 2,4-7)\n switch_number ('int'): Switch number on which diagnostic has to be performed \n port ('str'): word (e.g. 1-8 or all)\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.platform.execute", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "execute_diagnostic_start_switch_port", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1892" + } + } + }, "execute_diagnostic_start_switch_test": { "folders": { "iosxe": { @@ -27133,7 +27203,7 @@ "os": "iosxe" }, "uid": "execute_install_abort", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L669" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L674" } } }, @@ -27161,7 +27231,7 @@ "os": "iosxe" }, "uid": "execute_install_add", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L339" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L344" } } }, @@ -27189,7 +27259,7 @@ "os": "iosxe" }, "uid": "execute_install_auto_abort_timer_stop", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L591" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L596" } } }, @@ -27203,7 +27273,7 @@ "os": "iosxe" }, "uid": "execute_install_commit", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L440" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L445" } } }, @@ -27231,7 +27301,7 @@ "os": "iosxe" }, "uid": "execute_install_deactivate", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L733" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L738" } } }, @@ -27287,7 +27357,7 @@ "os": "iosxe" }, "uid": "execute_install_package_reload_fast", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L918" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L923" } } }, @@ -27343,7 +27413,7 @@ "os": "iosxe" }, "uid": "execute_install_rollback", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L827" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py#L832" } } }, @@ -28198,6 +28268,20 @@ } } }, + "execute_test_platform_hardware_cman": { + "folders": { + "iosxe": { + "doc": "\n Execute 'test platform hardware cman_thermal switch {mode} {route_processor} {function} {sub_functional_part} {action}' command on the device.\n Args:\n device (obj): Device object for executing commands.\n cman (str): CMAN type, either 'cman_thermal' or 'cman_fep'.\n mode (str): Mode of operation. Options are 'active/standby', '1', or '2'.\n route_processor (str): Route processor, such as 'R0' or 'RP'.\n function (str, optional): Functional aspect to control. Options include 'fan', 'status', or 'temperature'.\n Default is None.\n sub_functional_part (str, optional): Sub-functional part. Can be one of 'fake', 'hotspot', 'inlet', 'outlet', or \n 'fan-curve'. Default is None.\n action (str, optional): Action to perform. Options include 'on', 'off', any integer between -255 and 255, or one \n of 'normal', 'test', or 'turbo'. Default is None.\n action2 (str, optional): Secondary action, either 'on' or 'off'. Default is None.\n slot (int, optional): Slot number. Can be 0, 1, or 2. Default is 0.\n \n Returns:\n str: Output of the command\n ", + "module_name": "iosxe.interface.execute", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "execute_test_platform_hardware_cman", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/execute.py#L149" + } + } + }, "execute_test_platform_hardware_fantray": { "folders": { "iosxe": { @@ -28268,6 +28352,34 @@ } } }, + "execute_test_sfp_port_lpn_fake_insert": { + "folders": { + "iosxe": { + "doc": " \n Args:\n device ('obj'): device to use \n mode ('str'): mode active/ standby\n lpn_num ('str'): lpn number\n Returns:\n Return the test command execution output\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.interface.execute", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "execute_test_sfp_port_lpn_fake_insert", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/execute.py#L183" + } + } + }, + "execute_test_sfp_port_lpn_fake_remove": { + "folders": { + "iosxe": { + "doc": " \n Args:\n device ('obj'): device to use \n mode ('str'): mode active/ standby\n lpn_num ('str'): lpn number\n Returns:\n Return the test command execution output\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.interface.execute", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "execute_test_sfp_port_lpn_fake_remove", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/execute.py#L201" + } + } + }, "execute_test_telemetry_show_logging": { "folders": { "iosxe": { @@ -37531,7 +37643,7 @@ "os": "iosxe" }, "uid": "health_core", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L382" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L398" }, "iosxr": { "doc": "Get the default directory of this device\n\n Args:\n device (`obj`) : Device object\n default_dir (`str` or `list`) : default directory where core is generated \n on device\n ex.) `harddisk:/dumper`\n output (`str`) : Output of `dir` command\n keyword (`list`): List of keywords to search\n num_of_cores (`bool`): flag to return number of core files\n Default to False\n remote_device (`str`): remote device in testbed yaml\n Default to None\n remote_path (`str`): path with/without file on remote device\n Default to None\n remote_via (`str`) : specify connection to get ip\n Default to None\n protocol (`str`): protocol for copy. Default to scp\n vrf (`str`): use vrf where scp find route to remote device\n Default to None\n archive (`bool`): flag to save the decode output as file in archive\n Defaults to False\n delete_core (`bool`): flag to delete core files only when copying to\n remove_device is successfully done\n Defaults to False\n\n ### CISCO INTERNAL ###\n decode (`bool`): flag to enable for decoding core\n copy core file to remote_server and decode on remote_server\n decode_timeout (`int`): timeout to execute decode script\n Default to 300\n\n Returns:\n all_corefiles (`dict`): return health_data format.\n ex.)\n {\n \"health_data\": {\n \"num_of_cores\": 1,\n \"core_files\": [\n {\n \"filename\": \"asr-MIB-1_RP_1_nginx_23178_20210317-175351-UTC.core.gz\",\n \"decode\": \"\"\"\n \n \"\"\"\n }\n ]\n }\n }\n ", @@ -37570,14 +37682,14 @@ "health_cpu": { "folders": { "iosxe": { - "doc": "Get cpu load on device\n\n Args:\n device (`obj`): Device object\n command (`str`): Override show command\n Default to `show processes cpu`\n processes (`list`): List of processes to check\n if not specified, will return one ALL_PROCESSES\n with total cpu load\n check_key (`str`): Key to check in parsed output\n Default to `five_sec_cpu`\n check_key_total (`str`): Key to check in parsed output for Total\n Default to `five_sec_cpu_total`\n add_total (`bool`): If True, add total cpu load\n output (`str`): Output of show command\n timeout (`int`): Timeout(secs). Defaults to None\n Returns:\n cpu_load_dict (`dict`): Cpu load dictionary on the device\n example:\n {\n \"health_data\": [\n {\n \"process\": \"OMP\",\n \"value\": 0.0,\n },\n {\n \"process\": \"NAT-ROUTE\",\n \"value\": 0.0,\n }\n ]\n }\n ", + "doc": "Get cpu load on device\n\n Args:\n device (`obj`): Device object\n command (`str`) or list(`str`): Override show commands\n Default to `show processes cpu sorted` and `show processes cpu platform sorted`\n processes (`list`): List of processes to check\n if not specified, will return one ALL_PROCESSES\n with total cpu load\n check_key (`str`): Key to check in parsed output\n Default to `five_sec_cpu`\n check_key_total (`str`): Key to check in parsed output for Total\n Default to `five_sec_cpu_total`\n add_total (`bool`): If True, add total cpu load\n output (`str`): Output of show command\n timeout (`int`): Timeout(secs). Defaults to None\n Returns:\n cpu_load_dict (`dict`): Cpu load dictionary on the device\n example:\n {\n \"health_data\": [\n {\n \"process\": \"OMP\",\n \"value\": 0.0,\n },\n {\n \"process\": \"NAT-ROUTE\",\n \"value\": 0.0,\n }\n ]\n }\n ", "module_name": "iosxe.health.health", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "health_cpu", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L17" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L18" }, "iosxr": { "doc": "Get cpu load on device\n\n Args:\n device (`obj`): Device object\n command (`str`): Override show command\n Default to `show processes cpu`\n processes (`list`): List of processes to check\n Default to None\n check_key (`str`): Key to check in parsed output\n Default to `one_min_cpu`\n check_key_total (`str`): Key to check in parsed output\n for Total. Default to `one_min_cpu`\n add_total (`bool`): If True, add total cpu load\n output (`str`): Output of show command\n Default to None\n timeout (`int`): Timeout(secs). Defaults to None\n Returns:\n cpu_load_dict (`dict`): Cpu load dictionary on the device\n Example:\n {\n \"health_data\": [\n {\n \"process\": \"netconf\",\n \"value\": 0.0,\n },\n {\n \"process\": \"bgp\",\n \"value\": 0.0,\n }\n ]\n }\n ", @@ -37611,7 +37723,7 @@ "os": "iosxe" }, "uid": "health_logging", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L295" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L311" }, "iosxr": { "doc": "Get logging messages\n\n Args:\n device (`obj`): Device object\n command (`str`): N/A\n files (`list`): Not applicable on this platform\n keywords (`list`): List of keywords to match\n Default to ['traceback', 'Traceback', 'TRACEBACK']\n output (`str`): Output of show command\n num_of_logs (`bool`): flag to return number of log messages\n Default to False\n clear_log (`bool`): flag to clear logging message\n Default to False\n health (`bool`): wheather return health_data format or not\n Default to True\n Returns:\n logs (`dict`): return health_data format.\n ex.)\n {\n \"health_data\": {\n \"num_of_logs\": 1,\n \"logs\": [\n {\n \"line\": \"-Traceback= D667B8 D66F04 41463C 40FFF8 411834 423A6C A6E428 A64EF8 (EEHYP_CS_801-1)\",\n \"decode\": \"\", # Optional\n }\n ]\n }\n }\n ", @@ -37645,7 +37757,7 @@ "os": "iosxe" }, "uid": "health_memory", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L125" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py#L141" }, "iosxr": { "doc": "Get memory usage on device\n\n Args:\n device (`obj`): Device object\n command (`str`): Override show command\n Default to `show processes memory`\n processes (`list`): List of processes to check\n If both processes and check_key are given,\n processes are preferred.\n Default to None\n check_key (`str`): Key to check in parsed output\n Default to `dynamic`\n add_total (`bool`): If True, add total memory usage\n output (`str`): Output of show command\n Deault to None\n timeout (`int`): Timeout(secs). Defaults to None\n threshold (`int`): N/A\n Returns:\n memory_usage_dict (`dict`): memory usage dict on the device (percentage)\n example:\n {\n \"health_data\": [\n {\n \"process\": \"OMP\",\n \"value\": 0.0012294695662956926,\n },\n {\n \"process\": \"NAT-ROUTE\",\n \"value\": 0.0012294695662956926,\n }\n ]\n }\n ", @@ -38848,7 +38960,7 @@ "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/utils.py#L2822" }, "load_image": { - "doc": " Load image template\n Args:\n Renders the clean template and uses it to call clean. A clean template is JSON\n data which can have placeholders for data which the user needs to\n provide when calling this API. Similar to how Python functions\n can have keyword arguments with default values, default arguments\n may also be defined for a clean template. These are stored in\n a Python dictionary whose variable name should follow this\n convention: {template_name}_ARGS\n Shortened example:\n ```python\n from genie.conf.base.api import OPTIONAL, REQUIRED\n MY_TEMPLATE = {\n \"order\": [\n \"connect\",\n \"apply_configuration\",\n \"ping_server\",\n \"copy_to_device\",\n ],\n \"images\": r\"%CLEANARG{images}\",\n \"connect\": {},\n \"apply_configuration\": {\n \"configuration\": r\"%CLEANARG{config_str}\",\n },\n \"ping_server\": {\n \"server\": \"%CLEANARG{server}\",\n \"vrf\": \"%CLEANARG{vrf}\",\n },\n \"copy_to_device\": {\n \"overwrite\": r\"%CLEANARG{overwrite}\",\n \"origin\": {\n \"hostname\": \"%CLEANARG{server}\",\n },\n \"vrf\": \"%CLEANARG{vrf}\",\n },\n }\n\n MY_TEMPLATE_ARGS = {\n \"vrf\": \"management\", # argument with default which user can override\n \"server\": REQUIRED, # required argument which user must provide\n \"overwrite\": OPTIONAL, # optional argument\n \"config_str\": REQUIRED,\n \"images\": REQUIRED,\n }\n\n ```\n Arguments:\n 1. device: device object\n 2. template_name: which clean template to use, or None to not use any\n clean template\n 3. template_override: optionally override data in clean template. This\n is done with a recursive dictionary update.\n Example:\n ```python\n # template assumes config string is being provided. We want\n # to use a config file\n config_file_location = \"...\"\n override = {\"apply_configuration\": {\"file\": config_file_location}}\n dev.api.clean(template_name=\"MY_TEMPLATE\", template_override=config_file_location)\n ```\n 4. kwargs: arguments which are substituted into the template.\n Example:\n ```python\n dev.api.clean(\n template_name=\"MY_TEMPLATE\",\n vrf=\"Mgmt\",\n server=\"10.10.10.10\",\n images={\n \"server\": [...],\n \"kickstart\": [...],\n }\n ...\n )\n ```\n vrf, server and config_str are all kwargs, and will be substituted into\n the MY_TEMPLATE template to render the clean YAML that is used when\n invoking clean\n ", + "doc": " Load image api\n Args:\n device (obj): Device object\n images (list): Image to install\n server (str): Name of the server. Defaults to None\n protocol (str): Protocol used for copy operation. Defaults to None\n ", "folders": {}, "module_name": "utils", "package": "genie.libs.sdk.apis", @@ -39181,6 +39293,20 @@ } } }, + "platform_hardware_fed_switch_phy_debug": { + "folders": { + "iosxe": { + "doc": "Execute a PHY debug command on the specified switch and port\n Args:\n device ('obj'): Device to use\n mode ('str'): Mode identifier (e.g., 'active')\n port_num ('int'): Port number\n debug_command_options ('str'): Debug command to execute\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.platform.execute", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "platform_hardware_fed_switch_phy_debug", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1872" + } + } + }, "platform_software_fed_fnf_sw_stats_clear": { "folders": { "iosxe": { @@ -39219,7 +39345,7 @@ "os": "iosxe" }, "uid": "platform_software_fed_switch_phy_options", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1785" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1801" } } }, @@ -39285,7 +39411,7 @@ "module_name": "api_unittest_generator", "package": "genie.libs.sdk.apis", "uid": "print_header", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/api_unittest_generator.py#L40" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/api_unittest_generator.py#L44" }, "question_mark": { "doc": " Verify if ? works as expected on device\n\n Args:\n device (`obj`): Device object\n cmd (`str`): Command\n expected (`str`): Expected output\n timeout (`int`): Timeout in second\n state (`str`): Cli state\n Returns:\n None\n ", @@ -39543,6 +39669,20 @@ } } }, + "remove_default_ipv6_sgacl": { + "folders": { + "iosxe": { + "doc": " Remove a default static SGACL(ipv6)\n Args:\n device ('obj'): device to use\n sgacl ('str'): Role-based Access-list name\n Returns:\n None\n Raises:\n SubCommandFailure: Failed to remove default static SGACL(ipv6)\n ", + "module_name": "iosxe.cts.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "remove_default_ipv6_sgacl", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L406" + } + } + }, "remove_device_tracking_policy": { "folders": { "iosxe": { @@ -40231,6 +40371,20 @@ } } }, + "request_platform_hardware_pfu": { + "folders": { + "iosxe": { + "doc": " request platform hardware pfu switch 1 R0 set-power-slot 0 on\n Args:\n device (obj): Device object\n mode (str): The switch number or mode. Specify as a number (e.g., '1', '2') or as a mode such as 'active' or 'standby' to identify the target switch.\n route_processor (str): The route processor unit for the switch, such as 'R0' or 'RP'. This typically identifies the control processor for the specified switch.\n slot (int): The slot number for the hardware component or module where the power will be set. Use '0' or a relevant slot number, depending on the switch type or configuration.\n action ('str'): off/on\n Returns:\n Command output\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.platform.execute", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "request_platform_hardware_pfu", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1916" + } + } + }, "request_platform_software_cflow_copy": { "folders": { "iosxe": { @@ -40287,6 +40441,20 @@ } } }, + "request_platform_software_trace_rotate_all": { + "folders": { + "iosxe": { + "doc": " Request platform software trace rotate all\n Args:\n device (`obj`): Device object\n\n Return:\n None\n Raise:\n SubCommandFailure: Failed configuring\n ", + "module_name": "iosxe.platform.execute", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "request_platform_software_trace_rotate_all", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1785" + } + } + }, "request_routing_engine_login_other_routing_engine": { "folders": { "junos": { @@ -40625,7 +40793,7 @@ "os": "iosxe" }, "uid": "send_break_boot", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py#L108" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py#L112" } } }, @@ -40717,6 +40885,20 @@ } } }, + "set_platform_soft_trace_ptp_debug": { + "folders": { + "iosxe": { + "doc": " set platform software trace fed ptp debug\n Args:\n device ('obj'): Device object\n sprocess ('str'): process for trace logs\n feature_type ('str'): feature name\n debug_type ('str'): type of the debugs warning/debug etc\n switch ('str', optional): switch for SVL/Stack devices\n snumber ('str', optional): switch number 1/2/active/standby\n ", + "module_name": "iosxe.debug.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "set_platform_soft_trace_ptp_debug", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/debug/configure.py#L475" + } + } + }, "set_snmp_snmpset": { "folders": { "linux": { @@ -41229,7 +41411,7 @@ "os": "iosxe" }, "uid": "test_platform_software_fru_fake_insert_remove", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1834" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1850" } } }, @@ -41243,7 +41425,7 @@ "os": "iosxe" }, "uid": "test_platform_software_usb_fake_insert_remove", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1814" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py#L1830" } } }, @@ -41479,7 +41661,7 @@ "os": "iosxe" }, "uid": "unconfig_access_session_accnt_attr_filter_spec_include_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2571" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2575" } } }, @@ -41493,7 +41675,7 @@ "os": "iosxe" }, "uid": "unconfig_access_session_auth_attr_filter_spec_include_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2512" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2516" } } }, @@ -42193,7 +42375,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_accounting_commands", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2227" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2231" } } }, @@ -42207,7 +42389,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_accounting_dot1x_default_start_stop_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3073" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3077" } } }, @@ -42221,7 +42403,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_accounting_exec_default_start_stop_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2400" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2404" } } }, @@ -42235,7 +42417,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_accounting_identity_default_start_stop", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2717" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2721" } } }, @@ -42249,7 +42431,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_accounting_network_default_start_stop_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2787" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2791" } } }, @@ -42263,7 +42445,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_accounting_update", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2699" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2703" } } }, @@ -42277,7 +42459,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_accounting_update_periodic_interval", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2752" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2756" } } }, @@ -42333,7 +42515,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_authentication_enable", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2078" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2082" } } }, @@ -42347,7 +42529,7 @@ "os": "iosxe" }, "uid": "unconfigure_aaa_authorization_commands", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2140" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2144" } } }, @@ -42473,7 +42655,7 @@ "os": "iosxe" }, "uid": "unconfigure_access_session_attr_filter_list", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2627" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2631" } } }, @@ -42487,7 +42669,7 @@ "os": "iosxe" }, "uid": "unconfigure_access_session_attr_filter_list_protocol", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2646" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2650" } } }, @@ -43271,14 +43453,14 @@ "unconfigure_call_home": { "folders": { "iosxe": { - "doc": " Unconfigures call-home\n Example : no call-home\n Args:\n device ('obj'): device to use\n Returns:\n None\n Raises: \n SubCommandFailure\n ", - "module_name": "iosxe.call_home.configure", + "doc": " Unconfigures call-home\n Example : no call-home\n\n Args:\n device ('obj'): device to use\n Returns:\n None\n Raises: \n SubCommandFailure\n ", + "module_name": "iosxe.platform_licensing.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "unconfigure_call_home", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/call_home/configure.py#L404" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform_licensing/configure.py#L267" } } }, @@ -43693,14 +43875,14 @@ "unconfigure_crypto_pki_server": { "folders": { "iosxe": { - "doc": " Unconfigures crypto pki server on device\n\n Args:\n device (`obj`): Device object\n server_name ('str'): Name of the server\n\n Returns:\n None\n\n Raise:\n SubCommandFailure: Failed to unconfigure crypto pki server on device\n ", - "module_name": "iosxe.eaptls.configure", + "doc": "\n Configure crypto pki server\n Args:\n device ('obj'): Device object\n server_name ('str'): Name for the pki server\n ", + "module_name": "iosxe.pki.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "unconfigure_crypto_pki_server", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eaptls/configure.py#L136" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/pki/configure.py#L604" } } }, @@ -43728,7 +43910,7 @@ "os": "iosxe" }, "uid": "unconfigure_cts_aaa_methods", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1058" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1076" } } }, @@ -43756,7 +43938,7 @@ "os": "iosxe" }, "uid": "unconfigure_cts_enforcement_interface", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L907" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L925" } } }, @@ -43770,7 +43952,7 @@ "os": "iosxe" }, "uid": "unconfigure_cts_enforcement_logging", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1009" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1027" } } }, @@ -43784,7 +43966,7 @@ "os": "iosxe" }, "uid": "unconfigure_cts_manual", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L468" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L486" } } }, @@ -43798,7 +43980,7 @@ "os": "iosxe" }, "uid": "unconfigure_cts_role_based_monitor", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L860" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L878" } } }, @@ -43812,7 +43994,7 @@ "os": "iosxe" }, "uid": "unconfigure_cts_role_based_permission", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L772" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L790" } } }, @@ -43826,7 +44008,7 @@ "os": "iosxe" }, "uid": "unconfigure_cts_role_based_permission_default", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L811" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L829" } } }, @@ -44377,7 +44559,7 @@ "os": "iosxe" }, "uid": "unconfigure_dscp_global", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2358" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2362" } } }, @@ -44391,7 +44573,7 @@ "os": "iosxe" }, "uid": "unconfigure_dscp_radius_server", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2416" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2420" } } }, @@ -44405,7 +44587,7 @@ "os": "iosxe" }, "uid": "unconfigure_dscp_radius_server_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2438" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2442" } } }, @@ -44657,7 +44839,7 @@ "os": "iosxe" }, "uid": "unconfigure_enable_password", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1827" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L1831" } } }, @@ -45231,7 +45413,7 @@ "os": "iosxe" }, "uid": "unconfigure_host_ip_to_sgt_mapping", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L650" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L668" } } }, @@ -45803,7 +45985,7 @@ "os": "iosxe" }, "uid": "unconfigure_interface_cts_role_based_sgt_map", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1147" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L1165" } } }, @@ -47490,14 +47672,14 @@ "unconfigure_ip_multicast_routing_distributed": { "folders": { "iosxe": { - "doc": "Unconfigure ip multicast routing on device\n Args:\n device (`obj`): Device object\n Returns:\n None\n ", - "module_name": "iosxe.mcast.configure", + "doc": "Unconfigure IP multicast routing\n Args:\n device (`obj`): Device object\n no_spd (): Selective packet discard\n punt_limit (`str` or `int`): Punt limit. Acceptable values are:\n integer (packets per second)\n default\n disable\n Return:\n None\n Raise:\n SubCommandFailure: Failure while configuring\n ", + "module_name": "iosxe.multicast.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "unconfigure_ip_multicast_routing_distributed", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/mcast/configure.py#L63" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/multicast/configure.py#L481" } } }, @@ -47833,7 +48015,7 @@ "os": "iosxe" }, "uid": "unconfigure_ip_role_based_acl", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L973" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L991" } } }, @@ -48001,7 +48183,7 @@ "os": "iosxe" }, "uid": "unconfigure_ip_subnet_to_sgt_mapping_vrf", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L730" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L748" } } }, @@ -48029,7 +48211,7 @@ "os": "iosxe" }, "uid": "unconfigure_ip_to_sgt_mapping_vrf", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L689" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L707" } } }, @@ -48232,14 +48414,14 @@ "unconfigure_ipv6_acl": { "folders": { "iosxe": { - "doc": " Unconfigure IPv6 ACL\n\n Args:\n device (`obj`): Device object\n acl_name ('str'): access-list name to unconfigure\n Returns:\n None\n Raises:\n SubCommandFailure\n \n ", - "module_name": "iosxe.acl.configure", + "doc": " Unconfigure IPv6 ACL\n\n Args:\n device (`obj`): Device object\n acl_name ('str'): access-list name\n\n Returns:\n None\n\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.ogacl.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "unconfigure_ipv6_acl", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/acl/configure.py#L499" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/ogacl/configure.py#L372" } } }, @@ -48981,7 +49163,7 @@ "os": "iosxe" }, "uid": "unconfigure_ipv6_subnet_to_sgt_mapping", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L611" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L629" } } }, @@ -48995,7 +49177,7 @@ "os": "iosxe" }, "uid": "unconfigure_ipv6_to_sgt_mapping", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L572" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py#L590" } } }, @@ -49753,7 +49935,7 @@ "os": "iosxe" }, "uid": "unconfigure_mab_on_switchport_mode_access_interface", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2823" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2827" } } }, @@ -51246,6 +51428,20 @@ } } }, + "unconfigure_parameter_map_subscriber": { + "folders": { + "iosxe": { + "doc": "UnConfigure parameter map subscriber\n Args:\n device ('obj'): device to use\n parameter_map_name (`str`): Parameter Map name to be unconfigured\n Returns:\n None\n Raises:\n SubCommandFailure: Failed to unconfigure parameter map subscriber\n ", + "module_name": "iosxe.dot1x.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "unconfigure_parameter_map_subscriber", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/dot1x/configure.py#L2384" + } + } + }, "unconfigure_parser_view": { "folders": { "iosxe": { @@ -51512,6 +51708,20 @@ } } }, + "unconfigure_policy_map_set_cos_cos_table": { + "folders": { + "iosxe": { + "doc": " \n Args:\n device ('obj'): device to use\n policy_map_name ('str'): name of policy-map\n class_name ('str'): class-default or any user defined class name\n table_name('str'): table name\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.policy_map.configure", + "package": "genie.libs.sdk.apis", + "tokens": { + "os": "iosxe" + }, + "uid": "unconfigure_policy_map_set_cos_cos_table", + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py#L1019" + } + } + }, "unconfigure_policy_map_type_service": { "folders": { "iosxe": { @@ -52096,7 +52306,7 @@ "os": "iosxe" }, "uid": "unconfigure_radius_attribute_policy_name_globally", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2953" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2957" } } }, @@ -52110,7 +52320,7 @@ "os": "iosxe" }, "uid": "unconfigure_radius_attribute_policy_name_under_server", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2999" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3003" } } }, @@ -52124,7 +52334,7 @@ "os": "iosxe" }, "uid": "unconfigure_radius_attribute_policy_name_under_servergroup", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3049" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L3053" } } }, @@ -52705,14 +52915,14 @@ "unconfigure_service_private_config_encryption": { "folders": { "iosxe": { - "doc": " \n no service private-config-encryption\n Args:\n device ('obj'): Device object\n Returns:\n None\n Raises:\n SubCommandFailure exception\n ", - "module_name": "iosxe.csdl.configure", + "doc": " no service private-config-encryption\n Args:\n device (`obj`): Device object\n Returns:\n None\n Raises:\n SubCommandFailure : Failed configuring device\n ", + "module_name": "iosxe.sudi.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "unconfigure_service_private_config_encryption", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/csdl/configure.py#L14" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/sudi/configure.py#L60" } } }, @@ -53840,14 +54050,14 @@ "unconfigure_switch_provision": { "folders": { "iosxe": { - "doc": " Unconfigures switch provisioning\n Example : no switch 3 provision\n\n Args:\n device ('obj'): device to use\n switch_number('int'): switch number (Range 1-16)\n\n Returns:\n None\n\n Raises: \n SubCommandFailure\n ", - "module_name": "iosxe.offline_provisioning.configure", + "doc": " Unconfigure switch provision for switch\n Args:\n device ('obj'): Device object\n switch_number('int'): switch number\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.platform.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "unconfigure_switch_provision", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/offline_provisioning/configure.py#L33" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/configure.py#L573" } } }, @@ -54085,7 +54295,7 @@ "os": "iosxe" }, "uid": "unconfigure_tacacs_group", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2292" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2296" } } }, @@ -54099,7 +54309,7 @@ "os": "iosxe" }, "uid": "unconfigure_tacacs_server", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2273" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py#L2277" } } }, @@ -54302,14 +54512,14 @@ "unconfigure_udld_message_time": { "folders": { "iosxe": { - "doc": " Unconfigures udld message time\n Example : no udld message time\n\n Args:\n device ('obj'): device to use\n Returns:\n None\n Raises:\n SubCommandFailure\n ", - "module_name": "iosxe.platform.configure", + "doc": " Unconfigures UDLD Message Time on Target Device globally\n Args:\n device ('obj') : device to use\n Returns:\n None\n Raises:\n SubCommandFailure\n ", + "module_name": "iosxe.udld.configure", "package": "genie.libs.sdk.apis", "tokens": { "os": "iosxe" }, "uid": "unconfigure_udld_message_time", - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/configure.py#L2426" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/udld/configure.py#L113" } } }, diff --git a/pkgs/sdk-pkg/sdk_generator/output/github_triggers.json b/pkgs/sdk-pkg/sdk_generator/output/github_triggers.json index af5fb7ad5..ba7a628ac 100644 --- a/pkgs/sdk-pkg/sdk_generator/output/github_triggers.json +++ b/pkgs/sdk-pkg/sdk_generator/output/github_triggers.json @@ -3723,7 +3723,7 @@ "interval": 10, "max_time": 180 }, - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/modify/bgp/iosxe/modify.py" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/modify/bgp/iosxr/modify.py" }, "top": { "contribute": false, @@ -3800,7 +3800,7 @@ "interval": 10, "max_time": 180 }, - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/modify/bgp/iosxe/modify.py" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/modify/bgp/iosxr/modify.py" }, "top": { "contribute": false, @@ -3958,7 +3958,7 @@ "interval": 10, "max_time": 180 }, - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/modify/interface/iosxe/modify.py" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/modify/interface/iosxr/modify.py" }, "top": { "contribute": false, @@ -8511,7 +8511,7 @@ "interval": 10, "max_time": 180 }, - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/shutnoshut/interface/iosxe/shutnoshut.py" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/shutnoshut/interface/iosxr/shutnoshut.py" }, "top": { "contribute": false, @@ -9016,7 +9016,7 @@ "interval": 10, "max_time": 180 }, - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/unconfigconfig/bgp/iosxe/unconfigconfig.py" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/unconfigconfig/bgp/iosxr/unconfigconfig.py" }, "top": { "contribute": false, @@ -9818,7 +9818,7 @@ "interval": 10, "max_time": 180 }, - "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/unconfigconfig/bgp/iosxe/unconfigconfig.py" + "url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/sdk-pkg/src/genie/libs/sdk/triggers/unconfigconfig/bgp/iosxr/unconfigconfig.py" }, "top": { "contribute": false, diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/__init__.py index 15d01783f..c9c47e4c3 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/__init__.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/__init__.py @@ -7,7 +7,7 @@ ''' # metadata -__version__ = '24.10' +__version__ = '24.11' __author__ = 'Cisco Systems Inc.' __contact__ = ['pyats-support@cisco.com', 'pyats-support-ext@cisco.com'] __copyright__ = 'Copyright (c) 2020, Cisco Systems Inc.' diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/api_unittest_generator.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/api_unittest_generator.py index 06b7564af..384f6ef27 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/api_unittest_generator.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/api_unittest_generator.py @@ -1,5 +1,9 @@ +from __future__ import annotations import argparse +import ast +import dill import importlib +import inspect import logging import os import pprint @@ -49,29 +53,18 @@ def __init__(self, *args, **kwargs): self.start_time = datetime.now() self.end_time = None - def add_successful_test(self, values): + def add_test_result(self, values, success:bool): """ Adds API test to a dictionary containing successful tests Args: values (dict): all key-value pairs to add + success (bool): if it is a successful test or a failure Returns: None """ - for key, value in values.items(): - self._tests['passed'][key] = value - - def add_failed_test(self, values): - """ - Adds API test to a dictionary containing failed tests - - Args: - values (dict): all key-value pairs to add - Returns: - None - """ - for key, value in values.items(): - self._tests['failed'][key] = value + test_result = 'passed' if success else 'failed' + self._tests[test_result].update(values) def print_results(self, *args, **kwargs): """ @@ -125,18 +118,336 @@ def print_results(self, *args, **kwargs): for k, v in self._tests['failed'].items(): logger.info('{}: {}'.format(k, v)) + logger.info('='*DEFAULT_HEADER_WIDTH) + logger.warning('Tests have been generated but still need to be executed to ensure they work correctly.') + logger.warning('To run the tests, navigate to the folder created by the script and use the following command:') + logger.warning('python -m unittest test_*.py') + logger.info('='*DEFAULT_HEADER_WIDTH) + + +class MethodCallVisitor(ast.NodeVisitor): + def __init__(self, device_class_name): + self.device_class_name = device_class_name + self.calls = [] + + def visit_Call(self, node): + if isinstance(node.func, ast.Attribute): + if isinstance(node.func.value, ast.Name) and node.func.value.id == self.device_class_name: + self.calls.append(node.func.attr) + self.generic_visit(node) + class TestGenerator: - def __init__( - self, - testbed, - device, - module=None, - module_path=None, - api=None, - test_arguments=None, - test_arguments_yaml=None, - destination=None): + def __init__(self, device, module_import, api): + self.device = device + self.module_import = module_import + self.api = api + + def _build_imports(self): + return [ + 'from unittest import TestCase', + 'from {} import {}'.format(self.module_import, self.api.__name__) + ] + + def build_test_class(self): + """ + Creates a test class for the given API. + + Returns: + dict: a dictionary containing the file content. + """ + + api_name = self.api.__name__ + + # load module into unit test + # Create setUpClass to connect to mocked device + imports = self._build_imports() + + class_name = 'Test' + ''.join( + [c.capitalize() for c in api_name.split('_')]) + + ret_dict = { + 'api': api_name, + 'class_name': class_name, + 'device': self.device.name, + 'imports': imports, + } + + return ret_dict + + def build_test_method(self, arguments, result): + """ + Creates a test method for the given API and its arguments. + + Args: + api_name (str): The name of the API. + arguments (str): A comma-separated string containing test arguments + result: the output of the API call + Returns: + dict: Arguments to render a test method in the jinja template + """ + expected_output = pprint.pformat(result) + + ret_dict = { + 'api': self.api.__name__, + 'arguments': arguments, + 'expected_output': expected_output + } + + return ret_dict + + def build_write_args(self, arguments, varargs, kwargs): + """ + Builds a string containing all arguments used in a test. + + Args: + arguments (dict): The arguments necessary to run the test + varargs (dict): Positional arguments necessary to run the test + kwargs (dict): Keyword arguments necessary to run the test + Returns: + str: a string containing all arguments used in the API call + """ + + write_args = [] + + for value in arguments: + if value == self.device: + arg_value = 'self.device' + else: + arg_value = pprint.pformat(value) + write_args.append('{}'.format(arg_value)) + if varargs: + for var in varargs: + write_args.append('{}'.format(var)) + if kwargs: + for key, value in kwargs.items(): + arg_value = pprint.pformat(value) + write_args.append('{}={}'.format(key, arg_value)) + + return ', '.join(write_args) + + def create_test_files(self, test_file_data:dict, template:"Template", destination:str): + """ + Arguments: + test_file_data (dict): Dictionary containing all data required to build the test script + template (Template): Jinja template + """ + api_folder = os.path.join(destination, self.api.__name__) + + Path(api_folder).mkdir(parents=True, exist_ok=True) + + # create empty __init__.py file + with open(os.path.join(api_folder, '__init__.py'), 'w'): pass + + file_name = os.path.join( + api_folder, f'{TEST_FILE_NAME_PREFIX}{self.api.__name__}.py') + + # generate file content from jinja template + content = template.render(test_file_data) + with open(file_name, 'w') as tf: + tf.write(content) + + def get_api_expected_output(self, arguments, api_result, index=0): + api = arguments.get(self.api.__name__, {}) + if 'arguments' in api: + if isinstance(api['arguments'], list): + test_instance = api['arguments'][index] + else: + test_instance = api['arguments'] + # if expected output is provided, return it + # if not, use API result instead + if expected_result := test_instance.get('expected_output'): + return expected_result + else: + return api_result + return None + + def get_mock_data_file(self): + # collects data from pickle file with device name + return os.path.join(TEMP_DIR, self.device.name) + + +class ParserTestGenerator(TestGenerator): + """ + This is the original test generator. + It uses unicon recordings to generate mock data and unit tests that load them to compare outputs + """ + def _build_imports(self): + imports = ['import os', 'from pyats.topology import loader'] + imports.extend(super()._build_imports()) + return imports + + def _create_testbed(self): + """ + Creates the testbed file used to connect to the mock data. + + Args: + api_name (str): the name of the API + mock_data_path (str): the path to the mock data folder + Returns: + None + """ + + cmd = 'mock_device_cli --os {} --mock_data_dir {{os.path.dirname(__file__)}}/{} --state connect'.\ + format(self.device.os, MOCK_DATA_FOLDER) + + tb_info = { + 'cmd': cmd, + 'device': self.device.name, + 'os': self.device.os, + 'platform': self.device.platform, + 'type': self.device.type, + 'has_mock_data': True + } + + return tb_info + + def _create_mock_data(self, destination, router='switch'): + """ + Creates mock data YAML file and corresponding testbed file + + Args: + api_name (str): name of the API + router (str): name of the router/hostname + Returns: + None + """ + + # creates data YAML file and testbed file + mock_data_path = os.path.join( + destination, self.api.__name__, MOCK_DATA_FOLDER) + outfile = os.path.join( + mock_data_path, self.device.os, MOCK_DATA_FILE_NAME) + + # collects data from pickle file with device name + file_name = self.get_mock_data_file() + + self.device.create_yaml( + file_name, router, outfile, allow_repeated_commands=True) + + def create_test_files(self, test_file_data:dict, template:"Template", destination:str): + """ + Arguments: + test_file_data (dict): Dictionary containing all data required to build the test script + template (Template): Jinja template + destination (str): Test's parent folder + """ + test_file_data.update(self._create_testbed()) + + super().create_test_files(test_file_data, template, destination) + + # create mock data and testbed file for test cases + self._create_mock_data(destination, router=self.device.hostname) + + +class ConfigureTestGenerator(TestGenerator): + def _build_imports(self): + imports = super()._build_imports() + imports.append('from unittest.mock import Mock') + return imports + + def _create_mock_variables(self): + data_path = self.get_mock_data_file() + + with open(data_path, 'rb') as f: + data = dill.load(f) + + configure_calls = [] + + for cli, _ in data['configure'].items(): + # breaks multiple commands into a list of commands + # e.g. ['ip access-list extended acl_in', 'permit ip any any'] + if cli.startswith('[') or cli.endswith(']'): + # if multiple commands, create one key for each command + configure_calls.append([c.strip() for c in cli.replace("'", '').strip("']['").split(',')]) + else: + configure_calls.append(pprint.pformat(cli)) + + return { + 'test_type': 'configure', + 'configure_calls': configure_calls + } + + def create_test_files(self, test_file_data: dict, template: "Template", destination: str): + test_file_data.update(self._create_mock_variables()) + print('This is the test_file_data:', test_file_data) + return super().create_test_files(test_file_data, template, destination) + + +class ExecuteTestGenerator(TestGenerator): + def _build_imports(self): + imports = super()._build_imports() + imports.append('from unittest.mock import Mock') + return imports + + def _create_mock_variables(self): + data_path = self.get_mock_data_file() + + with open(data_path, 'rb') as f: + data = dill.load(f) + + execute_asserts = {} + + for cli, output in data['execute'].items(): + if cli in 'show version': + continue + # gets only first output recorded for a command + # this might not work on all cases + execute_asserts[cli] = output[0]['output'] + return { + 'test_type': 'execute', + 'execute_asserts': execute_asserts + } + + def create_test_files(self, test_file_data: dict, template: "Template", destination: str): + test_file_data.update(self._create_mock_variables()) + return super().create_test_files(test_file_data, template, destination) + + +class TestFactory: + + @classmethod + def _inspect_function(cls, func, device_class_name): + source = ast.parse(inspect.getsource(func)) + visitor = MethodCallVisitor(device_class_name) + visitor.visit(source) + return visitor.calls + + @classmethod + def select_test_generator(cls, device, module_import, api): + """ + Create a test object based on the API name. + + Args: + device (obj): The device object. + api_name (str): The name of the API. + arguments (str): A comma-separated string containing test arguments. + + Returns: + Test: An instance of the appropriate test class. + """ + # extracts a list of all device method calls to determine which approach to use + method_calls = cls._inspect_function(api, 'device') + + if 'parse' in method_calls: + return ParserTestGenerator(device, module_import, api) + elif 'execute' in method_calls: + return ExecuteTestGenerator(device, module_import,api) + elif 'configure' in method_calls: + return ConfigureTestGenerator(device, module_import, api) + else: + # default generator for now + return ParserTestGenerator(device, module_import, api) + + +class APIUTGenerator: + def __init__(self, + testbed, device, + module=None, module_path=None, + api=None, + test_arguments=None, test_arguments_yaml=None, + destination=None): + self.testbed = testbed try: self.device = self.testbed.devices[device] @@ -158,8 +469,7 @@ def __init__( self.test_arguments = self._load_arguments( test_arguments, test_arguments_yaml) self.report = TestReport() - self.template_env = Environment( - loader=FileSystemLoader(TEMPLATE_FOLDER)) + self.template_env = Environment(loader=FileSystemLoader(TEMPLATE_FOLDER)) def run(self): """ @@ -170,90 +480,67 @@ def run(self): for api_name, api in self.apis: print_header('Generating tests for API {}'.format(api_name)) - argspec = getfullargspec(api) - arguments = argspec.args - varargs = argspec.varargs - varkw = argspec.varkw - defaults = argspec.defaults + api_args = self._build_api_args(api) - api_args = self._build_api_args( - api_name, arguments, varargs, varkw, defaults) + test_generator = TestFactory.select_test_generator( + self.device, + self.module_import, + api + ) - test_info = (self._build_test_class(api_name)) + test_info = test_generator.build_test_class() - try: - self._set_stored_data() - except Exception: - logger.error('Failed to record device information') - self._cleanup() - raise + self._set_stored_data() test_class = test_info.setdefault('unit_tests', []) # generates a test for each item in the list of API arguments for index, test_arg in enumerate(api_args): - # if test arguments contain the expected output - # extract it from list of arguments - expected_output = self._get_api_expected_output( - api_name, index) + report_result = {} + expected_output = None try: args, varargs, kwargs = test_arg + # api call result api_result = api(*args, *varargs, **kwargs) + # if test arguments contain the expected output + # extract it from list of arguments + expected_output = test_generator.get_api_expected_output(self.test_arguments, api_result, index) except TypeError as t: - error_message = \ - 'Update test-arguments YAML: {}'.\ - format(t) - - logger.warning(error_message) - self.report.add_failed_test({api_name: error_message}) + message = f'Update test-arguments YAML: {t}' + logger.warning(message) + report_result = {api_name: message} + self.report.add_test_result(report_result, success=False) continue except Exception as e: - logger.warning(e) - # add to report as a failure - self.report.add_failed_test({api_name: e}) + report_result = {api_name: e} + self.report.add_test_result(report_result, success=False) continue if expected_output and expected_output != api_result: # API result does not match expected_output - error_message = 'API result does not match expected output' - logger.warning(error_message) + message = 'API result does not match expected output' + logger.warning(message) # add to report as a failure - self.report.add_failed_test({api_name: error_message}) + report_result = {api_name: message} + self.report.add_test_result(report_result, success=False) else: - arguments = self._build_write_args(args, varargs, kwargs) - test_class.append(self._build_test_method( - api_name, - arguments, - api_result - )) - - self.report.add_successful_test({api_name: 'Created'}) + arguments = test_generator.build_write_args(args, varargs, kwargs) + test_class.append( + test_generator.build_test_method( + arguments, + expected_output + ) + ) + report_result = {api_name: 'Created'} + self.report.add_test_result(report_result, success=True) # if there are tests to generate if test_class: - test_info.update(self._create_testbed()) - - template = self.template_env.get_template(TEMPLATE_TEST) - api_folder = os.path.join( - self.destination, api_name) - - Path(api_folder).mkdir(parents=True, exist_ok=True) - - # create empty __init__.py file - init_file = os.path.join(api_folder, '__init__.py') - with open(init_file, 'w'): pass - - test_file_name = '{}{}.py'.format( - TEST_FILE_NAME_PREFIX, api_name) - file_name = os.path.join(api_folder, test_file_name) - - # generate file content from jinja template - content = template.render(test_info) - with open(file_name, 'w') as tf: - tf.write(content) - # create mock data and testbed file for test cases - self._create_mock_data( - api_name, router=self.device.hostname) + test_generator.create_test_files( + test_file_data=test_info, + template=self.template_env.get_template(TEMPLATE_TEST), + destination=self.destination + ) # resets recording before next API call self._reset_stored_data() @@ -263,38 +550,31 @@ def run(self): self._cleanup() print_args = {'destination': self.destination} + # tests were generated in a folder other than the default if hasattr(self, 'base_destination'): print_args.update({'base_destination': self.base_destination}) self.report.print_results(**print_args) - def _get_api_expected_output(self, api_name, index=0): - api = self.test_arguments.get(api_name, {}) - if 'arguments' in api: - if isinstance(api['arguments'], list): - test_instance = api['arguments'][index] - else: - test_instance = api['arguments'] - return test_instance.get('expected_output', None) - return None - - def _build_api_args(self, api_name, args, - varargs, varkw, defaults): + def _build_api_args(self, api): """ Creates list of test arguments for the given API. Args: - api_name (str): the name of the API - arguments (str): API arguments - varargs (str): the name of the variable containing positional arguments - varkw (str): the name of the variable containing keyword arguments - defaults (list): all default values for the given API + api (obj): the API Returns: list: List of dictionaries with API arguments and values """ def_args = {} args_list = [] - test_args_list = self._get_test_arguments(api_name) + # get arguments from API reference + argspec = getfullargspec(api) + args = argspec.args + varargs = argspec.varargs + varkw = argspec.varkw + defaults = argspec.defaults + + test_args_list = self._get_test_arguments(api.__name__) # if test arguments are not provided if not test_args_list: @@ -333,112 +613,7 @@ def _build_api_args(self, api_name, args, api_varkw = test_args_dict[varkw] args_list.append((api_args, api_varargs, api_varkw)) - return args_list - - def _build_test_class(self, api_name): - """ - Creates a test class for the given API. - - Args: - api_name: the name of the API - Returns: - dict: a dictionary containing the file content. - """ - - # load module into unit test - # Create setUpClass to connect to mocked device - imports = [ - 'import os', - 'import unittest', - 'from pyats.topology import loader', - 'from {} import {}'.format(self.module_import, api_name) - ] - - class_name = 'Test' + ''.join( - [c.capitalize() for c in api_name.split('_')]) - - ret_dict = { - 'api': api_name, - 'class_name': class_name, - 'device': self.device.name, - 'imports': imports, - } - - return ret_dict - - def _build_test_method(self, api_name, arguments, value): - """ - Creates a test method for the given API and its arguments. - - Args: - api_name (str): The name of the API. - arguments (str): A comma-separated string containing test arguments - Returns: - dict: Arguments to render a test method in the jinja template - """ - value = pprint.pformat(value) - - ret_dict = { - 'api': api_name, - 'arguments': arguments, - 'expected_output': value - } - - return ret_dict - - def _build_write_args(self, arguments, varargs, kwargs): - """ - Builds a string containing all arguments used in a test. - - Args: - arguments (dict): The arguments necessary to run the test - varargs (dict): Positional arguments necessary to run the test - kwargs (dict): Keyword arguments necessary to run the test - Returns: - str: a string containing all arguments used in the API call - """ - - write_args = [] - - for value in arguments: - if value == self.device: - arg_value = 'self.device' - else: - arg_value = pprint.pformat(value) - write_args.append('{}'.format(arg_value)) - if varargs: - for var in varargs: - write_args.append('{}'.format(var)) - if kwargs: - for key, value in kwargs.items(): - arg_value = pprint.pformat(value) - write_args.append('{}={}'.format(key, arg_value)) - - return ', '.join(write_args) - - def _create_testbed(self): - """ - Creates the testbed file used to connect to the mock data. - - Args: - api_name (str): the name of the API - mock_data_path (str): the path to the mock data folder - Returns: - None - """ - - cmd = 'mock_device_cli --os {} --mock_data_dir {{os.path.dirname(__file__)}}/{} --state connect'.\ - format(self.device.os, MOCK_DATA_FOLDER) - - tb_info = { - 'cmd': cmd, - 'device': self.device.name, - 'os': self.device.os, - 'platform': self.device.platform, - 'type': self.device.type, - } - - return tb_info + return args_list def _get_test_arguments(self, api_name): ''' @@ -664,29 +839,6 @@ def _reset_stored_data(self): # adds connection data back to the recording self.device.update_stored_data(self._connected_data) - def _create_mock_data(self, api_name, router='switch'): - """ - Creates mock data YAML file and corresponding testbed file - - Args: - api_name (str): name of the API - router (str): name of the router/hostname - Returns: - None - """ - - # creates data YAML file and testbed file - mock_data_path = os.path.join( - self.destination, api_name, MOCK_DATA_FOLDER) - outfile = os.path.join( - mock_data_path, self.device.os, MOCK_DATA_FILE_NAME) - - # collects data from pickle file with device name - file_name = os.path.join(TEMP_DIR, self.device.name) - - self.device.create_yaml( - file_name, router, outfile, allow_repeated_commands=True) - if __name__ == '__main__': logging.basicConfig(stream=sys.stdout, level=logging.INFO) @@ -751,14 +903,11 @@ def _create_mock_data(self, api_name, router='switch'): args = parser.parse_args() - test_generator = TestGenerator( - args.testbed, - args.device, - module=args.module, - module_path=args.module_path, + APIUTGenerator( + args.testbed, args.device, + module=args.module, module_path=args.module_path, api=args.api, test_arguments=args.test_arguments, test_arguments_yaml=args.test_arguments_yaml, - destination=args.destination) - - test_generator.run() + destination=args.destination + ).run() \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py index 560e5a452..22ccf67e9 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/aaa/configure.py @@ -1692,7 +1692,8 @@ def configure_masked_unmasked_credentials (device, ccp_name=None, algorithm_type=None, masked=True, - secret=True,): + secret=True, + view=None,): """ Configure masked or unmasked credentials with privilege,common criteria policy and encryption algorithm type. @@ -1706,6 +1707,7 @@ def configure_masked_unmasked_credentials (device, algorithm_type ('str', optional): specified algorithm type else None masked ('bool'): masked secret if True else unmasked. secret ('bool'): secret if True else plain-text + view ('str', optional): specified CLI view else None Return : None Raise: @@ -1714,6 +1716,8 @@ def configure_masked_unmasked_credentials (device, cmd=f"username {username}" if privilege : cmd+=f" privilege {privilege}" + if view: + cmd+=f" view {view}" if ccp_name : cmd+=f" common-criteria-policy {ccp_name}" if algorithm_type : diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py index 5b58528f8..0a27bf334 100755 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/cts/configure.py @@ -403,6 +403,24 @@ def remove_default_ipv4_sgacl(device, sgacl): "Could not remove default sgacl {}.Error: {}".format(sgacl,str(e)) ) +def remove_default_ipv6_sgacl(device, sgacl): + """ Remove a default static SGACL(ipv6) + Args: + device ('obj'): device to use + sgacl ('str'): Role-based Access-list name + Returns: + None + Raises: + SubCommandFailure: Failed to remove default static SGACL(ipv6) + """ + log.info("Remove default ipv6 SGACL") + try: + device.configure(["no cts role-based permissions default ipv6 {}".format(sgacl)]) + except SubCommandFailure as e: + raise SubCommandFailure( + "Could not remove default sgacl ipv6 {}.Error: {}".format(sgacl,str(e)) + ) + def clear_cts_credentials(device): """ clear CTS credentials Args: diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/debug/configure.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/debug/configure.py index b98d5bc96..f827bdbf8 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/debug/configure.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/debug/configure.py @@ -470,4 +470,42 @@ def debug_platform_software_fed_drop_capture_buffer( except SubCommandFailure as e: raise SubCommandFailure( f"Could not configure debug platform software fed drop-capture commands on {device}. Error:\n{e}" - ) \ No newline at end of file + ) + +def set_platform_soft_trace_ptp_debug(device, sprocess, snumber, feature_type, debug_type, switch=None): + ''' set platform software trace fed ptp debug + Args: + device ('obj'): Device object + sprocess ('str'): process for trace logs + feature_type ('str'): feature name + debug_type ('str'): type of the debugs warning/debug etc + switch ('str', optional): switch for SVL/Stack devices + snumber ('str', optional): switch number 1/2/active/standby + ''' + if switch: + cmd = f"set platform software trace {sprocess} {switch} {snumber} {feature_type} {debug_type}" + else: + cmd = f"set platform software trace {sprocess} {snumber} {feature_type} {debug_type}" + try: + device.execute(cmd) + except SubCommandFailure as e: + raise SubCommandFailure(f"Could not set platform software trace fed debug {device}. Error:\n{e}") +def debug_software_cpm_switch_pcap(device, mode, enable_disable): + """ debug software cpm switch pcap + Args: + device ('obj'): device to use + mode ('str'): active/standby + enable_disable('str'): enable or disable + Returns + None + Raises: + SubCommandFailure + """ + + cmd = f"debug platform software cpm switch {mode} b0 pcap {enable_disable}" + try: + device.execute(cmd) + except SubCommandFailure as e: + + raise SubCommandFailure(f"Failed to perform pcap enable/disable. Error:\n{e}") + \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/dot1x/configure.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/dot1x/configure.py index e74e5f3a6..8bcc51338 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/dot1x/configure.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/dot1x/configure.py @@ -2380,3 +2380,23 @@ def unconfigure_parameter_map(device, parameter_map_name): raise SubCommandFailure( f"Failed to unconfigure parameter map {parameter_map_name}.Error:\n{e}" ) + +def unconfigure_parameter_map_subscriber(device, parameter_map_name): + """UnConfigure parameter map subscriber + Args: + device ('obj'): device to use + parameter_map_name (`str`): Parameter Map name to be unconfigured + Returns: + None + Raises: + SubCommandFailure: Failed to unconfigure parameter map subscriber + """ + cmd = f'no parameter-map type subscriber attribute-to-service {parameter_map_name}' + + log.debug("UnConfigure parameter map subscriber") + + try: + device.configure(cmd) + except SubCommandFailure as e: + raise SubCommandFailure( + "Could not unconfigure parameter map subscriber") \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py index 886e26223..e9bb165cc 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/health/health.py @@ -9,13 +9,14 @@ from genie.metaparser.util.exceptions import (SchemaEmptyParserError, InvalidCommandError) from genie.libs.parser.iosxe.show_logging import ShowLogging +from genie.utils import Dq # Logger log = logging.getLogger(__name__) def health_cpu(device, - command='show processes cpu sorted | exclude 0.00%', + command=['show processes cpu sorted | exclude 0.00%', 'show processes cpu platform sorted | exclude 0%'], processes=None, check_key='five_sec_cpu', check_key_total='five_sec_cpu_total', @@ -27,8 +28,8 @@ def health_cpu(device, Args: device (`obj`): Device object - command (`str`): Override show command - Default to `show processes cpu` + command (`str`) or list(`str`): Override show commands + Default to `show processes cpu sorted` and `show processes cpu platform sorted` processes (`list`): List of processes to check if not specified, will return one ALL_PROCESSES with total cpu load @@ -57,16 +58,23 @@ def health_cpu(device, ''' cpu_load_dict = {} - - try: - parsed = device.parse(command, output=output, timeout=timeout) - except SchemaEmptyParserError as e: - log.error("Command '{cmd}' did not return any output\n{msg}".\ - format(cmd=command, msg=str(e))) + parsed_output = [] + # Check if the command is a list if its not make it a list + if not isinstance(command, list): + command = [command] + # loop through the list of commands and add the parsed output to parsed_output + for cmd in command: + try: + parsed = device.parse(cmd, output=output, timeout=timeout) + parsed_output.append(parsed) + except SchemaEmptyParserError as e: + log.error(f"Command '{cmd}' did not return any output\n{e}") + if not parsed_output: return None if processes: for ps_item in processes: + for output in parsed_output: # To get process id based on check_key # { # (snip)) @@ -75,14 +83,17 @@ def health_cpu(device, # "process": "Chunk Manager", # (snip) # "five_sec_cpu": 0.0, - indexes = parsed.q.contains_key_value( - 'process', ps_item, value_regex=True).get_values('sort') - for index in indexes: - cpu_load_dict.update({ - parsed['sort'][index]['process']: - parsed['sort'][index][check_key] - }) - + indexes = Dq(output).contains_key_value( + 'process', ps_item, value_regex=True).get_values('sort') + for index in indexes: + if output['sort'][index]['process'] not in cpu_load_dict: + process = output['sort'][index]['process'] + else: + process = output['sort'][index]['process'] + '_1' + cpu_load_dict.update({ + process: + output['sort'][index][check_key] + }) # if health is True, change the dict # from: # cpu_load_dict = { @@ -102,6 +113,11 @@ def health_cpu(device, # } # ] # } + # if we have more than one parser we use the one with biggest value of the the 2 commands for the check_key_total + if len(parsed_output) == 2 and parsed_output[1].get('cpu_utilization', {}).get(check_key_total): + total = max(float(parsed_output[0][check_key_total]), float(parsed_output[1]['cpu_utilization'][check_key_total])) + else: + total = float(parsed_output[0][check_key_total]) if health: health_data = {} health_data.setdefault('health_data', []) @@ -110,14 +126,14 @@ def health_cpu(device, 'process': 'ALL_PROCESSES', 'value': - float(parsed[check_key_total]) + total }) for k, v in cpu_load_dict.items(): health_data['health_data'].append({'process': k, 'value': v}) return health_data if add_total: - cpu_load_dict.update({'ALL_PROCESSES': float(parsed[check_key_total])}) + cpu_load_dict.update({'ALL_PROCESSES': total}) return cpu_load_dict diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py index bd30252d2..e819872be 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/install/execute.py @@ -305,6 +305,11 @@ def slow_sendline(spawn): args = None, loop_continue = False, continue_timer = False), + Statement(pattern = r".*FAILED\: install_add_activate_commit.*", + action = None, + args = None, + loop_continue = False, + continue_timer = False), ]) log.info(f"Perform install one shot {device.name}") @@ -326,7 +331,7 @@ def slow_sendline(spawn): try: device.api.execute_write_memory() - output = device.execute(cmd, reply=dialog, timeout=timeout) + _, output = device.reload(cmd, reply=dialog, timeout=timeout, return_output=True) except Exception as e: log.error(f"Error while executing {cmd} on {device.name}: {e}") @@ -988,4 +993,5 @@ def slow_sendline(spawn): match = re.search(r".*SUCCESS: install_add_activate_commit.*", output) result = 'successful' if match else 'failed' log.info(f"install reloadfast {result} on {device.name}") - return output if match else match \ No newline at end of file + return output if match else match + diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/configure.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/configure.py index 2c2a1bb37..6351d8384 100755 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/configure.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/configure.py @@ -10535,4 +10535,23 @@ def unconfigure_port_channel(device, port_channel): raise SubCommandFailure( f"Failed to unconfigure interface Port-channel {port_channel}. Error: {e}") - +def configure_interface_speed_auto(device, interface): + """ configure speed auto on interface + Args: + device ('obj'): Device object + interface ('str'): Interface name + Returns: + None + Raises: + SubCommandFailure + """ + log.debug(f"Configuring speed auto on interface {interface}") + + config = [ + f'interface {interface}', + 'speed auto' + ] + try: + device.configure(config) + except SubCommandFailure as e: + raise SubCommandFailure(f"Could not configure speed auto on {interface}. Error:\n{e}") diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/execute.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/execute.py index 604baa667..b1707529c 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/execute.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/interface/execute.py @@ -144,4 +144,76 @@ def execute_test_fru_fake_insert(device, mode): out = device.execute(cmd) except SubCommandFailure as e: raise SubCommandFailure(f'Failed to perform FRU Fake-insert. Error:\n{e}') - return out \ No newline at end of file + return out + +def execute_test_platform_hardware_cman(device, cman, mode, route_processor, function=None, sub_functional_part=None, action=None, action2=None, slot=0): + """ + Execute 'test platform hardware cman_thermal switch {mode} {route_processor} {function} {sub_functional_part} {action}' command on the device. + Args: + device (obj): Device object for executing commands. + cman (str): CMAN type, either 'cman_thermal' or 'cman_fep'. + mode (str): Mode of operation. Options are 'active/standby', '1', or '2'. + route_processor (str): Route processor, such as 'R0' or 'RP'. + function (str, optional): Functional aspect to control. Options include 'fan', 'status', or 'temperature'. + Default is None. + sub_functional_part (str, optional): Sub-functional part. Can be one of 'fake', 'hotspot', 'inlet', 'outlet', or + 'fan-curve'. Default is None. + action (str, optional): Action to perform. Options include 'on', 'off', any integer between -255 and 255, or one + of 'normal', 'test', or 'turbo'. Default is None. + action2 (str, optional): Secondary action, either 'on' or 'off'. Default is None. + slot (int, optional): Slot number. Can be 0, 1, or 2. Default is 0. + + Returns: + str: Output of the command + """ + if cman == 'cman-fep': + command = f"test platform hardware {cman} switch {mode} {route_processor} {slot} dump-statistics" + elif action2: + command = f"test platform hardware {cman} switch {mode} {route_processor} {function} {sub_functional_part} {action} {action2}" + elif sub_functional_part: + command = f"test platform hardware {cman} switch {mode} {route_processor} {function} {sub_functional_part} {action}" + else: + command = f"test platform hardware {cman} switch {mode} {route_processor} {function}" + + try: + device.execute(command) + except SubCommandFailure as e: + raise SubCommandFailure(f"Failed to execute test platfrom hardware cman_thermal. Error:\n{e}") + +def execute_test_sfp_port_lpn_fake_insert(device, mode, lpn_num): + """ + Args: + device ('obj'): device to use + mode ('str'): mode active/ standby + lpn_num ('str'): lpn number + Returns: + Return the test command execution output + Raises: + SubCommandFailure + """ + cmd = f"test platform software fed switch {mode} sfp port {lpn_num} fake-insert" + try: + out = device.execute(cmd) + except SubCommandFailure as e: + raise SubCommandFailure('Failed to perform sfp port lpn Fake-insert.Error:\n{e}') + return out + +def execute_test_sfp_port_lpn_fake_remove(device, mode, lpn_num): + """ + Args: + device ('obj'): device to use + mode ('str'): mode active/ standby + lpn_num ('str'): lpn number + Returns: + Return the test command execution output + Raises: + SubCommandFailure + """ + cmd = f"test platform software fed switch {mode} sfp port {lpn_num} fake-remove" + try: + out = device.execute(cmd) + except SubCommandFailure as e: + + raise SubCommandFailure('Failed to perform sfp port lpn Fake-remove.Error:\n{e}') + return out + diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py index 74e6afb7d..fce9aef59 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/platform/execute.py @@ -1782,6 +1782,22 @@ def send_username(spawn): log.debug(f"Reload is successful on {device.name}") return True +def request_platform_software_trace_rotate_all(device): + """ Request platform software trace rotate all + Args: + device (`obj`): Device object + + Return: + None + Raise: + SubCommandFailure: Failed configuring + """ + cmd = f"request platform software trace rotate all" + try: + device.execute(cmd) + except SubCommandFailure as e: + raise SubCommandFailure(f"Could not perform request platform software rotate all {device}. Error:\n{e}") + def platform_software_fed_switch_phy_options(device, mode, lpn, phy_info, read_mode, phy_mode, phy_side, phy_device_id, phy_page_number, phy_register_address): """ Execute 'test platform software fed switch' command with the specified parameters. @@ -1852,3 +1868,69 @@ def test_platform_software_fru_fake_insert_remove(device, switch_num, action): except SubCommandFailure as e: raise SubCommandFailure(f"Failed to perform fake insert/remove for fru. Error:\n{e}") + +def platform_hardware_fed_switch_phy_debug(device, mode, port_num, debug_command_options): + """Execute a PHY debug command on the specified switch and port + Args: + device ('obj'): Device to use + mode ('str'): Mode identifier (e.g., 'active') + port_num ('int'): Port number + debug_command_options ('str'): Debug command to execute + Returns: + None + Raises: + SubCommandFailure + """ + + cmd = f"test platform hardware fed switch {mode} port {port_num} phy phy-debug Debug_Command {debug_command_options}" + + try: + device.execute(cmd) + except SubCommandFailure as e: + raise SubCommandFailure(f"Failed to execute PHY debug command. Error:\n{e}") + +def execute_diagnostic_start_switch_port(device, switch_number, test_id, port_num): + """ execute diagnostic start switch 1 test + Args: + device ('obj'): Device object + test_id ('str'): Test ID list (e.g. 1,3-6) or Test Name or minimal or complete + Interface port number WORD Port number list (e.g. 2,4-7) + switch_number ('int'): Switch number on which diagnostic has to be performed + port ('str'): word (e.g. 1-8 or all) + Returns: + None + Raises: + SubCommandFailure + """ + if test_id and port_num: + cmd = f"diagnostic start switch {switch_number} test {test_id} port {port_num}" + else: + raise ValueError("Both test_id and port_num must be provided.") + try: + device.execute(cmd) + except SubCommandFailure as e: + raise SubCommandFailure( + + f"Could not execute diagnostic start switch {switch_number} test {test_id} on device. Error:\n{e}") + +def request_platform_hardware_pfu(device, mode, route_processor, slot, action): + """ request platform hardware pfu switch 1 R0 set-power-slot 0 on + Args: + device (obj): Device object + mode (str): The switch number or mode. Specify as a number (e.g., '1', '2') or as a mode such as 'active' or 'standby' to identify the target switch. + route_processor (str): The route processor unit for the switch, such as 'R0' or 'RP'. This typically identifies the control processor for the specified switch. + slot (int): The slot number for the hardware component or module where the power will be set. Use '0' or a relevant slot number, depending on the switch type or configuration. + action ('str'): off/on + Returns: + Command output + Raises: + SubCommandFailure + """ + + cmd = f'request platform hardware pfu switch {mode} {route_processor} set-power-slot {slot} {action}' + + try: + output = device.execute(cmd) + except SubCommandFailure as e: + raise SubCommandFailure(f"Failed to perform powerslot off/on Error:\n{e}") + diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py index 753d488a7..7aa95aa81 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/policy_map/configure.py @@ -1016,6 +1016,33 @@ def configure_policy_map_set_cos_cos_table(device, policy_map_name, class_name, except SubCommandFailure as e: raise SubCommandFailure("Could not configure policy map set cos cos table. Error:\n{error}".format(error=e)) +def unconfigure_policy_map_set_cos_cos_table(device, policy_map_name, class_name, table_name): + """ + Args: + device ('obj'): device to use + policy_map_name ('str'): name of policy-map + class_name ('str'): class-default or any user defined class name + table_name('str'): table name + Returns: + None + Raises: + SubCommandFailure + """ + config = [] + + if class_name != 'class-default': + config.append("class-map {}".format(class_name)) + + config.extend([ + "policy-map {}".format(policy_map_name), + "class {}".format(class_name), + "no set cos cos table {}".format(table_name) + ]) + + try: + device.configure(config) + except SubCommandFailure as e: + raise SubCommandFailure("Could not unconfigure policy map set cos cos table. Error:\n{error}".format(error=e)) def configure_policy_map_class(device, policy_name, @@ -1092,3 +1119,60 @@ def configure_policy_map_class(device, raise SubCommandFailure( f"Could not configure class_map. Error:\n{e}" ) + +def configure_policy_map_with_police_cir_percentage(device, policy_map_name, class_name=None, percent=None, action=None): + """ Configure policy-map with police cir percentage + Args: + device ('obj'): device to use + policy_map_name('str'): Policy-map name + class_name('str',optional) : Class-name + percent('int',optional) : police cir percentage + action('str',optional) : exceed-action to do (drop/transmit) + Returns: + None + Raises: + SubCommandFailure + """ + log.debug("Configuring policy-map with police cir percentage on device") + + config = [f'policy-map {policy_map_name}'] + if class_name: + config.append(f'class {class_name}') + if percent and action: + config.append(f'police cir percent {percent} conform-action transmit exceed-action {action}') + try: + device.configure(config) + + except SubCommandFailure as e: + raise SubCommandFailure( + f"Could not configure policy-map with police cir percentage on device {device}.Error:\n{e}") + +def configure_policy_map_parameters(device, policy_map_name, class_name=None, priority_level=None, bandwidth_remaining_percent=None): + """ Configure policy-map parameters on device + Args: + device ('obj'): device to use + policy_map_name('str'): Policy-map name + class_name('str',optional) : Class-name + priority_level('int',optional): value of priority queue from 0 to 7 + bandwidth_remaining_percent('int',optional) :bandwidth remaining percent + Returns: + None + Raises: + SubCommandFailure + """ + log.debug("Configuring policy-map parameters on device") + + config = [f'policy-map type queueing {policy_map_name}'] + if class_name: + config.append(f'class {class_name}') + if priority_level: + config.append(f'priority level {priority_level}') + if bandwidth_remaining_percent: + config.append(f'bandwidth remaining ratio {bandwidth_remaining_percent}') + try: + device.configure(config) + + except SubCommandFailure as e: + raise SubCommandFailure( + f"Could not configure policy-map parameters on device {device}.Error:\n{e}") + \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py index f70c3db71..4c441c7d6 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/rommon/utils.py @@ -2,14 +2,18 @@ import time import logging -log = logging.getLogger(__name__) + from pyats.log.utils import banner +from pyats.utils.secret_strings import to_plaintext + # Unicon from unicon.core.errors import SubCommandFailure from unicon.eal.dialogs import Statement, Dialog + # Genie from genie.libs.clean.utils import print_message +log = logging.getLogger(__name__) def device_rommon_boot(device, golden_image=None, tftp_boot=None, error_pattern=[]): '''Boot device using golden image or using tftp image @@ -231,17 +235,32 @@ def grub_breakboot(spawn, break_char): # add the pattern for all the states for the device to connection_dialog for state in device.state_machine.states: connection_dialog.append( - Statement(state.pattern, - action=print_message, - args={'message': f'Device reached {state} state in break boot stage'}, - )) + Statement( + state.pattern, + action=print_message, + args={'message': f'Device reached {state} state in break boot stage'}, + ) + ) + # To process the break boot dialogs - connection_dialog.process(spawn, timeout=timeout) + credentials = device.credentials + connection_dialog.process( + spawn, + timeout=timeout, + context={ + 'password': to_plaintext(credentials.get('default', {}).get('password')), + 'username': to_plaintext(credentials.get('default', {}).get('username')), + 'enable_password': to_plaintext(credentials.get('enable', {}).get('password')) + }, + prompt_recovery=True + ) # Check the device state after breaking the boot process device.sendline() device.state_machine.go_to('any', spawn=device.spawn, context=device.default.context) + if not device.state_machine.current_state == 'rommon': log.warning(f"The device {device.name} is not in rommon") + # send a new line in order to catch the buffer output in recovery process device.sendline() diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/startup_config/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/startup_config/verify.py index ce8c024f8..f0b06a6bd 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/startup_config/verify.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/startup_config/verify.py @@ -18,10 +18,13 @@ def verify_ignore_startup_config(device): try: output = device.parse(cmd) - if output['version']['next_config_register'] != '0x2102': - return False except SubCommandFailure as e: raise SubCommandFailure( f"Could not verify the ignore startup config on {device.name}. Error:\n{e}") + # first check the next config register if its not there check the current config register + config_reg = output['version'].get('next_config_register') or output['version'].get('curr_config_register') - return True \ No newline at end of file + if config_reg != '0x2102': + return False + + return True diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/test_templates/test_api.py.jinja b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/test_templates/test_api.py.jinja index a83922d29..27d02ed89 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/test_templates/test_api.py.jinja +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/test_templates/test_api.py.jinja @@ -2,8 +2,9 @@ {{imp}} {% endfor %} -class {{class_name}}(unittest.TestCase): +class {{class_name}}(TestCase): +{%- if has_mock_data|default(false) %} @classmethod def setUpClass(self): testbed = f""" @@ -26,9 +27,46 @@ class {{class_name}}(unittest.TestCase): init_config_commands=[], init_exec_commands=[] ) +{%- endif %} {% for ut in unit_tests %} def test_{{ut.api}}{% if loop.index0 > 0 %}_{{loop.index0}}{% endif %}(self): + {%- if not has_mock_data|default(false) %} + self.device = Mock() + {%- endif %} + {%- if test_type != 'execute' %} result = {{ut.api}}({{ut.arguments}}) + {%- endif %} + {%- if test_type == 'configure' %} + {%- for configure_call in configure_calls %} + self.assertEqual( + self.device.configure.mock_calls[{{loop.index0}}].args, + ({{configure_call}},) + ) + {%- endfor %} + {%- elif test_type == 'execute' %} + results_map = { + {%- for key, value in execute_asserts.items() %} + '{{ key }}': '{{ value }}', + {%- endfor %} + } + + def results_side_effect(arg, **kwargs): + return results_map.get(arg) + + self.device.execute.side_effect = results_side_effect + + result = {{ut.api}}({{ut.arguments}}) + + {%- for key in execute_asserts.keys() %} + self.assertIn( + '{{key}}', + self.device.execute.call_args_list[{{loop.index0}}][0] + ) + {%- endfor %} + {%- endif %} + + {%- if ut.expected_output and test_type != 'configure' %} expected_output = {{ut.expected_output}} self.assertEqual(result, expected_output) + {%- endif %} {% endfor %} \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index f66270155..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - access-session accounting attributes filter-spec include list aaa_attr: "access-session - accounting attributes filter-spec include list aaa_attr\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/test_api_config_access_session_accnt_attr_filter_spec_include_list.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/test_api_config_access_session_accnt_attr_filter_spec_include_list.py index 42b86fad8..88d7ca9f3 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/test_api_config_access_session_accnt_attr_filter_spec_include_list.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_accnt_attr_filter_spec_include_list/test_api_config_access_session_accnt_attr_filter_spec_include_list.py @@ -1,35 +1,15 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import config_access_session_accnt_attr_filter_spec_include_list - class TestConfigAccessSessionAccntAttrFilterSpecIncludeList(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_config_access_session_accnt_attr_filter_spec_include_list(self): - result = config_access_session_accnt_attr_filter_spec_include_list(self.device, 'aaa_attr') - expected_output = None - self.assertEqual(result, expected_output) + config_access_session_accnt_attr_filter_spec_include_list(self.device, 'aaa_attr') + self.device.configure.assert_called_once_with([ + 'access-session accounting attributes filter-spec include list aaa_attr' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 432ba2a85..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - access-session authentication attributes filter-spec include list aaa_attr: "access-session - authentication attributes filter-spec include list aaa_attr\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/test_api_config_access_session_auth_attr_filter_spec_include_list.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/test_api_config_access_session_auth_attr_filter_spec_include_list.py index c65051f4d..0e7b86b17 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/test_api_config_access_session_auth_attr_filter_spec_include_list.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/config_access_session_auth_attr_filter_spec_include_list/test_api_config_access_session_auth_attr_filter_spec_include_list.py @@ -1,35 +1,16 @@ -import os -import unittest -from pyats.topology import loader +from unittest import TestCase +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import config_access_session_auth_attr_filter_spec_include_list - -class TestConfigAccessSessionAuthAttrFilterSpecIncludeList(unittest.TestCase): +class TestConfigAccessSessionAuthAttrFilterSpecIncludeList(TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_config_access_session_auth_attr_filter_spec_include_list(self): - result = config_access_session_auth_attr_filter_spec_include_list(self.device, 'aaa_attr') - expected_output = None - self.assertEqual(result, expected_output) + config_access_session_auth_attr_filter_spec_include_list(self.device, 'aaa_attr') + self.device.configure.assert_called_with([ + 'access-session authentication attributes filter-spec include list aaa_attr' + ]) + diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_commands/test_api_configure_aaa_accounting_commands.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_commands/test_api_configure_aaa_accounting_commands.py index c551775b7..1df508dbc 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_commands/test_api_configure_aaa_accounting_commands.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_commands/test_api_configure_aaa_accounting_commands.py @@ -1,35 +1,16 @@ -import os -import unittest -from pyats.topology import loader +from unittest import TestCase +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_accounting_commands -class TestConfigureAaaAccountingCommands(unittest.TestCase): +class TestConfigureAaaAccountingCommands(TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - startrek-bgl-2: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: STARTREK - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['startrek-bgl-2'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_accounting_commands(self): - result = configure_aaa_accounting_commands(self.device, '15', 'test', 'none', None) - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_accounting_commands(self.device, '15', 'test', 'none', None) + self.device.configure.assert_called_once_with( + 'aaa accounting commands 15 test none' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_exec_default_start_stop_group/test_api_configure_aaa_accounting_exec_default_start_stop_group.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_exec_default_start_stop_group/test_api_configure_aaa_accounting_exec_default_start_stop_group.py index 6f0164706..e3120ba0a 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_exec_default_start_stop_group/test_api_configure_aaa_accounting_exec_default_start_stop_group.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_exec_default_start_stop_group/test_api_configure_aaa_accounting_exec_default_start_stop_group.py @@ -1,35 +1,15 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_accounting_exec_default_start_stop_group - class TestConfigureAaaAccountingExecDefaultStartStopGroup(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - SecG-A3-9410HA: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['SecG-A3-9410HA'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_accounting_exec_default_start_stop_group(self): - result = configure_aaa_accounting_exec_default_start_stop_group(self.device, 'ISEGRP') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_accounting_exec_default_start_stop_group(self.device, 'ISEGRP') + self.device.configure.assert_called_once_with( + 'aaa accounting exec default start-stop group ISEGRP' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 3ecf80f91..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - aaa accounting identity default start-stop group radius: "aaa accounting identity - default start-stop group radius\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: stack-12m(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: stack-12m(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: stack-12m# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/test_api_configure_aaa_accounting_identity_default_start_stop.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/test_api_configure_aaa_accounting_identity_default_start_stop.py index 3f3c9579b..67c084380 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/test_api_configure_aaa_accounting_identity_default_start_stop.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_identity_default_start_stop/test_api_configure_aaa_accounting_identity_default_start_stop.py @@ -1,34 +1,15 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_accounting_identity_default_start_stop - class TestConfigureAaaAccountingIdentityDefaultStartStop(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - stack-12m: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack-12m'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_accounting_identity_default_start_stop(self): - result = configure_aaa_accounting_identity_default_start_stop(self.device, 'group', 'radius') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_accounting_identity_default_start_stop(self.device, 'group', 'radius') + self.device.configure.assert_called_once_with( + 'aaa accounting identity default start-stop group radius' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 1805e42e5..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - aaa accounting update periodic 3: "aaa accounting update periodic 3\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: T1-9400-SP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T1-9400-SP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T1-9400-SP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/test_api_configure_aaa_accounting_update.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/test_api_configure_aaa_accounting_update.py index 03b3e9103..bb66d76d9 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/test_api_configure_aaa_accounting_update.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update/test_api_configure_aaa_accounting_update.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_accounting_update @@ -8,28 +7,10 @@ class TestConfigureAaaAccountingUpdate(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - Switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500L - type: c9500L - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_accounting_update(self): - result = configure_aaa_accounting_update(self.device, 'periodic', 3) - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_accounting_update(self.device, 'periodic', 3) + self.device.configure.assert_called_once_with( + 'aaa accounting update periodic 3' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/test_api_configure_aaa_accounting_update_periodic.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/test_api_configure_aaa_accounting_update_periodic.py index 2a6634ede..721241e03 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/test_api_configure_aaa_accounting_update_periodic.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/test_api_configure_aaa_accounting_update_periodic.py @@ -1,34 +1,15 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_accounting_update_periodic - class TestConfigureAaaAccountingUpdatePeriodic(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - stack-12m: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack-12m'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_accounting_update_periodic(self): - result = configure_aaa_accounting_update_periodic(self.device, '2880') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_accounting_update_periodic(self.device, '2880') + self.device.configure.assert_called_with( + 'aaa accounting update newinfo periodic 2880' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic_interval/test_api_configure_aaa_accounting_update_periodic_interval.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic_interval/test_api_configure_aaa_accounting_update_periodic_interval.py index e5bab4bc6..30b6cfc91 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic_interval/test_api_configure_aaa_accounting_update_periodic_interval.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic_interval/test_api_configure_aaa_accounting_update_periodic_interval.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_accounting_update_periodic_interval @@ -8,28 +7,10 @@ class TestConfigureAaaAccountingUpdatePeriodicInterval(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - SW2: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['SW2'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_accounting_update_periodic_interval(self): - result = configure_aaa_accounting_update_periodic_interval(self.device, 10) - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_accounting_update_periodic_interval(self.device, 10) + self.device.configure.assert_called_once_with( + 'aaa accounting update periodic 10' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index ffce6834e..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - aaa authorization auth-proxy default group ISEGRP: "aaa authorization auth-proxy - default group ISEGRP\r\n" - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no logging console: '' - prompt: LG-PK(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: LG-PK(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: LG-PK# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/test_api_configure_aaa_auth_proxy.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/test_api_configure_aaa_auth_proxy.py index 020517e36..0f2af25ca 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/test_api_configure_aaa_auth_proxy.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_auth_proxy/test_api_configure_aaa_auth_proxy.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_auth_proxy @@ -7,28 +7,10 @@ class TestConfigureAaaAuthProxy(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - LG-PK: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['LG-PK'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_auth_proxy(self): - result = configure_aaa_auth_proxy(self.device, 'ISEGRP') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_auth_proxy(self.device, 'ISEGRP') + self.device.configure.assert_called_once_with([ + 'aaa authorization auth-proxy default group ISEGRP' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 33c90cc37..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - aaa authentication enable default group DATANET enable: "aaa authentication enable - default group DATANET enable\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: NG_SVL_switch(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: NG_SVL_switch(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: NG_SVL_switch# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/test_api_configure_aaa_authentication_enable.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/test_api_configure_aaa_authentication_enable.py index 660e2ef2a..e55336972 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/test_api_configure_aaa_authentication_enable.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_enable/test_api_configure_aaa_authentication_enable.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_authentication_enable @@ -8,28 +7,10 @@ class TestConfigureAaaAuthenticationEnable(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - NG_SVL_switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: Nyquist - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['NG_SVL_switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_authentication_enable(self): - result = configure_aaa_authentication_enable(self.device, 'group', 'DATANET', 'enable') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_authentication_enable(self.device, 'group', 'DATANET', 'enable') + self.device.configure.assert_called_once_with( + 'aaa authentication enable default group DATANET enable' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index d32f608b0..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - aaa authentication login default local group radius: "aaa authentication login - default local group radius\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: Switch-9300(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: Switch-9300(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: Switch-9300# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/test_api_configure_aaa_authentication_login.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/test_api_configure_aaa_authentication_login.py index 15023d0f2..8dae1c7c1 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/test_api_configure_aaa_authentication_login.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authentication_login/test_api_configure_aaa_authentication_login.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_authentication_login @@ -8,28 +7,10 @@ class TestConfigureAaaAuthenticationLogin(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - Switch-9300: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Switch-9300'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_authentication_login(self): - result = configure_aaa_authentication_login(self.device, 'default', 'local', 'radius') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_authentication_login(self.device, 'default', 'local', 'radius') + self.device.configure.assert_called_once_with( + 'aaa authentication login default local group radius' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 63d7976fb..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - aaa authorization commands 15 test local: "aaa authorization commands 15 test - local\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: NG_SVL_switch(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: NG_SVL_switch(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: NG_SVL_switch# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/test_api_configure_aaa_authorization_commands.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/test_api_configure_aaa_authorization_commands.py index 23363753d..5bbe52897 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/test_api_configure_aaa_authorization_commands.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_commands/test_api_configure_aaa_authorization_commands.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_authorization_commands @@ -8,28 +7,10 @@ class TestConfigureAaaAuthorizationCommands(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - NG_SVL_switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: Nyquist - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['NG_SVL_switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_authorization_commands(self): - result = configure_aaa_authorization_commands(self.device, '15', 'test', 'local', None) - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_authorization_commands(self.device, '15', 'test', 'local', None) + self.device.configure.assert_called_once_with( + 'aaa authorization commands 15 test local' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index b73e41fd9..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - aaa authorization exec default local group radius: "aaa authorization exec default - local group radius\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: Switch-9300(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: Switch-9300(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: Switch-9300# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/test_api_configure_aaa_authorization_exec_default.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/test_api_configure_aaa_authorization_exec_default.py index 1303c26ee..14d8c7845 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/test_api_configure_aaa_authorization_exec_default.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_exec_default/test_api_configure_aaa_authorization_exec_default.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_authorization_exec_default @@ -8,28 +7,10 @@ class TestConfigureAaaAuthorizationExecDefault(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - Switch-9300: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Switch-9300'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_authorization_exec_default(self): - result = configure_aaa_authorization_exec_default(self.device, 'local', 'radius') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_authorization_exec_default(self.device, 'local', 'radius') + self.device.configure.assert_called_once_with( + 'aaa authorization exec default local group radius' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 865f9b28c..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - aaa authorization network cts-mlist group CTS-group: "aaa authorization network - cts-mlist group CTS-group\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: stack3-nyquist-1(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: stack3-nyquist-1(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: stack3-nyquist-1# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/test_api_configure_aaa_authorization_network.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/test_api_configure_aaa_authorization_network.py index d969927aa..956e09786 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/test_api_configure_aaa_authorization_network.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_authorization_network/test_api_configure_aaa_authorization_network.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_authorization_network @@ -8,28 +7,10 @@ class TestConfigureAaaAuthorizationNetwork(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - stack3-nyquist-1: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack3-nyquist-1'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_authorization_network(self): - result = configure_aaa_authorization_network(self.device, 'cts-mlist', 'CTS-group') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_authorization_network(self.device, 'cts-mlist', 'CTS-group') + self.device.configure.assert_called_once_with( + 'aaa authorization network cts-mlist group CTS-group' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 85030178e..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,44 +0,0 @@ -configure: - commands: - aaa accounting network default start-stop group ISEGRP: "aaa accounting network - default start-stop group ISEGRP\r\n" - aaa authentication dot1x default group ISEGRP: "aaa authentication dot1x default - group ISEGRP\r\n" - aaa authorization auth-proxy default group ISEGRP: "aaa authorization auth-proxy - default group ISEGRP\r\n" - aaa authorization network MLIST group ISEGRP: "aaa authorization network MLIST - group ISEGRP\r\n" - aaa authorization network default group ISEGRP: "aaa authorization network default - group ISEGRP\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: stack-12m(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: stack-12m(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: stack-12m# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/test_api_configure_aaa_default_group_methods.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/test_api_configure_aaa_default_group_methods.py index 89a2acdfe..4d1f8966d 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/test_api_configure_aaa_default_group_methods.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_default_group_methods/test_api_configure_aaa_default_group_methods.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_default_group_methods @@ -7,28 +7,14 @@ class TestConfigureAaaDefaultGroupMethods(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - stack-12m: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack-12m'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_default_group_methods(self): - result = configure_aaa_default_group_methods(self.device, 'group', 'ISEGRP') - expected_output = None - self.assertEqual(result, expected_output) + configure_aaa_default_group_methods(self.device, 'group', 'ISEGRP') + self.device.configure.assert_called_once_with([ + 'aaa authentication dot1x default group ISEGRP', + 'aaa authorization network default group ISEGRP', + 'aaa authorization network MLIST group ISEGRP', + 'aaa authorization auth-proxy default group ISEGRP', + 'aaa accounting network default start-stop group ISEGRP' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 67c400cbf..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - aaa authentication dot1x MACSEC-UPLINK local: "aaa authentication dot1x MACSEC-UPLINK - local\r\n" - aaa authorization credential-download MACSEC-UPLINK local: "aaa authorization - credential-download MACSEC-UPLINK local\r\n" - aaa authorization network MACSEC-UPLINK local: "aaa authorization network MACSEC-UPLINK - local\r\n" - aaa local authentication MACSEC-UPLINK authorization MACSEC-UPLINK: "aaa local - authentication MACSEC-UPLINK authorization MACSEC-UPLINK\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: Switch(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: Switch(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: Switch# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/test_api_configure_aaa_local_auth.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/test_api_configure_aaa_local_auth.py index 002682e04..e6ba14e91 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/test_api_configure_aaa_local_auth.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_local_auth/test_api_configure_aaa_local_auth.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_aaa_local_auth @@ -8,28 +7,13 @@ class TestConfigureAaaLocalAuth(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - Switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9200 - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_aaa_local_auth(self): result = configure_aaa_local_auth(self.device, 'MACSEC-UPLINK', 1) - expected_output = None - self.assertEqual(result, expected_output) + self.device.configure.assert_called_once_with([ + 'aaa authentication dot1x MACSEC-UPLINK local', + 'aaa local authentication MACSEC-UPLINK authorization MACSEC-UPLINK', + 'aaa authorization network MACSEC-UPLINK local', + 'aaa authorization credential-download MACSEC-UPLINK local' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 0dccc9c06..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - access-session attributes filter-list list aaa_attr: "access-session attributes - filter-list list aaa_attr\r\n" - cdp: "cdp\r\n" - dhcp: "dhcp\r\n" - dhcpv6: "dhcpv6\r\n" - end: - new_state: execute - http: "http\r\n" - line console 0: - new_state: configure_line - lldp: "lldp\r\n" - no logging console: '' - vlan-id: "vlan-id\r\n" - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/test_api_configure_access_session_attr_filter_list.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/test_api_configure_access_session_attr_filter_list.py index c27ec298e..922d3e54d 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/test_api_configure_access_session_attr_filter_list.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_access_session_attr_filter_list/test_api_configure_access_session_attr_filter_list.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_access_session_attr_filter_list @@ -8,28 +7,17 @@ class TestConfigureAccessSessionAttrFilterList(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_access_session_attr_filter_list(self): - result = configure_access_session_attr_filter_list(self.device, 'aaa_attr', 'vlan-id', 'cdp', 'dhcp', 'lldp', 'dhcpv6', 'http') - expected_output = None - self.assertEqual(result, expected_output) + configure_access_session_attr_filter_list( + self.device, 'aaa_attr', 'vlan-id', 'cdp', 'dhcp', 'lldp', 'dhcpv6', 'http') + self.device.configure.assert_called_once_with([ + 'access-session attributes filter-list list aaa_attr', + 'vlan-id', + 'cdp', + 'dhcp', + 'lldp', + 'dhcpv6', + 'http' + ]) \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 128b78cfd..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,37 +0,0 @@ -configure: - commands: - aaa server radius dynamic-author: "aaa server radius dynamic-author\r\n" - client 100.8.12.110 vrf cwa server-key cisco123: "client 100.8.12.110 vrf cwa - server-key cisco123\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: 9400_L2_DUT(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9400_L2_DUT(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9400_L2_DUT# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/test_api_configure_coa.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/test_api_configure_coa.py index 21e7b9342..b28840e02 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/test_api_configure_coa.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_coa/test_api_configure_coa.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_coa @@ -7,28 +7,11 @@ class TestConfigureCoa(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - 9400_L2_DUT: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9400_L2_DUT'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_coa(self): - result = configure_coa(self.device, {'hostname': '100.8.12.110', 'server_key': 'cisco123', 'vrf': 'cwa'}) - expected_output = None - self.assertEqual(result, expected_output) + configure_coa(self.device, {'hostname': '100.8.12.110', 'server_key': 'cisco123', 'vrf': 'cwa'}) + self.device.configure.assert_called_once_with([ + 'aaa server radius dynamic-author', + 'client 100.8.12.110 vrf cwa server-key cisco123' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index eb8bc8737..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,44 +0,0 @@ -configure: - commands: - aaa common-criteria policy ABCD: "aaa common-criteria policy ABCD\r\n" - char-changes 5: "char-changes 5\r\n" - character-repetition 5: "character-repetition 5\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - lower-case 1: "lower-case 1\r\n" - max-length 20: "max-length 20\r\n" - min-length 8: "min-length 8\r\n" - no logging console: '' - numeric-count 1: "numeric-count 1\r\n" - restrict-consecutive-letters: "restrict-consecutive-letters\r\n" - special-case 1: "special-case 1\r\n" - upper-case 1: "upper-case 1\r\n" - prompt: VTP-PK1(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: VTP-PK1(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: VTP-PK1# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/test_api_configure_common_criteria_policy.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/test_api_configure_common_criteria_policy.py index 433ff65be..b5c40cec1 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/test_api_configure_common_criteria_policy.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_common_criteria_policy/test_api_configure_common_criteria_policy.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_common_criteria_policy @@ -7,58 +7,25 @@ class TestConfigureCommonCriteriaPolicy(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - VTP-PK1: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VTP-PK1'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_common_criteria_policy(self): - result = configure_common_criteria_policy(self.device, 'ABCD', 5, 0, 0, 1, 1, 20, 8, 0, 1, 5, True, 1) - expected_output = None - self.assertEqual(result, expected_output) + configure_common_criteria_policy(self.device, 'ABCD', None, None, None, None, None, None, 1, None, None, None, False, None) + self.device.configure.assert_called_with([ + 'aaa common-criteria policy ABCD' + ]) -class TestConfigureCommonCriteriaPolicyBase(unittest.TestCase): - - @classmethod - def setUpClass(self): - testbed = f""" - devices: - Router: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: vwlc - type: wlc - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Router'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - - def test_configure_common_criteria_policy(self): - result = configure_common_criteria_policy(self.device, 'ABCD', None, None, None, None, None, None, 1, None, None, None, False, None) - expected_output = None - self.assertEqual(result, expected_output) + def test_configure_common_criteria_policy_1(self): + configure_common_criteria_policy(self.device, 'CDEF', 5, None, None, 1, 1, 20, 8, None, 1, 5, True, 1) + self.device.configure.assert_called_with([ + 'aaa common-criteria policy CDEF', + 'char-changes 5', + 'lower-case 1', + 'upper-case 1', + 'max-length 20', + 'min-length 8', + 'numeric-count 1', + 'special-case 1', + 'character-repetition 5', + 'restrict-consecutive-letters' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 116ae59c7..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no key config-key password-encrypt: "no key config-key password-encrypt\r\n" - no logging console: '' - prompt: 9300stack(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9300stack(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9300stack# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/test_api_configure_disable_config_key_encryption.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/test_api_configure_disable_config_key_encryption.py index a80e15d6e..c10e7478b 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/test_api_configure_disable_config_key_encryption.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_disable_config_key_encryption/test_api_configure_disable_config_key_encryption.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock, patch from genie.libs.sdk.apis.iosxe.aaa.configure import configure_disable_config_key_encryption @@ -8,28 +7,12 @@ class TestConfigureDisableConfigKeyEncryption(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - 9300stack: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: router - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9300stack'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_disable_config_key_encryption(self): - result = configure_disable_config_key_encryption(self.device) - expected_output = None - self.assertEqual(result, expected_output) + with patch('genie.libs.sdk.apis.iosxe.aaa.configure.Dialog') as mock_dialog: + configure_disable_config_key_encryption(self.device) + self.device.configure.assert_called_once_with( + 'no key config-key password-encrypt', + reply=mock_dialog() + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_dscp_global/test_api_configure_dscp_global.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_dscp_global/test_api_configure_dscp_global.py index 70dc56b1a..b38c402bf 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_dscp_global/test_api_configure_dscp_global.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_dscp_global/test_api_configure_dscp_global.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_dscp_global @@ -8,28 +7,11 @@ class TestConfigureDscpGlobal(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - SecG-A3-9410HA: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9600 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['SecG-A3-9410HA'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_dscp_global(self): result = configure_dscp_global(self.device, '50', '40') - expected_output = None - self.assertEqual(result, expected_output) + self.device.configure.assert_called_once_with([ + 'radius-server dscp auth 50', + 'radius-server dscp acct 40' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index cf6470cf6..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,43 +0,0 @@ -configure: - commands: - enable common-criteria-policy enable_test password 0 Test12: | - enable common-criteria-policy enable_test password 0 Test12 - WARNING: Configured enable password CLI with weak encryption type 0 will be deprecated in future. Hence please migrate to enable secret CLI which accomplishes same functionality as enable password CLI and which also supports strong irreversible encryption type 9 - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no logging console: '' - prompt: HCR_pk(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: HCR_pk(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: HCR_pk# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/test_api_configure_enable_policy_password.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/test_api_configure_enable_policy_password.py index f32c1648e..970cd62fd 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/test_api_configure_enable_policy_password.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_enable_policy_password/test_api_configure_enable_policy_password.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_enable_policy_password @@ -7,28 +7,15 @@ class TestConfigureEnablePolicyPassword(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - HCR_pk: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['HCR_pk'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_enable_policy_password(self): - result = configure_enable_policy_password(device=self.device, password='Test12', policy_name='enable_test', password_type=0) - expected_output = None - self.assertEqual(result, expected_output) + self.device.configure.side_effect = """ +enable common-criteria-policy enable_test password 0 Test12 +WARNING: Configured enable password CLI with weak encryption type 0 will be deprecated in future. Hence please migrate to enable secret CLI which accomplishes same functionality as enable password CLI and which also supports strong irreversible encryption type 9 + """ + configure_enable_policy_password( + device=self.device, password='Test12', + policy_name='enable_test', password_type=0) + self.device.configure.assert_called_once_with( + 'enable common-criteria-policy enable_test password 0 Test12') diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/mock_data/iosxe/mock_data.yaml new file mode 100644 index 000000000..3216fae93 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/mock_data/iosxe/mock_data.yaml @@ -0,0 +1,43 @@ +configure: + commands: + end: + new_state: execute + line console 0: + new_state: configure_line + no logging console: '' + username USER privilege 15 view VIEW common-criteria-policy POLICY secret test: "username\ + \ USER privilege 15 view VIEW common-criteria-policy PO\b\b\b\b\b\b\b\b\b\b\b\ + \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\ + \b\b\b\b\b\b\b\b\b\b\b\b\b$ER privilege 15 view VIEW common-criteria-policy\ + \ POL \b\b\b\b\b\b\b\b\bICY secre\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\ + \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\ + \b\b\b\b\bge 15 view VIEW common-criteria-policy POLICY secret \b\b\b\ + \b\b\b\b\b\b test\r\n% CC policy \"POLICY\" not found in policy map\r\n" + prompt: 9200-3(config)# +configure_line: + commands: + end: + new_state: execute + exec-timeout 0: '' + prompt: 9200-3(config-line)# +connect: + commands: + ? '' + : new_state: execute + preface: 'Trying mock_device ... + + Connected to mock_device. + + Escape character is ''^]''.' + prompt: '' +execute: + commands: + config term: + new_state: configure + config-transaction: + new_state: configure + show version: '' + show version | include operating mode: '' + term length 0: '' + term width 0: '' + prompt: 9200-3# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/test_api_configure_masked_unmasked_credentials.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/test_api_configure_masked_unmasked_credentials.py new file mode 100644 index 000000000..cb9e59c6e --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_masked_unmasked_credentials/test_api_configure_masked_unmasked_credentials.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.aaa.configure import configure_masked_unmasked_credentials + + +class TestConfigureMaskedUnmaskedCredentials(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + 9200-3: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: c9300 + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['9200-3'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_configure_masked_unmasked_credentials(self): + result = configure_masked_unmasked_credentials(self.device, 'USER', 'test', 15, 'POLICY', None, False, True, 'VIEW') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index d7b8dbfb2..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - radius-server attribute 25 access-request include: "radius-server attribute 25 - access-request include\r\n" - prompt: stack-12m(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: stack-12m(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: stack-12m# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/test_api_configure_radius_attribute_25.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/test_api_configure_radius_attribute_25.py index eac9c0b5b..d43d8188e 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/test_api_configure_radius_attribute_25.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_25/test_api_configure_radius_attribute_25.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_radius_attribute_25 @@ -7,28 +7,10 @@ class TestConfigureRadiusAttribute25(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - stack-12m: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack-12m'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_radius_attribute_25(self): - result = configure_radius_attribute_25(self.device) - expected_output = None - self.assertEqual(result, expected_output) + configure_radius_attribute_25(self.device) + self.device.configure.assert_called_once_with( + 'radius-server attribute 25 access-request include' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 8e4aae217..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - radius-server attribute 31 mac format ietf upper-case: "radius-server attribute - 31 mac format ietf upper-case\r\n" - prompt: stack-12m(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: stack-12m(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: stack-12m# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/test_api_configure_radius_attribute_31_mac_format.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/test_api_configure_radius_attribute_31_mac_format.py index d10406dc8..4bbcc8bfb 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/test_api_configure_radius_attribute_31_mac_format.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_mac_format/test_api_configure_radius_attribute_31_mac_format.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_radius_attribute_31_mac_format @@ -7,28 +7,10 @@ class TestConfigureRadiusAttribute31MacFormat(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - stack-12m: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack-12m'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_radius_attribute_31_mac_format(self): - result = configure_radius_attribute_31_mac_format(self.device) - expected_output = None - self.assertEqual(result, expected_output) + configure_radius_attribute_31_mac_format(self.device) + self.device.configure.assert_called_once_with( + 'radius-server attribute 31 mac format ietf upper-case' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 242a3cd39..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - radius-server attribute 31 send nas-port-detail mac-only: "radius-server attribute - 31 send nas-port-detail mac-only\r\n" - prompt: stack-12m(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: stack-12m(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: stack-12m# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/test_api_configure_radius_attribute_31_send_mac.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/test_api_configure_radius_attribute_31_send_mac.py index d12d68675..14f8b760b 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/test_api_configure_radius_attribute_31_send_mac.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_31_send_mac/test_api_configure_radius_attribute_31_send_mac.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_radius_attribute_31_send_mac @@ -7,28 +7,10 @@ class TestConfigureRadiusAttribute31SendMac(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - stack-12m: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack-12m'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_radius_attribute_31_send_mac(self): - result = configure_radius_attribute_31_send_mac(self.device) - expected_output = None - self.assertEqual(result, expected_output) + configure_radius_attribute_31_send_mac(self.device) + self.device.configure.assert_called_once_with( + 'radius-server attribute 31 send nas-port-detail mac-only' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 0ce9c3323..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - radius-server attribute 8 include-in-access-req: "radius-server attribute 8 include-in-access-req\r\ - \n" - prompt: stack-12m(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: stack-12m(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: stack-12m# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/test_api_configure_radius_attribute_8.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/test_api_configure_radius_attribute_8.py index bd4d033b3..9a0d0c8b2 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/test_api_configure_radius_attribute_8.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_attribute_8/test_api_configure_radius_attribute_8.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_radius_attribute_8 @@ -7,28 +7,10 @@ class TestConfigureRadiusAttribute8(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - stack-12m: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack-12m'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_radius_attribute_8(self): - result = configure_radius_attribute_8(self.device) - expected_output = None - self.assertEqual(result, expected_output) + configure_radius_attribute_8(self.device) + self.device.configure.assert_called_once_with( + 'radius-server attribute 8 include-in-access-req' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 72b832860..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,37 +0,0 @@ -configure: - commands: - aaa group server radius ISEGRP2: "aaa group server radius ISEGRP2\r\n" - dscp acct 32: "dscp acct 32\r\n" - dscp auth 40: "dscp auth 40\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: n08HA(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: n08HA(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: n08HA# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/test_api_configure_radius_group.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/test_api_configure_radius_group.py index 02b54a718..693f87dbb 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/test_api_configure_radius_group.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_group/test_api_configure_radius_group.py @@ -1,40 +1,24 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_radius_group class TestConfigureRadiusGroup(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - n08HA: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['n08HA'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_radius_group(self): + self.device = Mock() result = configure_radius_group(self.device, {'server_group': 'ISEGRP2'}) expected_output = ['aaa group server radius ISEGRP2'] + self.assertEqual( + self.device.configure.call_args_list[0][0][0], + ['aaa group server radius ISEGRP2',]) self.assertEqual(result, expected_output) def test_configure_radius_group_1(self): + self.device = Mock() result = configure_radius_group(self.device, {'dscp_acct': '32', 'dscp_auth': '40', 'server_group': 'ISEGRP2'}) expected_output = ['aaa group server radius ISEGRP2', 'dscp auth 40', 'dscp acct 32'] + self.assertEqual( + self.device.configure.call_args_list[0][0][0], + ['aaa group server radius ISEGRP2', 'dscp auth 40', 'dscp acct 32']) self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/test_api_configure_radius_server_dead_criteria.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/test_api_configure_radius_server_dead_criteria.py index 0311d0cd7..cfc62e46a 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/test_api_configure_radius_server_dead_criteria.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/test_api_configure_radius_server_dead_criteria.py @@ -1,34 +1,14 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_radius_server_dead_criteria class TestConfigureRadiusServerDeadCriteria(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - LG-PK: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['LG-PK'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_radius_server_dead_criteria(self): - result = configure_radius_server_dead_criteria(self.device, '2', '1') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + configure_radius_server_dead_criteria(self.device, '2', '1') + self.device.configure.assert_called_once_with([ + "radius-server dead-criteria time 2 tries 1" + ]) + diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index bdce14485..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - radius-server source-ports extended: "radius-server source-ports extended\r\n" - prompt: Nik_netconf_dut(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: Nik_netconf_dut(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: Nik_netconf_dut# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/test_api_configure_radius_server_source_ports_extended.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/test_api_configure_radius_server_source_ports_extended.py index 3942588ed..2863c417d 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/test_api_configure_radius_server_source_ports_extended.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_source_ports_extended/test_api_configure_radius_server_source_ports_extended.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_radius_server_source_ports_extended class TestConfigureRadiusServerSourcePortsExtended(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - Nik_netconf_dut: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9200 - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Nik_netconf_dut'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_radius_server_source_ports_extended(self): - result = configure_radius_server_source_ports_extended(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + configure_radius_server_source_ports_extended(self.device) + self.device.configure.assert_called_once_with([ + 'radius-server source-ports extended' + ]) \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index fb27b3da9..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,41 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no logging console: '' - service password-encryption: "service password-encryption\r\n" - prompt: HCR_pk(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: HCR_pk(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: HCR_pk# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/test_api_configure_service_password_encryption.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/test_api_configure_service_password_encryption.py index d95ea7e23..3187385eb 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/test_api_configure_service_password_encryption.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_service_password_encryption/test_api_configure_service_password_encryption.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_service_password_encryption class TestConfigureServicePasswordEncryption(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - HCR_pk: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['HCR_pk'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_service_password_encryption(self): - result = configure_service_password_encryption(device=self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + configure_service_password_encryption(device=self.device) + self.device.configure.assert_called_once_with( + "service password-encryption" + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 9b60138dc..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,37 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - username test privilege 1 password lab: | - username test privilege 1 password lab - WARNING: Command has been added to the configuration using a type 0 password. However, recommended to migrate to strong type-6 encryption - prompt: Switch-9300(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: Switch-9300(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: Switch-9300# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/test_api_configure_username.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/test_api_configure_username.py index ec173a75e..6c798b6f4 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/test_api_configure_username.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_username/test_api_configure_username.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_username class TestConfigureUsername(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - Switch-9300: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Switch-9300'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_username(self): - result = configure_username(self.device, 'test', 'lab', 0, '1') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + configure_username(self.device, 'test', 'lab', 0, '1') + self.device.configure.assert_called_once_with( + 'username test privilege 1 password lab' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index f5a4490ea..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no logging console: '' - radius-server attribute 6 support-multiple: "radius-server attribute 6 support-multiple\r\ - \n" - prompt: LG-PK(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: LG-PK(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: LG-PK# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/test_api_configure_wired_radius_attribute.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/test_api_configure_wired_radius_attribute.py index f5f05a2ed..2342fa180 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/test_api_configure_wired_radius_attribute.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_wired_radius_attribute/test_api_configure_wired_radius_attribute.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import configure_wired_radius_attribute class TestConfigureWiredRadiusAttribute(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - LG-PK: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['LG-PK'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_wired_radius_attribute(self): - result = configure_wired_radius_attribute(self.device, '6', 'support-multiple') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + configure_wired_radius_attribute(self.device, '6', 'support-multiple') + self.device.configure.assert_called_once_with([ + "radius-server attribute 6 support-multiple" + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 8b1def9a4..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa authentication login default local: "no aaa authentication login default - local\r\n" - no logging console: '' - prompt: 9500H_SVL_SSN_V07(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9500H_SVL_SSN_V07(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9500H_SVL_SSN_V07# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/test_api_disable_aaa_authentication_login.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/test_api_disable_aaa_authentication_login.py index 413bb2398..36fee8eea 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/test_api_disable_aaa_authentication_login.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_authentication_login/test_api_disable_aaa_authentication_login.py @@ -1,34 +1,15 @@ import unittest -from pyats.topology import loader from genie.libs.sdk.apis.iosxe.aaa.configure import disable_aaa_authentication_login - +from unittest.mock import Mock class TestDisableAaaAuthenticationLogin(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - 9500H_SVL_SSN_V07: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9500H_SVL_SSN_V07'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_disable_aaa_authentication_login(self): - result = disable_aaa_authentication_login(self.device, 'default', 'local', None) - expected_output = None - self.assertEqual(result, expected_output) + disable_aaa_authentication_login(self.device, 'default', 'local', auth_db2=None) + self.device.configure.assert_called_once_with( + 'no aaa authentication login default local' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 8fe2ed951..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa password restriction: "no aaa password restriction\r\n" - no logging console: '' - prompt: 9500H_SVL_SSN_V07(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9500H_SVL_SSN_V07(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9500H_SVL_SSN_V07# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/test_api_disable_aaa_password_restriction.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/test_api_disable_aaa_password_restriction.py index dddd53ede..df024bd1c 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/test_api_disable_aaa_password_restriction.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_aaa_password_restriction/test_api_disable_aaa_password_restriction.py @@ -1,34 +1,15 @@ import unittest -from pyats.topology import loader from genie.libs.sdk.apis.iosxe.aaa.configure import disable_aaa_password_restriction - +from unittest.mock import Mock class TestDisableAaaPasswordRestriction(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - 9500H_SVL_SSN_V07: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9500H_SVL_SSN_V07'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_disable_aaa_password_restriction(self): - result = disable_aaa_password_restriction(self.device) - expected_output = None - self.assertEqual(result, expected_output) + disable_aaa_password_restriction(self.device) + self.device.configure.assert_called_once_with( + 'no aaa password restriction' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index ad1d3266f..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - no login password-reuse-interval: "no login password-reuse-interval\r\n" - prompt: 9500H_SVL_SSN_V07(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9500H_SVL_SSN_V07(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9500H_SVL_SSN_V07# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/test_api_disable_login_password_reuse_interval.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/test_api_disable_login_password_reuse_interval.py index a73fb2451..51ccac682 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/test_api_disable_login_password_reuse_interval.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/disable_login_password_reuse_interval/test_api_disable_login_password_reuse_interval.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import disable_login_password_reuse_interval class TestDisableLoginPasswordReuseInterval(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - 9500H_SVL_SSN_V07: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9500H_SVL_SSN_V07'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_disable_login_password_reuse_interval(self): - result = disable_login_password_reuse_interval(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + disable_login_password_reuse_interval(self.device) + self.device.configure.assert_called_once_with( + "no login password-reuse-interval" + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 60e7cc5f0..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - aaa authentication login default local tacacs+: "aaa authentication login default - local tacacs+\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: 9500H_SVL_SSN_V07(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9500H_SVL_SSN_V07(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9500H_SVL_SSN_V07# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/test_api_enable_aaa_authentication_login.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/test_api_enable_aaa_authentication_login.py index 9fbdb331c..2d23d29b3 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/test_api_enable_aaa_authentication_login.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_authentication_login/test_api_enable_aaa_authentication_login.py @@ -1,34 +1,15 @@ import unittest -from pyats.topology import loader from genie.libs.sdk.apis.iosxe.aaa.configure import enable_aaa_authentication_login - +from unittest.mock import Mock class TestEnableAaaAuthenticationLogin(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - 9500H_SVL_SSN_V07: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9500H_SVL_SSN_V07'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_enable_aaa_authentication_login(self): - result = enable_aaa_authentication_login(self.device, 'default', 'local', 'tacacs+') - expected_output = None - self.assertEqual(result, expected_output) + enable_aaa_authentication_login(self.device, 'default', 'local', 'tacacs+') + self.device.configure.assert_called_once_with( + 'aaa authentication login default local tacacs+' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index f2b10a4a8..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - aaa password restriction: "aaa password restriction\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: 9500H_SVL_SSN_V07(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9500H_SVL_SSN_V07(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9500H_SVL_SSN_V07# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/test_api_enable_aaa_password_restriction.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/test_api_enable_aaa_password_restriction.py index 57924e671..28d78e777 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/test_api_enable_aaa_password_restriction.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_aaa_password_restriction/test_api_enable_aaa_password_restriction.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import enable_aaa_password_restriction class TestEnableAaaPasswordRestriction(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - 9500H_SVL_SSN_V07: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9500H_SVL_SSN_V07'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_enable_aaa_password_restriction(self): - result = enable_aaa_password_restriction(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + enable_aaa_password_restriction(self.device) + self.device.configure.assert_called_once_with( + "aaa password restriction" + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 25e82887e..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - login password-reuse-interval 250: "login password-reuse-interval 250\r\n" - no logging console: '' - prompt: 9500H_SVL_SSN_V07(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9500H_SVL_SSN_V07(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9500H_SVL_SSN_V07# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/test_api_enable_login_password_reuse_interval.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/test_api_enable_login_password_reuse_interval.py index 4ed2d438b..e6b0e5fca 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/test_api_enable_login_password_reuse_interval.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_login_password_reuse_interval/test_api_enable_login_password_reuse_interval.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import enable_login_password_reuse_interval class TestEnableLoginPasswordReuseInterval(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - 9500H_SVL_SSN_V07: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9500H_SVL_SSN_V07'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_enable_login_password_reuse_interval(self): - result = enable_login_password_reuse_interval(self.device, 250) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + enable_login_password_reuse_interval(self.device, 250) + self.device.configure.assert_called_once_with( + "login password-reuse-interval 250" + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 34f8f5709..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,38 +0,0 @@ -configure: - commands: - automate-tester username user1 probe-on vrf red: "automate-tester username user1 - probe-\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b - \b\b$ster username user1 probe-o \b\b\b\b\b\b\b\b\bn vrf red\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - radius server serv1: "radius server serv1\r\n" - prompt: 9500H_SVL_SSN_V07(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9500H_SVL_SSN_V07(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9500H_SVL_SSN_V07# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/test_api_enable_radius_automate_tester_probe_on.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/test_api_enable_radius_automate_tester_probe_on.py index 118ab1ace..6f52ae856 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/test_api_enable_radius_automate_tester_probe_on.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/enable_radius_automate_tester_probe_on/test_api_enable_radius_automate_tester_probe_on.py @@ -1,34 +1,22 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import enable_radius_automate_tester_probe_on class TestEnableRadiusAutomateTesterProbeOn(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - 9500H_SVL_SSN_V07: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9500H_SVL_SSN_V07'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_enable_radius_automate_tester_probe_on(self): - result = enable_radius_automate_tester_probe_on(self.device, 'serv1', 'user1', 'red') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + enable_radius_automate_tester_probe_on(self.device, 'serv1', 'user1', 'red') + self.device.configure.assert_called_once_with([ + "radius server serv1", + "automate-tester username user1 probe-on vrf red" + ]) + + def test_enable_radius_automate_tester_probe_on_1(self): + self.device = Mock() + enable_radius_automate_tester_probe_on(self.device, 'serv1', 'user1') + self.device.configure.assert_called_once_with([ + "radius server serv1", + "automate-tester username user1 probe-on" + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index bfc90a306..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no access-session accounting attributes filter-spec include list aaa_attr: "no - access-session accounting attributes filter-spec include list aaa_attr\r\n" - no logging console: '' - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/test_api_unconfig_access_session_accnt_attr_filter_spec_include_list.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/test_api_unconfig_access_session_accnt_attr_filter_spec_include_list.py index 558dfb8a5..34c35fad1 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/test_api_unconfig_access_session_accnt_attr_filter_spec_include_list.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_accnt_attr_filter_spec_include_list/test_api_unconfig_access_session_accnt_attr_filter_spec_include_list.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfig_access_session_accnt_attr_filter_spec_include_list class TestUnconfigAccessSessionAccntAttrFilterSpecIncludeList(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfig_access_session_accnt_attr_filter_spec_include_list(self): - result = unconfig_access_session_accnt_attr_filter_spec_include_list(self.device, 'aaa_attr') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfig_access_session_accnt_attr_filter_spec_include_list(self.device, 'aaa_attr') + self.device.configure.assert_called_once_with([ + "no access-session accounting attributes filter-spec include list aaa_attr" + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 9c4c70e85..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,37 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no access-session authentication attributes filter-spec include list aaa_attr: "no - access-session authentication attributes filter-spec include list aaa_attr\r\ - \n" - no logging console: '' - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/test_api_unconfig_access_session_auth_attr_filter_spec_include_list.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/test_api_unconfig_access_session_auth_attr_filter_spec_include_list.py index 4a9e87ef2..7c52a8fd9 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/test_api_unconfig_access_session_auth_attr_filter_spec_include_list.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfig_access_session_auth_attr_filter_spec_include_list/test_api_unconfig_access_session_auth_attr_filter_spec_include_list.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfig_access_session_auth_attr_filter_spec_include_list class TestUnconfigAccessSessionAuthAttrFilterSpecIncludeList(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfig_access_session_auth_attr_filter_spec_include_list(self): - result = unconfig_access_session_auth_attr_filter_spec_include_list(self.device, 'aaa_attr') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfig_access_session_auth_attr_filter_spec_include_list(self.device, 'aaa_attr') + self.device.configure.assert_called_once_with([ + "no access-session authentication attributes filter-spec include list aaa_attr" + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 90cb45deb..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa accounting commands 15 test none: "no aaa accounting commands 15 test none\r\ - \n" - no logging console: '' - prompt: startrek-bgl-2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: startrek-bgl-2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: startrek-bgl-2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/test_api_unconfigure_aaa_accounting_commands.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/test_api_unconfigure_aaa_accounting_commands.py index d47cfcde7..2258fb08c 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/test_api_unconfigure_aaa_accounting_commands.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_commands/test_api_unconfigure_aaa_accounting_commands.py @@ -1,35 +1,20 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_accounting_commands class TestUnconfigureAaaAccountingCommands(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - startrek-bgl-2: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: STARTREK - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['startrek-bgl-2'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] + def test_unconfigure_aaa_accounting_commands(self): + self.device = Mock() + unconfigure_aaa_accounting_commands(self.device, '15', 'test', 'none', '', None) + self.device.configure.assert_called_with( + 'no aaa accounting commands 15 test none' ) - def test_unconfigure_aaa_accounting_commands(self): - result = unconfigure_aaa_accounting_commands(self.device, '15', 'test', 'none', '', None) - expected_output = None - self.assertEqual(result, expected_output) + def test_unconfigure_aaa_accounting_commands_1(self): + self.device = Mock() + unconfigure_aaa_accounting_commands(self.device, '1', 'default', 'start-stop', 'broadcast', 'DATANET') + self.device.configure.assert_called_with( + 'no aaa accounting commands 1 default start-stop broadcast group DATANET' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 33d0a16d5..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa accounting exec default start-stop group ISEGRP: "no aaa accounting exec - default start-stop group ISEGRP\r\n" - no logging console: '' - prompt: SecG-A3-9410HA(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: SecG-A3-9410HA(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: SecG-A3-9410HA# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/test_api_unconfigure_aaa_accounting_exec_default_start_stop_group.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/test_api_unconfigure_aaa_accounting_exec_default_start_stop_group.py index d93a42304..224b538fa 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/test_api_unconfigure_aaa_accounting_exec_default_start_stop_group.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_exec_default_start_stop_group/test_api_unconfigure_aaa_accounting_exec_default_start_stop_group.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_accounting_exec_default_start_stop_group class TestUnconfigureAaaAccountingExecDefaultStartStopGroup(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - SecG-A3-9410HA: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['SecG-A3-9410HA'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_accounting_exec_default_start_stop_group(self): - result = unconfigure_aaa_accounting_exec_default_start_stop_group(self.device, 'ISEGRP') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_accounting_exec_default_start_stop_group(self.device, 'ISEGRP') + self.device.configure.assert_called_with( + 'no aaa accounting exec default start-stop group ISEGRP' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 2f9480f92..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,39 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa accounting identity default start-stop group My-Radius: "no aaa accounting - identity default start-stop group My-Ra\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b - \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b - $unting identity default start-stop group My-Rad \b\b\b\b\b\b\b\b\b\ - ius\r\n" - no logging console: '' - prompt: T1-9400-SP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T1-9400-SP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T1-9400-SP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/test_api_unconfigure_aaa_accounting_identity_default_start_stop.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/test_api_unconfigure_aaa_accounting_identity_default_start_stop.py index 7f879b6c5..3ab54c425 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/test_api_unconfigure_aaa_accounting_identity_default_start_stop.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_identity_default_start_stop/test_api_unconfigure_aaa_accounting_identity_default_start_stop.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_accounting_identity_default_start_stop class TestUnconfigureAaaAccountingIdentityDefaultStartStop(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - Switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500L - type: c9500L - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_accounting_identity_default_start_stop(self): - result = unconfigure_aaa_accounting_identity_default_start_stop(self.device, 'group', 'My-Radius') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_accounting_identity_default_start_stop(self.device, 'group', 'My-Radius') + self.device.configure.assert_called_with( + 'no aaa accounting identity default start-stop group My-Radius' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 0889b207c..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa accounting update periodic 3: "no aaa accounting update periodic 3\r\n" - no logging console: '' - prompt: T1-9400-SP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T1-9400-SP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T1-9400-SP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/test_api_unconfigure_aaa_accounting_update.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/test_api_unconfigure_aaa_accounting_update.py index 3476dd3b0..3f9751728 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/test_api_unconfigure_aaa_accounting_update.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update/test_api_unconfigure_aaa_accounting_update.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_accounting_update class TestUnconfigureAaaAccountingUpdate(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - Switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500L - type: c9500L - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_accounting_update(self): - result = unconfigure_aaa_accounting_update(self.device, 'periodic', 3) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_accounting_update(self.device, 'periodic', 3) + self.device.configure.assert_called_with( + "no aaa accounting update periodic 3" + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index b72746fda..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa accounting update periodic 10: "no aaa accounting update periodic 10\r\n" - no logging console: '' - prompt: SW2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: SW2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: SW2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/test_api_unconfigure_aaa_accounting_update_periodic_interval.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/test_api_unconfigure_aaa_accounting_update_periodic_interval.py index f3b8ced4d..3b3a461d1 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/test_api_unconfigure_aaa_accounting_update_periodic_interval.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_accounting_update_periodic_interval/test_api_unconfigure_aaa_accounting_update_periodic_interval.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_accounting_update_periodic_interval class TestUnconfigureAaaAccountingUpdatePeriodicInterval(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - SW2: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['SW2'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_accounting_update_periodic_interval(self): - result = unconfigure_aaa_accounting_update_periodic_interval(self.device, 10) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_accounting_update_periodic_interval(self.device, 10) + self.device.configure.assert_called_with( + 'no aaa accounting update periodic 10' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index beea1b2ef..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no aaa authorization auth-proxy default group ISEGRP: "no aaa authorization auth-proxy - default group ISEGRP\r\n" - no logging console: '' - prompt: LG-PK(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: LG-PK(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: LG-PK# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/test_api_unconfigure_aaa_auth_proxy.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/test_api_unconfigure_aaa_auth_proxy.py index 4e8fa5a55..2065b561d 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/test_api_unconfigure_aaa_auth_proxy.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_auth_proxy/test_api_unconfigure_aaa_auth_proxy.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_auth_proxy class TestUnconfigureAaaAuthProxy(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - LG-PK: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['LG-PK'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_auth_proxy(self): - result = unconfigure_aaa_auth_proxy(self.device, 'ISEGRP') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_auth_proxy(self.device, 'ISEGRP') + self.device.configure.assert_called_with([ + 'no aaa authorization auth-proxy default group ISEGRP' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index ef44105e9..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa authentication enable default: "no aaa authentication enable default\r\n" - no logging console: '' - prompt: NG_SVL_switch(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: NG_SVL_switch(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: NG_SVL_switch# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/test_api_unconfigure_aaa_authentication_enable.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/test_api_unconfigure_aaa_authentication_enable.py index d2dcfbafc..ecfb48a2b 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/test_api_unconfigure_aaa_authentication_enable.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authentication_enable/test_api_unconfigure_aaa_authentication_enable.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_authentication_enable class TestUnconfigureAaaAuthenticationEnable(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - NG_SVL_switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: Nyquist - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['NG_SVL_switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_authentication_enable(self): - result = unconfigure_aaa_authentication_enable(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_authentication_enable(self.device) + self.device.configure.assert_called_with( + 'no aaa authentication enable default' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 8b4dc7e44..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa authorization commands 15 test local: "no aaa authorization commands 15 - test local\r\n" - no logging console: '' - prompt: NG_SVL_switch(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: NG_SVL_switch(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: NG_SVL_switch# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/test_api_unconfigure_aaa_authorization_commands.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/test_api_unconfigure_aaa_authorization_commands.py index 6dd22cbd6..2c0ff8ca4 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/test_api_unconfigure_aaa_authorization_commands.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_authorization_commands/test_api_unconfigure_aaa_authorization_commands.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_authorization_commands class TestUnconfigureAaaAuthorizationCommands(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - NG_SVL_switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: Nyquist - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['NG_SVL_switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_authorization_commands(self): - result = unconfigure_aaa_authorization_commands(self.device, '15', 'test', 'local', None) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_authorization_commands(self.device, '15', 'test', 'local', None) + self.device.configure.assert_called_with( + 'no aaa authorization commands 15 test local' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 07b07402f..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,40 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa authentication dot1x default local: "no aaa authentication dot1x default - local\r\n" - no aaa authorization network default local: "no aaa authorization network default - local\r\n" - no aaa local authentication default authorization default: "no aaa local authentication - default authorization default\r\n" - no logging console: '' - prompt: LG-PK(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: LG-PK(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: LG-PK# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/test_api_unconfigure_aaa_local_auth.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/test_api_unconfigure_aaa_local_auth.py index 7ee92722d..8d5fa8ab9 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/test_api_unconfigure_aaa_local_auth.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_local_auth/test_api_unconfigure_aaa_local_auth.py @@ -1,34 +1,15 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_local_auth class TestUnconfigureAaaLocalAuth(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - LG-PK: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['LG-PK'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_local_auth(self): - result = unconfigure_aaa_local_auth(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_local_auth(self.device) + self.device.configure.assert_called_with([ + 'no aaa authorization network default local', + 'no aaa local authentication default authorization default', + 'no aaa authentication dot1x default local' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/test_api_unconfigure_aaa_new_model.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/test_api_unconfigure_aaa_new_model.py index aff4b57a3..f1921bb50 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/test_api_unconfigure_aaa_new_model.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/test_api_unconfigure_aaa_new_model.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_aaa_new_model class TestUnconfigureAaaNewModel(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - HCR_pk: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['HCR_pk'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_aaa_new_model(self): - result = unconfigure_aaa_new_model(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_aaa_new_model(self.device) + self.device.configure.assert_called_with([ + 'no aaa new-model' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index a88d2be6a..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no access-session attributes filter-list list aaa_attr: "no access-session attributes - filter-list list aaa_attr\r\n" - no logging console: '' - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/test_api_unconfigure_access_session_attr_filter_list.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/test_api_unconfigure_access_session_attr_filter_list.py index 4e8e4c1ea..4fb6252d4 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/test_api_unconfigure_access_session_attr_filter_list.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list/test_api_unconfigure_access_session_attr_filter_list.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_access_session_attr_filter_list class TestUnconfigureAccessSessionAttrFilterList(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_access_session_attr_filter_list(self): - result = unconfigure_access_session_attr_filter_list(self.device, 'aaa_attr') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_access_session_attr_filter_list(self.device, 'aaa_attr') + self.device.configure.assert_called_once_with([ + "no access-session attributes filter-list list aaa_attr" + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 6665536ef..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - access-session attributes filter-list list aaa_attr: "access-session attributes - filter-list list aaa_attr\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no cdp: "no cdp\r\n" - no dhcp: "no dhcp\r\n" - no dhcpv6: "no dhcpv6\r\n" - no http: "no http\r\n" - no lldp: "no lldp\r\n" - no logging console: '' - no vlan-id: "no vlan-id\r\n" - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/test_api_unconfigure_access_session_attr_filter_list_protocol.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/test_api_unconfigure_access_session_attr_filter_list_protocol.py index 001736b15..959989554 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/test_api_unconfigure_access_session_attr_filter_list_protocol.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_access_session_attr_filter_list_protocol/test_api_unconfigure_access_session_attr_filter_list_protocol.py @@ -1,35 +1,27 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_access_session_attr_filter_list_protocol class TestUnconfigureAccessSessionAttrFilterListProtocol(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_access_session_attr_filter_list_protocol(self): - result = unconfigure_access_session_attr_filter_list_protocol(self.device, 'aaa_attr', 'vlan-id', 'cdp', 'dhcp', 'lldp', 'dhcpv6', 'http') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_access_session_attr_filter_list_protocol( + self.device, + 'aaa_attr', + 'vlan-id', + 'cdp', + 'dhcp', + 'lldp', + 'dhcpv6', + 'http') + self.device.configure.assert_called_with([ + 'access-session attributes filter-list list aaa_attr', + 'no vlan-id', + 'no cdp', + 'no dhcp', + 'no lldp', + 'no dhcpv6', + 'no http' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 4637f158a..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa server radius dynamic-author: "no aaa server radius dynamic-author\r\n" - no logging console: '' - prompt: 9400_L2_DUT(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9400_L2_DUT(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9400_L2_DUT# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/test_api_unconfigure_coa.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/test_api_unconfigure_coa.py index a95372bae..9de0559f0 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/test_api_unconfigure_coa.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_coa/test_api_unconfigure_coa.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_coa class TestUnconfigureCoa(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - 9400_L2_DUT: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9400_L2_DUT'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_coa(self): - result = unconfigure_coa(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_coa(self.device) + self.device.configure.assert_called_with([ + 'no aaa server radius dynamic-author' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 64a472e40..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no aaa common-criteria policy enable_test: "no aaa common-criteria policy enable_test\r\ - \n" - no logging console: '' - prompt: HCR_pk(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: HCR_pk(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: HCR_pk# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/test_api_unconfigure_common_criteria_policy.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/test_api_unconfigure_common_criteria_policy.py index 09ece0a78..6a3cad66d 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/test_api_unconfigure_common_criteria_policy.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_common_criteria_policy/test_api_unconfigure_common_criteria_policy.py @@ -1,34 +1,14 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_common_criteria_policy class TestUnconfigureCommonCriteriaPolicy(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - HCR_pk: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['HCR_pk'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_common_criteria_policy(self): - result = unconfigure_common_criteria_policy(device=self.device, policy_name='enable_test') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + self.device.configure.return_value = "no aaa common-criteria policy enable_test" + unconfigure_common_criteria_policy(device=self.device, policy_name='enable_test') + self.device.configure.assert_called_with( + 'no aaa common-criteria policy enable_test' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_global/test_api_unconfigure_dscp_global.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_global/test_api_unconfigure_dscp_global.py index c1d42ac5c..6f4cabd5d 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_global/test_api_unconfigure_dscp_global.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_global/test_api_unconfigure_dscp_global.py @@ -1,35 +1,14 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_dscp_global class TestUnconfigureDscpGlobal(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - SecG-A2-8M9300: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['SecG-A2-8M9300'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_dscp_global(self): - result = unconfigure_dscp_global(self.device, '10', '20') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_dscp_global(self.device, '10', '20') + self.device.configure.assert_called_with([ + 'no radius-server dscp auth 10', + 'no radius-server dscp acct 20' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server/test_api_unconfigure_dscp_radius_server.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server/test_api_unconfigure_dscp_radius_server.py index 35a5784f8..9c98ce581 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server/test_api_unconfigure_dscp_radius_server.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server/test_api_unconfigure_dscp_radius_server.py @@ -1,40 +1,22 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_dscp_radius_server class TestUnconfigureDscpRadiusServer(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - n08HA: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['n08HA'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_dscp_radius_server(self): - result = unconfigure_dscp_radius_server(self.device, 'ISE2.7', None, None) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_dscp_radius_server(self.device, 'ISE2.7', None, None) + self.device.configure.assert_called_with([ + 'radius server ISE2.7' + ]) def test_unconfigure_dscp_radius_server_1(self): - result = unconfigure_dscp_radius_server(self.device, 'ISE2.7', '20', '10') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_dscp_radius_server(self.device, 'ISE2.7', '20', '10') + self.device.configure.assert_called_with([ + 'radius server ISE2.7', + 'no dscp auth 20', + 'no dscp acct 10' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 994f76ef0..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,37 +0,0 @@ -configure: - commands: - aaa group server radius ISEGRP2: "aaa group server radius ISEGRP2\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no dscp acct 32: "no dscp acct 32\r\n" - no dscp auth 40: "no dscp auth 40\r\n" - no logging console: '' - prompt: n08HA(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: n08HA(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: n08HA# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/test_api_unconfigure_dscp_radius_server_group.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/test_api_unconfigure_dscp_radius_server_group.py index 08762d4f6..1663f784a 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/test_api_unconfigure_dscp_radius_server_group.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server_group/test_api_unconfigure_dscp_radius_server_group.py @@ -1,40 +1,22 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_dscp_radius_server_group class TestUnconfigureDscpRadiusServerGroup(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - n08HA: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9500 - type: c9500 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['n08HA'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_dscp_radius_server_group(self): - result = unconfigure_dscp_radius_server_group(self.device, 'ISEGRP2', None, None) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_dscp_radius_server_group(self.device, 'ISEGRP2', None, None) + self.device.configure.assert_called_with([ + 'aaa group server radius ISEGRP2' + ]) def test_unconfigure_dscp_radius_server_group_1(self): - result = unconfigure_dscp_radius_server_group(self.device, 'ISEGRP2', '40', '32') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_dscp_radius_server_group(self.device, 'ISEGRP2', '40', '32') + self.device.configure.assert_called_with([ + 'aaa group server radius ISEGRP2', + 'no dscp auth 40', + 'no dscp acct 32' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 4c99458f3..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no enable secret level 15: "no enable secret level 15\r\n" - no logging console: '' - prompt: 9300_stack(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: 9300_stack(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: 9300_stack# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/test_api_unconfigure_enable_password.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/test_api_unconfigure_enable_password.py index 8e3b8f7cf..c1e882b43 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/test_api_unconfigure_enable_password.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_password/test_api_unconfigure_enable_password.py @@ -1,34 +1,28 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_enable_password class TestUnconfigureEnablePassword(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - 9300_stack: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9300_stack'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] + def test_unconfigure_enable_password(self): + self.device = Mock() + unconfigure_enable_password(self.device, False, None) + self.device.configure.assert_called_with( + 'no enable password' ) - def test_unconfigure_enable_password(self): - result = unconfigure_enable_password(self.device, True, 15) - expected_output = None - self.assertEqual(result, expected_output) + def test_unconfigure_enable_password_1(self): + self.device = Mock() + unconfigure_enable_password(self.device, False, 15) + self.device.configure.assert_called_with( + 'no enable password level 15' + ) + + def test_unconfigure_enable_password_2(self): + self.device = Mock() + unconfigure_enable_password(self.device, True, 15) + self.device.configure.assert_called_with( + 'no enable secret level 15' + ) + diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index de7f39024..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no enable common-criteria-policy enable_test password 0 Test12: "no enable common-criteria-policy - enable_test password 0 Test12\r\n" - no logging console: '' - prompt: HCR_pk(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: HCR_pk(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: HCR_pk# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/test_api_unconfigure_enable_policy_password.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/test_api_unconfigure_enable_policy_password.py index 3e06eda80..cb03dd7d6 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/test_api_unconfigure_enable_policy_password.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_enable_policy_password/test_api_unconfigure_enable_policy_password.py @@ -1,34 +1,20 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_enable_policy_password class TestUnconfigureEnablePolicyPassword(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - HCR_pk: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['HCR_pk'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] + def test_unconfigure_enable_policy_password(self): + self.device = Mock() + unconfigure_enable_policy_password(device=self.device, password='Test12', policy_name=None, password_type=None) + self.device.configure.assert_called_with( + 'no enable password Test12' ) - def test_unconfigure_enable_policy_password(self): - result = unconfigure_enable_policy_password(device=self.device, password='Test12', policy_name='enable_test', password_type=0) - expected_output = None - self.assertEqual(result, expected_output) + def test_unconfigure_enable_policy_password_1(self): + self.device = Mock() + unconfigure_enable_policy_password(device=self.device, password='Test12', policy_name='enable_test', password_type=0) + self.device.configure.assert_called_with( + 'no enable common-criteria-policy enable_test password 0 Test12' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 99d3f1b88..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,36 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - no radius-server dead-criteria time 2 tries 1: "no radius-server dead-criteria - time 2 tries 1\r\n" - prompt: LG-PK(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: LG-PK(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: LG-PK# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/test_api_unconfigure_radius_server_dead_criteria.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/test_api_unconfigure_radius_server_dead_criteria.py index ab6603a0b..d7c1e0338 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/test_api_unconfigure_radius_server_dead_criteria.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_radius_server_dead_criteria/test_api_unconfigure_radius_server_dead_criteria.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_radius_server_dead_criteria class TestUnconfigureRadiusServerDeadCriteria(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - LG-PK: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['LG-PK'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_radius_server_dead_criteria(self): - result = unconfigure_radius_server_dead_criteria(self.device, '2', '1') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_radius_server_dead_criteria(self.device, '2', '1') + self.device.configure.assert_called_with([ + 'no radius-server dead-criteria time 2 tries 1' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 4fb4bc52f..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,41 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no logging console: '' - no service password-encryption: "no service password-encryption\r\n" - prompt: HCR_pk(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: HCR_pk(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: HCR_pk# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/test_api_unconfigure_service_password_encryption.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/test_api_unconfigure_service_password_encryption.py index ae3090b6b..b5c2a80bc 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/test_api_unconfigure_service_password_encryption.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_service_password_encryption/test_api_unconfigure_service_password_encryption.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_service_password_encryption class TestUnconfigureServicePasswordEncryption(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - HCR_pk: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9200 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['HCR_pk'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_service_password_encryption(self): - result = unconfigure_service_password_encryption(device=self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_service_password_encryption(device=self.device) + self.device.configure.assert_called_with( + 'no service password-encryption' + ) \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 4dd400227..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no aaa group server tacacs Test: "no aaa group server tacacs Test\r\n" - no logging console: '' - prompt: NG_SVL_switch(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: NG_SVL_switch(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: NG_SVL_switch# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/test_api_unconfigure_tacacs_group.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/test_api_unconfigure_tacacs_group.py index 072c8e91a..38a4b3e13 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/test_api_unconfigure_tacacs_group.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_group/test_api_unconfigure_tacacs_group.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_tacacs_group class TestUnconfigureTacacsGroup(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - NG_SVL_switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: Nyquist - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['NG_SVL_switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_tacacs_group(self): - result = unconfigure_tacacs_group(self.device, 'Test') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_tacacs_group(self.device, 'Test') + self.device.configure.assert_called_with( + 'no aaa group server tacacs Test' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 8a8f7a16f..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - no tacacs server Test: "no tacacs server Test\r\n" - prompt: NG_SVL_switch(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: NG_SVL_switch(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: NG_SVL_switch# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/test_api_unconfigure_tacacs_server.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/test_api_unconfigure_tacacs_server.py index 0c091f5cc..38493305c 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/test_api_unconfigure_tacacs_server.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_tacacs_server/test_api_unconfigure_tacacs_server.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_tacacs_server class TestUnconfigureTacacsServer(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - NG_SVL_switch: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: Nyquist - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['NG_SVL_switch'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_tacacs_server(self): + self.device = Mock() result = unconfigure_tacacs_server(self.device, 'Test') - expected_output = None - self.assertEqual(result, expected_output) + self.device.configure.assert_called_with( + 'no tacacs server Test' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 54f97101b..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no logging console: '' - no radius-server attribute 6 support-multiple: "no radius-server attribute 6 support-multiple\r\ - \n" - prompt: LG-PK(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: LG-PK(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: LG-PK# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/test_api_unconfigure_wired_radius_attribute.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/test_api_unconfigure_wired_radius_attribute.py index f11caff5a..3b4032023 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/test_api_unconfigure_wired_radius_attribute.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_wired_radius_attribute/test_api_unconfigure_wired_radius_attribute.py @@ -1,34 +1,13 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.configure import unconfigure_wired_radius_attribute class TestUnconfigureWiredRadiusAttribute(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = """ - devices: - LG-PK: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['LG-PK'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_unconfigure_wired_radius_attribute(self): - result = unconfigure_wired_radius_attribute(self.device, '6', 'support-multiple') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_wired_radius_attribute(self.device, '6', 'support-multiple') + self.device.configure.assert_called_with([ + 'no radius-server attribute 6 support-multiple' + ]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/execute_clear_aaa_counters_server/test_api_execute_clear_aaa_counters_server.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/execute_clear_aaa_counters_server/test_api_execute_clear_aaa_counters_server.py index 878e2790b..2410d69db 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/execute_clear_aaa_counters_server/test_api_execute_clear_aaa_counters_server.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/execute_clear_aaa_counters_server/test_api_execute_clear_aaa_counters_server.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.execute import execute_clear_aaa_counters_server @@ -8,28 +7,10 @@ class TestExecuteClearAaaCountersServer(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - 9300_UUT1: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: switch - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9300_UUT1'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_execute_clear_aaa_counters_server(self): - result = execute_clear_aaa_counters_server(self.device) - expected_output = None - self.assertEqual(result, expected_output) + execute_clear_aaa_counters_server(self.device) + self.assertIn( + 'clear aaa counters servers all', + self.device.execute.call_args[0]) \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/set_platform_soft_trace_debug/test_api_set_platform_soft_trace_debug.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/set_platform_soft_trace_debug/test_api_set_platform_soft_trace_debug.py index 0d9305790..8c5147db7 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/set_platform_soft_trace_debug/test_api_set_platform_soft_trace_debug.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/set_platform_soft_trace_debug/test_api_set_platform_soft_trace_debug.py @@ -1,6 +1,4 @@ -import os import unittest -from pyats.topology import loader from genie.libs.sdk.apis.iosxe.aaa.execute import set_platform_soft_trace_debug @@ -8,28 +6,16 @@ class TestSetPlatformSoftTraceDebug(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - Prasad_9500X: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: router - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['Prasad_9500X'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = unittest.mock.Mock() def test_set_platform_soft_trace_debug(self): - result = set_platform_soft_trace_debug(self.device, 'smd', 'active', 'r0', 'aaa-acct', 'debug', 'switch') - expected_output = None - self.assertEqual(result, expected_output) + set_platform_soft_trace_debug(self.device, 'smd', 'active', 'r0', 'aaa-acct', 'debug', 'switch') + self.assertIn( + 'set platform software trace smd switch active r0 aaa-acct debug', + self.device.execute.call_args[0]) + + def test_set_platform_soft_trace_debug_1(self): + set_platform_soft_trace_debug(self.device, 'smd', 'active', 'r0', 'aaa-acct', 'debug') + self.assertIn( + 'set platform software trace smd r0 aaa-acct debug', + self.device.execute.call_args[0]) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 55482f90e..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,98 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: T13-C9407-Dual-SUP2(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: T13-C9407-Dual-SUP2(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show logging process smd start last clear to-file flash:vlan_id_attr_log.txt: - response: - - |- - Logging display requested on 2023/07/26 13:04:29 (IST) for Hostname: [T13-C9407-Dual-SUP2], Model: [C9407R ], Version: [17.13.01], SN: [FXS212202PJ], MD_SN: [FXS2124Q59U] - - executing cmd on chassis 1 ... - Files being merged in the background, please check [/bootflash/vlan_id_attr_log.txt] output file - Unified Decoder Library Init .. DONE - - unified trace decoder estimates: [2] number of files, [179680] number of messages - that may be processed. Use CTRL+SHIFT+6 to break. - Found 1 UTF Streams - 2023-07-26 13:04:29.788504 - unified trace decoder estimate: processed 5% - 2023-07-26 13:04:29.969942 - unified trace decoder estimate: processed 10% - 2023-07-26 13:04:30.151345 - unified trace decoder estimate: processed 15% - 2023-07-26 13:04:30.332773 - unified trace decoder estimate: processed 20% - 2023-07-26 13:04:30.514256 - unified trace decoder estimate: processed 25% - 2023-07-26 13:04:30.695670 - unified trace decoder estimate: processed 30% - 2023-07-26 13:04:30.877013 - unified trace decoder estimate: processed 35% - 2023-07-26 13:04:31.058388 - unified trace decoder estimate: processed 40% - 2023-07-26 13:04:31.239898 - unified trace decoder estimate: processed 45% - 2023-07-26 13:04:31.490039 - unified trace decoder estimate: processed 50% - 2023-07-26 13:04:31.724274 - unified trace decoder estimate: processed 55% - 2023-07-26 13:04:31.954547 - unified trace decoder estimate: processed 60% - 2023-07-26 13:04:32.185182 - unified trace decoder estimate: processed 65% - 2023-07-26 13:04:32.416308 - unified trace decoder estimate: processed 70% - 2023-07-26 13:04:32.646625 - unified trace decoder estimate: processed 75% - 2023-07-26 13:04:32.882466 - unified trace decoder estimate: processed 80% - 2023-07-26 13:04:33.113086 - unified trace decoder estimate: processed 85% - 2023-07-26 13:04:33.344036 - unified trace decoder estimate: processed 90% - 2023-07-26 13:04:33.576200 - unified trace decoder estimate: processed 95% - 2023-07-26 13:04:33.801717 - unified trace decoder estimate: processed 100% - 2023-07-26 13:04:33.801733 - unified trace decoder : processing complete Result:[Success] - - =========================================================== - ======= Unified Trace Decoder Information/Statistics ====== - =========================================================== - ----------------- Decoder Input Information --------------- - =========================================================== - Num of Unique Streams .. 1 - Total UTF To Process ... 2 - Total UTM To Process ... 179680 - UTM Process Filter ..... smd - MRST Filter Rules ...... 1 - =========================================================== - ----------------- Decoder Output Information -------------- - =========================================================== - First UTM TimeStamp ............... 2023/07/26 07:45:57.065862770 - Last UTM TimeStamp ................ 2023/07/26 13:04:27.254888137 - UTM [Skipped / Rendered / Total] .. 176270 / 3410 / 179680 - UTM [ENCODED] ..................... 3410 - UTM [PLAIN TEXT] .................. 0 - UTM [DYN LIB] ..................... 0 - UTM [MODULE ID] ................... 0 - UTM [TDL TAN] ..................... 0 - UTM [APP CONTEXT] ................. 0 - UTM [MARKER] ...................... 0 - UTM [PCAP] ........................ 0 - UTM [LUID NOT FOUND] .............. 0 - UTM Level [EMERGENCY / ALERT / CRITICAL / ERROR] .. 0 / 0 / 0 / 2490 - UTM Level [WARNING / NOTICE / INFO / DEBUG] ....... 0 / 0 / 920 / 0 - UTM Level [VERBOSE / NOISE / INVALID] ............. 0 / 0 / 0 - =========================================================== - response_type: circular - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: T13-C9407-Dual-SUP2# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/test_api_show_logging_smd_output_to_file.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/test_api_show_logging_smd_output_to_file.py index 79e3b6c93..9a1cf1ff8 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/test_api_show_logging_smd_output_to_file.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/show_logging_smd_output_to_file/test_api_show_logging_smd_output_to_file.py @@ -1,6 +1,5 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.execute import show_logging_smd_output_to_file @@ -8,28 +7,11 @@ class TestShowLoggingSmdOutputToFile(unittest.TestCase): @classmethod def setUpClass(self): - testbed = f""" - devices: - VCR: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9400 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['VCR'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_show_logging_smd_output_to_file(self): - result = show_logging_smd_output_to_file(self.device, 'smd', 'vlan_id_attr_log.txt') - expected_output = None - self.assertEqual(result, expected_output) + show_logging_smd_output_to_file(self.device, 'smd', 'vlan_id_attr_log.txt') + self.assertIn( + 'show logging process smd start last clear to-file flash:vlan_id_attr_log.txt', + self.device.execute.call_args[0] + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_enable_password/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_enable_password/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_enable_password/test_api_verify_enable_password.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_enable_password/test_api_verify_enable_password.py index 460239ed8..ad82121a6 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_enable_password/test_api_verify_enable_password.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_enable_password/test_api_verify_enable_password.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.verify import verify_enable_password @@ -7,28 +7,17 @@ class TestVerifyEnablePassword(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - 9300_stack: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9300_stack'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_verify_enable_password(self): + self.device.execute.side_effect = ['', 'Password:'] result = verify_enable_password(self.device, 'dnac1', 15) - expected_output = True - self.assertEqual(result, expected_output) + self.assertIn( + 'exit', + self.device.execute.call_args_list[0][0] + ) + self.assertIn( + 'enable 15', + self.device.execute.call_args_list[1][0] + ) + self.assertEqual(result, True) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_login_credentials_enable_password/test_api_verify_login_credentials_enable_password.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_login_credentials_enable_password/test_api_verify_login_credentials_enable_password.py index 6c72382b2..70048965b 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_login_credentials_enable_password/test_api_verify_login_credentials_enable_password.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/verify/verify_login_credentials_enable_password/test_api_verify_login_credentials_enable_password.py @@ -1,5 +1,5 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.aaa.verify import verify_login_credentials_enable_password @@ -7,28 +7,18 @@ class TestVerifyLoginCredentialsEnablePassword(unittest.TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - 9300_stack: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: ng9k_stack - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9300_stack'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_verify_login_credentials_enable_password(self): - result = verify_login_credentials_enable_password(self.device, 'dnac', 'cisco123', True, 'dnac1', '15') - expected_output = True - self.assertEqual(result, expected_output) + self.device.execute.side_effect = ['', 'Password:'] + result = verify_login_credentials_enable_password( + self.device, 'dnac', 'cisco123', True, 'dnac1', '15') + self.assertIn( + 'exit', + self.device.execute.call_args_list[0][0] + ) + self.assertIn( + 'enable 15', + self.device.execute.call_args_list[1][0] + ) + self.assertEqual(result, True) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 6ed93ea32..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,35 +0,0 @@ -configure: - commands: - config-reg 0x2102: "config-reg 0x2102\r\n" - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: ott-asr1k-67(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: ott-asr1k-67(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: ott-asr1k-67# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/test_api_configure_autoboot.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/test_api_configure_autoboot.py index 92bc3bd07..b71e93fba 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/test_api_configure_autoboot.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/asr1k/configure/configure_autoboot/test_api_configure_autoboot.py @@ -1,35 +1,13 @@ -import os import unittest -from pyats.topology import loader +from unittest.mock import Mock from genie.libs.sdk.apis.iosxe.asr1k.configure import configure_autoboot class TestConfigureAutoboot(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - ott-asr1k-67: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: asr1k - type: asr1k - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['ott-asr1k-67'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_autoboot(self): - result = configure_autoboot(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + configure_autoboot(self.device) + self.device.configure.assert_called_once_with( + 'config-reg 0x2102' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/mock_data/iosxe/mock_data.yaml similarity index 67% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/mock_data/iosxe/mock_data.yaml index a9d6d0371..ad916374f 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/mock_data/iosxe/mock_data.yaml @@ -1,26 +1,27 @@ configure: commands: - boot manual: "boot manual\r\n" end: new_state: execute line console 0: new_state: configure_line + no cts role-based permissions default ipv6 DEFAULT_PERMIT_v6: "" no logging console: '' - prompt: cts_client(config)# + prompt: PE-A(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: cts_client(config-line)# + prompt: PE-A(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -29,7 +30,7 @@ execute: config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: cts_client# + prompt: PE-A# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/test_api_remove_default_ipv6_sgacl.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/test_api_remove_default_ipv6_sgacl.py new file mode 100644 index 000000000..1eea27c76 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/cts/configure/remove_default_ipv6_sgacl/test_api_remove_default_ipv6_sgacl.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.cts.configure import remove_default_ipv6_sgacl + + +class TestRemoveDefaultIpv6Sgacl(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + PE-A: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: c9300 + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['PE-A'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_remove_default_ipv6_sgacl(self): + result = remove_default_ipv6_sgacl(self.device, 'DEFAULT_PERMIT_v6') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/clear_counters/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/mock_data/iosxe/mock_data.yaml similarity index 74% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/clear_counters/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/mock_data/iosxe/mock_data.yaml index 93a59617f..d112bde26 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/clear_counters/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/mock_data/iosxe/mock_data.yaml @@ -5,13 +5,13 @@ configure: line console 0: new_state: configure_line no logging console: '' - prompt: javelin-morph-sj-full3-dut1(config)# + prompt: SA-C9350-24P(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: javelin-morph-sj-full3-dut1(config-line)# + prompt: SA-C9350-24P(config-line)# connect: commands: ? '' @@ -24,16 +24,16 @@ connect: prompt: '' execute: commands: - clear counters: - response: - - Clear "show interface" counters on all interfaces [confirm] - response_type: circular config term: new_state: configure config-transaction: new_state: configure + debug platform software cpm switch active b0 pcap disable: + response: + - Disabling CPM packet capture + response_type: circular show version: '' show version | include operating mode: '' term length 0: '' term width 0: '' - prompt: javelin-morph-sj-full3-dut1# + prompt: SA-C9350-24P# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/test_api_debug_software_cpm_switch_pcap.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/test_api_debug_software_cpm_switch_pcap.py new file mode 100644 index 000000000..d1b96cd2e --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/debug_software_cpm_switch_pcap/test_api_debug_software_cpm_switch_pcap.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.debug.configure import debug_software_cpm_switch_pcap + + +class TestDebugSoftwareCpmSwitchPcap(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + SA-C9350-24P: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: None + type: None + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['SA-C9350-24P'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_debug_software_cpm_switch_pcap(self): + result = debug_software_cpm_switch_pcap(self.device, 'active', 'disable') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/set_platform_soft_trace_debug/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/mock_data/iosxe/mock_data.yaml similarity index 66% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/set_platform_soft_trace_debug/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/mock_data/iosxe/mock_data.yaml index b4f22d6c1..be4369559 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/set_platform_soft_trace_debug/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/mock_data/iosxe/mock_data.yaml @@ -5,21 +5,22 @@ configure: line console 0: new_state: configure_line no logging console: '' - prompt: Prasad_9500X(config)# + prompt: Skyfox(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: Prasad_9500X(config-line)# + prompt: Skyfox(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -27,12 +28,12 @@ execute: new_state: configure config-transaction: new_state: configure - set platform software trace smd switch active r0 aaa-acct debug: + set platform software trace fed active ptp_proto debug: response: - - '' + - '' response_type: circular show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: Prasad_9500X# + prompt: Skyfox# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/test_api_set_platform_soft_trace_ptp_debug.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/test_api_set_platform_soft_trace_ptp_debug.py new file mode 100644 index 000000000..7d890b147 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/debug/configure/set_platform_soft_trace_ptp_debug/test_api_set_platform_soft_trace_ptp_debug.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.debug.configure import set_platform_soft_trace_ptp_debug + + +class TestSetPlatformSoftTracePtpDebug(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + Gryphon: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: c9500 + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['Gryphon'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_set_platform_soft_trace_ptp_debug(self): + result = set_platform_soft_trace_ptp_debug(self.device, 'fed', 'active', 'ptp_proto', 'debug', None) + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dns/configure/unconfigure_ip_domain_lookup/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dns/configure/unconfigure_ip_domain_lookup/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dns/configure/unconfigure_ip_domain_lookup/test_api_unconfigure_ip_domain_lookup.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dns/configure/unconfigure_ip_domain_lookup/test_api_unconfigure_ip_domain_lookup.py new file mode 100644 index 000000000..dcc98f649 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dns/configure/unconfigure_ip_domain_lookup/test_api_unconfigure_ip_domain_lookup.py @@ -0,0 +1,11 @@ +from unittest import TestCase +from genie.libs.sdk.apis.iosxe.dns.configure import unconfigure_ip_domain_lookup +from unittest.mock import Mock + + +class TestUnconfigureIpDomainLookup(TestCase): + + def test_unconfigure_ip_domain_lookup(self): + self.device = Mock() + result = unconfigure_ip_domain_lookup(self.device) + self.device.configure.assert_called_with(['no ip domain lookup']) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_global/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/mock_data/iosxe/mock_data.yaml similarity index 51% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_global/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/mock_data/iosxe/mock_data.yaml index 3433b25ea..2844556bb 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_global/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/mock_data/iosxe/mock_data.yaml @@ -5,23 +5,26 @@ configure: line console 0: new_state: configure_line no logging console: '' - no radius-server dscp acct 20: "no radius-server dscp acct 20\r\n" - no radius-server dscp auth 10: "no radius-server dscp auth 10\r\n" - prompt: SecG-A2-8M9300(config)# + no parameter-map type subscriber attribute-to-service BUILTIN_DEVICE_TO_TEMPLATE: "no\ + \ parameter-map type subscriber attribute-to-service BUILTIN_DEVICE_TO_TEMPLATE\r\ + \nDeleting Parameter-Map which is already in use, may impact new and existing\ + \ Sessions. \r\nDo you wish to continue? [yes]: yes\r\n" + prompt: C9300-Fabric-Edge(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: SecG-A2-8M9300(config-line)# + prompt: C9300-Fabric-Edge(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -30,7 +33,7 @@ execute: config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: SecG-A2-8M9300# + prompt: C9300-Fabric-Edge# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/test_api_unconfigure_parameter_map_subscriber.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/test_api_unconfigure_parameter_map_subscriber.py new file mode 100644 index 000000000..cad4e4bd0 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/dot1x/configure/unconfigure_parameter_map_subscriber/test_api_unconfigure_parameter_map_subscriber.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.dot1x.configure import unconfigure_parameter_map_subscriber + + +class TestUnconfigureParameterMapSubscriber(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + C9300-Fabric-Edge: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: svl + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['C9300-Fabric-Edge'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_unconfigure_parameter_map_subscriber(self): + result = unconfigure_parameter_map_subscriber(self.device, 'BUILTIN_DEVICE_TO_TEMPLATE') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/health/health_cpu/test_api_health_cpu.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/health/health_cpu/test_api_health_cpu.py index 03766759a..42d72f955 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/health/health_cpu/test_api_health_cpu.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/health/health_cpu/test_api_health_cpu.py @@ -1,34 +1,105 @@ import unittest -from pyats.topology import loader +from unittest.mock import Mock, MagicMock, patch +from pyats.topology.device import Device from genie.libs.sdk.apis.iosxe.health.health import health_cpu class TestHealthCpu(unittest.TestCase): - - @classmethod - def setUpClass(self): - testbed = """ - devices: - R1_xe: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: csr1000v - type: router - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['R1_xe'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_health_cpu(self): - result = health_cpu(self.device) - expected_output = {'health_data': []} + dev1 = Device('r1', os='iosxe', platform='iosxe') + output1 = { + 'five_sec_cpu_total': 0, + 'five_sec_cpu_interrupts': 0, + 'one_min_cpu': 0, + 'five_min_cpu': 0, + 'nonzero_cpu_processes': ['process1', 'process2'], + 'sort': { + 1: { + 'process': 'process1', + 'pid': 127, + 'runtime': 1003398, + 'invoked': 123494916, + 'usecs': 8, + 'tty': 0, + 'five_sec_cpu': 0.07, + 'one_min_cpu': 0.04, + 'five_min_cpu': 0.05 + }, + 2: { + 'process': 'process2', + 'pid': 112, + 'runtime': 1205941, + 'invoked': 10486225, + 'usecs': 115, + 'tty': 0, + 'five_sec_cpu': 0.07, + 'one_min_cpu': 0.05, + 'five_min_cpu': 0.07 + } + }, + } + output2 = { + 'cpu_utilization': { + 'five_sec_cpu_total': 0.01, + 'one_min_cpu': 0.02, + 'five_min_cpu': 0.07, + 'core': { + 'Core 0': { + 'core_cpu_util_five_secs': 00.01, + 'core_cpu_util_one_min': 0.01, + 'core_cpu_util_five_min': 0.01 + }, + 'Core 1': { + 'core_cpu_util_five_secs': 0.01, + 'core_cpu_util_one_min': 0.01, + 'core_cpu_util_five_min': 0.01 + }, + 'Core 2': { + 'core_cpu_util_five_secs': 0.01, + 'core_cpu_util_one_min': 0.01, + 'core_cpu_util_five_min': 0.01 + } + } + }, + 'sort': { + 0: { + 'ppid': 17811, + 'five_sec_cpu': 0.01, + 'one_min_cpu': 0.02, + 'five_min_cpu': 0.01, + 'status': 'S', + 'size': 299824, + 'process': 'process3' + }, + 1: { + 'ppid': 15826, + 'five_sec_cpu': 0.01, + 'one_min_cpu': 0.02, + 'five_min_cpu': 0.03, + 'status': 'S', + 'size': 794488, + 'process': 'process1' + } + } + } + dev1.parse = Mock() + dev1.parse.side_effect = [output1, output2] + result = health_cpu(dev1, processes=['process1', 'process2', 'process3']) + expected_output = {'health_data': [{'process': 'process1', 'value': 0.07}, {'process': 'process1_1', 'value': 0.01}, + {'process': 'process2', 'value': 0.07}, {'process': 'process3', 'value': 0.01}]} + self.assertEqual(result, expected_output) + + dev2 = Device('r2', os='iosxe', platform='iosxe') + dev2.parse = Mock() + dev2.parse.side_effect = [output1, output2] + result = health_cpu(dev2, processes=['process1', 'process2', 'process3'], add_total=True) + expected_output = {'health_data': [{'process': 'ALL_PROCESSES', 'value': 0.01}, {'process': 'process1', 'value': 0.07}, + {'process': 'process1_1', 'value': 0.01}, {'process': 'process2', 'value': 0.07}, {'process': 'process3', 'value': 0.01}]} self.assertEqual(result, expected_output) + + dev3 = Device('r3', os='iosxe', platform='iosxe') + dev3.parse = Mock() + dev3.parse.side_effect = [output1] + result = health_cpu(dev3, command='test_command', processes=['process1', 'process2', 'process3']) + expected_output = {'health_data': [{'process': 'process1', 'value': 0.07}, {'process': 'process2', 'value': 0.07}]} + self.assertEqual(result, expected_output) \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index a27c2ac78..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,60 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: PI-9300-Stack-103(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: PI-9300-Stack-103(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - install activate file flash:cat9k_iosxe.2022-06-06_12.21_mcpre.24042.CSCvq24042.SSA.smu.bin: - response: - - |- - $2022-06-06_12.21_mcpre.24042.CSCvq24042.SSA.smu.bin - install_activate: START Sun Aug 07 12:17:46 UTC 2022 - install_activate: Activating SMU - --- Starting SMU Activate operation --- - Performing SMU_ACTIVATE on all members - [1] SMU_ACTIVATE package(s) on Switch 1 - [2] SMU_ACTIVATE package(s) on Switch 2 - [3] SMU_ACTIVATE package(s) on Switch 3 - [2] Finished SMU_ACTIVATE on Switch 2 - [3] Finished SMU_ACTIVATE on Switch 3 - [1] Finished SMU_ACTIVATE on Switch 1 - Checking status of SMU_ACTIVATE on [1 2 3] - SMU_ACTIVATE: Passed on [1 2 3] - Finished SMU Activate operation - - SUCCESS: install_activate Sun Aug 07 12:18:00 U - response_type: circular - show version: '' - term length 0: '' - term width 0: '' - write memory: - response: - - |- - Building configuration... - [OK] - response_type: circular - show version | include operating mode: '' - prompt: PI-9300-Stack-103# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/test_api_execute_install_activate.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/test_api_execute_install_activate.py index cd3a6b21e..4b2ef6078 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/test_api_execute_install_activate.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_activate/test_api_execute_install_activate.py @@ -1,37 +1,14 @@ -import os import unittest -from pyats.topology import loader +import unittest.mock from genie.libs.sdk.apis.iosxe.install.execute import execute_install_activate class TestExecuteInstallActivate(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - PI-9300-Stack-103: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: None - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['PI-9300-Stack-103'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_execute_install_activate(self): - result = execute_install_activate(self.device, None, True, False, 'True', 'flash:cat9k_iosxe.2022-06-06_12.21_mcpre.24042.CSCvq24042.SSA.smu.bin', 900, 10) - expected_output = ('$2022-06-06_12.21_mcpre.24042.CSCvq24042.SSA.smu.bin\r\n' + self.device = unittest.mock.Mock() + self.device.execute = unittest.mock.Mock( + return_value='$2022-06-06_12.21_mcpre.24042.CSCvq24042.SSA.smu.bin\r\n' 'install_activate: START Sun Aug 07 12:17:46 UTC 2022\r\n' 'install_activate: Activating SMU\r\n' '--- Starting SMU Activate operation ---\r\n' @@ -45,6 +22,12 @@ def test_execute_install_activate(self): 'Checking status of SMU_ACTIVATE on [1 2 3]\r\n' 'SMU_ACTIVATE: Passed on [1 2 3]\r\n' 'Finished SMU Activate operation\r\n' - '\r\n' 'SUCCESS: install_activate Sun Aug 07 12:18:00 U') - self.assertEqual(result, expected_output) + + execute_install_activate(self.device, None, True, False, 'True', 'flash:cat9k_iosxe.2022-06-06_12.21_mcpre.24042.CSCvq24042.SSA.smu.bin', 900, 10) + + self.assertEqual(self.device.execute.call_count, 1) + self.assertEqual( + self.device.execute.call_args[0][0], + 'install activate file flash:cat9k_iosxe.2022-06-06_12.21_mcpre.24042.CSCvq24042.SSA.smu.bin' + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/install_image_reload.txt b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/install_image_reload.txt new file mode 100644 index 000000000..ab5c622cc --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/install_image_reload.txt @@ -0,0 +1,137 @@ + + + +Initializing Hardware ... + + +System integrity status: 88170200 21030117 00000300 +Procyon RSM done +Procyon RSM done +Procyon RSM done +Procyon RSM done + + +System Bootstrap, Version 17.15(1r), DEVELOPMENT SOFTWARE +Copyright (c) 1994-2024 by cisco Systems, Inc. +Compiled Tue May 7 17:46:07 2024 by siballa + + +Current image running: Boot ROM1 + +Last reset cause: LocalSoft + + +LEDA FPGA Version: 0x02080921 + +Castor 0 FPGA Version: 0x21310821 + +Castor 1 FPGA Version: 0x21310821 + + +C8500-20X6C-K9 platform with 67108864 Kbytes of main memory + + +File size is 0x00000473 + +Located packages.conf + +Image size 1139 inode num 269309, bks cnt 1 blk size 8*512 + +# + +File size is 0x04885b48 + +Located c8500x_COMPUTE_ASR1K.rpboot.BLD_LUX_DEV_LATEST_20241029_211620.SSA.pkg + +Image size 76045128 inode num 1248521, bks cnt 18566 blk size 8*512 + +###################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### + +Boot image size = 76045128 (0x4885b48) bytes + + +ROM:RSA Self Test Passed + +ROM:Sha512 Self Test Passed + + +Package header rev 3 structure detected + +Validating main package signatures + + +RSA Signed DEVELOPMENT Image Signature Verification Successful. + +Image validated + +find_debug_conf.sh:Info: User specified /bootflash/debug.conf as debug.conf file +find_debug_conf.sh:Error: /bootflash/debug.conf does not exist or has zero size. +find_debug_conf.sh:Error: Failed to fetch debug.conf. (rc=4) +Nov 6 11:51:54.016: %BOOT-5-OPMODE_LOG: R0/0: binos: System booted in AUTONOMOUS mode + + Restricted Rights Legend + +Use, duplication, or disclosure by the Government is +subject to restrictions as set forth in subparagraph +(c) of the Commercial Computer Software - Restricted +Rights clause at FAR sec. 52.227-19 and subparagraph +(c) (1) (ii) of the Rights in Technical Data and Computer +Software clause at DFARS sec. 252.227-7013. + + Cisco Systems, Inc. + 170 West Tasman Drive + San Jose, California 95134-1706 + + + +Cisco IOS Software [Lux], c8000aep Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Experimental Version 17.17.20241029:213734 [BLD_LUX_DEV_LATEST_20241029_211620:/nobackup/build 101] +Copyright (c) 1986-2024 by Cisco Systems, Inc. +Compiled Tue 29-Oct-24 21:40 by mcpre + + +This software version supports only Smart Licensing as the software licensing mechanism. + + +Please read the following carefully before proceeding. By downloading, +installing, and/or using any Cisco software product, application, feature, +license, or license key (collectively, the "Software"), you accept and +agree to the following terms. If you do not agree, do not proceed and do not +use this Software. + +This Software and its use are governed by Cisco's General Terms and any +relevant supplemental terms found at +https://www.cisco.com/site/us/en/about/legal/contract-experience/index.html. +If you have a negotiated agreement with Cisco that includes this Software, the +terms of that agreement apply as well. In the event of a conflict, the order +of precedence stated in your negotiated agreement controls. + +Cisco Software is licensed on a term and/or subscription-basis. The license to +the Software is valid only for the duration of the specified term, or in the +case of a subscription-based license, only so long as all required subscription +payments are current and fully paid-up. While Cisco may provide you +licensing-related alerts, it is your sole responsibility to monitor your usage. +Using Cisco Software without a valid license is not permitted and may result in +fees charged to your account. Cisco reserves the right to terminate access to, +or restrict the functionality of, any Cisco Software, or any features thereof, +that are being used without a valid license. + + +cisco C8500-20X6C (ACE) processor (revision ACE) with 32404776K/6147K bytes of memory. +Processor board ID FOX2541P3Y7 +Router operating mode: Autonomous +20 Ten Gigabit Ethernet interfaces +6 Hundred Gigabit Ethernet interfaces +32768K bytes of non-volatile configuration memory. +67108864K bytes of physical memory. +468786007K bytes of SATA hard disk at harddisk:. +26763263K bytes of eUSB flash at bootflash:. + + +% If cipher currently being used is not configured, new SAK will be generated + + WARNING: Command has been added to the configuration using a type 0 password. However, recommended to migrate to strong type-6 encryption + + WARNING: ** NOTICE ** The H.323 protocol is no longer supported from IOS-XE release 17.6.1. Please consider using SIP for multimedia applications. + + +Press RETURN to get started! \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/mock_data.yaml index 4a17b1bab..6280e4278 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/mock_data/iosxe/mock_data.yaml @@ -32,20 +32,20 @@ execute: activate reloadfast commit : response: - |- - $is/images/cat9k_iosxe.17.10.01.SPA.bin activate reloadfast commit - install_add_activate_commit: START Thu Nov 9 23:18:39 PDT 2023 - STACK_GR: Inside xFSU check if switch stack - System not ready for reload fast, Please run this command later - FAILED: xFSU requirement pre-check - Checking STP eligibility: Eligible - - [1]: Performing xFSU-pre-check - 300+0 records in - 300+0 records out - 307200 bytes (307 kB, 300 KiB) copied, 0.195192 s, 1.6 MB/s - SUCCESS: xFSU-pre-check finished - [1]: xFSU-pre-check package(s) on switch 1 - FAILED: xFSU requirement pre-check + $is/images/cat9k_iosxe.17.10.01.SPA.bin activate reloadfast commit + install_add_activate_commit: START Thu Nov 9 23:18:39 PDT 2023 + STACK_GR: Inside xFSU check if switch stack + System not ready for reload fast, Please run this command later + FAILED: xFSU requirement pre-check + Checking STP eligibility: Eligible + + [1]: Performing xFSU-pre-check + 300+0 records in + 300+0 records out + 307200 bytes (307 kB, 300 KiB) copied, 0.195192 s, 1.6 MB/s + SUCCESS: xFSU-pre-check finished + [1]: xFSU-pre-check package(s) on switch 1 + FAILED: xFSU requirement pre-check FAILED: install_add_activate_commit : Abort xFSU install since requirement does not met response_type: circular show version: '' @@ -54,8 +54,88 @@ execute: write memory: response: - |- - Building configuration... + Building configuration... [OK] response_type: circular show version | include operating mode: '' prompt: AMZ-Acc-4# + +connect1: + commands: + '': + new_state: execute1 + preface: |- + Trying mock_device ... + Connected to mock_device. + Escape character is '^]'. + prompt: '' + +execute1: + prompt: "AMZ-Acc-4#" + commands: + show version | include operating mode: '' + config term: + new_state: configure + config-transaction: + new_state: configure + write memory: | + Building configuration... + [OK] + install add file bootflash:c8500x_COMPUTE_ASR1K.image.BLD_LUX_DEV_LATEST_20241029_211620.SSA.bin activate commit prompt-level none: + new_state: install_image_state + +install_image_state: + prompt: "AMZ-Acc-4#" + preface: | + install_add_activate_commit: START Wed Nov 06 17:18:32 IST 2024 + install_add: START Wed Nov 06 17:18:32 IST 2024 + install_add: Adding IMG + --- Starting initial file syncing --- + Copying bootflash:c8500x_COMPUTE_ASR1K.image.BLD_LUX_DEV_LATEST_20241029_211620.SSA.bin from R0 to R0 + Info: Finished copying to the selected + Finished initial file syncing + + --- Starting Add --- + Performing Add on all members + Checking status of Add on [R0] + Add: Passed on [R0] + Image added. Version: 22.1.1.0.2956 + + Finished Add + + install_activate: START Wed Nov 06 17:19:22 IST 2024 + install_activate: Activating IMG + Following packages shall be activated: + /bootflash/c8500x_COMPUTE_ASR1K.empty.BLD_LUX_DEV_LATEST_20241029_211620.SSA.pkg + /bootflash/c8500x_COMPUTE_ASR1K.rpboot.BLD_LUX_DEV_LATEST_20241029_211620.SSA.pkg + --- Starting Activate --- + Performing Activate on all members + [1] Activate package(s) on R0 + Warning: Booting with bundle mode will be deprecated in the near future. Migration to install mode is required. + Building configuration... + [OK] [1] Finished Activate on R0 + Checking status of Activate on [R0] + Activate: Passed on [R0] + Finished Activate + + --- Starting Commit --- + Performing Commit on all members + [1] Commit package(s) on R0 + [1] Finished Commit on R0 + Checking status of Commit on [R0] + Commit: Passed on [R0] + Finished Commit operation + + SUCCESS: install_add_activate_commit Wed Nov 06 17:19:32 IST 2024 + commands: + '': + new_state: install_image_reload_state + +install_image_reload_state: + prompt: "" + preface: file|iosxe/install_image_reload.txt + timing: + - 0:,0,0.005 + commands: + '': + new_state: execute1 diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/test_api_execute_install_one_shot.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/test_api_execute_install_one_shot.py index 888d3fc6e..0b7ea693b 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/test_api_execute_install_one_shot.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/install/execute/execute_install_one_shot/test_api_execute_install_one_shot.py @@ -28,8 +28,43 @@ def setUpClass(self): init_config_commands=[], init_exec_commands=[] ) + self.device.settings.POST_RELOAD_WAIT = 1 def test_execute_install_one_shot(self): - result = execute_install_one_shot(self.device, 'tftp://172.27.18.5/auto/iconatest/users/byodis/images/cat9k_iosxe.17.10.01.SPA.bin', True, False, False, 900, 10, False, 'True') + result = execute_install_one_shot(self.device, 'tftp://172.27.18.5/auto/iconatest/users/byodis/images/cat9k_iosxe.17.10.01.SPA.bin', + True, False, False, 5, 10, False, 'True') expected_output = False self.assertEqual(result, expected_output) + + +class TestExecuteInstallOneShot1(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + AMZ-Acc-4: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect1 + protocol: unknown + os: iosxe + platform: cat9k + type: c9300 + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['AMZ-Acc-4'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + self.device.settings.POST_RELOAD_WAIT = 1 + + def test_execute_install_one_shot(self): + result = execute_install_one_shot(self.device, 'bootflash:c8500x_COMPUTE_ASR1K.image.BLD_LUX_DEV_LATEST_20241029_211620.SSA.bin', + False, False, False, 5, 10, False, False) + self.assertIn('install add file bootflash:c8500x_COMPUTE_ASR1K.image.BLD_LUX_DEV_LATEST_20241029_211620.SSA.bin activate commit prompt-level none', + result) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/mock_data/iosxe/mock_data.yaml similarity index 64% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/mock_data/iosxe/mock_data.yaml index a61f61d9d..5efbe99de 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_radius_server_dead_criteria/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/mock_data/iosxe/mock_data.yaml @@ -2,26 +2,27 @@ configure: commands: end: new_state: execute + interface GigabitEthernet1/0/1: "interface GigabitEthernet1/0/1\r\n" line console 0: new_state: configure_line no logging console: '' - radius-server dead-criteria time 2 tries 1: "radius-server dead-criteria time - 2 tries 1\r\n" - prompt: LG-PK(config)# + speed auto: "speed auto\r\n" + prompt: Raitt(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: LG-PK(config-line)# + prompt: Raitt(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -30,7 +31,7 @@ execute: config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: LG-PK# + prompt: Raitt# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/test_api_configure_interface_speed_auto.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/test_api_configure_interface_speed_auto.py new file mode 100644 index 000000000..faf6c906e --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/configure/configure_interface_speed_auto/test_api_configure_interface_speed_auto.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.interface.configure import configure_interface_speed_auto + + +class TestConfigureInterfaceSpeedAuto(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + Raitt: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: iosxe + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['Raitt'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_configure_interface_speed_auto(self): + result = configure_interface_speed_auto(self.device, 'GigabitEthernet1/0/1') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/execute_clear_aaa_counters_server/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/mock_data/iosxe/mock_data.yaml similarity index 60% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/execute_clear_aaa_counters_server/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/mock_data/iosxe/mock_data.yaml index 232be760a..a7f4c1c15 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/execute/execute_clear_aaa_counters_server/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/mock_data/iosxe/mock_data.yaml @@ -5,36 +5,35 @@ configure: line console 0: new_state: configure_line no logging console: '' - prompt: 9300_UUT1(config)# + prompt: SA-C9350-24P(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: 9300_UUT1(config-line)# + prompt: SA-C9350-24P(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: - clear aaa counters servers all: - response: - - |- - clear aaa counters servers [confirm] - The process for the command is not responding or is otherwise unavailable - response_type: circular config term: new_state: configure config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: 9300_UUT1# + test platform hardware cman-thermal switch active R0 temperature fake on: + response: + - '!!!Temperature Fake On!!!' + response_type: circular + prompt: SA-C9350-24P# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/test_api_execute_test_platform_hardware_cman.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/test_api_execute_test_platform_hardware_cman.py new file mode 100644 index 000000000..18c7bb569 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_platform_hardware_cman/test_api_execute_test_platform_hardware_cman.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.interface.execute import execute_test_platform_hardware_cman + + +class TestExecuteTestPlatformHardwareCman(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + SA-C9350-24P: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: None + type: None + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['SA-C9350-24P'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_execute_test_platform_hardware_cman(self): + result = execute_test_platform_hardware_cman(self.device, 'cman-thermal', 'active', 'R0', 'temperature', 'fake', 'on', None, 0) + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/mock_data/iosxe/mock_data.yaml similarity index 61% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/mock_data/iosxe/mock_data.yaml index 30535b2c1..c8b51b403 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/mock_data/iosxe/mock_data.yaml @@ -1,27 +1,26 @@ configure: commands: - aaa accounting update newinfo periodic 2880: "aaa accounting update newinfo periodic - 2880\r\n" end: new_state: execute line console 0: new_state: configure_line no logging console: '' - prompt: stack-12m(config)# + prompt: SA-C9350-24P(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: stack-12m(config-line)# + prompt: SA-C9350-24P(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -30,7 +29,11 @@ execute: config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: stack-12m# + test platform software fed switch active sfp port 1 fake-insert: + response: + - '' + response_type: circular + prompt: SA-C9350-24P# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/test_api_execute_test_sfp_port_lpn_fake_insert.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/test_api_execute_test_sfp_port_lpn_fake_insert.py new file mode 100644 index 000000000..9c2754f9d --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_insert/test_api_execute_test_sfp_port_lpn_fake_insert.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.interface.execute import execute_test_sfp_port_lpn_fake_insert + + +class TestExecuteTestSfpPortLpnFakeInsert(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + SA-C9350-24P: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: None + type: None + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['SA-C9350-24P'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_execute_test_sfp_port_lpn_fake_insert(self): + result = execute_test_sfp_port_lpn_fake_insert(self.device, 'active', 1) + expected_output = '' + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/mock_data/iosxe/mock_data.yaml new file mode 100644 index 000000000..f38a69838 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/mock_data/iosxe/mock_data.yaml @@ -0,0 +1,39 @@ +configure: + commands: + end: + new_state: execute + line console 0: + new_state: configure_line + no logging console: '' + prompt: SA-C9350-24P(config)# +configure_line: + commands: + end: + new_state: execute + exec-timeout 0: '' + prompt: SA-C9350-24P(config-line)# +connect: + commands: + ? '' + : new_state: execute + preface: 'Trying mock_device ... + + Connected to mock_device. + + Escape character is ''^]''.' + prompt: '' +execute: + commands: + config term: + new_state: configure + config-transaction: + new_state: configure + show version: '' + show version | include operating mode: '' + term length 0: '' + term width 0: '' + test platform software fed switch active sfp port 1 fake-remove: + response: + - '' + response_type: circular + prompt: SA-C9350-24P# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/test_api_execute_test_sfp_port_lpn_fake_remove.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/test_api_execute_test_sfp_port_lpn_fake_remove.py new file mode 100644 index 000000000..15e2b202b --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/execute/execute_test_sfp_port_lpn_fake_remove/test_api_execute_test_sfp_port_lpn_fake_remove.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.interface.execute import execute_test_sfp_port_lpn_fake_remove + + +class TestExecuteTestSfpPortLpnFakeRemove(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + SA-C9350-24P: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: None + type: None + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['SA-C9350-24P'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_execute_test_sfp_port_lpn_fake_remove(self): + result = execute_test_sfp_port_lpn_fake_remove(self.device, 'active', 1) + expected_output = '' + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/mock_data/iosxe/mock_data.yaml index 176d80170..58d7c5be6 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/mock_data/iosxe/mock_data.yaml @@ -2,76 +2,84 @@ configure: commands: end: new_state: execute - line console: - new_state: configure_line line console 0: new_state: configure_line no logging console: '' - prompt: R1_xe(config)# + prompt: ott-c9300-66(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: R1_xe(config-line)# + prompt: ott-c9300-66(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: config term: new_state: configure - show ip interface brief: |- - Interface IP-Address OK? Method Status Protocol - GigabitEthernet1 172.16.1.211 YES TFTP up up - GigabitEthernet2 unassigned YES unset up up - GigabitEthernet2.90 10.12.90.1 YES TFTP up up - GigabitEthernet2.110 10.12.110.1 YES TFTP up up - GigabitEthernet2.115 10.12.115.1 YES TFTP up up - GigabitEthernet2.120 10.12.120.1 YES TFTP up up - GigabitEthernet2.390 10.12.90.1 YES TFTP up up - GigabitEthernet2.410 10.12.110.1 YES TFTP up up - GigabitEthernet2.415 10.12.115.1 YES TFTP up up - GigabitEthernet2.420 10.12.120.1 YES TFTP up up - GigabitEthernet3 unassigned YES unset up up - GigabitEthernet3.90 10.13.90.1 YES TFTP up up - GigabitEthernet3.110 10.13.110.1 YES TFTP up up - GigabitEthernet3.115 10.13.115.1 YES TFTP up up - GigabitEthernet3.120 10.13.120.1 YES TFTP up up - GigabitEthernet3.390 10.13.90.1 YES TFTP up up - GigabitEthernet3.410 10.13.110.1 YES TFTP up up - GigabitEthernet3.415 10.13.115.1 YES TFTP up up - GigabitEthernet3.420 10.13.120.1 YES TFTP up up - GigabitEthernet4 unassigned YES unset up up - GigabitEthernet5 unassigned YES unset up up - GigabitEthernet6 unassigned YES unset up up - GigabitEthernet7 unassigned YES unset up up - Loopback0 1.1.1.1 YES TFTP up up - Loopback300 1.1.1.1 YES TFTP up up - Port-channel12 unassigned YES unset down down - Port-channel13 unassigned YES unset up up - Tunnel0 unassigned YES unset up up - Tunnel1 unassigned YES unset up up - Tunnel2 10.13.110.1 YES unset up down - Tunnel3 10.13.110.1 YES unset up down - Tunnel4 1.1.1.1 YES unset up up - Tunnel5 1.1.1.1 YES unset up up - Tunnel6 1.1.1.1 YES unset up up - Tunnel7 1.1.1.1 YES unset up up - Tunnel8 unassigned YES unset up down - Tunnel9 unassigned YES unset up down + config-transaction: + new_state: configure + show ip interface brief: + response: + - "Interface IP-Address OK? Method Status Protocol\r\ + \nVlan1 unassigned YES unset administratively down\ + \ down \r\nGigabitEthernet0/0 5.40.13.66 YES manual up \ + \ up \r\nGigabitEthernet1/0/1 unassigned YES unset\ + \ up up \r\nGigabitEthernet1/0/2 unassigned \ + \ YES unset down down \r\nGigabitEthernet1/0/3 unassigned\ + \ YES unset down down \r\nGigabitEthernet1/0/4 \ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/5\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/6\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/7\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/8\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/9\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/10\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/11\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/12\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/13\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/14\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/15\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/16\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/17\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/18\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/19\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/20\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/21\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/22\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/23\ + \ unassigned YES unset down down \r\nGigabitEthernet1/0/24\ + \ unassigned YES unset down down \r\nGigabitEthernet1/1/1\ + \ unassigned YES unset down down \r\nGigabitEthernet1/1/2\ + \ unassigned YES unset down down \r\nGigabitEthernet1/1/3\ + \ unassigned YES unset down down \r\nGigabitEthernet1/1/4\ + \ unassigned YES unset down down \r\nTe1/1/1 \ + \ unassigned YES unset down down \r\ + \nTe1/1/2 unassigned YES unset down \ + \ down \r\nTe1/1/3 unassigned YES unset down \ + \ down \r\nTe1/1/4 unassigned YES unset\ + \ down down \r\nTe1/1/5 unassigned \ + \ YES unset down down \r\nTe1/1/6 unassigned\ + \ YES unset down down \r\nTe1/1/7 \ + \ unassigned YES unset down down \r\nTe1/1/8 \ + \ unassigned YES unset down down \r\ + \nFo1/1/1 unassigned YES unset down \ + \ down \r\nFo1/1/2 unassigned YES unset down \ + \ down \r\nTwentyFiveGigE1/1/1 unassigned YES unset\ + \ down down \r\nTwentyFiveGigE1/1/2 unassigned \ + \ YES unset down down \r\nAp1/0/1 unassigned\ + \ YES unset up up" + response_type: circular show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: R1_xe# + prompt: ott-c9300-66# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/test_api_get_interface_names.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/test_api_get_interface_names.py index ce4a625a1..2ba99ab8e 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/test_api_get_interface_names.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/interface/get/get_interface_names/test_api_get_interface_names.py @@ -1,71 +1,38 @@ -import unittest -from pyats.topology import loader +import os +from unittest import TestCase from genie.libs.sdk.apis.iosxe.interface.get import get_interface_names +from pyats.topology import loader -class TestGetInterfaceNames(unittest.TestCase): +class TestGetInterfaceNames(TestCase): + @classmethod def setUpClass(self): - testbed = """ + + testbed = f""" devices: - R1_xe: + ott-c9300-66: connections: defaults: class: unicon.Unicon a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect protocol: unknown os: iosxe - platform: iosxe - type: CSR1000v + platform: cat9k + type: cat9k """ self.testbed = loader.load(testbed) - self.device = self.testbed.devices["R1_xe"] + self.device = self.testbed.devices['ott-c9300-66'] self.device.connect( learn_hostname=True, init_config_commands=[], init_exec_commands=[] ) + def test_get_interface_names(self): result = get_interface_names(self.device) - expected_output = [ - "GigabitEthernet1", - "GigabitEthernet2", - "GigabitEthernet2.90", - "GigabitEthernet2.110", - "GigabitEthernet2.115", - "GigabitEthernet2.120", - "GigabitEthernet2.390", - "GigabitEthernet2.410", - "GigabitEthernet2.415", - "GigabitEthernet2.420", - "GigabitEthernet3", - "GigabitEthernet3.90", - "GigabitEthernet3.110", - "GigabitEthernet3.115", - "GigabitEthernet3.120", - "GigabitEthernet3.390", - "GigabitEthernet3.410", - "GigabitEthernet3.415", - "GigabitEthernet3.420", - "GigabitEthernet4", - "GigabitEthernet5", - "GigabitEthernet6", - "GigabitEthernet7", - "Loopback0", - "Loopback300", - "Port-channel12", - "Port-channel13", - "Tunnel0", - "Tunnel1", - "Tunnel2", - "Tunnel3", - "Tunnel4", - "Tunnel5", - "Tunnel6", - "Tunnel7", - "Tunnel8", - "Tunnel9", - ] - self.assertEqual(result, expected_output) + + + diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 32fbf22b5..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,39 +0,0 @@ -configure: - commands: - eid-table vlan 110: "eid-table vlan 110\r\n" - end: - new_state: execute - instance-id 2: "instance-id 2\r\n" - line console 0: - new_state: configure_line - no enhanced-forwarding: "no enhanced-forwarding\r\n" - no logging console: '' - router lisp: "router lisp\r\n" - service ethernet: "service ethernet\r\n" - prompt: FE1(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: FE1(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: FE1# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/test_api_unconfigure_lisp_enhanced_forwarding.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/test_api_unconfigure_lisp_enhanced_forwarding.py index 1c6b0532d..a5f897a28 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/test_api_unconfigure_lisp_enhanced_forwarding.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/lisp/configure/unconfigure_lisp_enhanced_forwarding/test_api_unconfigure_lisp_enhanced_forwarding.py @@ -1,35 +1,10 @@ -import os -import unittest -from pyats.topology import loader +from unittest import TestCase from genie.libs.sdk.apis.iosxe.lisp.configure import unconfigure_lisp_enhanced_forwarding +from unittest.mock import Mock - -class TestUnconfigureLispEnhancedForwarding(unittest.TestCase): - - @classmethod - def setUpClass(self): - testbed = f""" - devices: - FE1: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: router - type: router - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['FE1'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) +class TestUnconfigureLispEnhancedForwarding(TestCase): def test_unconfigure_lisp_enhanced_forwarding(self): - result = unconfigure_lisp_enhanced_forwarding(self.device, '2', '110') - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + unconfigure_lisp_enhanced_forwarding(self.device, '1', '2') + self.device.configure.assert_called_with(['router lisp', 'instance-id 1', 'service ethernet', 'eid-table vlan 2', 'no enhanced-forwarding']) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/logging/get/execute_clear_logging/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/logging/get/execute_clear_logging/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/logging/get/execute_clear_logging/test_api_execute_clear_logging.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/logging/get/execute_clear_logging/test_api_execute_clear_logging.py new file mode 100644 index 000000000..584d2ee4f --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/logging/get/execute_clear_logging/test_api_execute_clear_logging.py @@ -0,0 +1,16 @@ +import os +from unittest import TestCase +from genie.libs.sdk.apis.iosxe.logging.get import execute_clear_logging +from unittest.mock import Mock +class TestExecuteClearLogging(TestCase): + + @classmethod + def setUpClass(self): + self.device = Mock() + + def test_execute_clear_logging(self): + result = execute_clear_logging(self.device) + self.assertIn( + 'clear logging', + self.device.execute.call_args_list[0][0] + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 36c4c4d84..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,42 +0,0 @@ -configure: - commands: - crypto pki server ca: "crypto pki server ca\r\n" - database archive pkcs12: "database archive pkcs12\r\n" - database archive pkcs12 password cisco123: "database archive pkcs12 password\ - \ cisco123\r\n" - 'database url p12 bootflash:': "database url p12 bootflash:\r\n" - end: - new_state: execute - grant auto: "grant auto\r\n" - ip http server: "ip http server\r\n" - line console 0: - new_state: configure_line - no logging console: '' - no shut: "no shut\r\n" - prompt: fugazi(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: fugazi(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - show version | include operating mode: '' - prompt: fugazi# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/test_api_configure_crypto_pki_server.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/test_api_configure_crypto_pki_server.py index 8379805ce..65ff9a07c 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/test_api_configure_crypto_pki_server.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/pki/configure/configure_crypto_pki_server/test_api_configure_crypto_pki_server.py @@ -6,30 +6,16 @@ class TestConfigureCryptoPkiServer(unittest.TestCase): - @classmethod - def setUpClass(self): - testbed = f""" - devices: - fugazi: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: iosxe - type: iosxe - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['fugazi'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - def test_configure_crypto_pki_server(self): + self.device = unittest.mock.MagicMock() result = configure_crypto_pki_server(self.device, 'ca', 'cisco123', None, None, None, None, 'pkcs12', 'cisco123', None, 'bootflash:', None, 'p12', False, None, 'auto', None, None, None, None, None, None, None, None, None, None, False, None, None, None, None, None, 80) expected_output = True + self.assertEqual( + self.device.configure.mock_calls[0].args, + (['ip http server', 'crypto pki server ca', 'database archive pkcs12', 'database archive pkcs12 password cisco123', 'database url p12 bootflash:', 'grant auto'],) + ) + self.assertEqual( + self.device.configure.mock_calls[1].args, + (['crypto pki server ca', 'no shut'],) + ) self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/test_api_configure_boot_manual.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/test_api_configure_boot_manual.py index 4ef39f45c..6391fd60a 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/test_api_configure_boot_manual.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_boot_manual/test_api_configure_boot_manual.py @@ -1,34 +1,14 @@ -import unittest -from pyats.topology import loader +import os +from unittest import TestCase from genie.libs.sdk.apis.iosxe.platform.configure import configure_boot_manual +from unittest.mock import Mock - -class TestConfigureBootManual(unittest.TestCase): +class TestConfigureBootManual(TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - cts_client: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat3k - type: single_rp - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['cts_client'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_boot_manual(self): result = configure_boot_manual(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device.configure.assert_called_with('boot manual') diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier/test_api_configure_device_classifier.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier/test_api_configure_device_classifier.py index a8bc6750f..710e7a579 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier/test_api_configure_device_classifier.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier/test_api_configure_device_classifier.py @@ -1,35 +1,22 @@ -import os -import unittest -from pyats.topology import loader +from unittest import TestCase from genie.libs.sdk.apis.iosxe.platform.configure import configure_device_classifier +from unittest.mock import Mock -class TestConfigureDeviceClassifier(unittest.TestCase): - - @classmethod - def setUpClass(self): - testbed = f""" - devices: - 9300-24UX-2: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['9300-24UX-2'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) +class TestConfigureDeviceClassifier(TestCase): def test_configure_device_classifier(self): + self.device = Mock() result = configure_device_classifier(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.assertEqual( + self.device.configure.mock_calls[0].args, + ('device classifier',) + ) + + def test_configure_device_classifier_1(self): + self.device = Mock() + result = configure_device_classifier(self.device, 'some_option', 'some_value') + self.assertEqual( + self.device.configure.mock_calls[0].args, + ('device classifier some_option some_value',) + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier_command/test_api_configure_device_classifier_command.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier_command/test_api_configure_device_classifier_command.py index fe94597dd..89b5bf535 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier_command/test_api_configure_device_classifier_command.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_device_classifier_command/test_api_configure_device_classifier_command.py @@ -1,35 +1,14 @@ -import os -import unittest -from pyats.topology import loader +from unittest import TestCase from genie.libs.sdk.apis.iosxe.platform.configure import configure_device_classifier_command +from unittest.mock import Mock -class TestConfigureDeviceClassifierCommand(unittest.TestCase): - - @classmethod - def setUpClass(self): - testbed = f""" - devices: - stack3-nyquist-1: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: c9300 - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['stack3-nyquist-1'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) +class TestConfigureDeviceClassifierCommand(TestCase): def test_configure_device_classifier_command(self): - result = configure_device_classifier_command(self.device, 'condition', 'COND_TEST_A', 'no lldp', 'tlv-type 6 value String Cisco', 'no device classifier', 60) - expected_output = None - self.assertEqual(result, expected_output) + self.device = Mock() + result = configure_device_classifier_command(self.device, 'condition', 'COND_TEST_A', 'no lldp', 'tlv-type 6 value String Cisco', 'no device classifier', 30) + self.assertEqual( + self.device.configure.mock_calls[0].args, + (['device classifier condition COND_TEST_A', 'no lldp tlv-type 6 value String Cisco', 'no device classifier'],) + ) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 2f785002c..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,39 +0,0 @@ -configure: - commands: - line console: - new_state: configure_line - line console 0: - new_state: configure_line - no logging console: '' - no boot manual: '' - end: - new_state: execute - prompt: c2_core_sf(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - line vty: '' - terminal width 511: '' - prompt: c2_core_sf(config-line)# -connect: - commands: - '': - new_state: execute - preface: |- - Trying mock_device ... - Connected to mock_device. - Escape character is '^]'. - prompt: '' -execute: - commands: - config term: - new_state: configure - show version: '' - term length 0: '' - term width 0: '' - term width 511: '' - terminal session-timeout 0: '' - show version | include operating mode: '' - prompt: c2_core_sf# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/test_api_configure_no_boot_manual.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/test_api_configure_no_boot_manual.py index ebeadd9fb..46b943f7a 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/test_api_configure_no_boot_manual.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/configure/configure_no_boot_manual/test_api_configure_no_boot_manual.py @@ -1,34 +1,14 @@ -import unittest -from pyats.topology import loader +import os +from unittest import TestCase from genie.libs.sdk.apis.iosxe.platform.configure import configure_no_boot_manual +from unittest.mock import Mock - -class TestConfigureNoBootManual(unittest.TestCase): +class TestConfigureNoBootManual(TestCase): @classmethod def setUpClass(self): - testbed = """ - devices: - c2_core_sf: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: c9300 - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['c2_core_sf'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) + self.device = Mock() def test_configure_no_boot_manual(self): result = configure_no_boot_manual(self.device) - expected_output = None - self.assertEqual(result, expected_output) + self.device.configure.assert_called_with('no boot manual') diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/mock_data/iosxe/mock_data.yaml similarity index 53% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/mock_data/iosxe/mock_data.yaml index ab12a5b11..00cea32f6 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_aaa_new_model/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/mock_data/iosxe/mock_data.yaml @@ -4,35 +4,23 @@ configure: new_state: execute line console 0: new_state: configure_line - no aaa new-model: - new_state: no_aaa_model no logging console: '' - prompt: HCR_pk(config)# - -no_aaa_model: - preface: | - no aaa new-model - Changing configuration back to no aaa new-model is not supported. - prompt: Continue?[confirm] - commands: - '': - new_state: configure - - + prompt: SA-C9350-24P(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: HCR_pk(config-line)# + prompt: SA-C9350-24P(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -40,8 +28,13 @@ execute: new_state: configure config-transaction: new_state: configure + diagnostic start switch 1 test 4 port 2: + response: + - "Diagnostic[switch 1]: Running test(s) 4 may disrupt normal system operation\ + \ and requires reload\r\nDo you want to continue? [no]: yes" + response_type: circular show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: HCR_pk# + prompt: SA-C9350-24P# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/test_api_execute_diagnostic_start_switch_port.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/test_api_execute_diagnostic_start_switch_port.py new file mode 100644 index 000000000..6c10b9ba9 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/execute_diagnostic_start_switch_port/test_api_execute_diagnostic_start_switch_port.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.platform.execute import execute_diagnostic_start_switch_port + + +class TestExecuteDiagnosticStartSwitchPort(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + SA-C9350-24P: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: None + type: None + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['SA-C9350-24P'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_execute_diagnostic_start_switch_port(self): + result = execute_diagnostic_start_switch_port(self.device, 1, '4', '2') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_dscp_global/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/mock_data/iosxe/mock_data.yaml similarity index 60% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_dscp_global/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/mock_data/iosxe/mock_data.yaml index 233e6fefb..401b22516 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_dscp_global/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/mock_data/iosxe/mock_data.yaml @@ -5,23 +5,22 @@ configure: line console 0: new_state: configure_line no logging console: '' - radius-server dscp acct 40: "radius-server dscp acct 40\r\n" - radius-server dscp auth 50: "radius-server dscp auth 50\r\n" - prompt: SecG-A3-9410HA(config)# + prompt: hendrix(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: SecG-A3-9410HA(config-line)# + prompt: hendrix(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -30,7 +29,11 @@ execute: config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: SecG-A3-9410HA# + test platform hardware fed switch active port 1 phy phy-debug Debug_Command MCUDebugLogs: + response: + - '' + response_type: circular + prompt: hendrix# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/test_api_platform_hardware_fed_switch_phy_debug.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/test_api_platform_hardware_fed_switch_phy_debug.py new file mode 100644 index 000000000..587ebc842 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/platform_hardware_fed_switch_phy_debug/test_api_platform_hardware_fed_switch_phy_debug.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.platform.execute import platform_hardware_fed_switch_phy_debug + + +class TestPlatformHardwareFedSwitchPhyDebug(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + hendrix: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: None + type: None + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['hendrix'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_platform_hardware_fed_switch_phy_debug(self): + result = platform_hardware_fed_switch_phy_debug(self.device, 'active', 1, 'MCUDebugLogs') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_commands/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/mock_data/iosxe/mock_data.yaml similarity index 61% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_commands/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/mock_data/iosxe/mock_data.yaml index d66a2d0a8..fa4e7c8a8 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_commands/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/mock_data/iosxe/mock_data.yaml @@ -1,26 +1,26 @@ configure: commands: - aaa accounting commands 15 test none: "aaa accounting commands 15 test none\r\n" end: new_state: execute line console 0: new_state: configure_line no logging console: '' - prompt: startrek-bgl-2(config)# + prompt: SA-C9350-24P(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: startrek-bgl-2(config-line)# + prompt: SA-C9350-24P(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -28,8 +28,12 @@ execute: new_state: configure config-transaction: new_state: configure + request platform hardware pfu switch 1 R0 set-power-slot 2 off: + response: + - '' + response_type: circular show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: startrek-bgl-2# + prompt: SA-C9350-24P# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/test_api_request_platform_hardware_pfu.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/test_api_request_platform_hardware_pfu.py new file mode 100644 index 000000000..fbb19c0f5 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_hardware_pfu/test_api_request_platform_hardware_pfu.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.platform.execute import request_platform_hardware_pfu + + +class TestRequestPlatformHardwarePfu(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + SA-C9350-24P: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: None + type: None + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['SA-C9350-24P'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_request_platform_hardware_pfu(self): + result = request_platform_hardware_pfu(self.device, '1', 'R0', 2, 'off') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/mock_data/iosxe/mock_data.yaml similarity index 65% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/mock_data/iosxe/mock_data.yaml index 467d52ac0..b5967eca9 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/unconfigure_dscp_radius_server/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/mock_data/iosxe/mock_data.yaml @@ -4,25 +4,23 @@ configure: new_state: execute line console 0: new_state: configure_line - no dscp acct 10: "no dscp acct 10\r\n" - no dscp auth 20: "no dscp auth 20\r\n" no logging console: '' - radius server ISE2.7: "radius server ISE2.7\r\n" - prompt: n08HA(config)# + prompt: stack-9350(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: n08HA(config-line)# + prompt: stack-9350(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -30,8 +28,12 @@ execute: new_state: configure config-transaction: new_state: configure + request platform software trace rotate all: + response: + - '' + response_type: circular show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: n08HA# + prompt: stack-9350# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/test_api_request_platform_software_trace_rotate_all.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/test_api_request_platform_software_trace_rotate_all.py new file mode 100644 index 000000000..768459fcc --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/platform/execute/request_platform_software_trace_rotate_all/test_api_request_platform_software_trace_rotate_all.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.platform.execute import request_platform_software_trace_rotate_all + + +class TestRequestPlatformSoftwareTraceRotateAll(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + stack-9350: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: C9300 + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['stack-9350'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_request_platform_software_trace_rotate_all(self): + result = request_platform_software_trace_rotate_all(self.device) + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_exec_default_start_stop_group/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/mock_data/iosxe/mock_data.yaml similarity index 56% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_exec_default_start_stop_group/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/mock_data/iosxe/mock_data.yaml index 298eaa6af..90cbc71b1 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_exec_default_start_stop_group/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/mock_data/iosxe/mock_data.yaml @@ -1,27 +1,30 @@ configure: commands: - aaa accounting exec default start-stop group ISEGRP: "aaa accounting exec default - start-stop group ISEGRP\r\n" + bandwidth remaining ratio 40: "bandwidth remaining ratio 40\r\n" + class tc7: "class tc7\r\n" end: new_state: execute line console 0: new_state: configure_line no logging console: '' - prompt: SecG-A3-9410HA(config)# + policy-map type queueing abc: "policy-map type queueing abc\r\n" + priority level 1: "priority level 1\r\n" + prompt: Raitt(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: SecG-A3-9410HA(config-line)# + prompt: Raitt(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -30,7 +33,7 @@ execute: config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: SecG-A3-9410HA# + prompt: Raitt# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/test_api_configure_policy_map_parameters.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/test_api_configure_policy_map_parameters.py new file mode 100644 index 000000000..6579f3075 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_parameters/test_api_configure_policy_map_parameters.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.policy_map.configure import configure_policy_map_parameters + + +class TestConfigurePolicyMapParameters(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + Raitt: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: iosxe + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['Raitt'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_configure_policy_map_parameters(self): + result = configure_policy_map_parameters(self.device, 'abc', 'tc7', 1, 40) + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/mock_data/iosxe/mock_data.yaml new file mode 100644 index 000000000..f1bba0876 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/mock_data/iosxe/mock_data.yaml @@ -0,0 +1,42 @@ +configure: + commands: + class cm-acl100: "class cm-acl100\r\n" + end: + new_state: execute + line console 0: + new_state: configure_line + no logging console: '' + police cir percent 10 conform-action transmit exceed-action drop: "police cir\ + \ percent 10 conform-action transmit exceed-act\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\ + \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\ + \b\b\b$percent 10 conform-action transmit exceed-acti \b\b\b\b\b\b\b\ + \b\bon drop\r\n" + policy-map pm-acl-policer: "policy-map pm-acl-policer\r\n" + prompt: Raitt(config)# +configure_line: + commands: + end: + new_state: execute + exec-timeout 0: '' + prompt: Raitt(config-line)# +connect: + commands: + ? '' + : new_state: execute + preface: 'Trying mock_device ... + + Connected to mock_device. + + Escape character is ''^]''.' + prompt: '' +execute: + commands: + config term: + new_state: configure + config-transaction: + new_state: configure + show version: '' + show version | include operating mode: '' + term length 0: '' + term width 0: '' + prompt: Raitt# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/test_api_configure_policy_map_with_police_cir_percentage.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/test_api_configure_policy_map_with_police_cir_percentage.py new file mode 100644 index 000000000..5f8285db9 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/configure_policy_map_with_police_cir_percentage/test_api_configure_policy_map_with_police_cir_percentage.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.policy_map.configure import configure_policy_map_with_police_cir_percentage + + +class TestConfigurePolicyMapWithPoliceCirPercentage(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + Raitt: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: cat9k + type: iosxe + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['Raitt'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_configure_policy_map_with_police_cir_percentage(self): + result = configure_policy_map_with_police_cir_percentage(self.device, 'pm-acl-policer', 'cm-acl100', 10, 'drop') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic_interval/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/mock_data/iosxe/mock_data.yaml similarity index 65% rename from pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic_interval/mock_data/iosxe/mock_data.yaml rename to pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/mock_data/iosxe/mock_data.yaml index 44af5723e..9e4ced950 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/aaa/configure/configure_aaa_accounting_update_periodic_interval/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/mock_data/iosxe/mock_data.yaml @@ -1,26 +1,29 @@ configure: commands: - aaa accounting update periodic 10: "aaa accounting update periodic 10\r\n" + class class-default: "" end: new_state: execute line console 0: new_state: configure_line no logging console: '' - prompt: SW2(config)# + no set cos cos table cos2cos: "" + policy-map map1: "" + prompt: 9300-1(config)# configure_line: commands: end: new_state: execute exec-timeout 0: '' - prompt: SW2(config-line)# + prompt: 9300-1(config-line)# connect: commands: - '': - new_state: execute - preface: |- - Trying mock_device ... + ? '' + : new_state: execute + preface: 'Trying mock_device ... + Connected to mock_device. - Escape character is '^]'. + + Escape character is ''^]''.' prompt: '' execute: commands: @@ -29,7 +32,7 @@ execute: config-transaction: new_state: configure show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' - show version | include operating mode: '' - prompt: SW2# + prompt: 9300-1# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/test_api_unconfigure_policy_map_set_cos_cos_table.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/test_api_unconfigure_policy_map_set_cos_cos_table.py new file mode 100644 index 000000000..9dbd3b6e6 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/policy_map/configure/unconfigure_policy_map_set_cos_cos_table/test_api_unconfigure_policy_map_set_cos_cos_table.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.policy_map.configure import unconfigure_policy_map_set_cos_cos_table + + +class TestUnconfigurePolicyMapSetCosCosTable(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + stack3-nyquist-1: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: c9300 + type: c9300 + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['stack3-nyquist-1'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_unconfigure_policy_map_set_cos_cos_table(self): + result = unconfigure_policy_map_set_cos_cos_table(self.device, 'map1', 'class-default', 'cos2cos') + expected_output = None + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/rep/configure/unconfigure_rep_segment/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/rep/configure/unconfigure_rep_segment/mock_data/iosxe/mock_data.yaml index 928be4d81..56e7242aa 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/rep/configure/unconfigure_rep_segment/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/rep/configure/unconfigure_rep_segment/mock_data/iosxe/mock_data.yaml @@ -7,16 +7,13 @@ configure: line console 0: new_state: configure_line no logging console: '' - no rep fastmode: "IE-II-03-AgN1_2008_P(config-if)#no rep fastmode\r\n" - no rep segment 1 edge: "IE-II-03-AgN1_2008_P(config-if)#no rep segment 1 edge\r\ - \n" - no shut: "IE-II-03-AgN1_2008_P(config-if)#no shut\r\n" - no switchport mode trunk: "IE-II-03-AgN1_2008_P(config-if)#no switchport mode\ - \ trunk\r\n" - no switchport trunk allowed vlan 25: "IE-II-03-AgN1_2008_P(config-if)#no switchport\ - \ trunk allowed vlan 25\r\n" - no vlan 25: "no vlan 25\r\nIE-II-03-AgN1_2008_P(config)#" - shut: "IE-II-03-AgN1_2008_P(config-if)#shut\r\n" + no rep fastmode: "" + no rep segment 1 edge: "" + no shut: "" + no switchport mode trunk: "" + no switchport trunk allowed vlan 25: "" + no vlan 25: "" + shut: "" prompt: IE-II-03-AgN1_2008_PB(config)# interface: diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/spanning_tree/configure/configure_default_spanning_tree_vlan/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/spanning_tree/configure/configure_default_spanning_tree_vlan/mock_data/iosxe/mock_data.yaml index 47a1a6f50..2421cd40b 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/spanning_tree/configure/configure_default_spanning_tree_vlan/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/spanning_tree/configure/configure_default_spanning_tree_vlan/mock_data/iosxe/mock_data.yaml @@ -1,8 +1,7 @@ configure: commands: - default spanning-tree vlan 1-3 max-age: "default spanning-tree vlan 1-3 max-age\r\ - \njavelin-morph-bgl16-(config)#" - default spanning-tree vlan 3-8: "default spanning-tree vlan 3-8\r\njavelin-morph-bgl16-(config)#" + default spanning-tree vlan 1-3 max-age: "" + default spanning-tree vlan 3-8: "" end: new_state: execute line console 0: diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/startup_config/verify/test_verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/startup_config/verify/test_verify.py index 673de3e12..301c18fd5 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/startup_config/verify/test_verify.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/startup_config/verify/test_verify.py @@ -14,4 +14,7 @@ def test_verify_ignore_startup_config(self): self.assertEqual(output, True) device.parse.return_value = {'version':{'next_config_register':'0x2142'}} output = verify_ignore_startup_config(device) - self.assertEqual(output, False) \ No newline at end of file + self.assertEqual(output, False) + device.parse.return_value = {'version':{'curr_config_register':'0x2102'}} + output = verify_ignore_startup_config(device) + self.assertEqual(output, True) \ No newline at end of file diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/clear_counters/test_api_clear_counters.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/clear_counters/test_api_clear_counters.py index 07b587f45..bc094c720 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/clear_counters/test_api_clear_counters.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/clear_counters/test_api_clear_counters.py @@ -1,35 +1,24 @@ -import os -import unittest -from pyats.topology import loader +from unittest import TestCase from genie.libs.sdk.apis.iosxe.utils import clear_counters +from unittest.mock import Mock - -class TestClearCounters(unittest.TestCase): - - @classmethod - def setUpClass(self): - testbed = f""" - devices: - javelin-morph-sj-full3-dut1: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: cat9k - type: router - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['javelin-morph-sj-full3-dut1'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) +class TestClearCounters(TestCase): def test_clear_counters(self): - result = clear_counters(self.device, 90) + self.device = Mock() + results_map = { + 'clear counters': 'Clear "show interface" counters on all interfaces [confirm]', + } + + def results_side_effect(arg, **kwargs): + return results_map.get(arg) + + self.device.execute.side_effect = results_side_effect + + result = clear_counters(self.device) + self.assertIn( + 'clear counters', + self.device.execute.call_args_list[0][0] + ) expected_output = None self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/get_show_output_line_count/__init__.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/get_show_output_line_count/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/get_show_output_line_count/test_api_get_show_output_line_count.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/get_show_output_line_count/test_api_get_show_output_line_count.py new file mode 100644 index 000000000..84b77b1d8 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/utils/get_show_output_line_count/test_api_get_show_output_line_count.py @@ -0,0 +1,27 @@ +import os +from unittest import TestCase +from genie.libs.sdk.apis.iosxe.utils import get_show_output_line_count +from unittest.mock import Mock +class TestGetShowOutputLineCount(TestCase): + + @classmethod + def setUpClass(self): + self.device = Mock() + + def test_get_show_output_line_count(self): + results_map = { + 'show version | count ott-c9300-46': 'Number of lines which match regexp = 1', + } + + def results_side_effect(arg): + return results_map.get(arg) + + self.device.execute.side_effect = results_side_effect + + result = get_show_output_line_count(self.device, 'show version', 'ott-c9300-46', None) + self.assertIn( + 'show version | count ott-c9300-46', + self.device.execute.call_args_list[0][0] + ) + expected_output = 1 + self.assertEqual(result, expected_output) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/test_api_unittest_generator.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/test_api_unittest_generator.py index dfab2a0b6..7d7bd667f 100755 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/test_api_unittest_generator.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/test_api_unittest_generator.py @@ -1,10 +1,16 @@ from unittest import TestCase -from unittest.mock import MagicMock, patch, mock_open +from unittest.mock import Mock, MagicMock, patch, mock_open from collections import ChainMap -from genie.libs.sdk.apis.api_unittest_generator import TestGenerator +from genie.libs.sdk.apis.api_unittest_generator import ( + APIUTGenerator, TestGenerator, TestFactory, + ParserTestGenerator, ConfigureTestGenerator, ExecuteTestGenerator +) from genie.libs.sdk.apis.api_unittest_generator import Path from unicon.core.errors import ConnectionError -import logging +import pprint +import os +from datetime import datetime +from inspect import getmembers, isfunction TEST_ARGS_YAML = { 'default': { @@ -28,14 +34,328 @@ } } +class TestParserGenerator(TestCase): + def setUp(self): + self.device = Mock() + self.device.name = 'fake_device' + self.device.os = 'fake_os' + self.device.platform = 'fake_platform' + self.device.type = 'fake_type' + self.module_import = 'mock_module' + self.api = Mock() + self.api.__name__ = 'mock_api' + self.test_generator = ParserTestGenerator(self.device, self.module_import, self.api) + + def test_build_imports(self): + expected_imports = [ + 'import os', + 'from pyats.topology import loader', + 'from unittest import TestCase', + 'from mock_module import mock_api' + ] + self.assertEqual(self.test_generator._build_imports(), expected_imports) + + def test_build_test_class(self): + expected_class = { + 'api': 'mock_api', + 'class_name': 'TestMockApi', + 'device': 'fake_device', + 'imports': [ + 'import os', + 'from pyats.topology import loader', + 'from unittest import TestCase', + 'from mock_module import mock_api' + ] + } + self.assertEqual(self.test_generator.build_test_class(), expected_class) + + def test_build_test_method(self): + arguments = 'arg1, arg2' + result = {'key': 'value'} + expected_method = { + 'api': 'mock_api', + 'arguments': arguments, + 'expected_output': pprint.pformat(result) + } + self.assertEqual(self.test_generator.build_test_method(arguments, result), expected_method) + + def test_build_write_args(self): + arguments = ['arg1', 'arg2'] + varargs = ['var1'] + kwargs = {'kwarg1': 'value1'} + expected_args = "'arg1', 'arg2', var1, kwarg1='value1'" + self.assertEqual(self.test_generator.build_write_args(arguments, varargs, kwargs), expected_args) + + self.assertEqual( + self.test_generator.build_write_args([self.device], (), {}), + 'self.device' + ) + + # test with existing arguments + self.assertEqual( + self.test_generator.build_write_args(['intf1', 'abcd'], (), {}), + "'intf1', 'abcd'" + ) + + # test with empty arguments + self.assertEqual(self.test_generator.build_write_args([], (), {}), '') + + def test_create_testbed(self): + self.maxDiff = None + self.assertEqual( + self.test_generator._create_testbed(), + { + 'cmd': + 'mock_device_cli --os fake_os ' + '--mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect', + 'device': 'fake_device', + 'has_mock_data': True, + 'os': 'fake_os', + 'platform': 'fake_platform', + 'type': 'fake_type', + } + ) + +class TestConfigureGenerator(TestCase): + def setUp(self): + self.device = Mock() + self.device.name = 'fake_device' + self.device.os = 'fake_os' + self.device.platform = 'fake_platform' + self.device.type = 'fake_type' + self.module_import = 'mock_module' + self.api = Mock() + self.api.__name__ = 'mock_api' + self.test_generator = ConfigureTestGenerator(self.device, self.module_import, self.api) + + def test_build_imports(self): + expected_imports = [ + 'from unittest import TestCase', + 'from mock_module import mock_api', + 'from unittest.mock import Mock' + ] + self.assertEqual(self.test_generator._build_imports(), expected_imports) + + def test_build_test_class(self): + expected_class = { + 'api': 'mock_api', + 'class_name': 'TestMockApi', + 'device': 'fake_device', + 'imports': [ + 'from unittest import TestCase', + 'from mock_module import mock_api', + 'from unittest.mock import Mock' + ] + } + self.assertEqual(self.test_generator.build_test_class(), expected_class) + + @patch('genie.libs.sdk.apis.api_unittest_generator.dill') + @patch('builtins.open', new_callable=mock_open) + def test_create_mock_variables_configure(self, mock_open, mock_dill): + self.test_generator.get_mock_data_file = Mock() + mock_dill.load.return_value = { + 'configure': { + "['ip access-list extended acl_in', 'permit ip any any']": [], + }, + } + + self.assertEqual( + self.test_generator._create_mock_variables(), + { + 'test_type': 'configure', + 'configure_calls': [['ip access-list extended acl_in', 'permit ip any any']], + } + ) + + mock_dill.load.return_value = { + 'configure': { + "interface GigabitEthernet1\nno ip access-group acl_in in": [], + }, + } + + self.assertEqual( + self.test_generator._create_mock_variables(), + { + 'test_type': 'configure', + 'configure_calls': [pprint.pformat("interface GigabitEthernet1\nno ip access-group acl_in in")], + } + ) + +class TestExecuteGenerator(TestCase): + def setUp(self): + self.device = Mock() + self.device.name = 'fake_device' + self.device.os = 'fake_os' + self.device.platform = 'fake_platform' + self.device.type = 'fake_type' + self.module_import = 'mock_module' + self.api = Mock() + self.api.__name__ = 'mock_api' + self.test_generator = ExecuteTestGenerator(self.device, self.module_import, self.api) + + def test_build_imports(self): + expected_imports = [ + 'from unittest import TestCase', + 'from mock_module import mock_api', + 'from unittest.mock import Mock' + ] + self.assertEqual(self.test_generator._build_imports(), expected_imports) + + def test_build_test_class(self): + expected_class = { + 'api': 'mock_api', + 'class_name': 'TestMockApi', + 'device': 'fake_device', + 'imports': [ + 'from unittest import TestCase', + 'from mock_module import mock_api', + 'from unittest.mock import Mock' + ] + } + self.assertEqual(self.test_generator.build_test_class(), expected_class) + + @patch('genie.libs.sdk.apis.api_unittest_generator.dill') + @patch('builtins.open', new_callable=mock_open) + def test_create_mock_variables_execute(self, mock_open, mock_dill): + self.test_generator.get_mock_data_file = Mock() + mock_dill.load.return_value = { + 'execute': { + 'some_command': [{'output': 'some_output'}] + } + } + + self.assertEqual( + self.test_generator._create_mock_variables(), + { + 'test_type': 'execute', + 'execute_asserts': {'some_command': 'some_output'}, + } + ) + + +class TestTestFactory(TestCase): + @patch('genie.libs.sdk.apis.api_unittest_generator.TestFactory._inspect_function') + def test_select_test_generator(self, mock_inspect_function): + mock_inspect_function.return_value = ['parse', 'execute'] + result = TestFactory.select_test_generator('device', 'mock_import', 'mock_function') + + self.assertIsInstance(result, ParserTestGenerator) + mock_inspect_function.assert_called_once_with('mock_function', 'device') + + mock_inspect_function.return_value = ['execute', 'execute'] + result = TestFactory.select_test_generator('device', 'mock_import', 'mock_function') + + self.assertIsInstance(result, ExecuteTestGenerator) + + mock_inspect_function.return_value = ['configure'] + result = TestFactory.select_test_generator('device', 'mock_import', 'mock_function') + + # Assert the expected behavior + self.assertIsInstance(result, ConfigureTestGenerator) + + mock_inspect_function.return_value = ['some_other_test'] + result = TestFactory.select_test_generator('device', 'mock_import', 'mock_function') + self.assertIsInstance(result, ParserTestGenerator) + +class TestTestGenerator(TestCase): -class TestAPIUnittestGenerator(TestCase): + def setUp(self): + self.device = Mock() + self.device.name = 'mock_device' + self.module_import = 'mock_module' + self.api = Mock() + self.api.__name__ = 'mock_api' + self.test_generator = TestGenerator(self.device, self.module_import, self.api) + + def test_build_imports(self): + expected_imports = [ + 'from unittest import TestCase', + 'from mock_module import mock_api' + ] + self.assertEqual(self.test_generator._build_imports(), expected_imports) + + def test_build_test_class(self): + expected_class = { + 'api': 'mock_api', + 'class_name': 'TestMockApi', + 'device': 'mock_device', + 'imports': [ + 'from unittest import TestCase', + 'from mock_module import mock_api' + ] + } + self.assertEqual(self.test_generator.build_test_class(), expected_class) + + def test_build_test_method(self): + arguments = 'arg1, arg2' + result = {'key': 'value'} + expected_method = { + 'api': 'mock_api', + 'arguments': arguments, + 'expected_output': pprint.pformat(result) + } + self.assertEqual(self.test_generator.build_test_method(arguments, result), expected_method) + + def test_build_write_args(self): + arguments = ['arg1', 'arg2'] + varargs = ['var1'] + kwargs = {'kwarg1': 'value1'} + expected_args = "'arg1', 'arg2', var1, kwarg1='value1'" + self.assertEqual(self.test_generator.build_write_args(arguments, varargs, kwargs), expected_args) + + self.assertEqual( + self.test_generator.build_write_args([self.device], (), {}), + 'self.device' + ) + + # test with existing arguments + self.assertEqual( + self.test_generator.build_write_args(['intf1', 'abcd'], (), {}), + "'intf1', 'abcd'" + ) + + # test with empty arguments + self.assertEqual(self.test_generator.build_write_args([], (), {}), '') + + @patch('os.path.join', side_effect=lambda *args: '/'.join(args)) + @patch('builtins.open', new_callable=mock_open) + def test_create_test_files(self, mock_open, mock_path_join): + mock_test_file_data = {'key': 'mock_api'} + mock_template = MagicMock() + api = mock_test_file_data["key"] + mock_destination = f'mock_destination' + + # Mock the behavior of the template rendering if necessary + mock_template.render.return_value = 'rendered content' + + self.test_generator.create_test_files(mock_test_file_data, mock_template, mock_destination) + + expected_destination = f'mock_destination/{api}' + mock_path_join.assert_called_with(expected_destination, f'test_api_{api}.py') + expected_path = f'{expected_destination}/test_api_{api}.py' + mock_open.assert_called_with(expected_path, 'w') + mock_open().write.assert_called_with('rendered content') + + @patch('genie.libs.sdk.apis.api_unittest_generator.TEMP_DIR', new='/mock_temp_dir') + def test_get_mock_data_file(self): + expected_path = '/mock_temp_dir/mock_device' + + self.assertEqual(self.test_generator.get_mock_data_file(), expected_path) + + def test_get_api_expected_output(self): + self.assertEqual(self.test_generator.get_api_expected_output(TEST_ARGS_YAML, None), None) + self.test_generator.api = Mock() + self.test_generator.api.__name__ = 'get_interface_carrier_delay' + self.assertEqual(self.test_generator.get_api_expected_output(TEST_ARGS_YAML, None, index=1), 'blah') + + +class TestAPIUTGenerator(TestCase): def setUp(self): self.testbed = MagicMock() self.device = MagicMock() self.device.name = 'fake_device' - self.device.os = 'fake_os' + self.device.os.return_value = 'fake_os' self.device.platform = 'fake_platform' self.device.type = 'fake_type' self.testbed.devices.__getitem__.return_value = self.device @@ -44,8 +364,8 @@ def test_load_arguments(self): test_args = 'interface:intf1,another_var:abcd' # skips module import - with patch.object(TestGenerator, '_get_apis'): - ut_gen = TestGenerator( + with patch.object(APIUTGenerator, '_get_apis'): + ut_gen = APIUTGenerator( testbed=self.testbed, device='blah', module='interface.get', @@ -67,13 +387,13 @@ def test_load_arguments_yaml(self): test_args_yaml = 'fakepath/ta.yaml' # skips module import - with patch.object(TestGenerator, '_get_apis'): + with patch.object(APIUTGenerator, '_get_apis'): with patch("builtins.open", mock_open()) as mo: mo.return_value = MagicMock() # mock loading a yaml file with patch("yaml.load") as md: md.return_value = TEST_ARGS_YAML - ut_gen = TestGenerator( + ut_gen = APIUTGenerator( testbed=self.testbed, device='blah', module='interface.get', @@ -113,7 +433,7 @@ def test_load_arguments_yaml_no_default(self): test_args_yaml = 'fakepath/ta.yaml' # skips module import - with patch.object(TestGenerator, '_get_apis'): + with patch.object(APIUTGenerator, '_get_apis'): with patch("builtins.open", mock_open()) as mo: mo.return_value = MagicMock() # mock loading a yaml file @@ -125,7 +445,7 @@ def test_load_arguments_yaml_no_default(self): } } } - ut_gen = TestGenerator( + ut_gen = APIUTGenerator( testbed=self.testbed, device='blah', module='interface.get', @@ -141,402 +461,3 @@ def test_load_arguments_yaml_no_default(self): self.assertEqual(ut_gen.test_arguments, expected_arguments) - def test_get_api_expected_output(self): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.test_arguments = TEST_ARGS_YAML - - self.assertEqual( - ut_gen._get_api_expected_output('get_interface_carrier_delay'), - None) - self.assertEqual( - ut_gen._get_api_expected_output( - 'get_interface_carrier_delay', index=1), - 'blah') - - def test_build_api_args(self): - test_args = 'interface:intf1,another_arg:abcd' - - # skips module import - with patch.object(TestGenerator, '_get_apis'): - ut_gen = TestGenerator( - testbed=self.testbed, - device='blah', - module='interface.get', - api='get_bundled_interface', - test_arguments=test_args - ) - - # test with device as an argument - # get_bundled_interface(device) - self.assertEqual( - ut_gen._build_api_args( - 'get_bundled_interface', - ['device'], - '', - '', - None - ), - [([self.device], (), {})] - ) - - # test with existing and default arguments - # get_bundled_interface(interface, another_arg, test=None) - self.assertEqual( - ut_gen._build_api_args( - 'get_bundled_interface', - ['interface', 'another_arg', 'test'], - '', - '', - (None,) # None is a default argument - ), - [(['intf1', 'abcd', None], (), {})] - ) - - # test with non-existing arguments - # get_bundled_interface() - self.assertEqual( - ut_gen._build_api_args( - 'get_bundled_interface', - ['not_an_arg'], - '', - '', - None - ), - [([], (), {})] - ) - - def test_build_api_varargs(self): - test_args = 'interface:intf1,another_arg:abcd' - - # skips module import - with patch.object(TestGenerator, '_get_apis'): - ut_gen = TestGenerator( - testbed=self.testbed, - device='blah', - module='fake_module.get', - api='get_var_args_test', - test_arguments=test_args - ) - ut_gen.test_arguments = { - 'default': { - 'arguments': { - 'arg1': 'some_arg', - 'arg2': [1, 2, 3] - } - } - } - - # test with positional arguments - # get_var_args_test(arg1, *arg2) - self.assertEqual( - ut_gen._build_api_args( - 'get_var_args_test', - ['arg1'], - 'arg2', - '', - None - ), - [(['some_arg'], (1, 2, 3), {})] - ) - - def test_build_api_kwargs(self): - # skips module import - with patch.object(TestGenerator, '_get_apis'): - ut_gen = TestGenerator( - testbed=self.testbed, - device='blah', - module='jinja.get', - api='load_jinja_template', - test_arguments_yaml='' - ) - ut_gen.test_arguments = { - 'default': { - 'arguments': { - 'path': '', - 'file': 'interface.j2', - 'kwargs': { - 'interface': '', - 'desc': 'test description' - } - } - } - } - - # test with keyword arguments - # load_jinja_template(path, file, **kwargs) - self.assertEqual( - ut_gen._build_api_args( - 'load_jinja_template', - ['path', 'file'], - '', - 'kwargs', - None - ), - [( - ['', 'interface.j2'], # args - (), # positional args - {'interface': '', 'desc': 'test description'} # kwargs - )] - ) - - def test_build_test_class(self): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.test_arguments = TEST_ARGS_YAML - ut_gen.module_import = 'fake_module' - ut_gen.device = self.device - - expected_test_class = { - 'api': 'get_fake_api', - 'class_name': 'TestGetFakeApi', - 'device': 'fake_device', - 'imports': [ - 'import os', - 'import unittest', - 'from pyats.topology import loader', - 'from fake_module import get_fake_api' - ] - } - - self.assertEqual( - ut_gen._build_test_class('get_fake_api'), - expected_test_class - ) - - def test_build_test_method(self): - arguments = 'a=1, b=2, c="3"' - api_name = 'get_interface_names' - value = 'abc' - - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - - self.assertEqual( - ut_gen._build_test_method(api_name, arguments, value), - { - 'api': 'get_interface_names', - 'arguments': 'a=1, b=2, c="3"', - 'expected_output': "'abc'" - } - ) - - pass - - def test_build_write_args(self): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.device = self.device - - # test with device as an argument - self.assertEqual( - ut_gen._build_write_args( - [self.device], - (), - {} - ), - 'self.device' - ) - - # test with existing arguments - self.assertEqual( - ut_gen._build_write_args( - ['intf1', 'abcd'], - (), - {} - ), - "'intf1', 'abcd'" - ) - - # test with empty arguments - self.assertEqual( - ut_gen._build_write_args([], (), {}), - '' - ) - - def test_create_testbed(self): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.device = self.device - - self.assertEqual( - ut_gen._create_testbed(), - { - 'cmd': - 'mock_device_cli --os fake_os ' - '--mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect', - 'device': 'fake_device', - 'os': 'fake_os', - 'platform': 'fake_platform', - 'type': 'fake_type', - } - ) - - def test_get_test_arguments(self): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.test_arguments = TEST_ARGS_YAML - - # test with an api in test arguments yaml - self.assertEqual( - ut_gen._get_test_arguments('get_interface_carrier_delay'), - [ - ChainMap( - {'delay_type': 'up', 'expected_output': None}, - {'interface': 'GigabitEthernet1', - 'interface_list': ['GigabitEthernet1'], - 'ip_address': '172.16.1.139'}), - ChainMap( - {'delay_type': 'down', 'expected_output': 'blah'}, - {'interface': 'GigabitEthernet1', - 'interface_list': ['GigabitEthernet1'], - 'ip_address': '172.16.1.139'}) - ] - ) - - # test with an api not in test arguments yaml - self.assertEqual( - ut_gen._get_test_arguments('get_some_random_api'), - [ - ChainMap({ - 'interface': 'GigabitEthernet1', - 'interface_list': ['GigabitEthernet1'], - 'ip_address': '172.16.1.139' - }) - ] - ) - - @patch('genie.libs.sdk.apis.api_unittest_generator.importlib') - def test_get_apis_single_api(self, mock_import): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.device = self.device - ut_gen.exclude_apis = [] - - # assert with single API - mock_import.util.find_spec.return_value = '' - ut_gen.module = \ - mock_import.import_module.return_value = MagicMock() - ut_gen.module.fake_api_1 = 'fake_api_1' - apis = ut_gen._get_apis(module='interface.get', api='fake_api_1') - - self.assertEqual( - apis, - [('fake_api_1', ut_gen.module.fake_api_1)] - ) - - @patch('genie.libs.sdk.apis.api_unittest_generator.importlib') - @patch('genie.libs.sdk.apis.api_unittest_generator.getmembers') - def test_get_apis_module(self, mock_members, mock_import): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.device = self.device - ut_gen.exclude_apis = {} - - # assert getting all APIs - mock_import.util.find_spec.return_value = '' - ut_gen.module = \ - mock_import.import_module.return_value = MagicMock() - - mock_members.return_value = [ - ('fake_api_1', 'fake_api_1'), - ('fake_api_2', 'fake_api_2')] - - apis = ut_gen._get_apis(module='interface.get') - self.assertEqual( - apis, - [('fake_api_1', 'fake_api_1'), - ('fake_api_2', 'fake_api_2')] - ) - - # assert getting APIs with exclude - ut_gen.exclude_apis = {'regex': '_1'} - apis = ut_gen._get_apis(module='interface.get') - self.assertEqual( - apis, - [('fake_api_2', 'fake_api_2')] - ) - - @patch.object(Path, 'is_file') - @patch('genie.libs.sdk.apis.api_unittest_generator.importlib') - def test_get_apis_module_path(self, mock_import, mock_is_file): - # skipping __init__ as it is not necessary for this test - with patch.object(TestGenerator, '__init__') as mt: - mt.return_value = None - ut_gen = TestGenerator() - ut_gen.device = self.device - ut_gen.exclude_apis = {} - - path_1 = 'somepath/genie/libs/sdk/apis/nxos/interface/get.py' - mock_is_file.return_value = True - ut_gen._get_apis(module_path=path_1) - - # assert module path - self.assertEqual( - ut_gen.module_import, - 'genie.libs.sdk.apis.nxos.interface.get' - ) - # assert default path - self.assertEqual( - ut_gen.destination, - 'tests/nxos/interface/get' - ) - - path_2 = 'somepath/genielibs/src/sdk/apis/iosxe/interface/verify.py' - ut_gen._get_apis(module_path=path_2, destination='fake_folder') - # assert module path - self.assertEqual( - ut_gen.module_import, - 'genie.libs.sdk.apis.iosxe.interface.verify' - ) - - # assert with different destination - self.assertEqual( - ut_gen.destination, - 'fake_folder/iosxe/interface/verify' - ) - - path_3 = 'somepath/genielibs/src/sdk/apis/jinja/utils.py' - ut_gen._get_apis(module_path=path_3) - # assert module path - self.assertEqual( - ut_gen.module_import, - 'genie.libs.sdk.apis.jinja.utils' - ) - - @patch('genie.libs.sdk.apis.api_unittest_generator.logger') - @patch('genie.libs.sdk.apis.api_unittest_generator.os') - @patch('genie.libs.sdk.apis.api_unittest_generator.importlib') - @patch('genie.libs.sdk.apis.api_unittest_generator.getmembers') - def test_run_error(self, mock_members, mock_import, mock_os, mock_logger): - test_arguments = '' - self.device.is_connected.return_value = False - self.device.connect.side_effect = ConnectionError() - ut_gen = TestGenerator( - self.testbed, - self.device.name, - module='fake_module', - api='fake_api', - test_arguments=test_arguments - ) - ut_gen.destination = '' - mock_os.makedirs.return_value = True - mock_os.path.isdir.return_value = False - - self.assertRaises(SystemExit, ut_gen.run) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/utils.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/utils.py index 08435e9b3..74fce3296 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/utils.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/utils.py @@ -4592,90 +4592,31 @@ def configure_peripheral_terminal_server(device): log.error(f'Device {device} has no peripherals or terminal_server!') -def load_image(device, template_name="LOAD_IMAGE", template_override={}, template=None, **kwargs): - ''' Load image template +def load_image(device, images, server=None, protocol=None, **kwargs): + ''' Load image api Args: - Renders the clean template and uses it to call clean. A clean template is JSON - data which can have placeholders for data which the user needs to - provide when calling this API. Similar to how Python functions - can have keyword arguments with default values, default arguments - may also be defined for a clean template. These are stored in - a Python dictionary whose variable name should follow this - convention: {template_name}_ARGS - Shortened example: - ```python - from genie.conf.base.api import OPTIONAL, REQUIRED - MY_TEMPLATE = { - "order": [ - "connect", - "apply_configuration", - "ping_server", - "copy_to_device", - ], - "images": r"%CLEANARG{images}", - "connect": {}, - "apply_configuration": { - "configuration": r"%CLEANARG{config_str}", - }, - "ping_server": { - "server": "%CLEANARG{server}", - "vrf": "%CLEANARG{vrf}", - }, - "copy_to_device": { - "overwrite": r"%CLEANARG{overwrite}", - "origin": { - "hostname": "%CLEANARG{server}", - }, - "vrf": "%CLEANARG{vrf}", - }, - } - - MY_TEMPLATE_ARGS = { - "vrf": "management", # argument with default which user can override - "server": REQUIRED, # required argument which user must provide - "overwrite": OPTIONAL, # optional argument - "config_str": REQUIRED, - "images": REQUIRED, - } - - ``` - Arguments: - 1. device: device object - 2. template_name: which clean template to use, or None to not use any - clean template - 3. template_override: optionally override data in clean template. This - is done with a recursive dictionary update. - Example: - ```python - # template assumes config string is being provided. We want - # to use a config file - config_file_location = "..." - override = {"apply_configuration": {"file": config_file_location}} - dev.api.clean(template_name="MY_TEMPLATE", template_override=config_file_location) - ``` - 4. kwargs: arguments which are substituted into the template. - Example: - ```python - dev.api.clean( - template_name="MY_TEMPLATE", - vrf="Mgmt", - server="10.10.10.10", - images={ - "server": [...], - "kickstart": [...], - } - ... - ) - ``` - vrf, server and config_str are all kwargs, and will be substituted into - the MY_TEMPLATE template to render the clean YAML that is used when - invoking clean + device (obj): Device object + images (list): Image to install + server (str): Name of the server. Defaults to None + protocol (str): Protocol used for copy operation. Defaults to None ''' - try: - device.api.clean(template_name=template_name, - template_override=template_override, - template=template, - **kwargs) - except Exception as e: - raise Exception(f'Failed to load the image template from clean. Error: {e}') + # default template is set to LOAD IMAGE because + # it will not have the reset_configuration stage + kwargs.setdefault("template_name", "LOAD_IMAGE") + + if server and protocol: + device.api.clean(images=images, + copy_to_device__origin__hostname=server, + copy_to_device__protocol=protocol, + **kwargs) + elif server: + device.api.clean(images=images, + copy_to_device__origin__hostname=server, + **kwargs) + elif protocol: + device.api.clean(images=images, + copy_to_device__protocol=protocol, + **kwargs) + else: + device.api.clean(images=images, **kwargs)