def test_vtysh_prompt_modes_check_1(): vars = st.get_testbed_vars() st.change_prompt(vars.D1, "normal-user") # from vtysh mode to normal user and back to normal user st.change_prompt(vars.D1, "vtysh-user") st.change_prompt(vars.D1, "normal-user") # from sonic to vtysh config mode and back to normal user st.change_prompt(vars.D1, "vtysh-config") st.change_prompt(vars.D1, "normal-user") st.change_prompt(vars.D1, "vtysh-intf-config", interface="Ethernet40") st.change_prompt(vars.D1, "vtysh-intf-config", interface="Ethernet4") st.change_prompt(vars.D1, "vtysh-intf-config", interface="Ethernet40") st.change_prompt(vars.D1, "vtysh-user") # from sonic to vtysh router config mode and back to normal user st.change_prompt(vars.D1, "vtysh-router-config", router="bgp", instance="1") st.change_prompt(vars.D1, "vtysh-router-af-config", addr_family="ipv4", modifier="unicast") st.change_prompt(vars.D1, "vtysh-router-config", router="rip") st.change_prompt(vars.D1, "vtysh-user") st.change_prompt(vars.D1, "vtysh-router-config", router="bgp", instance="1") st.change_prompt(vars.D1, "vtysh-router-af-config", addr_family="ipv4", modifier="unicast") st.change_prompt(vars.D1, "vtysh-router-config", router="rip") # using vtysh_show and back to normal user st.vtysh_show(vars.D1, "show ip prefix-list", skip_tmpl=True) st.change_prompt(vars.D1, "normal-user") st.show(vars.D1, "show interfaces status") st.report_pass("operation_successful")
def test_vtysh_modes_check_2(): vars = st.get_testbed_vars() # Command in Config level - with mode change - with end and exit st.vtysh_config(vars.D1, "route-map test permit 1") st.vtysh_show(vars.D1, "show route-map test") st.vtysh_config(vars.D1, "exit") st.vtysh_config(vars.D1, "route-map test permit 1") st.vtysh_show(vars.D1, "show route-map test") st.vtysh_config(vars.D1, "end") st.report_pass("operation_successful")
def test_vtysh_modes_check_3(): vars = st.get_testbed_vars() # Multiple commands in Config level - with one mode change - with end and exit st.vtysh_config(vars.D1, "ip prefix-list test permit 5.5.5.0/24") st.vtysh_config(vars.D1, "route-map test permit 1") st.vtysh_show(vars.D1, "show ip prefix-list") st.vtysh_config(vars.D1, "end") st.vtysh_config(vars.D1, "ip prefix-list test permit 5.5.5.0/24") st.vtysh_config(vars.D1, "route-map test permit 1") st.vtysh_show(vars.D1, "show ip prefix-list") st.vtysh_config(vars.D1, "exit") st.report_pass("operation_successful")
def config_igmp_qmrestime(dut, **kwargs): """ Config IGMP. Author: Sathishkumar Sivashanmugam ([email protected]) :param :dut: :param :cli_type: click|klish :return: """ if 'port_alias' not in kwargs: st.error("Mandatory parameter port_alias not found") return False if 'qmrestime' not in kwargs: st.error("Mandatory parameter query max response time not found") return False if 'config' in kwargs: config = kwargs['config'] else: config = 'yes' cli_type = st.get_ui_type(dut, **kwargs) if cli_type == "klish": commands = list() commands.append("interface {}".format(kwargs.get('port_alias'))) if config.lower() == 'yes': commands.append("ip igmp query-max-response-time {}".format(kwargs.get('qmrestime'))) else: commands.append("no ip igmp query-max-response-time") commands.append("exit") else: st.error("UNSUPPORTED CLI TYPE -- {}".format(cli_type)) return False # Here handling the error while passing invalid parameters if kwargs.get('skip_error'): output = st.config(dut, commands, skip_error_check=kwargs.get('skip_error'), type=cli_type) errstr = '' if errstr in output or '% Error: Illegal parameter.' in output: return True else: return False else: try: st.config(dut, commands, type=cli_type) except Exception as e: st.log(e) return False #Verify FRR DB try: output = st.vtysh_show(dut, "show running-config | include igmp query-max-response-time", skip_tmpl=True) return bool(len(output)) except Exception as e: st.log(e) return False
def test_vtysh_modes_check_1(): vars = st.get_testbed_vars() # Command in Config level - no mode change - with end and exit st.vtysh_config(vars.D1, "ip prefix-list test permit 5.5.5.0/24") st.vtysh_show(vars.D1, "show ip prefix-list") st.vtysh_config(vars.D1, "end") st.vtysh_config(vars.D1, "ip prefix-list test permit 5.5.5.0/24") st.vtysh_show(vars.D1, "show ip prefix-list") st.vtysh_config(vars.D1, "exit") st.vtysh_config(vars.D1, "line vty") st.vtysh_config(vars.D1, "end") st.vtysh_config(vars.D1, "line vty") st.vtysh_config(vars.D1, "exit") st.report_pass("operation_successful")
def test_vtysh_modes_check_4(): vars = st.get_testbed_vars() # Multiple commands in Config level - with multiple mode change - with end and exit st.vtysh_config(vars.D1, "router bgp 65100") st.vtysh_show(vars.D1, "show ip bgp") st.vtysh_config(vars.D1, "end") st.vtysh_config(vars.D1, "router bgp 65100") st.vtysh_show(vars.D1, "show ip bgp") st.vtysh_config(vars.D1, "end") st.vtysh_config(vars.D1, "router bgp 65100") st.vtysh_config(vars.D1, "address-family ipv4 unicast") st.vtysh_config(vars.D1, "bgp dampening") st.vtysh_show(vars.D1, "show ip bgp") st.vtysh_config(vars.D1, "end") st.vtysh_config(vars.D1, "router bgp 65100") st.vtysh_config(vars.D1, "address-family ipv4 unicast") st.vtysh_config(vars.D1, "bgp dampening") st.vtysh_show(vars.D1, "show ip bgp") st.vtysh_config(vars.D1, "exit") st.report_pass("operation_successful")
def test_all_modes_check_1(): vars = st.get_testbed_vars() # from sonic to mgmt-cli mode st.show(vars.D1, "show ip interfaces") st.change_prompt(vars.D1, "mgmt-user") st.cli_show(vars.D1, "show interface status", skip_tmpl=True) # from mgmt-cli to sonic mode st.change_prompt(vars.D1, "normal-user") # from sonic to mgmt-cli interface mode st.change_prompt(vars.D1, "mgmt-intf-config", interface="Ethernet4") # from sonic to mgmt-cli interface mode with different interface st.change_prompt(vars.D1, "mgmt-intf-config", interface="Ethernet40") st.cli_show(vars.D1, "show interface status", skip_tmpl=True) st.cli_show(vars.D1, "show interface status | no-more ", skip_tmpl=True) # from mgmt-cli interface to sonic mode st.change_prompt(vars.D1, "normal-user") # from mgmt-cli interface mode to mgmt-cli acl mode and commands after mode change st.change_prompt(vars.D1, "mgmt-ipv4-acl-config", aclname="MyACL") # from sonic to mgmt-cli interface mode with different interface st.change_prompt(vars.D1, "mgmt-intf-config", interface="Ethernet40") # from mgmt-cli Config to various different modes and vice versa st.change_prompt(vars.D1, "mgmt-intf-config", interface="Ethernet4") st.show(vars.D1, "show neighbors", type="lldp") st.change_prompt(vars.D1, "mgmt-intf-config", interface="Ethernet4") st.vtysh_show(vars.D1, "show ip bgp") st.change_prompt(vars.D1, "mgmt-intf-config", interface="Ethernet4") st.vtysh_config(vars.D1, "do show ip bgp") st.change_prompt(vars.D1, "mgmt-intf-config", interface="Ethernet4") st.show(vars.D1, "show interfaces status") # from mgmt-cli normal mode to various different modes and vice versa st.change_prompt(vars.D1, "mgmt-user") st.show(vars.D1, "show neighbors", type="lldp") st.change_prompt(vars.D1, "mgmt-user") st.vtysh_show(vars.D1, "show ip bgp") st.change_prompt(vars.D1, "mgmt-user") st.vtysh_config(vars.D1, "do show ip bgp") st.change_prompt(vars.D1, "mgmt-user") st.show(vars.D1, "show interfaces status") # from lldp mode to remaining modes and vice versa st.show(vars.D1, "show neighbors", type="lldp") st.vtysh_show(vars.D1, "show ip bgp") st.show(vars.D1, "show neighbors", type="lldp") st.vtysh_config(vars.D1, "do show ip bgp") st.show(vars.D1, "show neighbors", type="lldp") st.show(vars.D1, "show interfaces status") # from vtysh config mode to remaining modes and vice versa st.vtysh_config(vars.D1, "do show ip bgp") st.vtysh_show(vars.D1, "show ip route") st.vtysh_config(vars.D1, "do show ip bgp") st.show(vars.D1, "show interfaces status") # from vtysh mode to remaining modes and vice versa st.vtysh_show(vars.D1, "show ip bgp") st.show(vars.D1, "show interfaces status") st.report_pass("operation_successful")