-
Notifications
You must be signed in to change notification settings - Fork 1
Unicorn Domain Server Northbound Spec (Draft)
The northbound API is based on the HTTP server-sent event extension.
When every unicorn server starts and finishes its bootstrap, it will send a registration request to the orchestrator. And the orchestrator will know that a new unicorn server is ready. Then the orchestrator can start an update stream connection immediately by using the update stream API.
GET /updates/ HTTP/1.1
Host: alto.example.com
Connection: keep-alive
Accept: text/event-stream
After sending the request, the orchestrator will return a URI for the related control stream API, keep the connection alive and wait for the unicorn server to send the query response from the SSE stream.
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/event-stream
event: application/updatestreamcontrol
data: {"control-uri": "http://alto.example.com/updates/streams/2718281828459"}
... Waiting for the control operation from the control stream ...
event: application/json
data: {"query-id": 123, “response”: [ "172.18.0.3", "172.18.0.4" ]}
The orchestrator can then send some control operations to the control-uri
which is returned by the initial event of the update stream.
POST /updates/streams/2718281828459 HTTP/1.1
Host: alto.example.com
Accept: text/event-stream,application/json
Content-Type: application/json
{
"action": "add",
"query-id": 123,
"query-type": "path-query",
"query-desc": [
{
"flow": {
"flow-id": 20,
"dst-ip": "192.168.1.100",
"src-ip": "192.168.2.100",
"dst-port": 54321,
"protocol": "tcp"
},
"ingress-point": ""
},
{
"flow": {
"flow-id": 10,
"dst-ip": "192.168.2.101",
"src-ip": "192.168.3.101",
"src-port": 1234,
"dst-port": 8080,
"protocol": "tcp"
},
"ingress-point": "172.17.0.2"
}
]
}
"$schema": http://json-schema.org/draft-06/schema#
properties:
action:
description: Action to manipulate queries
examples:
- add
id: "/properties/action"
title: The Action Schema.
type: string
enum
- add
- delete
- merge
- erase
- new
query-id:
type: integer
minimum: 0
example: 1
query-desc:
items:
properties:
flow:
properties:
flow-id:
description: The id of the flow
examples:
- 10
type: integer
minimum: 0
src-ip:
examples:
- 192.168.2.100
type: string
pattern: ^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|$
dst-ip:
examples:
- 192.168.1.100
type: string
pattern: ^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|$
dst-port:
examples:
- '54321'
type: integer
minimum: 0
protocol:
default: tcp
examples:
- tcp
type: string
enum:
- tcp
- udp
- sctp
type: object
required:
- flow-id
ingress-point:
default: ''
examples:
- "10.0.1.1"
type: string
pattern: ^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|$
type: object
required:
- flow
- ingress-point
type: array
query-type:
default: path-query
type: string
enum:
- path-query
- resource-query
type: object
required:
- action
- query-type
The unicorn server will return whether the control operation is successful.
Besides the unicorn server will return the query_id if the request ask for adding a query.
HTTP/1.1 200 OK
Content-Type: application/json
{
"query-id": "123456789",
"meta": {
"code": "success"
}
}
POST /deploys HTTP/1.1
Host: alto.example.com
Accept: text/event-stream,application/json
Content-Type: application/json
{
"src": "10.0.1.101",
"dst": "10.0.1.101"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"path": [
"10.0.1.101|openflow:6:3|openflow:5:3|openflow:1:1|openflow:2:1|openflow:3:1|10.0.1.201",
"10.0.1.201|openflow:3:3|openflow:2:3|openflow:1:2|openflow:5:1|openflow:6:1|10.0.1.101"
],
"error-code": "OK"
}