def expect_res_success_by_vlanid(duthost, vlanid, expected_content_list, unexpected_content_list): ensure_dhcp_server_up(duthost) output = dhcp_severs_by_vlanid(duthost, vlanid) # logger.info("vlanid {} expected {} unexpected{} output {}".format( # vlanid, expected_content_list, unexpected_content_list, output)) expect_res_success(duthost, output, expected_content_list, unexpected_content_list)
def expect_res_success_syslog(duthost, expected_content_list, unexpected_content_list): """Check if syslog server show as expected """ cmds = "show runningconfiguration syslog" output = duthost.shell(cmds) pytest_assert(not output['rc'], "'{}' is not running successfully".format(cmds) ) expect_res_success(duthost, output, expected_content_list, unexpected_content_list)
def expect_res_success_acl_rule(duthost, expected_content_list, unexpected_content_list): """Check if acl rule added as expected """ cmds = "sudo iptables -S" output = duthost.shell(cmds) pytest_assert(not output['rc'], "'{}' failed with rc={}".format(cmds, output['rc'])) expect_res_success(duthost, output, expected_content_list, unexpected_content_list)
def expect_res_success_acl_rule(duthost, expected_content_list, unexpected_content_list): """Check if acl rule added as expected """ time.sleep( 1 ) # Sleep 1 sec to ensure caclmgrd does update in case of its UPDATE_DELAY_SECS 0.5s cmds = "iptables -S" output = duthost.shell(cmds) pytest_assert(not output['rc'], "'{}' failed with rc={}".format(cmds, output['rc'])) expect_res_success(duthost, output, expected_content_list, unexpected_content_list)
def verify_monitor_config(duthost): """ This config contains 4 parts: ACL_TABLE, ACL_RULE, POLICER, MIRROR_SESSION admin@vlab-01:~$ show acl table EVERFLOW_DSCP_TEST Name Type Binding Description Stage ------------------ ----------- --------- ------------------ ------- EVERFLOW_DSCP_TEST MIRROR_DSCP Ethernet0 EVERFLOW_DSCP_TEST ingress ... admin@vlab-01:~$ show acl rule EVERFLOW_DSCP_TEST RULE_1 Table Rule Priority Action Match ------------------ ------ ---------- ---------------------------------------- ------- EVERFLOW_DSCP_TEST RULE_1 9999 MIRROR INGRESS: mirror_session_dscp_test DSCP: 5 admin@vlab-01:~/everflow$ show policer everflow_static_policer Name Type Mode CIR CBS ----------------------- ------ ------ -------- -------- everflow_policer_test bytes sr_tcm 12500000 12500000 admin@vlab-01:~$ show mirror_session mirror_session_dscp_test ERSPAN Sessions Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction ------------------------ -------- -------- -------- ----- ------ ----- ------- ----------------------- -------------- ---------- ----------- mirror_session_dscp_test active 1.1.1.1 2.2.2.2 5 32 everflow_policer_test ... """ table = duthost.shell("show acl table {}".format(MONITOR_CONFIG_ACL_TABLE)) expect_res_success(duthost, table, [MONITOR_CONFIG_ACL_TABLE], []) rule = duthost.shell("show acl rule {} {}".format(MONITOR_CONFIG_ACL_TABLE, MONITOR_CONFIG_ACL_RULE)) expect_res_success(duthost, rule, [ MONITOR_CONFIG_ACL_TABLE, MONITOR_CONFIG_ACL_RULE, MONITOR_CONFIG_MIRROR_SESSION ], []) policer = duthost.shell("show policer {}".format(MONITOR_CONFIG_POLICER)) expect_res_success(duthost, policer, [MONITOR_CONFIG_POLICER], []) mirror_session = duthost.shell( "show mirror_session {}".format(MONITOR_CONFIG_MIRROR_SESSION)) expect_res_success(duthost, mirror_session, [MONITOR_CONFIG_MIRROR_SESSION, MONITOR_CONFIG_POLICER], [])
def verify_no_monitor_config(duthost): """ Clean up monitor config in ACL_TABLE, ACL_RULE, POLICER, MIRROR_SESSION """ table = duthost.shell("show acl table {}".format(MONITOR_CONFIG_ACL_TABLE)) expect_res_success(duthost, table, [], [MONITOR_CONFIG_ACL_TABLE]) rule = duthost.shell("show acl rule {} {}".format(MONITOR_CONFIG_ACL_TABLE, MONITOR_CONFIG_ACL_RULE)) expect_res_success(duthost, rule, [], [ MONITOR_CONFIG_ACL_TABLE, MONITOR_CONFIG_ACL_RULE, MONITOR_CONFIG_MIRROR_SESSION ]) policer = duthost.shell("show policer {}".format(MONITOR_CONFIG_POLICER)) expect_res_success(duthost, policer, [], [MONITOR_CONFIG_POLICER]) mirror_session = duthost.shell( "show mirror_session {}".format(MONITOR_CONFIG_MIRROR_SESSION)) expect_res_success(duthost, mirror_session, [], [MONITOR_CONFIG_MIRROR_SESSION, MONITOR_CONFIG_POLICER])
def expect_res_success_by_vlanid(duthost, vlanid, expected_content_list, unexpected_content_list): ensure_dhcp_server_up(duthost) output = dhcp_severs_by_vlanid(duthost, vlanid) expect_res_success(duthost, output, expected_content_list, unexpected_content_list)