官术网_书友最值得收藏!

  • OpenDaylight Cookbook
  • Mathieu Lemay Alexis de Talhou?t Jamie Goodyear Rashmi Pujar Mohamed El Serngawy Yrineu Rodrigues
  • 630字
  • 2021-07-02 21:38:41

How to do it...

Perform the following steps:

  1. Start the OpenDaylight Karaf distribution using the karaf script. Using this script will give you access to the Karaf CLI:
$ ./bin/karaf 
  1. Install the user facing feature responsible for pulling in all dependencies needed to connect an NETCONF device:
opendaylight-user@root>feature:install odl-usc-channel-ui

It might take a minute or so to complete the installation.

  1. Start the USC agent and the echo server using a TCP session.

Open two terminal windows accessing this VM, then start the USC agent:

$ java -jar UscAgent.jar -t true 

Start the echo server:

$ java -jar EchoServer.jar -t true -p 2007 
  1. Create the channel using the following request. You will need the IP address of your VM, ${VM_IP_ADDRESS}:
  • Type: POST
  • Headers:

Authorization: Basic YWRtaW46YWRtaW4=

  • URL: http://localhost:8181/restconf/operations/usc-channel:add-channel
  • Payload:
{ 
"input":{
"channel":{
"hostname":"${VM_IP_ADDRESS}",
"port":2007,
"remote":false,
"tcp":true
}
}
}

If the request went fine, you will receive the following output:

{ 
"output": {
"result": "Succeed to connect device(${VM_IP_ADDRESS}:2007)!"
}
}
  1. View the created channel using either a REST call, or using the OpenDaylight DLUX component:

1. REST CALL: All the information written by the USC plugin is located under the usc topology, so we're reading the content contained in this topology:

  • Type: POST
  • Headers:

Authorization: Basic YWRtaW46YWRtaW4=

  • URL: http://localhost:8181/restconf/operations/usc-channel:view-channel
  • Payload:
{ 
"input":{
"topology-id":"usc"
}
}

This will return, among other information, a payload containing channel information such as its ID, composed of the hostname running OpenDaylight (inocybe.local), the VM IP address (192.168.2.26), and the type of protocol used to established the session (TLS). It also contains data regarding the session; this is the first created session, and we have zero written or read bytes:

"channel": [ 
{
"channel-id": "Controller:inocybe.local
-Device:192.168.2.26-type:TLS",
"channel-type": "TLS",
--[cut]--
"session": [
{
"session-id": "1",
"bytes-in": 0,
"bytes-out": 0,
"termination-point": {
"termination-point-id": "2007"
},
}
],
"destination": {
"dest-node": "192.168.2.26"
}
--[cut]--
}
]

2. Navigate to http://localhost:8181/index.html:

Log in using admin/admin. On the right, click the USC tab:

  1. Send a message through the channel. For this you will require the IP address of the VM running the USC agent, the port behind which the echo server is running, whether or not you're using TCP, and the message content:
  • Type: POST
  • Headers:

Authorization: Basic YWRtaW46YWRtaW4=

  • URL: http://localhost:8181/restconf/operations/usc-channel:send-message
  • Payload:
{ 
"input":{
"channel":{
"hostname":"192.168.2.26",
"port":"2007",
"tcp":"true",
"content":"This is a test message."
}
}
}

This request should return a message saying it worked. The return message here is going to be similar to the one sent, as we're using an echo server. Using your own device, you could define the return statement, and you could react as desired when receiving the message:

{ 
"output": {
"result": "Succeed to send request to device(192.168.2.26:2007),content is This is a test message."
}
}
  1. Look at the channel information again; we will now see the number of input and output bytes had increased. Use the same process as defined in step 5.

Here is the output for current session 1 for the channel. You can see the number of bytes has increased. It shows the bytes per session and for the whole channel:

"channel": [ 
{
"channel-id": "Controller:inocybe.local
-Device:192.168.2.26-type:TLS",
"source": {
"source-node": "inocybe.local"
},
"sessions": 1,
"channel-type": "TLS",
"call-home": "",
"channel-alarms": 0,
"session": [
{
"session-id": "1",
"bytes-in": 23,
"termination-point": {
"termination-point-id": "2007"
},
"session-alarms": 0,
"bytes-out": 23
}
],
"destination": {
"dest-node": "192.168.2.26"
},
"bytes-in": 23,
"bytes-out": 23
}
]
  1. Remove the session, cleaning up all the statistics:
  • Type: POST
  • Headers:

Authorization: Basic YWRtaW46YWRtaW4=

  • URL: http://localhost:8181/restconf/operations/usc-channel:remove-channel
  • Payload:
{ 
"input":{
"channel":{
"hostname":"192.168.2.26",
"port":"2007",
"tcp":"true"
}
}
}

This request will respond with a positive message saying the channel was successfully removed:

{ 
"output": {
"result": "Succeed to remove device(192.168.2.26:2007)!"
}
}

You can send the request seen at point 5; you will see the channel is still present, but the session was removed.

主站蜘蛛池模板: 崇阳县| 鄂托克前旗| 旌德县| 太康县| 普兰店市| 新巴尔虎右旗| 铜山县| 荥经县| 永新县| 西青区| 大新县| 炎陵县| 微博| 若尔盖县| 怀来县| 丹江口市| 西昌市| 黔南| 寿宁县| 玛多县| 洪泽县| 金门县| 龙里县| 泸水县| 沾益县| 仪陇县| 洛扎县| 曲阳县| 张掖市| 宁武县| 江陵县| 南丰县| 和林格尔县| 游戏| 东乡县| 吉林省| 横山县| 扶风县| 于都县| 杭锦后旗| 精河县|