REST API services in Floodlight (Device)
Introduction
- Device的API主要分成兩類,回傳符合條件的Device或是Entity
- Entity是一個包含MAC、VLAN、IPV4型態,用來代表網路中最基本的一個元件
- Device可以包含很多個Entity,每個Device除了會有多個Entity外,還會有所謂的AttachmentPoint。AttachmentPoint會紀錄該Device是與哪個Switch的哪個Port相連
- 一般情況下, Device與Entity是1:1的關係,但是某些情況下,可能一個Device會擁有多個AttachmentPoint、多個IP address或是相同的MAC address擁有不同的VLAN TAG,在此情況下就會有一個Device擁有多個Entity。
API
- /wm/device/ : 回傳Devices
- Method: GET
- Parameter: 這邊都是過慮的條件,只有符合這些條件的device才會被選出來。如果什麼參數都沒有,預設就是所有device。
- mac : device的mac address
- vlan : device的vlan tag
- ipv4 : device的ipv4 address
- dpid : 這個device所連接到的switch的dpid
- port : 這個device是連接到該switch的哪個port
- mac_startwith : 以下的參數都如同上面的概念,只不過上面的是要完整符合,這邊的是開頭符合就好
- vlan_startwith :
- ipv4_startwith :
- dpid_startwith :
- port_startwith :
- Code:
- DeviceRoutable.java
- AbstractDeviceResource.java
- DeviceResource.java
- DeviceSerializer.java
- Example:
+ curl -s http://localhost:8080/wm/device/?ipv4_startwith=10 | python -mjson.tool
- curl -s http://localhost:8080/wm/device/| python -mjson.tool
- curl -s http://localhost:8080/wm/device/?ipv4=10.0.0.2 | python -mjson.tool
[
{
"attachmentPoint": [
{
"errorStatus": null,
"port": 2,
"switchDPID": "00:00:00:00:00:00:00:03"
}
],
"entityClass": "DefaultEntityClass",
"ipv4": [
"10.0.0.2"
],
"lastSeen": 1408555008093,
"mac": [
"00:00:00:00:00:02"
],
"vlan": []
}
]
- /wm/device/debug : 回傳Entities
- Method: GET
- Parameter: 沒有參數,就回傳所有的Entity。
- Code:
- DeviceRoutable.java
- AbstractDeviceResource.jave
- DeviceEntityResource.java
- Example:
+ curl -s http://localhost:8080/wm/device/debug | python -mjson.tool
[
[
{
"activeSince": 1408555008106,
"ipv4Address": null,
"lastSeenTimestamp": 1408555008106,
"macAddress": "00:00:00:00:00:01",
"switchDPID": "00:00:00:00:00:00:00:02",
"switchPort": 2,
"vlan": null
},
{
"activeSince": 1408555007885,
"ipv4Address": "10.0.0.1",
"lastSeenTimestamp": 1408555007885,
"macAddress": "00:00:00:00:00:01",
"switchDPID": "00:00:00:00:00:00:00:02",
"switchPort": 2,
"vlan": null
}
],
[
{
"activeSince": 1408555008093,
"ipv4Address": "10.0.0.2",
"lastSeenTimestamp": 1408555008093,
"macAddress": "00:00:00:00:00:02",
"switchDPID": "00:00:00:00:00:00:00:03",
"switchPort": 2,
"vlan": null
}
]
]