taf.testlib.ui_onpss_shell.switch_driver¶
switch_driver.py
Switch Driver abstraction
-
class
taf.testlib.ui_onpss_shell.switch_driver.SwitchDriver(ui_instance, switch_instance)[source]¶ Bases:
object-
MODPROBE_COMMAND= 'modprobe'¶
-
SWITCH_DRIVERS= OrderedDict([('fm10kd', SwitchDriver(name='fm10kd', kernel_module='fm10ks', script='fm10kdr')), ('switchd', SwitchDriver(name='switchd', kernel_module='switch', script='switchdr'))])¶
-
__init__(ui_instance, switch_instance)[source]¶ Parameters: - ui_instance (UiOnpssShell) – ui_onpss_shell instance
- switch_instance (SwitchGeneral) – specific switch instance
-
static
_gen_which_command(prog)[source]¶ Parameters: prog (str) – command to search for in the patch Returns: path of program Return type: str
-
autodetect()[source]¶ Search for switch drivers and set the name, kernel_module and script accordingly.
Raises: UIException– when switch driver not found
-
is_active()[source]¶ Check is switch driver service is running.
Returns: True if switch driver service is running Return type: bool
-
kill()[source]¶ Kill the switch driver process.
Normally we would just stop the service, this is for those manual cases.
-
-
taf.testlib.ui_onpss_shell.switch_driver.SwitchDriverEntry¶ alias of
SwitchDriver
taf.testlib.ui_onpss_shell.ui_onpss_shell¶
ui_onpss_shell.py
ONPSS Shell UI wrappers Implementation
-
class
taf.testlib.ui_onpss_shell.ui_onpss_shell.InvalidPortContext(ui, ports)[source]¶ Bases:
objectClass to create a invalid port.
-
__init__(ui, ports)[source]¶ “Initialize Invalidport class
Parameters: - ui (UiOnpssShell) – instance of switch
- ports (iter()) – port id of invalid port
-
-
class
taf.testlib.ui_onpss_shell.ui_onpss_shell.UiOnpssShell(switch)[source]¶ Bases:
testlib.ui_helpers.UiHelperMixin,testlib.ui_wrapper.UiInterfaceClass with UiOnpssShell wrappers.
-
BRIDGE_VLAN_COMMAND_STRING= 'bridge vlan {command} vid {vlan} dev {port} self {tagged}'¶
-
COLLECTD_SRVC= 'collectd'¶
-
DCRP_CFG_CPP_KEY= 'cppname'¶
-
DCRP_CFG_FILE= '/etc/dcrpd.conf'¶
-
DCRP_CFG_MAC_DEFAULT= 'aa:bb:cc:dd:ee:ff'¶
-
DCRP_CFG_MESH_KEY= 'mesh_port'¶
-
DCRP_CFG_MLAG_MAC= 'lag_mac'¶
-
DCRP_CFG_MLAG_UPLINKS= 'uplink_port'¶
-
DCRP_CFG_PORTS_DEFAULT= '("sw0p1","sw0p5")'¶
-
DCRP_SRVC= 'dcrpd'¶
-
DCRP_SRVCS= ['dcrpd', 'isisd', 'zebra']¶
-
INDEX_NAME_RE= re.compile('(?P<index>\\d*):\\s(?P<name>\\w*)[@:]')¶
-
LAG_MODE_MAP= {'Active': True, 'Passive': False}¶
-
LAG_TIMEOUT_MAP= {'Short': True, 'Long': False}¶
-
LLDP_ADMINSTATUS= {'RxOnly': 'rx', 'Disabled': 'disabled', 'TxAndRx': 'rxtx', 'TxOnly': 'tx'}¶
-
MAX_EXIT_STATUS= 256¶
-
MULTICALL_THRESHOLD= 100¶
-
RX_TX_RE= re.compile('\\s+[RT]X[^:]*:')¶
-
SSH_NO_EXIT_STATUS= -1¶
-
__init__(switch)[source]¶ Initialize UiOnpssShell class.
Parameters: switch (SwitchGeneral) – Switch instance
-
_configure_fc_mode(ports=None, tx_mode='normal', traffic_class=255)[source]¶ Determines 802.3x pause frame format used.
Maps priorities to traffic classes.
Parameters:
-
_disable_rx_fc(ports=None)[source]¶ Disables receive of 802.3x pause frames.
Parameters: ports (list[int]) – list of port ids
-
_disable_tx_fc(ports=None)[source]¶ Disables transmit of 802.3x pause frames per port.
Parameters: ports (list[int]) – list of port ids
-
_enable_tx_fc(ports=None)[source]¶ Enables transmit of 802.3x pause frames per port.
Parameters: ports (list[int]) – list of port ids
-
classmethod
_generate_bridge_vlan_commands(command, ports, vlans, tagged='')[source]¶ Generate Bridge VLAN commands.
Parameters: Returns: list of Bridge VLAN commands
Return type:
-
_parse_networkctl(res)[source]¶ Parsing networkctl status output.
Parameters: res (str) – command output Returns: Returns networkctl status in dictionary format Return type: dict
-
_return_user_mode(results)[source]¶ Maintained for abstraction compatibility.
Method that returns to user mode of a switch.
Parameters: results (list) – list of command execution results
-
add_acl_rule_to_acl(acl_name=None, rule_id='', action=None, conditions=None)[source]¶ Add rule to ACL.
Parameters: Returns: None
Examples:
env.switch[1].ui.add_acl_rule_to_acl(acl_name='Test-1', rule_id=1, action=['forward', '1'], conditions=[['ip-source', '192.168.10.10', '255.255.255.255']])
-
bind_acl_to_ports(acl_name=None, ports=None)[source]¶ Bind ACL to ports.
Parameters: Returns: None
Examples:
env.switch[1].ui.bind_acl_to_ports(acl_name='Test-1', ports=[1, 2, 3])
-
check_device_state()[source]¶ Attempts to connect to the shell retries number of times.
Raises: SwitchException– device is not ready.
-
clear_l2_multicast()[source]¶ Clear L2Multicast table.
Returns: None Examples:
env.switch[1].ui.clear_l2_multicast()
Raises: SwitchException– not implemented.
-
clear_networkd_settings()[source]¶ Clear networkd settings.
Raises: UiCmdException– when restart fails
-
clear_per_port_dot1p_cos_mapping(ports, rx_attr_flag=False, dot1p=None)[source]¶ Clear PortsDot1p2CoS mapping.
Parameters: Examples:
env.switch[1].ui.clear_per_port_dot1p_cos_mapping(ports=[port1, ], dot1p=[6, ])
-
clear_statistics()[source]¶ Clear Statistics.
Returns: None Examples
env.switch[1].ui.clear_statistics()
-
clear_table_fdb(table='Static')[source]¶ Clear the the static FDB table for devices sw0p##
Parameters: table (str) – FDB table type
-
cli_get_all(commands, timeout=None, split_lines=True, expected_rcs=frozenset({0}), multicall_treshold=100)[source]¶ Sends a list of commands, will return [‘’] if exception.
Parameters: - commands (list[list[str]]) – list of commands to be executed
- timeout (int) – command execution timeout
- split_lines (bool) – split command execution results by lines or not
- expected_rcs (int | set | list | frozenset) – expected return code
- multicall_treshold (int) – minimum number of commands to be executed using multicall
Returns: list of outputs for each command
Return type:
-
cli_multicall(commands, timeout=None, expected_rcs=frozenset({0}))[source]¶ Sends a list of commands.
Parameters: Returns: list[tuple(str, tuple(str, str, int))]
Raises: UICmdException– when rc not in expected_rcs
-
cli_send_command(command, timeout=None, expected_rcs=frozenset({0}))[source]¶ Sends a single bash command
If the command hasn’t finished yet, this method will wait until it does, or until the channel is closed. If no exit status is provided by the server, -1 is returned.
Parameters: Raises: UIException– unexpected return codeReturns: Returns CmdStatus namedtuple of stdout, stderr, return code
Return type:
-
cli_set(commands, timeout=None, split_lines=True, expected_rcs=frozenset({0}), multicall_treshold=100)[source]¶ Sends a list of commands.
Will halt on exception from cli_send_command.
Parameters: - commands (list[list[str]]) – list of commands to be executed
- timeout (int) – command execution timeout
- split_lines (bool) – split command execution results by lines or not
- expected_rcs (int | set | list | frozenset) – expected return code
- multicall_treshold (int) – minimum number of commands to be executed using multicall
Returns: list of execution statuses for each command
Return type: Raises: UICmdException– when rc not in expected_rcs
-
configure_application_priority_rules(ports, app_prio_rules, delete_params=False, update_params=False)[source]¶ Configure Application Priority rules.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_application_priority_rules([1, 2], [{"selector": 1, "protocol": 2, "priority":1}, ])
Raises: SwitchException– not implemented
-
configure_arp(garp=None, refresh_period=None, delay=None, secure_mode=None, age_time=None, attemptes=None, arp_len=None)[source]¶ Configure ARPConfig table.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_arp(garp='Enabled')
Raises: SwitchException– not implemented
-
configure_bgp_router(asn=65501, enabled='Enabled')[source]¶ Modify BGPRouter record.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_bgp_router(asn=65501, enabled='Enabled')
Raises: SwitchException– not implemented
-
configure_cos_global(**kwargs)[source]¶ Configure global mapping of ingress VLAN priority to CoS per port or per switch (PortsDot1p2CoS records).
Parameters: **kwargs (dict) – parameters to be modified Returns: None Examples:
env.switch[1].ui.configure_cos_global(dotp2CoS=6)
Raises: SwitchException– not implemented
-
configure_dcbx_app(ports, **kwargs)[source]¶ Configure DCBx APP parameter for the ports list.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_dcbx_app([1, 2])
Raises: SwitchException– not implemented
-
configure_dcbx_cn(ports, **kwargs)[source]¶ Configure DCBx CN parameter for the ports list.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_dcbx_cn([1, 2], cnpvSupported='Enabled')
Raises: SwitchException– not implemented
-
configure_dcbx_ets(ports, **kwargs)[source]¶ Configure DCBx ETS Conf/Reco parameter for ports list.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_dcbx_ets([1, 2], confBandwidth=100)
Raises: SwitchException– not implemented
-
configure_dcbx_pfc(ports, **kwargs)[source]¶ Configure DCBx PFC parameter for the ports list.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_dcbx_pfc([1, 2])
Raises: SwitchException– not implemented
-
configure_dscp_to_cos_mapping_global(set_to_default=False, **kwargs)[source]¶ Configure PortsDscp2CoS records.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_dscp_to_cos_mapping_global(dscp0CoS=6)
-
configure_global_lldp_parameters(**kwargs)[source]¶ Configure global LLDP parameters.
Parameters: **kwargs (dict) – parameters to be modified: ‘messageFastTx’; ‘messageTxHoldMultiplier’; ‘messageTxInterval’; ‘reinitDelay’; ‘txCreditMax’; ‘txFastInit’; ‘locChassisIdSubtype’. Returns: None Examples:
env.switch[1].ui.configure_global_lldp_parameters(messageTxInterval=5)
Raises: SwitchException– not implemented
-
configure_igmp_global(mode='Enabled', router_alert=None, unknown_igmp_behavior=None, query_interval=None, querier_robustness=None)[source]¶ Modify IGMPSnoopingGlobalAdmin table.
Parameters: - mode (str) – mode parameter value. ‘Enabled’|’Disabled’
- router_alert (str) – routerAlertEnforced parameter value. ‘Enabled’|’Disabled’
- unknown_igmp_behavior (str) – unknownIgmpBehavior parameter value. ‘Broadcast’|’Drop’
- query_interval (int) – queryInterval parameter value
- querier_robustness (int) – querierRobustness parameter value
Returns: None
Examples:
env.switch[1].ui.configure_igmp_global(mode='Enabled')
Raises: SwitchException– not implemented
-
configure_igmp_per_ports(ports, mode='Enabled', router_port_mode=None)[source]¶ Modify IGMPSnoopingPortsAdmin table.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_igmp_per_ports([1, 2], mode='Enabled')
Raises: SwitchException– not implemented
-
configure_lldp_ports(ports, **kwargs)[source]¶ Configure LldpPorts records.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_lldp_ports([1, 2], adminStatus='Disabled')
Raises: SwitchException– not implemented
-
configure_ospf_router(**kwargs)[source]¶ Configure OSPFRouter table.
Parameters: **kwargs (dict) – parameters to be modified: “logAdjacencyChanges” - set logAdjacencyChanges value; “routerId” - set routerId value. Returns: None Examples:
env.switch[1].ui.configure_ospf_router(routerId='1.1.1.1')
Raises: SwitchException– not implemented
-
configure_ovs_resources(**kwargs)[source]¶ Configure OvsResources table.
Parameters: **kwargs (dict) – parameters to be configured: “controllerRateLimit”; “vlansLimit”; “untaggedVlan”; “rulesLimit”. Returns: None Examples:
env.switch[1].ui.configure_ovs_resources(rulesLimit=2000)
Raises: SwitchException– not implemented
-
configure_port_cos(ports=None, **kwargs)[source]¶ Configure PortsQoS records.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_port_cos([1, ], trustMode='Dot1p')
Raises: SwitchException– not implemented
-
configure_qinq_ports(ports, **kwargs)[source]¶ Configure QinQ Ports.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_qinq_ports([1, ], tpid=2)
Raises: SwitchException– not implemented
-
configure_qinq_vlan_mapping(ports, customer_vlan_id, customer_vlan_priority, provider_vlan_id, provider_vlan_priority)[source]¶ Configure QinQCustomerVlanMapping and QinQProviderVlanMapping.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_qinq_vlan_mapping([1, ], 2, 7, 5, 6)
Raises: SwitchException– not implemented
-
configure_qinq_vlan_stacking(ports, provider_vlan_id, provider_vlan_priority)[source]¶ Configure QinQVlanStacking.
Parameters: Returns: None
Examples
env.switch[1].ui.configure_qinq_vlan_stacking([1, ], 2, 7)
Raises: SwitchException– not implemented
-
configure_routing(routing='Enabled', ospf=None)[source]¶ Configure L3 routing.
Parameters: - routing (str) – enable L3 routing
- ospf (str|None) – enable OSPF. None|’Enabled’
Returns: None
Examples:
env.switch[1].ui.configure_routing(routing='Enabled', ospf='Enabled')
Raises: SwitchException– not implemented
-
configure_schedweight_to_cos_mapping(ports, **kwargs)[source]¶ Configure schedweight to cos mapping.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_schedweight_to_cos_mapping(ports=[1,2], schedWeight0=35)
-
configure_spanning_tree(**kwargs)[source]¶ Configure ‘SpanningTree’ table.
Parameters: kwargs (dict) – Possible parameters from ‘SpanningTree’ table to configure: “enable” - globally enable STP; “mode” - set STP mode. RSTP|MSTP|STP; “maxAge” - set maxAge value; “forwardDelay” - set forwardDelay value; “bridgePriority” - set bridgePriority value; “bpduGuard” - set bpduGuard value; “forceVersion” - set forceVersion value; “mstpciName” - set mstpciName value. Returns: None Example:
env.switch[1].ui.configure_spanning_tree(mode='MSTP')
-
configure_stp_instance(instance, **kwargs)[source]¶ Configure existing STP instance.
Parameters: Returns: None
Examples:
env.switch[1].ui.configure_stp_instance(instance=3, priority=2) # change instance priority env.switch[1].ui.configure_stp_instance(instance=3, vlan=10) # assign instance to the existed vlan
Raises: SwitchException– not implemented
-
configure_tunneling_global(**kwargs)[source]¶ Configure TunnelingGlobalAdmin table.
Parameters: **kwargs (dict) – parameters to be modified: “vnTag”; “vxlanInnerVlanProcessing”; “mode”, “vxlanDestUDPPort”. Returns: None Examples:
env.switch[1].ui.configure_tunneling_global()
Raises: SwitchException– not implemented
-
cpu_port= 0¶
-
create_acl(ports=None, expressions=None, actions=None, rules=None, acl_name='Test-ACL')[source]¶ Create ACLs.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_acl(ports=[1, 2], expressions=[[1, 'SrcMac', 'FF:FF:FF:FF:FF:FF', '00:00:00:11:11:11'], ], actions=[[1, 'Drop', ''], ], [[1, 1, 1, 'Ingress', 'Enabled', 0], ])
-
create_acl_name(acl_name=None)[source]¶ Create ACL name.
Parameters: acl_name (str) – ACL name to be created Returns: None Examples:
env.switch[1].ui.create_acl_name('Test-1')
-
create_area_ranges(area, range_ip, range_mask, substitute_ip, substitute_mask)[source]¶ Create OSPFAreas2Ranges record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_area_ranges("0.0.0.0", "10.0.2.0", "255.255.255.0", "11.0.2.0", "255.255.255.0")
Raises: SwitchException– not implemented
-
create_area_virtual_link(area, link)[source]¶ Create OSPFInterface record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_area_virtual_link("0.0.0.0", "1.1.1.2")
Raises: SwitchException– not implemented
-
create_bgp_aggregate_address(asn=65501, ip='22.10.10.0', mask='255.255.255.0')[source]¶ Create BGPAggregateAddress record
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_aggregate_address(asn=65501, ip='10.0.0.0', mask='255.255.255.0')
Raises: SwitchException– not implemented
-
create_bgp_bgp(asn=65501, router_id='1.1.1.1')[source]¶ Create BGPBgp record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_bgp(asn=65501, router_id="1.1.1.1")
Raises: SwitchException– not implemented
-
create_bgp_confederation_peers(asn=65501, peers=70000)[source]¶ Create BGPBgpConfederationPeers record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_confederation_peers(asn=65501, peers=70000)
Raises: SwitchException– not implemented
-
create_bgp_distance_admin(asn=65501, ext_distance=100, int_distance=200, local_distance=50)[source]¶ Create BGPDistanceAdmin record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_distance_admin(asn=65501, ext_distance=100, int_distance=200, local_distance=50)
Raises: SwitchException– not implemented
-
create_bgp_distance_network(asn=65501, ip='40.0.0.0/24', mask='255.255.255.0', distance=100, route_map='routeMap')[source]¶ Create BGPDistanceNetwork record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_distance_network(asn=65501, ip="40.0.0.0", mask='255.255.255.0', distance=100, route_map='routeMap')
Raises: SwitchException– not implemented
-
create_bgp_neighbor(asn=65501, ip='192.168.0.1')[source]¶ Create BGPNeighbor record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_neighbor(asn=65501, ip='192.168.0.1')
Raises: SwitchException– not implemented
-
create_bgp_neighbor_2_as(asn, ip, remote_as)[source]¶ Create BGPNeighbor2As record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_neighbor_2_as(65501, '10.0.5.102', 65502)
Raises: SwitchException– not implemented
-
create_bgp_neighbor_connection(asn=65501, ip='192.168.0.1', port=179)[source]¶ Create BGPNeighborConnection record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_neighbor_connection(asn=65501, ip='192.168.0.1', port=179)
Raises: SwitchException– not implemented
-
create_bgp_network(asn=65501, ip='10.0.0.0', mask='255.255.255.0', route_map='routeMap')[source]¶ Create BGPNetwork record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_network(asn=65501, ip='10.0.0.0', mask='255.255.255.0', route_map='routeMap')
Raises: SwitchException– not implemented
-
create_bgp_peer_group(asn=65501, name='mypeergroup')[source]¶ Create BGPPeerGroups record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_peer_group(65501, "test_name")
Raises: SwitchException– not implemented
-
create_bgp_peer_group_member(asn=65501, name='mypeergroup', ip='12.1.0.2')[source]¶ Create BGPPeerGroupMembers record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_peer_group_member(65501, "test_name", "12.1.0.2")
Raises: SwitchException– not implemented
-
create_bgp_redistribute(asn=65501, rtype='OSPF')[source]¶ Create BGPRedistribute record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_bgp_redistribute(65501, "OSPF")
Raises: SwitchException– not implemented
-
create_dcrp_config_file(lines, file_name='/etc/dcrpd.conf')[source]¶ Writes configuration required to file.
Parameters: Returns: None
Steps:
-# Using sftp client open the config file in write mode -# Write the configuration required for the DCRP Service.
-
create_dhcp_client_lease(file_name='/var/lib/dhcpd/dhcpd.leases')[source]¶ Creates a lease file via SFTP.
Parameters: file_name (str) – File name Returns: None Steps:
-# Create a lease file when DHCP Server is started
-
create_dhcp_config_file(lines, file_name='/etc/dhcp/dhcpd.conf')[source]¶ Writes configuration required to file.
Parameters: - lines (str) – Configuration
- file_name – File name
Returns: None
Steps:
-# Using sftp client open the config file in write mode -# Write the minimum configuration required by DHCP Server to the file
-
create_dhcp_relay(iface_name='global', server_ip=None, fwd_iface_name=None)[source]¶ Configure DhcpRelayAdmin or DhcpRelayV6Admin table.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_dhcp_relay(iface_name='global', server_ip='10.10.0.2')
Raises: SwitchException– not implemented
-
create_dot1p_to_cos_mapping(ports, rx_attr_flag=False, **kwargs)[source]¶ Configure mapping of ingress VLAN priority to CoS per port or per switch (PortsDot1p2CoS mapping).
Parameters: Returns: None
Examples:
env.switch[1].ui.create_dot1p_to_cos_mapping([1, ], dotp7CoS=6)
Raises: SwitchException– not implemented
-
create_interface_md5_key(vlan, network, key_id, key)[source]¶ Create OSPFInterfaceMD5Keys record.
Parameters: Returns: None
Example
env.switch[1].ui.create_interface_md5_key(10, “10.0.5.101/24”, 1, “Key1”)
Raises: SwitchException– not implemented
-
create_invalid_ports(ports=None, num=1)[source]¶ Creates port name if port id is passed say [Swop100, if 100 is passed as port id].
Else creates port name with a value incremented to 10 to existing length of ports Ex[sw0p34 , currently sw0p24 is last port]
Parameters:
-
create_lag(lag=None, key=0, lag_type='Static', hash_mode='None')[source]¶ Creates a lag group.
Parameters: Raises: ExistsErrorReturns: None
-
create_lag_ports(ports, lag, priority=1, key=None, aggregation='Multiple', lag_mode='Passive', timeout='Long', synchronization=False, collecting=False, distributing=False, defaulting=False, expired=False, partner_system='00:00:00:00:00:00', partner_syspri=32768, partner_number=1, partner_key=0, partner_pri=32768)[source]¶ Set port to a LAG. Most of the parameters don’t work for ONPSS.
Parameters: - ports (list[int]) – list of ports to be added into LAG
- lag (int) – LAG Id
- priority (int) – LAG priority
- key (int) – LAG key
- aggregation (str) – LAG aggregation
- lag_mode (str) – LAG mode
- timeout (str) – LAG timeout
- synchronization (bool) – LAG synchronization
- collecting (bool) – LAG collecting
- distributing (bool) – LAG distributing
- defaulting (bool) – LAG defaulting
- expired (bool) – LAG expired
- partner_system (str) – LAG partner system MAC address
- partner_syspri (int) – LAG partner system priority
- partner_number (int) – LAG partner number
- partner_key (int) – LAG partner key
- partner_pri (int) – LAG partner priority
Returns: int | str
Return type: lag
Raises: NotExistsErrorAccessError
-
create_match_api_rule(prio_id, handle_id, table_id, match_field_value_mask_list, action, action_value=None)[source]¶ Set a rule into the table using the method defined in maa.py
Parameters: - prio_id (int) – Higher id has a higher priority.
- handle_id (int) – handle for match.
- table_id (int) – the source table id where match to be set.
- match_field_value_mask_list (list[tuple(str, str, str)]) – field with match field, value and mask.
- action (str) – given action for source table
- action_value (int) – action value for a specified action
-
create_match_api_tcam_subtable(source_id, table_id, table_name, max_table_entries, match_field_type_pairs, actions)[source]¶ Create a sub-table of tcam using the method defined in maa.py.
Parameters: - source_id (int) – the source id in the tcam table.
- table_id (int) – a given table id. If switchd running, table id starts from 5 If matchd is running, table id starts from 4
- table_name (str) – a given table name.
- max_table_entries (int) – maximum number of flows can be set.
- match_field_type_pairs (list[tuple(str, str)]) – list of given match field with match type
- actions (list[str]) – list of actions for configurable matches
-
create_mirror_session(port, target, mode)[source]¶ Configure PortsMirroring table.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_mirror_session(1, 2, 'Redirect')
Raises: SwitchException– not implemented
-
create_multicast(port, vlans, macs)[source]¶ Create StaticL2Multicast record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_multicast(10, [5, ], ['01:00:05:11:11:11', ])
Raises: SwitchException– not implemented
-
create_network_2_area(network, area, mode)[source]¶ Create OSPFNetworks2Area record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_network_2_area('10.0.5.101/24', "0.0.0.0", 'Disabled')
Raises: SwitchException– not implemented
-
create_ospf_area(area, **kwargs)[source]¶ Create OSPFAreas record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ospf_area("0.0.0.0")
Raises: SwitchException– not implemented
-
create_ospf_interface(vlan, network, dead_interval=40, hello_interval=5, network_type='Broadcast', hello_multiplier=3, minimal='Enabled', priority=-1, retransmit_interval=-1)[source]¶ Create OSPFInterface record.
Parameters: - vlan (int) – Vlan Id
- network (str) – Route Interface network
- dead_interval (int) – dead interval
- hello_interval (int) – hello interval
- network_type (str) – network type
- hello_multiplier (int) – hello multiplier
- minimal (str) – minimal
- priority (int) – priority
- retransmit_interval (int) – retransmit interval
Returns: None
Examples:
env.switch[1].ui.create_ospf_interface(vlan_id, "10.0.5.101/24", 40, 5, network_type='Broadcast', minimal='Enabled', priority=1, retransmit_interval=3)
Raises: SwitchException– not implemented
-
create_ovs_bridge(bridge_name)[source]¶ Create OvsBridges record.
Parameters: bridge_name (str) – OVS bridge name Returns: None Examples:
env.switch[1].ui.create_ovs_bridge('spp0')
Raises: SwitchException– not implemented
-
create_ovs_bridge_controller(bridge_name, controller)[source]¶ Create OvsControllers record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ovs_bridge_controller("spp0", "tcp:127.0.0.1:6633")
Raises: SwitchException– not implemented
-
create_ovs_flow_actions(bridge_id, table_id, flow_id, action, param, priority=2000)[source]¶ Add row to OvsFlowActions table.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ovs_flow_actions(0, 0, 1, 'Output', '25')
Raises: SwitchException– not implemented
-
create_ovs_flow_qualifiers(bridge_id, table_id, flow_id, field, data, priority=2000)[source]¶ Add row to OvsFlowQualifiers table.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ovs_flow_qualifiers(0, 0, i, 'EthSrc', '00:00:00:00:00:01')
Raises: SwitchException– not implemented
-
create_ovs_flow_rules(bridge_id, table_id, flow_id, priority, enabled)[source]¶ Create OvsFlowRules table.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ovs_flow_rules(0, 0, 1, 2000, "Enabled")
Raises: SwitchException– not implemented
-
create_ovs_port(port, bridge_name)[source]¶ Create OvsPorts record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ovs_port(1, 'spp0')
Raises: SwitchException– not implemented
-
create_route_interface(vlan, ip, ip_type='InterVlan', bandwidth=1000, mtu=1500, status='Enabled', vrf=0, mode='ip')[source]¶ Create Route Interface.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_route_interface(10, '10.0.5.101/24', 'InterVlan', 1000, 1500, 'Enabled, 0, 'ip') env.switch[1].ui.create_route_interface(10, '2000::01/96', 'InterVlan', 1000, 1500, 'Enabled, 0, 'ipv6')
Raises: SwitchException– not implemented
-
create_route_redistribute(mode)[source]¶ Create OSPFRouteRedistribute record.
Parameters: mode (str) – redistribute mode Returns: None Examples:
env.switch[1].ui.create_route_redistribute("Static")
Raises: SwitchException– not implemented
-
create_static_macs(port=None, vlans=None, macs=None)[source]¶ Adds static MAC entries.
Parameters: Returns: None
Raises: ExistsError
-
create_static_route(ip, nexthop, network, distance=-1, mode='ip')[source]¶ Create StaticRoute record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_static_route('20.20.20.0/24', '10.0.5.102', '10.0.5.101/24')
Raises: SwitchException– not implemented
-
create_stp_instance(instance, priority)[source]¶ Create new STP instance in ‘STPInstances’ table.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_stp_instance(instance=3, priority=2)
Raises: SwitchException– not implemented
-
create_syslog(syslog_proto, syslog_ip, syslog_port, syslog_localport, syslog_transport, syslog_facility, syslog_severity)[source]¶ Configure Syslog settings.
Parameters: - syslog_proto (str) – syslog host protocol Udp | Tcp
- syslog_ip (str) – syslog host IP address
- syslog_port (int) – syslog host port
- syslog_localport (int) – syslog host local port
- syslog_transport (str) – syslog host transport
- syslog_facility (int) – syslog host facility
- syslog_severity (str) – syslog host severity
Raises: SwitchException– not implemented
-
create_tunnels(tunnel_id=None, destination_ip=None, vrf=0, encap_type=None)[source]¶ Configure TunnelsAdmin table.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_tunnels(tunnel_id=records_count, destination_ip=ip_list, encap_type='VXLAN')
Raises: SwitchException– not implemented
-
create_ufd_group(group_id, threshold=None, enable=None)[source]¶ Create UFDGroups record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ufd_group(1)
Raises: SwitchException– not implemented
-
create_ufd_network_file(port_name, config_parser_instance=None)[source]¶ Creating ufd network file
Parameters: - port_name (str) – name of the port, which network file to be created
- config_parser_instance (instance of ConfigParser) – configuration to be written in file
-
create_ufd_ports(ports, port_type, group_id)[source]¶ Create UFDPorts2Groups record.
Parameters: Returns: None
Examples:
env.switch[1].ui.create_ufd_ports([1, ], 'LtM' 2)
Raises: SwitchException– not implemented
-
create_vlan_ports(ports=None, vlans=None, tagged='Tagged')[source]¶ Creates VLANs on ports using tagged, untagged, or pvid.
Parameters: Raises: ValueError– invalid tagged type
-
delete_acl(ports=None, expression_ids=None, action_ids=None, rule_ids=None, acl_name=None)[source]¶ Delete ACLs.
Parameters: - ports (list[int]) – list of ports where ACLs will be deleted (mandatory).
- expression_ids (list[int]) – list of ACL expression IDs to be deleted (optional).
- action_ids (list[int]) – list of ACL action IDs to be deleted (optional).
- rule_ids (list[int]) – list of ACL rule IDs to be deleted (optional).
- acl_name (str) – ACL name
Returns: None
Example:
env.switch[1].ui.delete_acl(ports=[1, 2], rule_ids=[1, 2])
-
delete_lag_ports(ports, lag=None)[source]¶ Delete ports from created LAG.
Parameters: Returns: None
Examples:
env.switch[1].ui.delete_lag_ports([1, ], 3800)
Raises: UIEXception
-
delete_lags(lags=None)[source]¶ Delete lag groups.
Parameters: lags (iter() | str | list[str|int]) – list of lag IDs Raises: NotExistsErrorReturns: None
-
delete_match_api_rule(handle_id, table_id)[source]¶ Delete a match from the table using the method defined in maa.py.
Parameters:
-
delete_match_api_tcam_subtable(source_id, table_id=0, table_name=None)[source]¶ Destroy a sub-table of tcam using the method defined in maa.py.
Parameters:
-
delete_mirroring_session(port, target, mode)[source]¶ Delete mirroring session from the PortsMirroring table.
Parameters: Returns: None
Examples:
env.switch[1].ui.delete_mirroring_session(1, 2, 'Redirect')
Raises: SwitchException– not implemented
-
delete_multicast(port=None, vlan=None, mac=None)[source]¶ Delete StaticL2Multicast record.
Parameters: Returns: None
Examples:
env.switch[1].ui.delete_multicast(10, 5, '01:00:05:11:11:11')
Raises: SwitchException– not implemented
-
delete_ovs_bridge()[source]¶ Delete OVS Bridge.
Returns: None Examples:
env.switch[1].ui.delete_ovs_bridge()
Raises: SwitchException– not implemented
-
delete_ovs_flow_actions(bridge_id, table_id, flow_id, action, priority=2000)[source]¶ Delete row from OvsFlowActions table.
Parameters: Returns: None
Examples:
env.switch[1].ui.delete_ovs_flow_actions(0, 0, 1, 'Output')
Raises: SwitchException– not implemented
-
delete_ovs_flow_qualifiers(bridge_id, table_id, flow_id, field, priority=2000)[source]¶ Delete row from OvsFlowQualifiers table.
Parameters: Returns: None
Examples:
env.switch[1].ui.delete_ovs_flow_qualifiers(bridgeId, tableId, flowId, field)
Raises: SwitchException– not implemented
-
delete_ovs_flow_rules(bridge_id, table_id, flow_id, priority)[source]¶ Delete row from OvsFlowRules table.
Parameters: Returns: None
Examples:
env.switch[1].ui.delete_ovs_flow_rules(bridgeId, tableId, flowId, priority)
Raises: SwitchException– not implemented
-
delete_route_interface(vlan, ip, bandwith=1000, mtu=1500, vrf=0, mode='ip')[source]¶ Delete Route Interface.
Parameters: Returns: None
Examples:
env.switch[1].ui.delete_route_interface(10, '10.0.5.101/24', 1000, 1500, 0, 'ip') env.switch[1].ui.create_route_interface(10, '2000::01/96', 1000, 1500, 0, 'ipv6')
Raises: SwitchException– not implemented
-
delete_static_mac(port=None, mac=None, vlan=None)[source]¶ Removes static MAC entries from FDB table.
Parameters: Returns: None
Raises: NotExistsError
-
delete_static_route(network)[source]¶ Delete StaticRoute record.
Parameters: network (str) – RouteInterface network Returns: None Examples:
env.switch[1].ui.delete_static_route('10.0.5.101/24')
Raises: SwitchException– not implemented
-
delete_ufd_group(group_id)[source]¶ Delete UFDGroups record.
Parameters: group_id (int) – UFD group ID Returns: None Examples:
env.switch[1].ui.delete_ufd_group(2)
-
disable_lldp_on_device_ports(ports=None)[source]¶ Disable Lldp on device ports (if port=None Lldp should be disabled on all ports).
Parameters: ports (list[int]) – list of ports Returns: None Examples:
env.switch[1].ui.disable_lldp_on_device_ports()
-
enable_dcbx_tlv_transmission(ports, dcbx_tlvs='all', mode='Enabled')[source]¶ Enable/Disable the transmission of all Type-Length-Value messages.
Parameters: Returns: None
Examples:
env.switch[1].ui.enable_dcbx_tlv_transmission([1, 2], dcbx_tlvs="all", mode="Enabled")
Raises: SwitchException– not implemented
-
generate_port_name(port)[source]¶ Attempts to translate port in the port_map.
Parameters: port – int | str Raises: UIExceptionReturns: int | str
-
generate_port_name_mapping()[source]¶ Returns the device name (e.g. sw0p1), given a port number and vice versa.
-
get_acl_names()[source]¶ Get ACL names.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_acl_names()
-
get_available_switch_ports(ports=None)[source]¶ Check list of ports to see which are available.
Parameters: ports (list[int | str]) – list of port IDs Returns: list of port IDs that are available Return type: list[int | str]
-
get_cpu()[source]¶ Returns cpu utilization from switch.
Returns: cpu utilization from switch Return type: float
-
get_current_date(date_format='+%Y-%m-%d %T')[source]¶ Returns current date on device.
Parameters: date_format (str) – Date format to be returned Returns: Current date on device Return type: str
-
get_dhcp_client_lease_time(ports=None)[source]¶ Returns the lease time configured for the interfaces, will raise exception on any error.
Parameters: ports (list[int]) – List of port ids which denotes the switch interfaces Raises: SwitchException– no switch ports foundReturns: Dictionary with port id as key and lease time as value Return type: dict
-
get_dhcp_status(ps_name='dhcpd')[source]¶ Gets DHCP status.
Parameters: ps_name (str) – Service name Returns: Values ‘active’|’unknown’ Return type: str Steps:
-# Execute the command to get the status of "dhcpd" service -# Return the result
-
get_errdisable_ports(port=None, app_name=None, app_error=None, param=None)[source]¶ Get ErrdisablePorts table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_errdisable_ports()
Raises: SwitchException– not implemented
-
get_icmp_ping_result(ip_addr, ip_version, options='', timeout=None, expected_rcs=frozenset({0}))[source]¶ Return parsed result of ping command.
Parameters: Returns: a dictionary containing various statistics related to a ping command
Return type:
-
get_journalctl_log(date_since=None, date_until=None, boot_id='', additional_args='')[source]¶ Returns journalctl log.
Parameters: Returns: Generator of dicts of journalctl log
Return type: generator
-
get_memory(mem_type='usedMemory')[source]¶ Returns free cached/buffered memory from switch.
Parameters: mem_type (str) – memory type Returns: memory size Return type: float
-
get_mirroring_sessions()[source]¶ Get PortsMirroring table.
Returns: table (list of dictionaries) or value Return type: list[dict]|int|str Examples:
env.switch[1].ui.get_mirroring_sessions()
Raises: SwitchException– not implemented
-
get_port_configuration(port, **kwargs)[source]¶ Returns attribute value (int) for given port.
Parameters: - port (int | str) – port ID
- expected_rcs (int | set | list | frozenset) – expected return code
- **kwargs (dict) – Possible parameters: “getPortAttr”, “getPortStats”
Returns: port attribute value
Return type: int | str
Raises: AccessErrorSwitchException
-
get_port_configuration_snapshot(port, stats='attributes', skip_list=frozenset({0}))[source]¶ Get a list of port attributes and their values.
Parameters: Raises: SwitchExceptionReturns: dict
-
get_rules_match_api(table_id, handle_id=None)[source]¶ Lists the match api rules of the table using the method defined in maa.py
Parameters: Returns: list[dict]
-
get_table_acl(table=None, acl_name=None)[source]¶ Get ACL table.
Parameters: Returns: table (list of dictionaries)
Return type: Raises: UIException– Only ONP specific table is supportedExamples:
env.switch[1].ui.get_table_acl('ACLStatistics')
-
get_table_area_ranges()[source]¶ Get OSPFAreas2Ranges table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_area_ranges()
Raises: SwitchException– not implemented
-
get_table_arp(mode='arp')[source]¶ Getting ARP table.
Parameters: mode (str) – ARP table type, arp static | arp Returns: ARP table Return type: list[dict]
-
get_table_basic_statistics(port, stat_name=None)[source]¶ Returns a list of basic statistics found in /sys/class/net/.
Parameters: Returns: Statistics table or specific statistics value
Return type: dict | int
-
get_table_bgp_aggregate_address()[source]¶ Get BGPAggregateAddress table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_aggregate_address()
Raises: SwitchException– not implemented
-
get_table_bgp_confederation_peers()[source]¶ Get BGPBgpConfederationPeers table.
Returns: list[dict] table Examples:
env.switch[1].ui.get_table_bgp_confederation_peers()
Raises: SwitchException– not implemented
-
get_table_bgp_distance_admin()[source]¶ Get BGPDistanceAdmin table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_distance_admin()
Raises: SwitchException– not implemented
-
get_table_bgp_distance_network()[source]¶ Get BGPDistanceNetwork table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_distance_network()
Raises: SwitchException– not implemented
-
get_table_bgp_neighbor()[source]¶ Get BGPNeighbour table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_neighbor()
Raises: SwitchException– not implemented
-
get_table_bgp_neighbor_connections()[source]¶ Get BGPNeighborConnection table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_neighbor_connections()
Raises: SwitchException– not implemented
-
get_table_bgp_network()[source]¶ Get BGPNetwork table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_network()
Raises: SwitchException– not implemented
-
get_table_bgp_peer_group_members()[source]¶ Get BGPPeerGroupMembers table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_peer_group_members()
Raises: SwitchException– not implemented
-
get_table_bgp_peer_groups()[source]¶ Get BGPPeerGroups table
Returns: table Return type: list[dict] Example
env.switch[1].ui.get_table_bgp_peer_groups()
Raises: SwitchException– not implemented
-
get_table_bgp_redistribute()[source]¶ Get BGPRedistribute table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_bgp_redistribute()
Raises: SwitchException– not implemented
-
get_table_bridge_info(param=None, port=None)[source]¶ Retrieves switch properties organized under ONS 1.x.
Parameters: Raises: KeyError | UIException – port/management port info required
Returns: switch properties
Return type: str | int
-
get_table_dcbx_app_maps(table_type='Admin', port=None)[source]¶ Get DcbxAppMaps* table
Parameters: Returns: table (list of dictionaries)
Return type: Examples:
env.switch[1].ui.get_table_dcbx_app_maps("Admin", 1)
Raises: SwitchException– not implemented
-
get_table_dcbx_app_ports(port=None)[source]¶ Get DcbxAppPorts* table.
Parameters: Returns: table (list of dictionaries)
Return type: Examples:
env.switch[1].ui.get_table_dcbx_app_ports("Admin", 1)
Raises: SwitchException– not implemented
-
get_table_dcbx_app_remote(port=None)[source]¶ Get DcbxAppRemotes table.
Parameters: port (int) – port Id (optional) Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_dcbx_app_remote()
Raises: SwitchException– not implemented
-
get_table_dcbx_ets_ports(table_type='Admin', port=None)[source]¶ Get DcbxEtsPorts* table.
Parameters: Returns: table (list of dictionaries)
Return type: Examples:
env.switch[1].ui.get_table_dcbx_ets_ports()
Raises: SwitchException– not implemented
-
get_table_dcbx_pfc(table_type='Local', port=None)[source]¶ Get DcbxRemotes* table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_dcbx_pfc()
Raises: SwitchException– not implemented
-
get_table_dcbx_ports(port=None, param=None)[source]¶ Get DcbxPorts table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_dcbx_ports()
Raises: SwitchException– not implemented
-
get_table_dcbx_remotes(port=None, param=None)[source]¶ Get DcbxRemotes* table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_dcbx_remotes(1)
Raises: SwitchException– not implemented
-
get_table_dcrp_config(file_name='/etc/dcrpd.conf', options=None)[source]¶ Gets configuration from file.
Parameters: file_name (str) – File name Returns: DCRP configuration Steps:
-# Using sftp client open the config file in read only mode -# Return the contents of the file
-
get_table_dhcp_client_lease(file_name='/var/lib/dhcpd/dhcpd.leases')[source]¶ Gets data from a lease file.
Parameters: file_name (str) – File name Returns: dictionary or a particular key’s value based on the options provided Return type: dict Steps:
-# Using sftp client open the config file in read only mode -# Store the configurations in dictionary format -# Return the entire dictionary or a particular key's value based on the options provided
-
get_table_dhcp_config(file_name='/etc/dhcp/dhcpd.conf', options=None)[source]¶ Gets configuration from file.
Parameters: Returns: DHCP configuration
Return type: Steps:
-# Using sftp client open the config file in read only mode -# Store the configurations in dictionary format -# Return the entire dictionary or a particular key's value based on the options provided
-
get_table_dhcp_relay(dhcp_relay_ipv6=False)[source]¶ Return DhcpRelayAdmin or DhcpRelayV6Admin table
Parameters: dhcp_relay_ipv6 (bool) – is IPv6 config defined Returns: None Examples:
env.switch[1].ui.get_table_dhcp_relay(dhcp_relay_ipv6=False)
Raises: SwitchException– not implemented
-
get_table_dhcp_server_ip_list(pool=None)[source]¶ Gets configured range of ip address.
Parameters: pool (str) – “range” Returns: Range of ip address Return type: list Steps:
-# From server configuration file get the range -# Return the list
-
get_table_errdisable_config()[source]¶ Get ErrdisableConfig table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_errdisable_config()
Raises: SwitchException– not implemented
-
get_table_errdisable_errors_config(app_name=None, app_error=None)[source]¶ Get ErrdisableErrorsConfig table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_errdisable_errors_config()
Raises: SwitchException– not implemented
-
get_table_fdb(table='fdb')[source]¶ Getting FDB table.
Parameters: table (str) – FDB table type, static | dynamic | fdb Raises: UIException– invalid table nameReturns: FDB table Return type: list[dict]
-
get_table_igmp_snooping_global_admin(param=None)[source]¶ Get IGMPSnoopingGlobalAdmin table.
Parameters: param (str) – parameter name Returns: table (list of dictionaries) or value Return type: list[dict]|int|str Examples:
env.switch[1].ui.get_table_igmp_snooping_global_admin() env.switch[1].ui.get_table_igmp_snooping_global_admin('queryInterval')
Raises: SwitchException– not implemented
-
get_table_igmp_snooping_port_oper(port, param=None)[source]¶ Get IGMPSnoopingPortsOper table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_igmp_snooping_port_oper() env.switch[1].ui.get_table_igmp_snooping_port_oper('queryInterval')
Raises: SwitchException– not implemented
-
get_table_interface_authentication()[source]¶ Get OSPFInterfaceMD5Keys table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_interface_authentication()
Raises: SwitchException– not implemented
-
get_table_l2_multicast()[source]¶ Get L2Multicast table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_l2_multicast()
Raises: SwitchException– not implemented
-
get_table_lags()[source]¶ Get lag group information.
Note
we can also use networkctl lag command
Returns: list[dict]
-
get_table_lags_local(lag=None)[source]¶ Get LagsLocal table.
Parameters: lag (int) – LAG Id Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_lags_local() env.switch[1].ui.get_table_lags_local(3800)
-
get_table_lags_local_ports(lag=None, expected_rcs=frozenset({0}))[source]¶ Get Ports2LagLocal table.
Parameters: lag (int) – LAG Id Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_lags_local_ports() env.switch[1].ui.get_table_lags_local_ports(3800)
-
get_table_lags_remote(lag=None)[source]¶ Get LagsRemote table.
Parameters: lag (int) – LAG Id Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_lags_remote() env.switch[1].ui.get_table_lags_remote(3800)
Raises: SwitchException– not implemented
-
get_table_lags_remote_ports(lag=None)[source]¶ Get Ports2LagRemote table.
Parameters: lag (int) – LAG Id Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_lags_remote_ports() env.switch[1].ui.get_table_lags_remote_ports(lag=3800)
Raises: UIException– not implemented
-
get_table_link_aggregation()[source]¶ Get LinkAggregation table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_link_aggregation()
-
get_table_lldp(port=None)[source]¶ Get Lldp table.
Parameters: port (int) – port Id (optional) Returns: table (list of dictionaries) Return type: list[dict]|int|str Examples:
env.switch[1].ui.get_table_lldp()
-
get_table_lldp_ports(port=None, param=None)[source]¶ Get LldpPorts table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_lldp_ports(1)
Raises: SwitchException– not implemented
-
get_table_lldp_ports_stats(port=None, param=None)[source]¶ Get LldpPorts table statistics.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_lldp_ports_stats(1)
Raises: SwitchException– not implemented
-
get_table_lldp_remotes(port=None)[source]¶ Get LldpRemotes table.
Parameters: port (int) – port Id (optional) Returns: table (list of dictionaries) or value Return type: list[dict] Examples:
env.switch[1].ui.get_table_lldp_remotes(1)
Raises: SwitchException– not implemented
-
get_table_match_api(table_id=None)[source]¶ Lists the match api tables using the method defined in maa.py.
Parameters: table_id (int) – table ID Returns: list[dict]
-
get_table_mstp_ports(ports=None, instance=None)[source]¶ Get ‘MSTPPorts’ table.
Notes
Return all table or information about particular ports and STP instance.
Parameters: Returns: table (list of dictionaries)
Return type: Examples:
env.switch[1].ui.get_table_mstp_ports() env.switch[1].ui.get_table_mstp_ports([1, 2]) env.switch[1].ui.get_table_mstp_ports([1, 2], instance=3)
Raises: SwitchException– not implemented
-
get_table_network_2_area()[source]¶ Get OSPFNetworks2Area table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_network_2_area()
Raises: SwitchException– not implemented
-
get_table_ospf_area()[source]¶ Get OSPFAreas table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ospf_area()
Raises: SwitchException– not implemented
-
get_table_ospf_interface()[source]¶ Get OSPFInterface table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_interface_authentication()
Raises: SwitchException– not implemented
-
get_table_ospf_router()[source]¶ Get OSPFRouter table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ospf_router()
Raises: SwitchException– not implemented
-
get_table_ovs_bridges()[source]¶ Get OvsBridges table.
Returns: table (list of dictionaries)) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ovs_bridges()
Raises: SwitchException– not implemented
-
get_table_ovs_controllers()[source]¶ Get OvsControllers table.
Returns: table (list of dictionaries)) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ovs_controllers()
Raises: SwitchException– not implemented
-
get_table_ovs_flow_actions()[source]¶ Get OvsFlowActions table.
Returns: table (list of dictionaries)) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ovs_flow_actions()
Raises: SwitchException– not implemented
-
get_table_ovs_flow_qualifiers()[source]¶ Get OvsFlowQualifiers table.
Returns: table (list of dictionaries)) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ovs_flow_qualifiers()
Raises: SwitchException– not implemented
-
get_table_ovs_ports()[source]¶ Get OvsPorts table.
Returns: table (list of dictionaries)) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ovs_ports()
Raises: SwitchException– not implemented
-
get_table_ovs_rules()[source]¶ Get OvsFlowRules table.
Returns: table (list of dictionaries)) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ovs_rules()
Raises: SwitchException– not implemented
-
get_table_ports(ports=None, all_params=False, ip_addr=False)[source]¶ Returns the table ports dictionary.
Parameters: Raises: SwitchException– No switch ports foundReturns: ports table
Return type:
-
get_table_ports2lag()[source]¶ Retrieves ports to LAG information.
Note
We can also use networkctl lag command.
Returns: list[dict]
-
get_table_ports_dot1p2cos(port=None, rx_attr_flag=True)[source]¶ Get PortsDot1p2CoS table.
Parameters: - port (str|int) – port Id to get info about (‘All’ or port id)
- rx_attr_flag (bool) – whether get rx or tx attribute information
Returns: table (list of dictionaries)
Return type: Examples:
env.switch[1].ui.get_table_ports_dot1p2cos(1) env.switch[1].ui.get_table_ports_dot1p2cos('All')
Raises: SwitchException– not implemented
-
get_table_ports_dscp2cos()[source]¶ Get PortsDscp2CoS records.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ports_dscp2cos()
-
get_table_ports_qos_scheduling(port=None, indexes=None, **kwargs)[source]¶ Get PortsQoS scheduling information.
Parameters: Returns: table (list of dictionaries) or dictionary or param value
Return type: Raises: SwitchException– not implemented
-
get_table_qinq_customer_vlan_mapping()[source]¶ Get QinQCustomerVlanMapping table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_qinq_customer_vlan_mapping()
Raises: SwitchException– not implemented
-
get_table_qinq_ports(port=None, param=None)[source]¶ Get QinQPorts table.
Parameters: Returns: table (list of dictionaries) or value
Return type: Examples:
env.switch[1].ui.get_table_qinq_ports()
Raises: SwitchException– not implemented
-
get_table_qinq_provider_vlan_mapping()[source]¶ Get QinQProviderVlanMapping table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_qinq_provider_vlan_mapping()
Raises: SwitchException– not implemented
-
get_table_qinq_vlan_stacking()[source]¶ Get QinQVlanStacking table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_qinq_vlan_stacking()
Raises: SwitchException– not implemented
-
get_table_remotes_mgmt_addresses(port=None)[source]¶ Get LldpRemotesMgmtAddresses table.
Parameters: port (int) – port Id (optional) Returns: table (list of dictionaries) or value Return type: list[dict] Examples:
env.switch[1].ui.get_table_remotes_mgmt_addresses(1)
-
get_table_route(mode='ip')[source]¶ Get Route table.
Parameters: mode (str) – ‘ip’ or ‘ipv6’ Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_route()
Raises: SwitchException– not implemented
-
get_table_route_interface()[source]¶ Get RouteInterface table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_route_interface()
Raises: SwitchException– not implemented
-
get_table_route_redistribute()[source]¶ Get OSPFRouteRedistribute table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_route_redistribute()
Raises: SwitchException– not implemented
-
get_table_rstp_ports(ports=None)[source]¶ Get ‘MSTPPorts’ table.
Notes
Return all table or information about particular ports.
Parameters: ports (list) – list of ports. Returns: table (list of dictionaries) Return type: list(dict) Examples:
env.switch[1].ui.get_table_rstp_ports() env.switch[1].ui.get_table_rstp_ports([1, 2])
Raises: SwitchException– not implemented
-
get_table_spanning_tree()[source]¶ Get ‘SpanningTree’ table.
Returns: table (list of dictionaries) Return type: list(dict) Examples:
env.switch[1].ui.get_table_spanning_tree()
Raises: SwitchException– not implemented
-
get_table_spanning_tree_mst()[source]¶ Get ‘STPInstances’ table
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_spanning_tree_mst()
Raises: SwitchException– not implemented
-
get_table_static_route(mode='ip')[source]¶ Get StaticRoute table.
Parameters: mode (str) – ‘ip’ or ‘ipv6’ Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_static_route()
Raises: SwitchException– not implemented
-
get_table_statistics(port=None, stat_name=None)[source]¶ Returns port statistics via ethtool -S command.
Parameters: Raises: KeyError– invalid port IDReturns: Statistics table or specific statistics value
Return type: dict | str
-
get_table_tunnels_admin()[source]¶ Return TunnelsAdmin table.
Returns: table Return type: list[dict] Examples:
env.switch[1].ui.get_table_tunnels_admin()
Raises: SwitchException– not implemented
-
get_table_ufd_config()[source]¶ Get UFDConfig table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ufd_config()
Raises: SwitchException– not implemented
-
get_table_ufd_groups()[source]¶ Get UFDGroups table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ufd_groups()
Raises: SwitchException– not implemented
-
get_table_ufd_ports()[source]¶ Get UFDPorts2Groups table.
Returns: table (list of dictionaries) Return type: list[dict] Examples:
env.switch[1].ui.get_table_ufd_ports()
Raises: SwitchException– not implemented
-
get_temperature()[source]¶ Get temperature from Sensors table.
Returns: CPU temperature information (Sensors table) Return type: dict
-
get_ufd_networkctl_status(ports)[source]¶ Checking networkctl status.
Parameters: ports (list[int]) – ports to check networkctl status Returns: - Returns Port Status as Dictionary format for list of Ports with attribute
- as key and attribute value as value If Uplink port -> Returns Values for Keys {‘Carrier Bound By’, ‘Link File’, ‘Driver’, ‘MTU’, ‘Network File’, ‘State’, ‘Address’, ‘Type’} If Downlink port-> Returns Values for Keys {‘Carrier Bound To’, ‘Link File’, ‘Driver’, ‘MTU’, ‘Network File’, ‘State’, ‘Address’, ‘Type’}
Return type: dict
-
icmp_ping_request(ip_addr, ip_version, options='-c 4', timeout=None, expected_rcs=frozenset({0}))[source]¶ Execute ping command.
Parameters: Returns: str
-
import_hw_module(hw)[source]¶ Parameters: hw – Switch Returns: UiOnpssShell specific hardware module Return type: module
-
iputils_version(options='')[source]¶ Verify the versions of ping and ping6 in the iputils package.
Parameters: options (str) – options for the ping command Returns: str
-
is_port_switch_available(port)[source]¶ Check to see if the port has sysfs switch/ available
Raises: UiCmdExceptionReturns: bool
-
logs_add_message(level, message)[source]¶ Add message into device logs.
Parameters: Raises: SwitchException– not implemented
-
map_stat_name(generic_name)[source]¶ Returns actual counter name.
Parameters: generic_name (str) – counter Name Returns: str
-
modify_bridge_info(**kwargs)[source]¶ Used for mac aging time, maintained for ONS 1.x compatibility.
Raises: KeyError– cpu port is not defined
-
modify_dhcp_status(ps_name='dhcpd', operation='start')[source]¶ Changes DHCP status.
Parameters: Returns: Result of execution
Return type: Steps:
-# Execute the command to start/stop the "dhcpd" service -# Return the result
-
modify_dot1p_to_cos_mapping(ports, rx_attr_flag=False, **kwargs)[source]¶ Modify mapping of ingress VLAN priority to CoS per port or per switch (PortsDot1p2CoS mapping).
Parameters: Returns: None
Examples:
env.switch[1].ui.modify_dot1p_to_cos_mapping([1, ], dotp7CoS=6)
Raises: SwitchException– not implemented
-
modify_errdisable_config(interval=None)[source]¶ Configure ErrdisableConfig table.
Parameters: interval (int) – recovery interval Returns: None Examples:
env.switch[1].ui.modify_errdisable_config(10)
Raises: SwitchException– not implemented
-
modify_errdisable_errors_config(detect=None, recovery=None, app_name=None, app_error=None)[source]¶ Configure ErrdisableErrorsConfig table.
Parameters: Returns: None
Examples:
env.switch[1].ui.modify_errdisable_errors_config(detect="Enabled", app_name='L2UfdControlApp', app_error='ufd')
Raises: SwitchException– not implemented
-
modify_lags(lag, key=None, lag_type=None, hash_mode=None)[source]¶ Modify LagsAdmin table.
Parameters: Returns: None
Examples
env.switch[1].ui.modify_lags(lag=3800, lag_type=”Static”)
Raises: SwitchException– not implemented
-
modify_link_aggregation(globalenable=None, collectormaxdelay=None, globalhashmode=None, priority=None, lacpenable=None)[source]¶ Set the LAG hash mode attributes.
Parameters: globalhashmode (str) – hash mode attribute
-
modify_mstp_ports(ports, instance=0, **kwargs)[source]¶ Modify records in ‘MSTPPorts’ table.
Parameters: - ports (list) – list of ports.
- instance (int) – Instance number.
- **kwargs (dict) – Parameters to be modified. Parameters names should be the same as in XMLRPC nb.MSTPPorts.set.* calls “adminState” - change adminState; “portFast” - set portFast value; “rootGuard” - set rootGuard value; “bpduGuard” - set bpduGuard value; “autoEdgePort” - set autoEdgePort value; “adminPointToPointMAC” - set adminPointToPointMAC value; “externalCost” - set externalCost value; “internalCost” - set internalCost value.
Returns: None
Examples:
env.switch[1].ui.modify_mstp_ports([1, 2], instance=3, adminState='Enabled')
Raises: SwitchException– not implemented
-
modify_ports(ports, expected_rcs=frozenset({0}), **kwargs)[source]¶ Modifies settings on a list of ports.
Parameters: Raises: BoundaryErrorAccessError
Returns: None
-
modify_ports2lag(port, lag, priority=None, key=None, aggregation=None, lag_mode=None, timeout=None, synchronization=None, collecting=None, distributing=None, defaulting=None, expired=None, partner_system=None, partner_syspri=None, partner_number=None, partner_key=None, partner_pri=None)[source]¶ Modify Ports2LagAdmin table.
Parameters: - port (int) – LAG port
- lag (int) – LAG Id
- priority (int) – port priority
- key (int) – port key
- aggregation (str) – port aggregation (multiple or individual)
- lag_mode (str) – LAG mode (Passive or Active)
- timeout (str) – port timeout (Short or Long)
- synchronization (str) – port synchronization (True or False)
- collecting (str) – port collecting (True or False)
- distributing (str) – port distributing (True or False)
- defaulting (str) – port defaulting state (True or False)
- expired (str) – port expired state (True or False)
- partner_system (str) – partner LAG MAC address
- partner_syspri (int) – partner LAG priority
- partner_number (int) – partner port number
- partner_key (int) – partner port key
- partner_pri (int) – partner port priority
Returns: None
Examples:
env.switch[1].ui.modify_ports2lag(1, 3800, priority=100)
Raises: SwitchException– not implemented
-
modify_route_interface(vlan, ip, **kwargs)[source]¶ Modify Route Interface.
Parameters: Returns: None
Examples:
env.switch[1].ui.modify_route_interface(10, '10.0.5.101/24', adminMode='Disabled')
Raises: SwitchException– not implemented
-
modify_rstp_ports(ports, **kwargs)[source]¶ Modify records in ‘RSTPPorts’ table.
Parameters: - ports (list) – list of ports.
- **kwargs (dict) – Parameters to be modified. Parameters names should be the same as in XMLRPC nb.RSTPPorts.set.* calls “adminState” - change adminState; “portFast” - set portFast value; “rootGuard” - set rootGuard value; “bpduGuard” - set bpduGuard value; “autoEdgePort” - set autoEdgePort value; “adminPointToPointMAC” - set adminPointToPointMAC value; “cost” - set cost value.
Returns: None
Examples:
env.switch[1].ui.modify_rstp_ports([1, 2], adminState='Enabled')
Raises: SwitchException– not implemented
-
modify_ufd_group(group_id, threshold=None, enable=None)[source]¶ Modify UFDGroups record.
Parameters: Returns: None
Examples:
env.switch[1].ui.modify_ufd_group(1, enable='Disabled')
Raises: SwitchException– not implemented
-
modify_vlan_ports(ports=None, vlans=None, tagged='tagged')[source]¶ Changes vlan classification. Since no modify method exists in NOS, we need to delete the origin entry and re-add.
Parameters:
-
ntp_update()[source]¶ Update date and time stamp using NTP server.
Returns: status of operation (bool) or None if ntp_server not set Return type: bool | None
-
classmethod
parse_icmp_ping_result(ping_output)[source]¶ Parses the output of ping command.
Parameters: ping_output (str) – output of ping Returns: dict
-
classmethod
parse_ip_show_stats(input_lines)[source]¶ Returns list of IP statistics.
Parameters: input_lines (list[str]) – command output Returns: list of IP statistics Return type: dict
-
classmethod
parse_row_fdb(row, portid_map)[source]¶ Get parsed dictionary of fdb properties for devices in portid_map.
Parameters: - row (str) – FDB record
- portid_map (ChainMap) – port ID to port name mapping
Returns: FDB record in format {“portId”: portId, “macAddress”, macAddress, “vlanId”: vlanId, “type”: type}
Return type:
-
classmethod
parse_row_lag(row)[source]¶ Yield lag group information.
Will convert lagId to int for ONS 1.x compatibility.
Parameters: row (dict) – dict Returns: dict
-
classmethod
parse_row_ports2lag(row)[source]¶ Yield ports2lag group information.
Will convert lagId to int for ONS 1.x compatibility.
Parameters: row (dict) – dict Raises: ValueErrorReturns: dict
-
classmethod
parse_table_ports(ports_table)[source]¶ Returns generator of dictionaries of port properties.
Parameters: ports_table (list[str]) – port information Returns: generator of dicts of port properties Return type: generator
-
parse_table_vlan(vlan_table)[source]¶ Parses the vlan table. This needs to be a loop because previous the table is built based on previous entries.
Parameters: vlan_table (list[str] | iter()) – List of vlan raw output Returns: A dictionary containing the portId, vlanId, and tagged state for each vlan Return type: iter()
-
process_table_data(data, table_keys_mapping)[source]¶ Returns dictionary of items, given a table of elements.
Parameters: Returns: dict
-
remove_ufd_network_files(ports=None)[source]¶ Removing created ufd network files.
Parameters: ports (list[int]) – Device port lists for which the network files created
-
restart_networkd_service()[source]¶ Restarting systemd-networkd process.
Returns: True if result is none otherwise false Return type: bool Raises: UiCmdException– when restart fails
-
static
row_with_header(header, data)[source]¶ Returns dictionary per row of values for ‘ip show stats’.
Parameters: Returns: dictionary per row of values for ‘ip show stats’
Return type:
-
set_dcb_admin_mode(ports, mode='Enabled')[source]¶ Enable/Disable DCB on ports.
Parameters: Returns: None
Examples:
env.switch[1].ui.set_dcb_admin_mode([1, 2], "Enabled")
Raises: SwitchException– not implemented
-
set_flow_control_type(ports=None, control_type=None, tx_mode='normal', tc=None)[source]¶ Sets the flow control type.
Parameters:
-
start_dcrp_with_given_mesh_ports(mesh_ports=None, timeout=30, mlag_conf=None)[source]¶ Starts dcrp service with given mesh ports.
Parameters: Examples:
{'uplink_port': ['sw0p1', 'sw0p2' ], 'lag_mac': '00:55:ea:ea:ea:e1'}
-
start_ustack_with_given_mesh_ports(mesh_ports=(), dbglevel=0)[source]¶ Starts ustack mesh given ports.
Parameters: Raises: UIException– dbglevel is either 1 or 0Returns: ustack mesh command results
Return type:
-
test_point_connect()[source]¶ Connect to the device and start TestPointShared and switchdShared applications.
-
test_point_exec_command(command)[source]¶ Execute command in TestPointShared.
Parameters: command (str) – command in TestPointShared
-