Introduction
# Python examples use the python-jsonrpc library
# (https://pypi.python.org/pypi/python-jsonrpc)
import urllib2
import cookielib
import pyjsonrpc
jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
urllib2.install_opener(opener)
client = pyjsonrpc.HttpClient("http://mgmt-addr/jsonrpc")
Authentication
login
>>> client.login(username="admin", password="admin")
True
// Request
{
"method": "login",
"params": {
"username":"admin",
"password":"admin"
},
"id": 1
}
// Response
{
"result": true,
"id": 1
}
Authenticate as a user for the current session. Return true if the credentials are valid, error otherwise.
Parameters
Object containing the username and password as strings.
Field | Type | Description |
---|---|---|
username | string | Username to log in as |
password | string | Password for user |
logout
// Request
{
"method": "logout",
"id": 1
}
// Response
{
"result": true,
"id": 1
}
>>> client.logout()
True
Log out of the current session.
Parameters
None
whoami
// Request
{
"method": "whoami",
"id": 1
}
// Response
{
"result": "admin"
"id": 1
}
>>> client.whoami()
u'admin'
Returns the username of the current session.
Parameters
None
Result
Username of the logged in user.
Interfaces
get_interface
// Request
{
"method": "get_interface",
"params": "ethernet1/1"
}
// Response
{
"result": [
{
"interface": "ethernet1/1",
"data_rate": "10000",
"data_rates": ["1000","10000"],
"link_generation": true,
"rx_link": false,
"counters": {
"rx_frames": 0,
"rx_bytes": 0,
"rx_errors": 0,
"rx_unicast": 0,
"rx_multicast": 0,
"rx_broadcast": 0,
"rx_runt": 0,
"rx_pause": 0,
"rx_64b": 0,
"rx_65_127b": 0,
"rx_128_255b": 0,
"rx_256_511b": 0,
"rx_512_1023b": 0,
"rx_1024_1518b": 0,
"rx_1519_1522b": 0,
"tx_frames": 0,
"tx_bytes": 0,
"tx_errors": 0,
"tx_unicast": 0,
"tx_multicast": 0,
"tx_broadcast": 0,
"tx_64b": 0,
"tx_65_127b": 0,
"tx_128_255b": 0,
"tx_256_511b": 0,
"tx_512_1023b": 0,
"tx_1024_1518b": 0,
"tx_1519_1522b": 0
},
"lldp": {
"neighbors": []
},
"port": "ethernet1",
"port_lane": [1],
"transceiver": {
"module_type": "QSFP-DD",
"management_spec": "CMIS",
"applications": [
{
"host_interface_code": 11,
"media_interface_code": 9,
"host_lane_count": 8,
"media_lane_count": 8,
"host_lane_assignment": [1],
"media_lane_assignment": [1]
},
{
"host_interface_code": 11,
"media_interface_code": 9,
"host_lane_count": 4,
"media_lane_count": 4,
"host_lane_assignment": [1,5],
"media_lane_assignment":[1,5]
},
{
"host_interface_code": 5,
"media_interface_code": 3,
"host_lane_count": 1,
"media_lane_count": 1,
"host_lane_assignment": [1,2,3,4,5,6,7,8],
"media_lane_assignment": [1,2,3,4,5,6,7,8]
}
],
"vendor_oui": [100,63,95],
"vendor_name": "EXABLAZE",
"vendor_pn": "EXADDSR8",
"vendor_rev": "01",
"vendor_sn": "WTZSRIA0064",
"date_code": "190103",
"clei_code":"",
"power_class": 2,
"max_power": 3.5,
"length": 0,
"connector_type_code": 39,
"connector_type": "Unknown (0x27)",
"attenuation_5ghz": 0,
"attenuation_7ghz": 0,
"attenuation_12ghz9": 0,
"attenuation_25ghz8": 0,
"media_interface_tech_code": 0,
"media_interface_tech": "850 nm VCSEL",
"wavelength": 850,
"wavelength_tolerance": 10,
"implemented": {
"tx_polarity_flip": true,
"tx_disable": true,
"tx_squelch_disable": false,
"tx_force_squelch": false,
"tx_squelch_oma": false,
"tx_squelch_pave": false,
"tunable_transmitter": false,
"wavelength_control": false,
"rx_polarity_flip": true,
"rx_disable": true,
"rx_squelch_disable": true,
"tx_fault": true,
"tx_los": true,
"tx_cdr_lol": true,
"rx_los": true,
"rx_cdr_lol": true,
"temperature": true,
"voltage": true,
"tx_bias": true,
"tx_power": true,
"rx_power": true
},
"diagnostics": {
"temperature": 43.765625,
"voltage": -3.251,
"tx_fault": [false,false,false,false,false,false,false,false],
"tx_los": [false,false,false,false,false,false,false,false],
"rx_los": [true,true,true,true,true,true,true,true],
"tx_power": [1.0410,0.9805,1.0326,1.0814,1.0087,1.0625,1.0898,1.0752],
"tx_bias": [5.832,5.838,5.83,5.838,5.83,5.836,5.832,5.838],
"rx_power": [0.0001,0.0001,0.0001,0.0001,0.0001,0.0001,0.0001,0.0001]
}
}
}
]
}
Get status information about one or more interfaces.
Parameters
A list of interface names as an array of strings. If no parameters are provided, information is returned for all ports.
Result
An array of objects with the fields described below.
Basic interface information, valid for all interface types:
Field | Type | Description |
---|---|---|
interface | string | Interface name |
description | string | Interface description, omitted if empty |
enable | boolean | False if the interface is disabled, omitted otherwise |
Breakout information, valid for breakout capable interfaces only:
Field | Type | Description |
---|---|---|
breakout_mode | string | Current breakout mode |
breakout_modes | string | Supported breakout modes |
Information about available real interfaces (excluding interfaces that are not available because they have been broken out):
Field | Type | Description |
---|---|---|
data_rate | string | Configured data rate |
data_rates | array | Supported data rates |
rx_link | boolean | Rx link status |
counters | object | Interface counters |
lldp | object | LLDP remote systems information |
Physical interface information, including interfaces that have been broken out:
Field | Type | Description |
---|---|---|
port | string | Front panel port that this interface belongs to |
port_lane | array | Lanes of the front panel port used by this interface |
transceiver | object | SFP/QSFP/QSFP-DD transceiver information, omitted if transceiver not present |
Layer 1 configuration for this interface. These fields are omitted if the setting does not apply.
Field | Type | Description |
---|---|---|
link_generation | boolean | True if link generation is enabled |
patch | array | Patches that this interface belongs to |
tap | array | Taps that this interface belongs to |
get_interface_breakout_capability
Get supported breakout modes for one or more interfaces.
get_interface_capability
Get supported speeds for one or more interfaces.
get_interface_list
Get the list of all interfaces.
If an interface has been broken out, it will not be included in this list, but the breakout interfaces will be in the list.
get_port_list
Get the list of all physical ports on the device.
set_interface_breakout
Configure the breakout mode of an interface.
set_interface_data_rate
Configure the speed of an interface.
set_interface_description
Set the description field on an interface.
Patches and Taps
create_patch
// Request
{
"method": "create_patch",
"params": [ "ethernet1/1", "ethernet2/1" ],
"id": 1
}
// Response
{
"result": true,
"id": 1
}
>>> client.create_patch("ethernet1/1","ethernet2/1")
True
Create a new patch between two interfaces.
create_tap
// Request
{
"method": "create_tap",
"params": {
"output": "ethernet1/1",
"source": "ethernet2/1",
"direction": "output"
},
"id": 1
}
// Response
{
"result": true,
"id": 1
}
>>> client.create_tap(output="ethernet1/1", source="ethernet2/1", direction="output")
True
Create a tap on an interface.
A tap replicates data flow at layer 1 and sends it out another interface. The data flow on the tapped interface is not disturbed.
Field | Type | Description |
---|---|---|
output | string | Output interface |
source | string | Interface to be tapped |
direction | string | Direction of the tap, either input or output |
delete_patch
// Request
{
"method": "delete_patch",
"params": [ "ethernet1/1", "ethernet2/1" ],
"id": 1
}
// Response
{
"result": true,
"id": 1
}
>>> client.delete_patch("ethernet1/1","ethernet2/1")
True
Remove an existing patch between two interfaces.
delete_tap
// Request
{
"method": "delete_tap",
"params": {
"output": "ethernet1/1",
"source": "ethernet2/1",
"direction": "output"
},
"id": 1
}
// Response
{
"result": true,
"id": 1
}
>>> client.delete_tap(output="ethernet1/1", source="ethernet2/1", direction="output")
True
Remove an existing tap on an interface.
Field | Type | Description |
---|---|---|
output | string | Output interface |
source | string | Tapped interface |
direction | string | Direction of the tap, either input or output |
get_patch
// Request
{
"method": "get_patch",
"id": 1
}
// Response
{
"result": [
[ "ethernet1/1", "ethernet2/1" ]
],
"id": 1
}
>>> client.get_patch()
[[u'ethernet1/1', u'ethernet2/1']]
Get the list of currently configured patches.
get_tap
// Request
{
"method": "get_tap",
"id": 1
}
// Response
{
"result": [
{
"output": "ethernet1/1",
"source": "ethernet2/1",
"direction": "output"
}
],
"id": 1
}
>>> client.get_tap()
[{u'output': u'ethernet1/1', u'direction': u'output', u'source': u'ethernet2/1'}]
Get the list of currently configured taps.