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

  • 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.

主站蜘蛛池模板: 叶城县| 玉林市| 丹凤县| 耒阳市| 南川市| 柳江县| 和政县| 霍城县| 富蕴县| 和硕县| 昌黎县| 灌南县| 确山县| 梧州市| 叙永县| 汉源县| 琼结县| 青神县| 大余县| 井冈山市| 平湖市| 新余市| 金乡县| 乐平市| 晋城| 比如县| 竹溪县| 阿克| 开阳县| 台州市| 仁怀市| 揭西县| 微山县| 镇坪县| 鱼台县| 咸丰县| 安达市| 宝鸡市| 金华市| 临清市| 商南县|