OpenDayLight

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/iroy33/article/details/102648259

link参考教程

Fundamentals for OpenDaylight programming

Service Abstraction Layer (SAL)
搜索ubuntu 18.04 + OpenDayLight得到参考网页
在这里插入图片描述

/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

buntu@sdnhubvm:~[22:39]$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.
ubuntu@sdnhubvm:~[22:39]$ echo 'export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre' >> ~/.bashrc
ubuntu@sdnhubvm:~[22:40]$ source ~/.bashrc
ubuntu@sdnhubvm:~[22:40]$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre

Java接口:Java接口用于事件侦听,规范和形成模式。 这是特定捆绑软件实现事件回调功能并指示对特定状态的感知的主要方式。 许多界面都是使用YANG工具自动生成的。
Maven:OpenDayLight使用Maven简化了构建自动化。 Maven使用pom.xml(此捆绑包的项目对象模型)来编写捆绑包之间的依赖关系脚本,并描述开始时要加载的捆绑包。
OSGi:OpenDayLight后端的此框架允许动态加载捆绑包和打包的Jar文件,并将捆绑包绑定在一起以进行信息交换。
Karaf:Karaf是一个基于OSGi的小型运行时,它提供了一个轻量级的容器来加载不同的模块。

Maven and project building

Some basic understanding of maven is essential for working with OpenDaylight. Anytime you create a new project or module, or expand functionality of existing modules, you will have to appropriately upgrade the various pom.xml and feature.xml files.
wk,这个下载要半个多小时,这里网还那么慢orz
wk.20min左右崩溃了 9.47重新来

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] SDN Hub Tutorial project common properties ......... SUCCESS [  1.397 s]
[INFO] SDN Hub tutorial project common utils .............. SUCCESS [  1.713 s]
[INFO] learning-switch-parent ............................. SUCCESS [  0.031 s]
[INFO] SDN Hub tutorial project learning switch Impl ...... SUCCESS [  8.710 s]
[INFO] SDN Hub tutorial project Learning Switch Config .... SUCCESS [ 22.767 s]
[INFO] SDN Hub tutorial project Tap application Model ..... SUCCESS [  2.795 s]
[INFO] tapapp-parent ...................................... SUCCESS [  0.020 s]
[INFO] SDN Hub tutorial project Tap application Impl ...... SUCCESS [  7.540 s]
[INFO] SDN Hub tutorial Project Tap application Config .... SUCCESS [  0.060 s]
[INFO] SDN Hub tutorial project ACL application Model ..... SUCCESS [  0.510 s]
[INFO] acl-parent ......................................... SUCCESS [  0.018 s]
[INFO] SDN Hub tutorial project ACL application Impl ...... SUCCESS [  6.198 s]
[INFO] SDN Hub tutorial Project ACL application Config .... SUCCESS [  0.038 s]
[INFO] SDN Hub tutorial project Netconf exercise Model .... SUCCESS [  0.844 s]
[INFO] netconf-exercise-parent ............................ SUCCESS [  0.022 s]
[INFO] SDN Hub tutorial project Netconf exercise Impl ..... FAILURE [03:43 min]
[INFO] SDN Hub tutorial Project Netconf exercise Config ... SKIPPED
[INFO] SDN Hub tutorial project features .................. SKIPPED
[INFO] distribution-parent ................................ SKIPPED
[INFO] SDN Hub tutorial project Karaf branding ............ SKIPPED
[INFO] SDN Hub tutorial project distribution packaging .... SKIPPED
[INFO] main ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:37 min
[INFO] Finished at: 2019-10-20T19:47:42-07:00
[INFO] Final Memory: 86M/537M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project netconf-exercise-impl: Could not resolve dependencies for project org.sdnhub.odl.tutorial.netconf-exercise:netconf-exercise-impl:bundle:1.0.0-SNAPSHOT: The following artifacts could not be resolved: openexi:nagasena:jar:0000.0002.0053.0, openexi:nagasena-rta:jar:0000.0002.0053.0: Could not find artifact openexi:nagasena:jar:0000.0002.0053.0 in opendaylight-release (http://nexus.opendaylight.org/content/repositories/opendaylight.release/) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :netconf-exercise-impl
root@sdnhubvm:~/SDNHub_Opendaylight_Tutorial[19:47] (master)$ 
root@sdnhubvm:~/SDNHub_Opendaylight_Tutorial[20:13] (master)$ mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T04:57:37-07:00)
Maven home: /home/ubuntu/apache-maven-3.3.3
Java version: 1.8.0_222, vendor: Private Build
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-24-generic", arch: "amd64", family: "unix"

