6. API for spp_mirror¶
6.1. GET /v1/mirrors/{client_id}¶
Get the information of the spp_mirror
process.
- Normal response codes: 200
- Error response codes: 400, 404
6.1.2. Request example¶
$ curl -X GET -H 'application/json' \
http://127.0.0.1:7777/v1/mirrors/1
6.1.3. Response¶
Name | Type | Description |
---|---|---|
client-id | integer | client id. |
ports | array | an array of port ids used by the process. |
components | array | an array of component objects in the process. |
Component objects:
Name | Type | Description |
---|---|---|
core | integer | core id running on the component |
name | string | an array of port ids used by the process. |
type | string | an array of component objects in the process. |
rx_port | array | an array of port objects connected to the rx side of the component. |
tx_port | array | an array of port objects connected to the tx side of the component. |
Port objects:
Name | Type | Description |
---|---|---|
port | string | port id. port id is the form {interface_type}:{interface_id}. |
6.1.4. Response example¶
{
"client-id": 1,
"ports": [
"phy:0", "phy:1", "ring:0", "ring:1", "ring:2"
],
"components": [
{
"core": 2,
"name": "mr0",
"type": "mirror",
"rx_port": [
{
"port": "ring:0"
}
],
"tx_port": [
{
"port": "ring:1"
},
{
"port": "ring:2"
}
]
},
{
"core": 3,
"type": "unuse"
}
]
}
The component which type is unused
is to indicate unused core.
6.1.5. Equivalent CLI command¶
spp > mirror {client_id}; status
6.2. POST /v1/mirrors/{client_id}/components¶
Start component.
- Normal response codes: 204
- Error response codes: 400, 404
6.2.2. Request (body)¶
Name | Type | Description |
---|---|---|
name | string | component name. must be unique in the process. |
core | integer | core id. |
type | string | component type. only mirror is available. |
6.2.3. Request example¶
$ curl -X POST -H 'application/json' \
-d '{"name": "mr1", "core": 12, "type": "mirror"}' \
http://127.0.0.1:7777/v1/mirrors/1/components
6.2.4. Response¶
There is no body content for the response of a successful POST
request.
6.2.5. Equivalent CLI command¶
spp > mirror {client_id}; component start {name} {core} {type}
6.3. DELETE /v1/mirrors/{client_id}/components/{name}¶
Stop component.
- Normal response codes: 204
- Error response codes: 400, 404
6.3.1. Request (path)¶
Name | Type | Description |
---|---|---|
client_id | integer | client id. |
name | string | component name. |
6.3.2. Request example¶
$ curl -X DELETE -H 'application/json' \
http://127.0.0.1:7777/v1/mirrors/1/components/mr1
6.3.3. Response¶
There is no body content for the response of a successful POST
request.
6.3.4. Equivalent CLI command¶
spp > mirror {client_id}; component stop {name}
6.4. PUT /v1/mirrors/{client_id}/components/{name}/ports¶
Add or delete port to the component.
- Normal response codes: 204
- Error response codes: 400, 404
6.4.1. Request (path)¶
Name | Type | Description |
---|---|---|
client_id | integer | client id. |
name | string | component name. |
6.4.2. Request (body)¶
Name | Type | Description |
---|---|---|
action | string | attach or detach . |
port | string | port id. port id is the form {interface_type}:{interface_id}. |
dir | string | rx or tx . |
6.4.3. Request example¶
Attach rx port of ring:1
to component named mr1
.
$ curl -X PUT -H 'application/json' \
-d '{"action": "attach", "port": "ring:1", "dir": "rx"}' \
http://127.0.0.1:7777/v1/mirrors/1/components/mr1/ports
Detach tx port of ring:1
from component named mr1
.
$ curl -X PUT -H 'application/json' \
-d '{"action": "detach", "port": "ring:0", "dir": "tx"}' \
http://127.0.0.1:7777/v1/mirrors/1/components/mr1/ports
6.4.4. Response¶
There is no body content for the response of a successful PUT
request.
6.4.5. Equivalent CLI command¶
Action is attach
.
spp > mirror {client_id}; port add {port} {dir} {name}
Action is detach
.
spp > mirror {client_id}; port del {port} {dir} {name}