ODL - 一條龍

前置

必須得搞搞odl了

安裝

環境

root@vpp-test:~# java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)
root@vpp-test:~# cat /etc/issue
Ubuntu 18.04.4 LTS \n \l
#odl
Magnesium-SR2

下載 https://docs.opendaylight.org/en/latest/downloads.html

安裝java

apt install openjdk-11-jre-headless

設置JAVA_HOME

編輯/etc/profile

export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/"

加載

root@vpp-test:~# source /etc/profile
root@vpp-test:~# echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64/

啓動

root@vpp-test:~/odl# tar zxvf opendaylight-0.12.2.tar.gz 
root@vpp-test:~/odl# cd opendaylight-0.12.2/
root@vpp-test:~/odl/opendaylight-0.12.2# ./bin/karaf 
Apache Karaf starting up. Press Enter to open the shell now...
100% [========================================================================]

Karaf started in 0s. Bundle stats: 13 active, 13 total
                                                                                           
    ________                       ________                .__  .__       .__     __       
    \_____  \ ______   ____   ____ \______ \ _____  ___.__.|  | |__| ____ |  |___/  |_     
     /   |   \\____ \_/ __ \ /    \ |    |  \\__  \<   |  ||  | |  |/ ___\|  |  \   __\    
    /    |    \  |_> >  ___/|   |  \|    `   \/ __ \\___  ||  |_|  / /_/  >   Y  \  |      
    \_______  /   __/ \___  >___|  /_______  (____  / ____||____/__\___  /|___|  /__|      
            \/|__|        \/     \/        \/     \/\/            /_____/      \/          
                                                                                           

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight.

opendaylight-user@root>                                                        

後臺啓動

./bin/start

控制檯

後臺啓動時怎麼登錄控制檯?

./bin/client

NETCONF設備

分兩種

模擬設備

模擬netconf設備有多種方式,這裏採用的是odl提供的netconf-testtool,文檔見這裏

下載testtool,我下載的是最新版,老版本的ODL需要注意下

https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/netconf/netconf-testtool

啓動

java -jar netconf-testtool-1.8.2-executable.jar

# 啓動情況如下
root@localhost:~/odljava -jar netconf-testtool-1.8.2-executable.jar 
10:42:59.373 [main] INFO  o.o.n.t.tool.NetconfDeviceSimulator - Starting 1, SSH simulated devices starting on port 17830
10:42:59.398 [main] INFO  o.o.n.t.tool.NetconfDeviceSimulator - Custom module loading skipped.
10:42:59.880 [main] INFO  o.o.n.t.tool.NetconfDeviceSimulator - using OperationsProvider.
10:42:59.978 [main] INFO  o.o.n.s.s.c.u.s.b.BouncyCastleSecurityProviderRegistrar - getOrCreateProvider(BC) created instance of org.bouncycastle.jce.provider.BouncyCastleProvider
10:42:59.980 [main] INFO  o.o.n.s.s.c.u.s.e.EdDSASecurityProviderRegistrar - getOrCreateProvider(EdDSA) created instance of org.opendaylight.netconf.shaded.eddsa.EdDSASecurityProvider
10:43:00.063 [main] WARN  io.netty.bootstrap.ServerBootstrap - Unknown channel option 'SO_BACKLOG' for channel '[id: 0x2c47b0bf]'
10:43:00.143 [main] INFO  o.o.n.t.tool.NetconfDeviceSimulator - All simulated devices started successfully from port 17830 to 17830

啓動後默認啓動了一個支持netconf的設備,默認端口17830

測試

ssh admin@localhost -p 17830 -s netconf

# 測試如下
root@localhost:~/odl/opendaylight-0.12.2/cache/schema# ssh root@localhost -p 17830 -s netconf
The authenticity of host '[localhost]:17830 ([127.0.0.1]:17830)' can't be established.
RSA key fingerprint is SHA256:+sqmaHkirjlLQdYJfKcYB677cMK2Hgdkq+9ZarwL/oY.
Are you sure you want to continue connecting (yes/no)? 

顯示以上信息,即netconf設備啓動成功。

具體綁定設備見下面

另外官網文檔說指定--distribution-folder就可自動綁定,但我測試未生效

java -jar netconf-testtool-1.8.2-executable.jar --device-count 2 --distribution-folder ~/odl/opendaylight-0.12.2/ --md-sal MD-SAL --debug DEBUG

實體設備

這裏叫實體設備,不太合適,也是由eve-ng模擬的。但其具備和實體設備一樣的功能,一樣的配置。

採用的是ios xr,具體安裝見這裏

安裝完後的拓撲見

綁定NETCONF設備

由於是開源的軟件,文檔更新速度,千百個草泥馬。按官網文檔從上到下是配置不成功的,新的架構已經改爲MD-SAL模式,故直接跳到這個地方

這裏很簡單,我覺得分2步

odl安裝feature

feature:install odl-restconf odl-netconf-connector-all odl-netconf-topology odl-netconf-console odl-mdsal-apidocs

其中

  • odl-restconf: 支撐的是北向restful的接口
  • odl-mdsal-apidocs: 提供API DOC, 通過web ui登錄
    • 地址:http://<odl-ip>:8181/apidoc/explorer/index.html
    • username: admin password: admin

啓用log

karaf shell界面執行

log:set TRACE org.opendaylight.controller.sal.connect.netconf

接入odl

node文件

<node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
  <node-id>new-netconf-device1</node-id>
  <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
  <port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
  <username xmlns="urn:opendaylight:netconf-node-topology">root</username>
  <password xmlns="urn:opendaylight:netconf-node-topology">xxx</password>
  <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
  <!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->
  <reconnect-on-changed-schema xmlns="urn:opendaylight:netconf-node-topology">false</reconnect-on-changed-schema>
  <connection-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">20000</connection-timeout-millis>
  <max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">0</max-connection-attempts>
  <between-attempts-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">2000</between-attempts-timeout-millis>
  <sleep-factor xmlns="urn:opendaylight:netconf-node-topology">1.5</sleep-factor>
  <!-- keepalive-delay set to 0 turns off keepalives-->
  <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>
</node>

以下接口調用的header指定如下,

Accept application/xml
Content-Type application/xml

添加node

這裏是put方法,多次提交是修改之前的,沒有node的話則新建,這裏注意

獲取看看

成功了!且我們能看到設備提供的netconf能力,這裏我摺疊了。

現在,mount點 yang-ext:mount 將可用於 CONFIG 和 Operational data store. URI這樣:/topology-netconf/node/{node name}/yang-ext:mount/

至此,設備綁定上了,亦或被ODL接管了。

刪除node

指定對應的node name,delete方法即可刪除

南向接口調用

創建YANG文件

進入odl的scheme目錄

cd ~/odl/opendaylight-0.12.2/cache/schema

創建yang model,這裏起了個簡單的

vim [email protected]

輸入下面內容 

module test {
    yang-version 1;
    namespace "urn:opendaylight:test";
    prefix "tt";

    revision "2014-10-17";


   container cont {

        leaf l {
            type string;
        }
   }
}

重啓ODL

system:shutdown

測試

注意這裏是POST方法

驗證,看下面已經推進去了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章