当前位置:网站首页>Opendaylight analysis of SDN learning (5)
Opendaylight analysis of SDN learning (5)
2022-04-22 17:10:00 【Hengrui】
This section mainly talks about odl Of netconf application , Actually odl More is the use of openflow On the switch downstream table , Realize the real separation of control and forwarding , However, sometimes it doesn't happen . Many actual switches can not achieve real control separation , If you can, then the equipment will make a lot less profits , Therefore, a compromise control scheme for the switch is to use netconf Control the switch ,netconf It can be regarded as a communication protocol , The switch is usually in 830 Port from a server , Accept the request of the client and call , The communication data is xml Format , The client can be python Script , If you want to use odl, It's equivalent to putting odl To the south of plugin As a client , Communicate with the switch .
Let's first introduce netconf,netconf It's based on XML Network configuration management protocol . Users can use this mechanism to increase 、 modify 、 Delete the configuration of the network device , Get the configuration and status information of network devices .NETCONF Connection oriented , The operation and control are realized by remote procedure call . use XML As the encoding method of configuration data and protocol message content ; Good scalability , Manufacturers can define their own protocol operations , To achieve unique functions ,netconf At the bottom is the establishment of ssh Connect , At the top layer, data interaction is used to obtain configuration , Or modify the machine configuration , Or finish nofication Notification, etc .

netconf Use simple based on RPC(Remote Procedure Call) Mechanism to realize the communication between client and server . The client can be a script or an application running on the network management . Server is a typical network device .NETCONF A central computer running network management software is provided ( Network management workstation ) To remotely manage and monitor equipment .
NETCONF The protocol divides data into configuration data and status data , And provide different operations for data addition, deletion, modification and query . The configuration data (configuration data) It is the data for configuring network devices , For example, create VLAN The data of . Configuration data is generally readable and writable . Status data (state data) It is the data reflecting the equipment status , For example, the up/down state , Message statistics, etc . Status data is generally read-only . There will be multiple databases , For example, for running , Or loaded at startup .

Client and server call rpc There is a process of interaction , First, you need to send hello message, Confirmation ability 
netconf The call operation layer is only hosted in <rpc> and <rpc-reply> On the news ,<hello> and <notification> Message has no operation layer . NETCONF The agreement provides for 9 It's a simple rpc operation , It also supports user-defined rpc operation . Let's put the content of custom actions in the content layer . The open but normative content layer is netconf The essence of the agreement . Its openness is reflected in netconf The protocol itself does not limit the data structure of the content layer . And its specification is reflected in its content layer need to use Yang Language models its data . The content layer does not specify a specific model structure , Instead, it specifies a modeling language –yang. That is to say, use yang Defined data model , Can be used as netconf The content layer of . So the extension is right netconf In other words, it is constantly increasing and modifying yang The file" . In the operation mentioned above netcon User defined operation is supported . In other words, we don't have to worry about standard setting 9 Is each operation type enough , According to the actual needs in yang The corresponding rpc operation .