在这里插入图片描述
所有的答案都指向这个,但是不work???
我也apt-get update了,现在尝试upgrade,惴惴不安,还是不行
但是之前的sudo -s可以直接到root权限,但是现在要输密码了orz
变成和我笔记本上一样的了orz,这是因为忘记换目录了

root@sdnhubvm:~[20:50]$ mvn clean install -nsu
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.069s
[INFO] Finished at: Sun Oct 20 20:51:24 PDT 2019
[INFO] Final Memory: 5M/75M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/ubuntu). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

更新后全完犊子了orz

[INFO] Reactor Summary:
[INFO] 
[INFO] SDN Hub Tutorial project common properties ........ FAILURE [1.212s]
[INFO] SDN Hub tutorial project common utils ............. SKIPPED
[INFO] learning-switch-parent ............................ SKIPPED
[INFO] SDN Hub tutorial project learning switch Impl ..... SKIPPED
[INFO] SDN Hub tutorial project Learning Switch Config ... SKIPPED
[INFO] SDN Hub tutorial project Tap application Model .... SKIPPED
[INFO] tapapp-parent ..................................... SKIPPED
[INFO] SDN Hub tutorial project Tap application Impl ..... SKIPPED
[INFO] SDN Hub tutorial Project Tap application Config ... SKIPPED
[INFO] SDN Hub tutorial project ACL application Model .... SKIPPED
[INFO] acl-parent ........................................ SKIPPED
[INFO] SDN Hub tutorial project ACL application Impl ..... SKIPPED
[INFO] SDN Hub tutorial Project ACL application Config ... SKIPPED
[INFO] SDN Hub tutorial project Netconf exercise Model ... SKIPPED
[INFO] netconf-exercise-parent ........................... SKIPPED
[INFO] SDN Hub tutorial project Netconf exercise Impl .... SKIPPED
[INFO] SDN Hub tutorial Project Netconf exercise Config .. SKIPPED
[INFO] SDN Hub tutorial project features ................. SKIPPED
[INFO] distribution-parent ............................... SKIPPED
[INFO] SDN Hub tutorial project Karaf branding ........... SKIPPED
[INFO] SDN Hub tutorial project distribution packaging ... SKIPPED
[INFO] main .............................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.888s
[INFO] Finished at: Sun Oct 20 20:54:42 PDT 2019
[INFO] Final Memory: 29M/301M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4:enforce (enforce-maven) on project commons: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

换了一个VM继续试,待会重启试试,先跳过

WK 谁能告诉我发生了什么,我就

cd SDNHub_Opendaylight_Tutorial

mvn install -nsu

就成功了???那之前的虚拟机咋回事啊,明明一样的orz,好了,主战场变更至在这里插入图片描述

