Skip to content

This Python CLI script facilitates interaction with Mellanox switches via OpenFlow commands, allowing users to add, delete, view, and import rules, as well as issue custom commands through the Mellanox API.

License

Notifications You must be signed in to change notification settings

lovc21/MellanoxAPI_Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Mellanox simple API Script for Openflow

About

This Python script is a simple CLI that captures user input through Python console/CLI. It issues OpenFlow commands to the Mellanox switch using its API on your behalf, so you don't need to know the exact syntax of the commands.

The script issues OpenFlow commands for IPv4 and IPv6 or custom commands.

Running the script

python3 MellanoxScript.py

Usage

When prompted by the program, input your choice to the console:

  1. Adding IPv4 OpenFlow rule(s)
  2. Adding IPv6 OpenFlow rule(s)
  3. Adding a custom OpenFlow rule(s)
  4. Deleting specific rule(s)
  5. Deleting all rules
  6. Show current OpenFlow rules
  7. Import rules from a text file ; see the instructions below.
  8. Issue a custom CLI command

Text file input

When trying to import multiple rules from file, the file should be formatted as:

priority=<priority>|in_port=Eth1/<port>|actions=push_vlan:0x8100,set_field:6395->vlan_vid,output:52,output:54
priority=<priority>|in_port=Eth1/<port>|nw_src=1.1.1.1|actions=output:1,output:10
priority=<priority>|in_port=Eth1/<port>|ipv6_src=2001:2000::|actions=output:1,output:10

or more generally

|attribute=value|...|actions=set_field:6395->vlan_vid,output:52,output:54

About

This Python CLI script facilitates interaction with Mellanox switches via OpenFlow commands, allowing users to add, delete, view, and import rules, as well as issue custom commands through the Mellanox API.

Topics

Resources

License

Stars

Watchers

Forks

Languages