Netmiko 设备命令

本节包含交换机能够执行的命令的详细信息,以及为所选命令模块向交换机发送的 CLI 命令。

交换机

AristaEos:

设备名称:Arista EOS

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
name {network_name}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport mode access
switchport access vlan {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no switchport access vlan {segmentation_id}
no switchport mode trunk
switchport trunk allowed vlan none

SET_NATIVE_VLAN:

设置指定的本机 VLAN

interface {port}
switchport mode trunk
switchport trunk native vlan {segmentation_id}
switchport trunk allowed vlan add {segmentation_id}

DELETE_NATIVE_VLAN:

删除本机 VLAN

interface {port}
no switchport trunk native vlan {segmentation_id}
switchport trunk allowed vlan remove {segmentation_id}

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

interface {port}
switchport trunk allowed vlan add {segmentation_id}

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

interface {port}
switchport trunk allowed vlan remove {segmentation_id}

ArubaOSCX:

设备名称:ArubaOS-CX

端口可以被禁用:True

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
name {network_name}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
no routing
vlan access {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no vlan access {segmentation_id}

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

interface {port}
no routing
vlan trunk allowed {segmentation_id}

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

interface {port}
no vlan trunk allowed {segmentation_id}

ENABLE_PORT:

启用端口

interface {port}
no shutdown

DISABLE_PORT:

关闭端口

interface {port}
shutdown

BrocadeFastIron:

设备名称:Brocade ICX (FastIron)

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id} by port
name {network_name}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

vlan {segmentation_id} by port
untagged ether {port}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

vlan {segmentation_id} by port
no untagged ether {port}

QUERY_PORT:

显示该端口的交换机详细信息

show interfaces ether {port} | include VLAN

CiscoIos:

设备名称:Cisco IOS

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
name {network_name}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport mode access
switchport access vlan {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no switchport access vlan {segmentation_id}
no switchport mode trunk
switchport trunk allowed vlan none

SET_NATIVE_VLAN:

设置指定的本机 VLAN

interface {port}
switchport mode trunk
switchport trunk native vlan {segmentation_id}
switchport trunk allowed vlan add {segmentation_id}

DELETE_NATIVE_VLAN:

删除本机 VLAN

interface {port}
no switchport mode trunk
no switchport trunk native vlan {segmentation_id}
switchport trunk allowed vlan remove {segmentation_id}

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

interface {port}
switchport mode trunk
switchport trunk allowed vlan add {segmentation_id}

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

interface {port}
switchport trunk allowed vlan remove {segmentation_id}

CiscoNxOS:

设备名称:Cisco NX-OS (Nexus)

端口可以被禁用:True

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
name {network_name}
exit

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport mode access
switchport access vlan {segmentation_id}
exit

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no switchport access vlan
exit

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

interface {port}
switchport mode trunk
switchport trunk allowed vlan add {segmentation_id}
exit

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

interface {port}
switchport trunk allowed vlan remove {segmentation_id}
exit

ENABLE_PORT:

启用端口

interface {port}
no shutdown
exit

DISABLE_PORT:

关闭端口

interface {port}
shutdown
exit

Cisco300:

设备名称:Cisco 300-Series

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport mode access
switchport access vlan {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no switchport access vlan
switchport trunk allowed vlan remove all

Cumulus:

设备名称:Cumulus Linux (via NCLU)

端口可以被禁用:True

为 Cumulus 4.x 构建

注意,对于此交换机,您需要如下配置,其中 secret 是需要 sudo su 的密码

[genericswitch:<hostname>]
device_type = netmiko_cumulus
ip = <ip>
username = <username>
password = <password>
secret = <password for sudo>
ngs_physical_networks = physnet1
ngs_max_connections = 1
ngs_port_default_vlan = 123
ngs_disable_inactive_ports = False

NETMIKO_DEVICE_TYPE:

Netmiko 兼容的设备类型 linux

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

net add vlan {segmentation_id}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

net del vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

net add interface {port} bridge access {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

net del interface {port} bridge access {segmentation_id}

PLUG_BOND_TO_NETWORK:

将 bond 作为 VLAN 的端口添加到桥接

net add bond {bond} bridge access {segmentation_id}

UNPLUG_BOND_FROM_NETWORK:

删除 bond 的访问 VLAN 分配

net del bond {bond} bridge access {segmentation_id}

ENABLE_PORT:

启用端口

net del interface {port} link down

DISABLE_PORT:

关闭端口

net add interface {port} link down

ENABLE_BOND:

通过移除链路关闭状态来启用 bond 接口

net del bond {bond} link down

DISABLE_BOND:

通过将其链路状态设置为关闭来禁用 bond 接口

net add bond {bond} link down

SAVE_CONFIGURATION:

保存配置

net commit

ERROR_MSG_PATTERNS:

正则表达式元组。这些模式用于匹配和处理交换机返回的错误消息。

re.compile('ERROR: Command not found.')
re.compile('command not found')
re.compile('is not a physical interface on this switch')

CumulusNVUE:

设备名称:Cumulus Linux(via NVUE)

端口可以被禁用:True

为 Cumulus 5.x 构建

注意,对于此交换机,您需要如下配置,其中 secret 是需要 sudo su 的密码

[genericswitch:<hostname>]
device_type = netmiko_cumulus_nvue
ip = <ip>
username = <username>
password = <password>
secret = <password for sudo>
ngs_physical_networks = physnet1
ngs_max_connections = 1
ngs_port_default_vlan = 123
ngs_disable_inactive_ports = False

NETMIKO_DEVICE_TYPE:

Netmiko 兼容的设备类型 linux

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

nv set bridge domain br_default vlan {segmentation_id}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

nv unset bridge domain br_default vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

nv unset interface {port} bridge domain br_default untagged
nv set interface {port} bridge domain br_default access {segmentation_id}

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

nv unset interface {port} bridge domain br_default access
nv set interface {port} bridge domain br_default vlan {segmentation_id}

ADD_NETWORK_TO_BOND_TRUNK:

将 VLAN 添加到 bond 接口进行中继

nv unset interface {bond} bridge domain br_default access
nv set interface {bond} bridge domain br_default vlan {segmentation_id}

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

nv unset interface {port} bridge domain br_default vlan {segmentation_id}

DELETE_NETWORK_ON_BOND_TRUNK:

从 bond 接口删除 VLAN 进行中继

nv unset interface {bond} bridge domain br_default vlan {segmentation_id}

SET_NATIVE_VLAN:

设置指定的本机 VLAN

nv unset interface {port} bridge domain br_default access
nv set interface {port} bridge domain br_default untagged {segmentation_id}
nv set interface {port} bridge domain br_default vlan {segmentation_id}

SET_NATIVE_VLAN_BOND:

设置 bond 接口的本机 VLAN

nv unset interface {bond} bridge domain br_default access
nv set interface {bond} bridge domain br_default untagged {segmentation_id}
nv set interface {bond} bridge domain br_default vlan {segmentation_id}

DELETE_NATIVE_VLAN:

删除本机 VLAN

nv unset interface {port} bridge domain br_default untagged {segmentation_id}
nv unset interface {port} bridge domain br_default vlan {segmentation_id}

DELETE_NATIVE_VLAN_BOND:

取消设置 bond 接口的本机 VLAN

nv unset interface {bond} bridge domain br_default untagged {segmentation_id}
nv unset interface {bond} bridge domain br_default vlan {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

nv unset interface {port} bridge domain br_default access
nv unset interface {port} bridge domain br_default untagged
nv unset interface {port} bridge domain br_default vlan

ENABLE_PORT:

启用端口

nv set interface {port} link state up

DISABLE_PORT:

关闭端口

nv set interface {port} link state down

SAVE_CONFIGURATION:

保存配置

nv config save

ERROR_MSG_PATTERNS:

正则表达式元组。这些模式用于匹配和处理交换机返回的错误消息。

re.compile('Invalid config')
re.compile('Config invalid at')
re.compile('ERROR: Command not found.')
re.compile('command not found')
re.compile('is not a physical interface on this switch')
re.compile('Error: Invalid parameter')
re.compile('Unable to restart services')
re.compile('Failure during apply')

DellNos:

设备名称:Dell Force10 (OS9)(netmiko_dell_force10)

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

interface vlan {segmentation_id}
description {network_name}
exit

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no interface vlan {segmentation_id}
exit

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface vlan {segmentation_id}
untagged {port}
exit

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface vlan {segmentation_id}
no untagged {port}
exit

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

interface vlan {segmentation_id}
tagged {port}
exit

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

interface vlan {segmentation_id}
no tagged {port}
exit

DellOS10:

设备名称:Dell OS10 (netmiko_dell_os10)

端口可以被禁用:True

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

interface vlan {segmentation_id}
description {network_name}
exit

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

no interface vlan {segmentation_id}
exit

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport mode access
switchport access vlan {segmentation_id}
exit

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no switchport access vlan
exit

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

interface {port}
switchport mode trunk
switchport trunk allowed vlan {segmentation_id}
exit

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

interface {port}
no switchport trunk allowed vlan {segmentation_id}
exit

SET_NATIVE_VLAN:

设置指定的本机 VLAN

interface {port}
switchport mode trunk
switchport access vlan {segmentation_id}

DELETE_NATIVE_VLAN:

删除本机 VLAN

interface {port}
no switchport access vlan

ENABLE_PORT:

启用端口

interface {port}
no shutdown
exit

DISABLE_PORT:

关闭端口

interface {port}
shutdown
exit

ERROR_MSG_PATTERNS:

正则表达式元组。这些模式用于匹配和处理交换机返回的错误消息。


DellPowerConnect:

设备名称:Dell PowerConnect

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan database
vlan {segmentation_id}
exit

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

vlan database
no vlan {segmentation_id}
exit

PLUG_PORT_TO_NETWORK_GENERAL:

允许 VLAN 并使其承载未标记帧

interface {port}
switchport general allowed vlan add {segmentation_id} untagged
switchport general pvid {segmentation_id}
exit

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport access vlan {segmentation_id}
exit

DELETE_PORT_GENERAL:

从允许列表中删除 VLAN 并停止允许其承载未标记帧

interface {port}
switchport general allowed vlan remove {segmentation_id}
no switchport general pvid
exit

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
switchport access vlan none
exit

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

interface {port}
switchport general allowed vlan add {segmentation_id} tagged
exit

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

interface {port}
switchport general allowed vlan remove {segmentation_id}
exit

ERROR_MSG_PATTERNS:

正则表达式元组。这些模式用于匹配和处理交换机返回的错误消息。

re.compile('\% Incomplete command')
re.compile('VLAN was not created by user')
re.compile('Configuration Database locked by another application \- try later')
re.compile('Port is not in Layer-2 mode')

Fake:

用于假交换机的 Netmiko 设备驱动程序。

NETMIKO_DEVICE_TYPE:

Netmiko 兼容的设备类型 linux

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

add network {segmentation_id}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

delete network {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

plug port {port} to network {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

delete port {port}

ADD_NETWORK_TO_TRUNK:

将网络添加到中继端口。

add network {segmentation_id} to trunk {port}

REMOVE_NETWORK_FROM_TRUNK:

从中继端口删除网络。

remove network {segmentation_id} from trunk {port}

ENABLE_PORT:

启用端口

enable {port}

DISABLE_PORT:

关闭端口

disable {port}

ADD_SECURITY_GROUP:

开始定义安全组 (ACL)

add security group {security_group}

REMOVE_SECURITY_GROUP:

删除一个安全组

remove security group {security_group}

ADD_SECURITY_GROUP_RULE_INGRESS:

向安全组添加入站规则

add ingress security group {security_group} rule {protocol} source {remote_ip_prefix} port {port_range_min} to {port_range_max}

ADD_SECURITY_GROUP_RULE_EGRESS:

向安全组添加出站规则

add egress security group {security_group} rule {protocol} source {remote_ip_prefix} port {port_range_min} to {port_range_max}

BIND_SECURITY_GROUP:

将端口绑定到安全组

apply security group {security_group} to port {port}

UNBIND_SECURITY_GROUP:

将端口从安全组解绑

remove security group {security_group} from port {port}

ERROR_MSG_PATTERNS:

正则表达式元组。这些模式用于匹配和处理交换机返回的错误消息。


HpeComware:

设备名称:HPE 5900 系列交换机

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

undo vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
port link-type access
port access vlan {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
undo port access vlan

HpeComware:

设备名称:HPE 5900 系列交换机

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

undo vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
port link-type access
port access vlan {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
undo port access vlan

Huawei:

设备名称:Huawei (VRP V3 和 V5)

适用于华为网络操作系统 VRP V3 和 V5。

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

undo vlan {segmentation_id}

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
port link-type access
port default vlan {segmentation_id}

DELETE_PORT:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
undo port default vlan {segmentation_id}

Huawei:

设备名称:Huawei (VRP V8)

适用于华为下一代网络操作系统 VRP V8。

ADD_NETWORK:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
commit

DELETE_NETWORK:

用于删除 VLAN 的命令字符串元组

undo vlan {segmentation_id}
commit

PLUG_PORT_TO_NETWORK:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
port link-type access
port default vlan {segmentation_id}
commit

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
undo port default vlan {segmentation_id}
commit

Juniper:

设备名称: Juniper Junos OS

端口可以被禁用:True

添加网络:

用于添加 VLAN 的命令字符串元组

set vlans {network_name} vlan-id {segmentation_id}

删除网络:

用于删除 VLAN 的命令字符串元组

delete vlans {network_name}

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

delete interfaces {port} unit 0 family ethernet-switching vlan members
set interfaces {port} unit 0 family ethernet-switching vlan members {segmentation_id}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

delete interfaces {port} unit 0 family ethernet-switching vlan members

启用端口:

启用端口

delete interfaces {port} disable

禁用端口:

关闭端口

set interfaces {port} disable

将网络添加到Trunk:

将网络添加到中继端口。

set interfaces {port} unit 0 family ethernet-switching vlan members {segmentation_id}

从Trunk移除网络:

从中继端口删除网络。

delete interfaces {port} unit 0 family ethernet-switching vlan members {segmentation_id}

MellanoxMlnxOS:

设备名称: Mellanox MLNX-OS

添加网络:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
name {network_id}

删除网络:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface ethernet {port}
switchport mode access
switchport access vlan {segmentation_id}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

interface ethernet {port}
no switchport access vlan
no switchport mode

NokiaSRL:

设备名称: Nokia SR Linux OS

添加网络:

用于添加 VLAN 的命令字符串元组

set tunnel-interface vxlan0 vxlan-interface {segmentation_id} type bridged
set tunnel-interface vxlan0 vxlan-interface {segmentation_id} ingress vni {segmentation_id}
set tunnel-interface vxlan0 vxlan-interface {segmentation_id} egress source-ip use-system-ipv4-address
set network-instance mac-vrf-{segmentation_id} type mac-vrf
set network-instance mac-vrf-{segmentation_id} description OS-Network-ID-{network_name}
set network-instance mac-vrf-{segmentation_id} vxlan-interface vxlan0.{segmentation_id}
set network-instance mac-vrf-{segmentation_id} protocols bgp-evpn bgp-instance 1 vxlan-interface vxlan0.{segmentation_id}
set network-instance mac-vrf-{segmentation_id} protocols bgp-evpn bgp-instance 1 evi {segmentation_id}
set network-instance mac-vrf-{segmentation_id} protocols bgp-evpn bgp-instance 1 ecmp 8
set network-instance mac-vrf-{segmentation_id} protocols bgp-vpn bgp-instance 1 route-target export-rt target:1:{segmentation_id}
set network-instance mac-vrf-{segmentation_id} protocols bgp-vpn bgp-instance 1 route-target import-rt target:1:{segmentation_id}

删除网络:

用于删除 VLAN 的命令字符串元组

delete network-instance mac-vrf-{segmentation_id}
delete tunnel-interface vxlan0 vxlan-interface {segmentation_id}

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

set interface {port} subinterface {segmentation_id} type bridged
set network-instance mac-vrf-{segmentation_id} interface {port}.{segmentation_id}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

delete network-instance mac-vrf-{segmentation_id} interface {port}.{segmentation_id}
delete interface {port} subinterface {segmentation_id}

OvsLinux:

设备名称: OpenVSwitch

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

ovs-vsctl set port {port} vlan_mode=access
ovs-vsctl set port {port} tag={segmentation_id}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

ovs-vsctl clear port {port} tag
ovs-vsctl clear port {port} trunks
ovs-vsctl clear port {port} vlan_mode

设置Native VLAN:

设置指定的本机 VLAN

ovs-vsctl set port {port} vlan_mode=native-untagged
ovs-vsctl set port {port} tag={segmentation_id}
ovs-vsctl add port {port} trunks {segmentation_id}

删除Native VLAN:

删除本机 VLAN

ovs-vsctl clear port {port} vlan_mode
ovs-vsctl clear port {port} tag
ovs-vsctl remove port {port} trunks {segmentation_id}

设置Bond的Native VLAN:

设置 bond 接口的本机 VLAN

ovs-vsctl set port {bond} vlan_mode=native-untagged
ovs-vsctl set port {bond} tag={segmentation_id}
ovs-vsctl add port {bond} trunks {segmentation_id}

删除Bond的Native VLAN:

取消设置 bond 接口的本机 VLAN

ovs-vsctl clear port {bond} vlan_mode
ovs-vsctl clear port {bond} tag
ovs-vsctl remove port {bond} trunks {segmentation_id}

将网络添加到Trunk:

将网络添加到中继端口。

ovs-vsctl add port {port} trunks {segmentation_id}

从Trunk移除网络:

从中继端口删除网络。

ovs-vsctl remove port {port} trunks {segmentation_id}

将网络添加到Bond Trunk:

将 VLAN 添加到 bond 接口进行中继

ovs-vsctl add port {bond} trunks {segmentation_id}

在Bond Trunk上删除网络:

从 bond 接口删除 VLAN 进行中继

ovs-vsctl remove port {bond} trunks {segmentation_id}

Pluribus:

设备名称: Pluribus

添加网络:

用于添加 VLAN 的命令字符串元组

vlan-create id {segmentation_id} scope fabric ports none description {network_name} auto-vxlan

删除网络:

用于删除 VLAN 的命令字符串元组

vlan-delete id {segmentation_id}

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

vlan-port-remove vlan-range all ports {port}
port-vlan-add port {port} untagged-vlan {segmentation_id}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

vlan-port-remove vlan-range all ports {port}

Ruijie:

设备名称: Ruijie

添加网络:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
name {network_name}

删除网络:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport mode access
switchport access vlan {segmentation_id}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no switchport access vlan {segmentation_id}
no switchport mode trunk
switchport trunk allowed vlan none

Sonic:

设备名称: SONiC

为SONiC 3.x构建

注意,对于此交换机,您需要如下配置,其中 secret 是需要 sudo su 的密码

[genericswitch:<hostname>]
device_type = netmiko_sonic
ip = <ip>
username = <username>
password = <password>
secret = <password for sudo>
ngs_physical_networks = physnet1
ngs_max_connections = 1
ngs_port_default_vlan = 123
ngs_disable_inactive_ports = False

NETMIKO_DEVICE_TYPE:

Netmiko 兼容的设备类型 linux

添加网络:

用于添加 VLAN 的命令字符串元组

config vlan add {segmentation_id}

删除网络:

用于删除 VLAN 的命令字符串元组

config vlan del {segmentation_id}

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

config vlan member add -u {segmentation_id} {port}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

config vlan member del {segmentation_id} {port}

将网络添加到Trunk:

将网络添加到中继端口。

config vlan member add {segmentation_id} {port}

从Trunk移除网络:

从中继端口删除网络。

config vlan member del {segmentation_id} {port}

保存配置:

保存配置

config save -y

错误消息模式:

正则表达式元组。这些模式用于匹配和处理交换机返回的错误消息。

re.compile('VLAN[0-9]+ doesn\'t exist')
re.compile('Invalid Vlan Id , Valid Range : 1 to 4094')
re.compile('Interface name is invalid!!')
re.compile('No such command')

SupermicroSmis:

设备名称: Supermicro

一个代表Supermicro SMIS交换机的类。

添加网络:

用于添加 VLAN 的命令字符串元组

vlan {segmentation_id}
name {network_name}

删除网络:

用于删除 VLAN 的命令字符串元组

no vlan {segmentation_id}

将端口连接到网络:

用于配置端口连接到特定 VLAN 的命令字符串元组

interface {port}
switchport mode access
switchport access vlan {segmentation_id}

删除端口:

用于从 VLAN 中删除端口的命令字符串元组

interface {port}
no switchport access vlan {segmentation_id}
no switchport mode trunk
switchport trunk allowed vlan none