[INFO] Reactor Summary:
[INFO] 
[INFO] SDN Hub Tutorial project common properties ......... SUCCESS [  1.867 s]
[INFO] SDN Hub tutorial project common utils .............. SUCCESS [  2.155 s]
[INFO] learning-switch-parent ............................. SUCCESS [  0.064 s]
[INFO] SDN Hub tutorial project learning switch Impl ...... SUCCESS [  7.818 s]
[INFO] SDN Hub tutorial project Learning Switch Config .... SUCCESS [  0.477 s]
[INFO] SDN Hub tutorial project Tap application Model ..... SUCCESS [  1.990 s]
[INFO] tapapp-parent ...................................... SUCCESS [  0.013 s]
[INFO] SDN Hub tutorial project Tap application Impl ...... SUCCESS [  4.536 s]
[INFO] SDN Hub tutorial Project Tap application Config .... SUCCESS [  0.073 s]
[INFO] SDN Hub tutorial project features .................. SUCCESS [  2.618 s]
[INFO] distribution-parent ................................ SUCCESS [  0.029 s]
[INFO] SDN Hub tutorial project Karaf branding ............ SUCCESS [  0.170 s]
[INFO] SDN Hub tutorial project distribution packaging .... SUCCESS [ 44.478 s]
[INFO] main ............................................... SUCCESS [  0.198 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:09 min
[INFO] Finished at: 2019-10-20T20:56:57-07:00
[INFO] Final Memory: 93M/316M
[INFO] ------------------------------------------------------------------------

成功了但是在执行

Karaf and feature creation

We installed the following features. Click on each feature to learn more about it:

odl-restconf: Allows access to RESTCONF API
odl-l2switch-switch: Provides network functionality similar to an Ethernet switch
odl-mdsal-apidocs: Allows access to Yang API
odl-dlux-all: OpenDaylight graphical user interface

feature:install odl-restconf
feature:install odl-l2switch-switch
feature:install odl-mdsal-apidocs
feature:install odl-dlux-all

之后无法登陆127.0.0.1:8181/index.html,在另一台虚拟机里(build failure那台是可以成功登陆的)

在这里插入图片描述
之后回到run-location目录,

rm -r data
./bin/karaf clean

再重复安装
It works!
tap 会显示295条指令
在这里插入图片描述
在这里插入图片描述
“feature:list” and “bundle:list -s” are commands that will help with look at active features and bundles in the Karaf runtime environment. ‘x’ means the feature is loaded and active. Work “Active” means the module/bundle is running, while “Resolved” would mean that it has been stopped, and “Installed” means it is blocked on some missing dependency.

ubuntu@sdnhubvm:~/SDNHub_Opendaylight_Tutorial/features/src/main/resources[00:00] (master)$ cat features.xml #注意和tutorial上不一样不是feature

所有的app必须有 feature description for the karaf shell to load it.The feature.xml file is where we define it. For instance, the sdnhub-tutorial- tapapp feature that is autoloaded, has the following corresponding feature description in the feature.xml file:
在这里插入图片描述
The above feature description dictates that the installation of the sdnhub-tutorial-tapapp features requires us to load all the following. Even if one of them cannot be loaded, the feature hangs:

OpenFlow plugin,
MD-SAL data broker,
TapApp model,
TapApp implementation,
TapApp configuration for the config subsystem
If you create a new application, do not forget to include its description in the feature file.

mininet

在这里插入图片描述
eth0的那个口是okk的
sudo mn --topo linear,3 --mac --controller=remote,ip=10.0.2.15 ,port=6633 --switch ovs,protocols=OpenFlow13
OpenDayLight那是有相应的,但是会报错

  1. after add all feature needed by OpenDaylight (ODL) , you can check port listening of your ODL system with command :

#netstat -an | grep tcp

make sure you can see port TCP:8181 as port service to access web interface OpenDaylight, TCP:6633 and TCP:6653 (Port Service Communication for OpenFlow)
在这里插入图片描述
在这里插入图片描述

sudo mn --topo single,3 --mac --switch ovsk,protocols=OpenFlow13 --controller=remote,ip=10.0.2.15,port=6633

在topo里面只显示交换机,未显示host,在node里面可以看到
在这里插入图片描述
虽然它抛出异常,我也不知道异常在说什么,但是成功连接了,在我笔记本上的版本,mininet会显示connecting to IP:6653,但是集成的环境里面没有,感到不知所措orz

opendaylight-user@root>Exception in thread "Thread-79" java.lang.IllegalStateException: Expected state: HANDSHAKING, actual state:RIP
	at org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductorImpl.checkState(ConnectionConductorImpl.java:391)
	at org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductorImpl.onConnectionReady(ConnectionConductorImpl.java:453)
	at org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl$3.run(ConnectionAdapterImpl.java:472)
	at java.lang.Thread.run(Thread.java:745)
h1 ping h2

在我的环境下,不会出现ping不通的情况
在这里插入图片描述
好啦OVS的知识用到啦

mininet>sh ovs-vsctl show

要先指定sh模式运行
在这里插入图片描述
这样的指令也是可以的,但是我没看到效果就是了orz

s1 ovs-ofctl add-flow tcp:127.0.0.1:6634 -OOpenFlow13 priority=1,action=output:controller

为了看到效果,我们来dump-flows~
这样为什么不行!???? s1明明就是br!!!

mininet> s1 ovs-ofctl dump-flows s1
ovs-ofctl: 127.0.0.1 is not a bridge or a socket

这样子就不会否认s1是br了,我估计是namespace的原因?

 sh ovs-ofctl dump-flows s1
2019-10-21T08:33:07Z|00001|vconn|WARN|unix:/var/run/openvswitch/s1.mgmt: version negotiation failed (we support version 0x01, peer supports version 0x04)
ovs-ofctl: s1: failed to connect to socket (Broken pipe)

在启动属性中设置protocol=OpenFlow13,OpenFlow12,OpenFlow11之后

在这里插入图片描述 s1就没有成功建立起来

mininet> dpctl dump-flows

*** s1 ------------------------------------------------------------------------
ovs-ofctl: s1 is not a bridge or a socket

不用sh也可以,直接把它去掉

mininet> sh ovs-dpctl show

在这里插入图片描述

sh ovs-ofctl -O Openflow13 dump-flows s1

在这里插入图片描述
咳咳,好像是之前-O顺序放错了,应该放在dump-flows的前面

3 introduction to OpenDaylight architecture

在这里插入图片描述
The idea with building applications on the OpenDaylight platform is to leverage functionality in other platform bundles, each of which export important services through Java interfaces. Many of these services are build in a provider-consumer model over an adaptation layer called MD-SAL.
(service abstraction layer)
在这里插入图片描述
Programming in OpenDaylight involves adopting the Model-View-Control approach for SDN application development:

  • YANG Model for data, RPC and notifications
  • REST API view autogenerated and accessible through RESTconf
  • Java Implementation coded to handle data changes, notifications and RPC call backs

3.1 Model-driven SAL (MD-SAL)

Model-driven Service Adaptation Layer (MD-SAL), is the kernel of the platform where the different layers and modules are interconnected through well-defined API. Here are some important notes about MD-SAL:

  • Each API is generated from models defined in the YANG language during build time and loaded into the controller when the model bundle is loaded onto the Karaf platform.
  • At the core of the platform is a logically centralized data store that keeps relevant state in two buckets – 1) config data store, 2) operational data store.
  • All event calls and data go from “provider” to a “consumer” through this central datastore using MD-SAL mapping logic.

