- Ansible Modules
- Sonichost Methods
- Multi ASIC Methods
- SONIC ASIC Methods
- Ptfhost Methods
- Pre-configured Function Arguments
There are many ways to communicate and interact with the PTF container and the DUT from the localhost. This wiki serves as a place to document these API calls. Below is a list of some of the many API calls.
localhost, ptfhost and sonichost objects can use the ansible modules. Many may not provide meaningful output if ptfhost is used (like reduce_and_add_sonic_images
).
# These arguments are examples of the pre-configured function arguments
def test_fun(duthosts, rand_one_dut_hostname, ptfhost):
duthost = duthosts[rand_one_dut_hostname]
# example dut api call
duthost.get_extended_minigraph_facts()
# example ptf api call
ptfhost.shell("ls")
-
acl_facts - Retrieves ACL information from remote host.
-
announce_routes - Announces Routes to the exabgp processes running in the PTF container
-
bgp_facts - Retreives BGP information using Quagga
-
bgp_route - Provides BGP routing info from Quagga using VTYSH cli.
-
command - Used to run commands via shell on remote host.
-
config_facts - Retreives configuration facts for a device
-
conn_graph_facts - Retreives info on lab fannout siwtches and vlan connections.
-
console_facts - Retrieves console feature and status information using Quagga.
-
copy - Used to copy local files to remote host.
-
exabgp - Start or stop exabgp instance with certain configurations
-
extract_log - Unrotate logs and extract information starting from a row with predefined string.
-
feature_facts - Provides the statuses for all active features on a host.
-
fetch - Copies file from remote host to local host.
-
file - Allows for setting attributes of file, symlinks, directories. Can be used to remove files.
-
find - Finds list of files based on specified criteria.
-
get_ip_in_range - Get certain number of ips within a prefix
-
image_facts - Get information on image from remote host.
-
interface_facts - Retrieves information on device interfaces.
-
lag_facts - Retrieve Ling Aggregation Group information from a device.
-
lldpctl_facts - Gathers LLDP facts from the SONiC device.
-
lldp_facts - Retrieve LLDP facts using SNMP
-
minigraph_facts - Retrieve minigraph facts for a device.
-
monit_process - Retrieve process cpu and memory usage
-
ping - Pings the remote host
-
port_alias - Find port-alias mapping if there is any configured.
-
reduce_and_add_sonic_images - Removes excess sonic images and installs a new image if requested.
-
replace - Replaces all instances of a pattern within a specified file. When using this method make sure that the pattern being used to match does not match the replacement text, otherwise the results may be undesirable.
-
sensors_facts - Retrieves sensor facts for a device.
-
service - Controls services on the dut.
-
setup - Gather facts about the duthost.
-
shell - Runs commands on the remote host.
-
shell_cmds - Allows you to run mutliple commands on a remote host.
-
show_interface - Retrieves status and counter values from DUT.
-
show_ip_interface - Retrieve ipv4 address of interface and ipv4 address for corresponding neighbor
-
snmp_facts - Retreives facts for device using SNMP
-
sonic_pfc_counters - Get or clear PFC counter for a device
-
stat - Retrieves facts on specified file.
-
switch_arptable - Reterives ARP table from the SONiC switch
-
switch_capabilities_facts - Retreive switch capability information.
-
sysfs_facts - Get sysfs information from switch
-
tempfile - Generates temp file or directory on remote host.
-
active_ip_interfaces - Provides information on all active IP (Ethernet or Portchannel) interfaces given a list of interface names.
-
all_critical_process_status - Provides summary and status of all critical services and their processes
-
check_bgp_session_nsf - Checks if BGP neighbor session has entered Nonstop Forwarding(NSF) state
-
check_bgp_session_state - Check whether the state of the bgp session matches a specified state for a list of bgp neighbors.
-
check_default_route - Provides the status of the default route
-
critical_process_status - Gets status of service and provides list of exited and running member processes.
-
critical_services - Provides a list of critical services running on the SONiC host.
-
critical_services_fully_started - Whether all critical services have started on the SONiC host.
-
critical_services_status - Checks status for cirtical services.
-
delete_container - Removes a docker container from the DUT.
-
facts - Returns platform information facts about the sonic device.
-
get_asic_name - Returns name of current ASIC. For use in multi-ASIC environments.
-
get_auto_negotiation_mode - Gets the auto negotiation status for a provided interface
-
get_bgp_neighbors - This command provides a summary of the bgp neighbors peered with the DUT. Returns a dictionary that maps the BGP address for each neighbor to another dictionary listing information on that neighbor device.
-
get_bgp_neighbor_info - Provides BGP neighbor info
-
get_container_autorestart_states - Get container names and their autorestart states. Containers that do not have the autorestart feature implemented are skipped by this test.
-
get_critical_group_and_process_lists - Provides lists of cirtical groups and processes
-
get_crm_facts - Parses
crm show
commands to gather facts on CRM. -
get_crm_resources - Gets information on CRM resources from host
-
get_dut_iface_mac - Gets the AMC address for specified interface
-
get_extended_minigraph_facts - Gets detailed facts on configured minigraph.
-
get_feature_status - Returns features and their states.
-
get_image_info - Get list of images installed on the DUT.
-
get_ip_route_info - Returns route information for a destionation. The destination could an ip address or ip prefix.
-
get_monit_services_status - Get metadata on services monitored by Monit.
-
get_namespace_ids - Gets ids of namespace where the container should reside in.
-
get_networking_uptime - Returns time since
networking
service started on the host. -
get_now_time - Gets current datetime as defined on the remote host
-
get_pmon_daemon_db_value - Gets the db value in state db to check the daemon expected status
-
get_pmon_daemon_states - Get states of daemons from the pmon docker.
-
get_pmon_daemon_status - Get daemon status in pmon docker using
supervisorctl status
command. -
get_rsyslog_ipv4 - Returns the rsyslog ipv4 address.
-
get_running_config_facts - Provides information on the currently running configuration of the dut.
-
get_service_props - Gets detailed properties of a service
-
get_speed - Gets configured speed for a given interface.
-
get_supported_speeds - Gets a list of all supported speeds for a given interface.
-
get_swss_docker_names - Gets list of swss docker names.
-
get_syncd_docker_names - Gets list of syncd docker names.
-
get_uptime - Returns the amount of time since device was started
-
get_up_ip_ports - Gets list of all
up
interfaces -
get_up_time - Returns
datetime
object representing date/time that device was started. -
get_vlan_intfs - Retrieves list of interfaces belonging to a VLAN.
-
hostname - Provides hostname for device.
-
is_backend_portchannel - Returns whether or not a provided portchannel is a backend portchannel.
-
is_bgp_state_idle - Checks if all BGP peers are in IDLE state.
-
is_container_running - Checks whether a docker container is running.
-
is_frontend_node - Checks whether the DUT is a frontend node. Used in multi-DUT setups.
-
is_multi_asic - Returns whether remote host is multi-ASIC
-
is_service_fully_started - Checks whether a service is fully started on the SONiC host.
-
is_service_running - Checks if a specified service is running. Can be a service within a docker.
-
is_supervisor_node - Checks if current node is a supervisor node. Used for multi-DUT setups.
-
kernel_version - Provides version of Sonic kernel on remote host
-
kill_pmon_daemon_pid_w_sig - Stops daemon in pmon docker using kill with a sig.
-
mgmt_ip - Provides management ip for host.
-
no_shutdown - Starts up a specied interface.
-
no_shutdown_multiple - Startup multiple interfaces.
-
num_asics - Provides number of asics
-
os_version - Provides string representing the version of SONiC being used
-
ping_v4 - Pings ipv4 address and provides result.
-
remove_ssh_tunnel_sai_rpc - Removes any ssh tunnels if present created for syncd RPC communication
-
reset_critical_services_tracking_list - Modifies the list of critical services used by the SONiC Host.
-
reset_service - Resets a service on a specified docker.
-
restart_service - Restarts a service on a specified docker.
-
run_redis_cli_cmd - Run redis command through the redis cli.
-
set_auto_negotiation_mode - Sets the auto negotiation mode for a provided interface
-
set_speed - Sets speed for desired interface.
-
show_and_parse - Runs a show command on the host and parses the input into a computer readable format, usually a list of entries. Works on any show command that has suimilar structure to
show interface status
-
shutdown - Shuts down a specified interface
-
shutdown_multiple - Shuts down multiple specified interfaces.
-
start_pmon_daemon - Start daemon in pmon docker using
supervisorctl start
-
start_service - Starts service on a specified docker.
-
stop_pmon_daemon - Stop daemon in pmon docker.
-
stop_pmon_daemon_service - Stops daemon in pmon docker using
supervisorctl stop
-
stop_service - Stops a specified service
-
asics - Get list of ASIC hosts
-
asic_instance - Retrieves the asic instance given an asic id. Device must be multi-ASIC
-
asic_instance_from_namespace - Provides ASIC instance given a corresponding namespace.
-
critical_services_tracking_list - Gets the list of services running on the DUT.
-
delete_container - Deletes container on sonichost if container's associated service is a default service. Otherwise, container is deleted on each ASIC.
-
get_asic_ids - Provides all ASIC indexes for the ASICs on the Multi-ASIC device.
-
get_asic_id_from_namespace - Returns numeric ID for ASIC given a namespace. This command only works if the dut is a multi-asic device.
-
get_asic_index_for_portchannel - Gets asic index associated with provided portchannel.
-
get_asic_namespace_list - Provides list of namspaces corresponding to ASICs on the duthost. The dut must be a multi-ASIC device for this method to work.
-
get_asic_or_sonic_host - Returns ASIC instance provided a corresponding ASIC instance id.
-
get_asic_or_sonic_host_from_namespace - Returns corresponding sonichost instance if arg
namespace
is not specified, or corresponding ASIC instance if argnamespace
is specified. -
get_backend_asic_ids - Provides list of ASIC indexes corresponding to ASICs on the Multi-ASIC device.
-
get_backend_asic_namespace_list - Provides list of namespaces for each ASIC on the Multi-ASIC device.
-
get_default_critical_services_list - Provides the default list of critical services for Multi-ASIC device.
-
get_frontend_asic_ids - Provides a list of ASIC indexes representing the ASICs on the device.
-
get_frontend_asic_namespace_list - Provides list of all namespaces corresponding to ASICs on Multi-ASIC device.
-
get_linux_ip_cmd_for_namespace - Specifies a linux
ip
command for the provided namespace. -
get_namespace_from_asic_id - Gets the namespace provided an ASIC ID. This only works on multi-ASIC devices.
-
get_port_asic_instance - Returns the numeric ASIC instance that a provided port belongs to. Will fail test if ASIC instance is not found for provided port.
-
get_queue_oid - Get the queue OID of given port and queue number.
-
get_queue_oid_asic_instance - Returns the ASIC instance which has the queue OID saved.
-
get_route - Retreives BGP routes on a provided an ip prefix that the route must match.
-
get_sonic_host_and_frontend_asic_instance - Returns sonic host and all frontend asic instances. Only works on multi-asic devices
-
get_vtysh_cmd_for_namespace - Provides modified VTYSH command provided ASIC namespace and command.
-
has_config_subcommand - Check if a config or show subcommand exists on the remote host. WARNING: to test whether it exists, the method will run the command. Ensure that there will be no negative sid-effects of having this command run on the remote host.
-
is_bgp_state_idle - Checks if all BGP peers are in IDLE state on the sonichost.
-
is_container_running - Returns whether or not a container is running on sonichost if the container's associated service is a default service. Otherwise, it returns whether or not the container is running on any ASIC.
-
is_service_running - Checks if a specified service is running. Can be a service within a docker.
-
restart_service - Restarts a service on the sonichost if the service is a default service. Otherwise service is restarted on each ASIC.
-
start_service - Starts service on sonichost if service is a default service. Otherwise service is started on each ASIC.
-
stop_service - Stops a service on the sonichost if service is a default service. Otherwise serviec is stopped on all ASICs.
-
bgp_drop_rule - Programs iptable rule to either add or remove DROP for BGP control frames
-
bgp_facts - Provides BGP facts for current ASIC.
-
check_bgp_statistic - Checks that the BGP statistic matches some expected value.
-
command - Runs commands specified for the ASIC calling the method.
-
config_facts - Current config facts for ASIC.
-
config_ip_intf - Allows for addition or removal of ip addresses to existing interfaces on the ASIC instance.
-
config_portchannel - Creates or removes a portchannel on the ASIC instance
-
config_portchannel_member - Adds or removes portchannel member for a specified portchannel on the ASIC instance.
-
create_ssh_tunnel_sai_rpc - Create ssh tunnel between host and ASIC namespace on syncd RPC port.
-
delete_container - Deletes a ASIC specific docker.
-
get_active_ip_interfaces - Provides a information on active IP interfaces. Works on ASIC devices.
-
get_asic_namespace - Provides namespace for ASIC.
-
get_bgp_statistic - Get the value corresponding to a named statistic for BGP.
-
get_critical_services - Gets the critical services for the ASIC.
-
get_docker_cmd - Provides modified command to be run on a specific docker container given an initail command and the name of the desired container.
-
get_docker_name - Gets ASIC specific name for docker container.
-
get_extended_minigraph_facts - Gets detailed facts on configured minigraph.
-
get_ip_route_info - Returns route information for a destionation. The destination could an ip address or ip prefix.
-
get_portchannel_and_members_in_ns - Finds a portchannel present on ASIC interface's namspace and returns its name and members.
-
get_queue_oid - Get the queue OID of given port and queue number.
-
get_service_name - Provides ASIC specific service name.
-
interface_facts - Gets information about interfaces associated with the ASIC calling the method.
-
is_backend_portchannel - Checks whether specified portchannel is a backend portchannel.
-
is_container_running - Returns whether or not a specified ASIC specific container is running.
-
is_it_backend - Checks whether the ASIC is a backend node
-
is_it_frontend - Checks whether ASIC is a frontend node.
-
is_service_running - Checks if a specified service is running. Can be a service within a docker.
-
os_version - Provides the SONiC OS version for the sonichost associated with the calling ASIC
-
ping_v4 - Pings specified ipv4 address via ASIC.
-
portchannel_on_asic - CHecks whether a specified portchannel is configured on ASIC instance
-
port_exists - Checks whether a provided port exists in the ASIC instance calling the method.
-
port_on_asic - Checks if provided port is configured on ASIC instance
-
remove_ssh_tunnel_sai_rpc - Removes any ssh tunnels if present created for syncd RPC communication
-
reset_service - Resets an ASIC service on the corresponding docker.
-
restart_service - Restarts an ASIC service on the corresponding docker.
-
run_redis_cli_cmd - Runs redist cmd through redis CLI for ASIC that calls method.
-
run_redis_cmd - Runs a redis command on the DUT.
-
shell - Runs a shell command via the sonichost associated with the ASIC instance calling the method.
-
show_interface - Show status and counter values for a given interface on the ASIC.
-
show_ip_interface - Retrieve ipv4 address for interface and ipv4 address for corresponding neighbor
-
shutdown_interface - Shuts down interface specified for the ASIC instance calling the method.
-
startup_interface - Starts up interface specified for ASIC instance calling the method.
-
start_service - Starts an ASIC service on its corresponding ASIC docker.
-
stop_service - Stops a specified ASIC service on the corresponding docker
-
switch_arptable - Gets ARP table information from sonichost device specified for ASIC instance calling the method.
-
change_mac_addresses - Updates interface mac addresses.
-
hostname - Provides hostname for device.
-
mgmt_ip - Provides management ip for host.
-
remove_ip_addresses - Removes all Interface IP Addresses
-
duthosts - Provides a dictionary that maps DUT hostnames to DUT instances
-
localhost - The localhost instance. Used to run ansible modules from the localhost.
-
ptfhost - The PTF container host instance. Used to run ptf methods and anisble modules from the PTF.
-
rand_one_dut_hostname - A random hostname belonging to one of the DUT instances defined by the deployed testbed.