Say again odl Inside netconf application development , The first step is to get the of the switch yang file ,yang The file is equivalent to the tree data in the switch , stay odl Inside is under the mount node datastore Save inside , As shown in the figure vlan Of yang Model
container vlan {
description
"VLAN management.";
container vlans {
description
"VLAN list.";
list vlan {
key "vlanId";
max-elements "4094";
description
"VLAN information.";
leaf vlanId {
type vlanId {
range "1..4094";
}
description
"VLAN ID.";
}
leaf vlanName {
type string {
length "1..31";
}
must "not(../vlanType='carrier' or ../vlanType='fcoe')";
description
"VLAN name.";
ext:allowDelete "true";
}
leaf vlanDesc {
type string {
length "1..80";
}
must "not(../vlanType='carrier' or ../vlanType='fcoe')";
description
"VLAN description.";
ext:allowDelete "true";
}
leaf vlanType {
type vlanType;
must "((../vlanType='common' or ../vlanType='super' or ../vlanType='principal') ) or (../vlanType='common' and (../vlanType='common' or ../vlanType='super' or ../vlanType='principal') ) or (../vlanType='group' and (../vlanType='common' or ../vlanType='group') ) or (../vlanType='principal' and (../vlanType='common' or ../vlanType='principal') ) or (../vlanType='seperate' and (../vlanType='common' or ../vlanType='seperate') ) or (../vlanType='sub' and (../vlanType='common' or ../vlanType='sub') ) or (../vlanType='super' and (../vlanType='common' or ../vlanType='super') ) or not(../vlanType!='common' and ../vlanType!='super' and ../vlanType!='sub' and ../vlanType!='principal' and ../vlanType!='group' and ../vlanType!='seperate' or ../vlanType='common' or ../vlanType='group' or ../vlanType='principal' or ../vlanType='seperate' or ../vlanType='sub' or ../vlanType='super')";
default "common";
description
"VLAN type, such as common VLANs, super VLANs, and sub-VLANs. ";
}
utilize yang File by yangtools Generate data nodes java file , Thus, the... Under the equipment node is constructed datasore data , The first is when the equipment is connected , Get mountPoint:
final Optional<MountPoint> deviceNodeOptional=mountService.getMountPoint(NetconfIidFactory.netconfNodeIid(deviceId));
deviceId yes connect device Set up device id, And then use it mountPoint Get datastore:
Preconditions.checkArgument(deviceNodeOptional.isPresent(),
"Unable to locate mountpoint: %s, not mounted yet or not configured", deviceId);
final MountPoint deviceNode = deviceNodeOptional.get();
// Get the DataBroker for the mounted node
final DataBroker deviceNodeBroker = deviceNode.getService(DataBroker.class).get();
And then the operations datastore The data in it , For example, to get all the information in the switch vlan Configuration of , It's reading datastore Data in node
final ReadOnlyTransaction deviceNodeReadTx = deviceNodeBroker.newReadOnlyTransaction();
InstanceIdentifier<Vlans> idn = InstanceIdentifier.create(
org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.vlan.rev181123.Vlan.class)
.child(Vlans.class);
Optional<Vlans> ldn;
try {
ldn=deviceNodeReadTx.read(LogicalDatastoreType.OPERATIONAL,idn).checkedGet();
} catch (ReadFailedException e) {
throw new IllegalStateException("Unexpected error reading data from " + deviceId, e);
}
conversely , To configure vlan Data is written using datastore To achieve :
final WriteTransaction deviceNodeWriteTx = deviceNodeBroker.newWriteOnlyTransaction();
try {
deviceNodeWriteTx.put(LogicalDatastoreType.CONFIGURATION, idn, data);
FluentFuture<? extends @NonNull CommitInfo> future = deviceNodeWriteTx.commit();
future.get(5000, TimeUnit.MILLISECONDS);
}catch (TimeoutException e){
return RpcResultBuilder.<ConfigVlanOutput>failed()
.withResult(new ConfigVlanOutputBuilder().setResult(e.getMessage())).buildFuture();
} catch (Exception e) {
return RpcResultBuilder.<ConfigVlanOutput>failed()
.withResult(new ConfigVlanOutputBuilder().setResult(e.getMessage())).buildFuture();
}
as for odl Internal implementation principle , It can be understood as the internal setting datastore The monitor for , When data changes , Initiate right mount node Of netconf signal communication , And yes odl netconf You can refer to the following :
ODL Netconf MountPoint And its cluster mode implementation
https://www.sdnlab.com/22981.html
ODL Netconf The underlying connection mechanism is implemented
https://www.sdnlab.com/22997.html
Use Docker Container building ODL colony
https://www.sdnlab.com/22554.html
ODL Netconf The underlying connection mechanism is implemented
版权声明
本文为[Hengrui]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221648468049.html
边栏推荐
猜你喜欢

Cognitive series 4: Notes on cognitive breakthrough

swagger Authorization测试

The most expensive new shares in 2022 are coming. Xiaomi and Huawei earn 10 times

2022年环境影响评价工程师考试技术导则与标准练习题及答案

Redis(16) -- Redis集群
![[Golang]力扣Leetcode - 657. 机器人能否返回原点(模拟)](/img/b1/035c907253739a3e8c68b5934fd4e0.png)
[Golang]力扣Leetcode - 657. 机器人能否返回原点(模拟)

openstack利用devstack安装,安装之后dashboard报错Internal Server Error

SDN学习之Opendaylight浅析(一)

How does glboalmapper20 convert hundreds of longitude and latitude projected images into national 2000 or other projected images at one time

Detailed explanation of kubernetes (VII) -- service object deployment and Application
随机推荐
leetcode:451. 根据字符出现频率排序
小熊电器的三重压力:扩张、存货和对手
How to select ECS
2022年环境影响评价工程师考试技术导则与标准练习题及答案
查看论文是否被SCI检索
leetcode:451. Sort by character frequency
js 获取汉字首字符
Leetcode problem brushing plan -- monotonic sequence
20220421 hardware imaging
Practice questions and answers of evaluation technical methods in 2022 environmental impact assessment engineer examination
sudo:抱歉,您必须拥有一个终端来执行 sudo
运维自动化之ansible--(playbook模式)
写LeetCode发现的一些神奇语句
15 ContentProvider
20220420 推理框架解析 什么是梯度
GlobalMapper20 如何批量的把shp转为kml并带上属性
Redis基本数据学习记录(一)
2022最贵新股来了,小米、华为小赚10倍
leetcode:23. Merge K ascending linked lists
Respectful and modest