3.2 YANG model

remote procedure call (RPC)

OpenDaylight heavily uses YANG to model any data, notification or remote procedure call (RPC) that goes between different modules. For those unfamiliar with YANG, we recommend going over the YANG tutorial by Tail-F systems. In a nutshell, YANG is a language for describing the basic structure of some application data that is stored in a tree hierarchy within containers.

As an example, here is an excerpt of the YANG model for storing nodes (i.e., switches) and node-connectors (i.e., interfaces or ports) defined within opendaylight-inventory.yang:

module opendaylight-inventory {
    namespace "urn:opendaylight:inventory";
    container nodes {
        list node {
            key "id";
            leaf id {
                type node-id;
            }
            list "node-connector" {
                key "id";
                leaf id {
                    type node-connector-id;
                }
            }
        }
    }
}

Once this model is provided to the MD-SAL platform by appropriately including in the feature file and loading in Karaf, MD-SAL creates two data stores for this module: 1) Config data store, 2) Operational data store. The config data store is persisted by default across different runs of the controller (The config data store is stored in snapshots and journals directories in the karaf run location).

3.3 Instance identifiers

An application or external end-user can post data, either through MD-SAL transaction or RESTconf, to this data store. The individual objects are stored in a parent-child hierarchy and accessible through YANG instance identifiers. For the above YANG model, let’s say there is a node-connector “openflow:1:1” that is stored in the data store. One can access details of that node-connector by creating an instance identifier as follows:

InstanceIdentifier ncIID = InstanceIdentifier.builder(Nodes.class)
	.child(Node.class, new NodeKey(new NodeId("openflow:1")))
	.child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:1:1")))
	.build();

Or, it could be accessed through RESTconf by going to the URL http://localhost:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/node-connector/openflow:1:1, where the keyword “opendaylight-inventory” corresponds to the namespace of that module, and “nodes” corresponds to the container at the root level of the tree.

Useful tip: In case you are provided with an instance identifier, it is possible to extract the instance identifier or key of the parent objects by performing firstKeyOf() or firstIdentifierOf() as follows:

    InstanceIdentifier nodeIID = ncIID.firstIdentifierOf(Node.class);
    NodeId nodeId = ncIID.firstKeyOf(Node.class, NodeKey.class).getId();

3.4 Data store Transactions

3.6 Northbound and Southbound plugins

识时务者为俊杰,从3开始撤,感觉入门难度太高了,先去看user guide或者Ryu

在这里插入图片描述
单击左上角的Edit,在弹出的对话框中,勾选Start CLI,如图在这里插入图片描述
在这里插入图片描述
点击run之后在controller界面就可以看到啦

猜你喜欢

转载自blog.csdn.net/iroy33/article/details/102648259
今日推荐