mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 10:21:52 +02:00
[ONOS-6199] Huawei driver create and instance delete.
Change-Id: I61e1a8518e9bd2a1a5ed9430052a3e6d3233f148
This commit is contained in:
parent
176905a665
commit
f7060cdb24
@ -17,6 +17,8 @@
|
||||
package org.onosproject.l3vpn.netl3vpn;
|
||||
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.behaviour.L3vpnConfig;
|
||||
import org.onosproject.net.driver.DriverHandler;
|
||||
import org.onosproject.net.driver.DriverService;
|
||||
import org.onosproject.yang.model.ModelObjectData;
|
||||
|
||||
@ -156,8 +158,8 @@ public class DeviceInfo {
|
||||
*/
|
||||
public ModelObjectData processCreateInstance(DriverService driverSvc,
|
||||
ModelObjectData modelData) {
|
||||
// TODO: Need to call the behaviour.
|
||||
return null;
|
||||
L3vpnConfig config = getL3VpnConfig(driverSvc);
|
||||
return (ModelObjectData) config.createInstance(modelData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,8 +173,8 @@ public class DeviceInfo {
|
||||
*/
|
||||
public ModelObjectData processCreateInterface(DriverService driverSvc,
|
||||
ModelObjectData modData) {
|
||||
// TODO: Need to call the behaviour.
|
||||
return null;
|
||||
L3vpnConfig config = getL3VpnConfig(driverSvc);
|
||||
return (ModelObjectData) config.bindInterface(modData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,8 +190,8 @@ public class DeviceInfo {
|
||||
public ModelObjectData processCreateBgpInfo(DriverService driverSvc,
|
||||
BgpInfo bgpInfo,
|
||||
BgpDriverInfo driverInfo) {
|
||||
// TODO: Need to call the behaviour.
|
||||
return null;
|
||||
L3vpnConfig config = getL3VpnConfig(driverSvc);
|
||||
return (ModelObjectData) config.createBgpInfo(bgpInfo, driverInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,9 +204,9 @@ public class DeviceInfo {
|
||||
* @return driver instance model object data
|
||||
*/
|
||||
public ModelObjectData processDeleteInstance(DriverService driverSvc,
|
||||
ModelObjectData modData) {
|
||||
// TODO: Need to call the behaviour.
|
||||
return null;
|
||||
ModelObjectData modData) {
|
||||
L3vpnConfig config = getL3VpnConfig(driverSvc);
|
||||
return (ModelObjectData) config.deleteInstance(modData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,7 +219,7 @@ public class DeviceInfo {
|
||||
* @return driver interface model object data
|
||||
*/
|
||||
public ModelObjectData processDeleteInterface(DriverService driverSvc,
|
||||
ModelObjectData objectData) {
|
||||
ModelObjectData objectData) {
|
||||
// TODO: Need to call the behaviour.
|
||||
return null;
|
||||
}
|
||||
@ -233,9 +235,20 @@ public class DeviceInfo {
|
||||
* @return driver BGP model object data
|
||||
*/
|
||||
public ModelObjectData processDeleteBgpInfo(DriverService driverSvc,
|
||||
BgpInfo bgpInfo,
|
||||
BgpDriverInfo driverInfo) {
|
||||
BgpInfo bgpInfo,
|
||||
BgpDriverInfo driverInfo) {
|
||||
// TODO: Need to call the behaviour.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the L3VPN config instance from the behaviour.
|
||||
*
|
||||
* @param driverSvc driver service
|
||||
* @return L3VPN config
|
||||
*/
|
||||
private L3vpnConfig getL3VpnConfig(DriverService driverSvc) {
|
||||
DriverHandler handler = driverSvc.createHandler(deviceId);
|
||||
return handler.behaviour(L3vpnConfig.class);
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,6 @@ import static org.onosproject.yang.runtime.helperutils.YangApacheUtils.getYangMo
|
||||
|
||||
/**
|
||||
* The IETF net l3vpn manager implementation.
|
||||
* // TODO: Implementation of the manager class.
|
||||
*/
|
||||
@Component(immediate = true)
|
||||
public class NetL3vpnManager {
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.net.behaviour;
|
||||
|
||||
import org.onosproject.net.driver.HandlerBehaviour;
|
||||
|
||||
/**
|
||||
* Behaviour for handling various drivers for l3vpn configurations.
|
||||
*/
|
||||
public interface L3vpnConfig extends HandlerBehaviour {
|
||||
|
||||
/**
|
||||
* Create virtual routing forwarding instance on requested device with
|
||||
* given standard device model object data.
|
||||
*
|
||||
* @param objectData standard device model object data
|
||||
* @return device model object data
|
||||
*/
|
||||
Object createInstance(Object objectData);
|
||||
|
||||
/**
|
||||
* Binds requested virtual routing forwarding instance to interface on the
|
||||
* requested device with given standard device model object data.
|
||||
*
|
||||
* @param objectData standard device model object data
|
||||
* @return device model object data
|
||||
*/
|
||||
Object bindInterface(Object objectData);
|
||||
|
||||
/**
|
||||
* Deletes virtual routing forwarding instance on requested device with
|
||||
* given standard device model object data.
|
||||
*
|
||||
* @param objectData standard device model object data
|
||||
* @return device model object data
|
||||
*/
|
||||
Object deleteInstance(Object objectData);
|
||||
|
||||
/**
|
||||
* Unbinds requested virtual routing forwarding instance to interface on the
|
||||
* requested device with given standard device model object data.
|
||||
*
|
||||
* @param objectData standard device model object data
|
||||
* @return device model object data
|
||||
*/
|
||||
Object unbindInterface(Object objectData);
|
||||
|
||||
/**
|
||||
* Creates BGP routing protocol info on requested device with given
|
||||
* BGP info object.
|
||||
*
|
||||
* @param bgpInfo BGP info object
|
||||
* @param bgpConfig BGP driver config
|
||||
* @return device model object data
|
||||
*/
|
||||
Object createBgpInfo(Object bgpInfo, Object bgpConfig);
|
||||
|
||||
/**
|
||||
* Deletes BGP routing protocol info on requested device with given
|
||||
* BGP info object.
|
||||
*
|
||||
* @param bgpInfo BGP info object
|
||||
* @param bgpConfig BGP driver config
|
||||
* @return device model object data
|
||||
*/
|
||||
Object deleteBgpInfo(Object bgpInfo, Object bgpConfig);
|
||||
}
|
16
drivers/huawei/BUCK
Normal file
16
drivers/huawei/BUCK
Normal file
@ -0,0 +1,16 @@
|
||||
BUNDLES = [
|
||||
'//drivers/huawei/yangmodel:onos-drivers-huawei-yangmodel',
|
||||
'//drivers/huawei/driver:onos-drivers-huawei-driver',
|
||||
]
|
||||
|
||||
onos_app(
|
||||
app_name = 'org.onosproject.drivers.huawei',
|
||||
title = 'Huawei Device Drivers',
|
||||
category = 'Drivers',
|
||||
url = 'http://onosproject.org',
|
||||
description = 'ONOS Huawei Device Drivers application.',
|
||||
included_bundles = BUNDLES,
|
||||
required_apps = [
|
||||
'org.onosproject.netconf'
|
||||
],
|
||||
)
|
25
drivers/huawei/driver/BUCK
Normal file
25
drivers/huawei/driver/BUCK
Normal file
@ -0,0 +1,25 @@
|
||||
COMPILE_DEPS = [
|
||||
'//lib:CORE_DEPS',
|
||||
'//lib:org.apache.servicemix.bundles.dom4j',
|
||||
'//apps/l3vpn/yangmodel:onos-apps-l3vpn-yangmodel',
|
||||
'//drivers/utilities:onos-drivers-utilities',
|
||||
'//protocols/netconf/api:onos-protocols-netconf-api',
|
||||
'//apps/l3vpn/netl3vpn:onos-apps-l3vpn-netl3vpn',
|
||||
'//drivers/huawei/yangmodel:onos-drivers-huawei-yangmodel',
|
||||
'//apps/config:onos-apps-config',
|
||||
'//lib:onos-yang-model',
|
||||
'//lib:onos-yang-runtime',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
'//lib:TEST_ADAPTERS',
|
||||
'//utils/osgi:onlab-osgi-tests',
|
||||
]
|
||||
|
||||
osgi_jar_with_tests(
|
||||
name = 'onos-drivers-huawei-driver',
|
||||
deps = COMPILE_DEPS,
|
||||
test_deps = TEST_DEPS,
|
||||
resources_root = 'src/main/resources',
|
||||
resources = glob(['src/main/resources/**']),
|
||||
)
|
90
drivers/huawei/driver/pom.xml
Normal file
90
drivers/huawei/driver/pom.xml
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2017-present Open Networking Laboratory
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<parent>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-drivers-huawei</artifactId>
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>onos-drivers-huawei-driver</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<description>Huawei driver implementation</description>
|
||||
<properties>
|
||||
<yang-tool-version>1.12.0-b7</yang-tool-version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-drivers-utilities</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-app-l3vpn-netl3vpn</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-app-l3vpn-yangmodel</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-yang-model</artifactId>
|
||||
<version>${yang-tool-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-drivers-huawei-yangmodel</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-netconf-api</artifactId>
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-app-yang</artifactId>
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.servicemix.bundles</groupId>
|
||||
<artifactId>org.apache.servicemix.bundles.dom4j</artifactId>
|
||||
<version>1.6.1_5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,319 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import org.onosproject.l3vpn.netl3vpn.BgpDriverInfo;
|
||||
import org.onosproject.l3vpn.netl3vpn.BgpInfo;
|
||||
import org.onosproject.l3vpn.netl3vpn.BgpModelIdLevel;
|
||||
import org.onosproject.l3vpn.netl3vpn.ProtocolInfo;
|
||||
import org.onosproject.l3vpn.netl3vpn.RouteProtocol;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.DefaultDevices;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.Devices;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.DefaultDevice;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.Device;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.DeviceKeys;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.Bgp;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.DefaultBgp;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.Bgpcomm;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.DefaultBgpcomm;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.BgpVrfs;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.DefaultBgpVrfs;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.BgpVrf;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.DefaultBgpVrf;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.BgpVrfAfs;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.DefaultBgpVrfAfs;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.BgpVrfAf;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.DefaultBgpVrfAf;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.DefaultImportRoutes;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.ImportRoutes;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.importroutes.DefaultImportRoute;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.importroutes.ImportRoute;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.BgpcommImRouteProtocol;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum;
|
||||
import org.onosproject.yang.model.InnerModelObject;
|
||||
import org.onosproject.yang.model.ModelObjectData;
|
||||
import org.onosproject.yang.model.ModelObjectId;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.UNSUPPORTED_MODEL_LVL;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getData;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.BgpcommPrefixType.of;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.DIRECT;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.OSPF;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.RIP;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.RIPNG;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.STATIC;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommprefixtype.BgpcommPrefixTypeEnum.IPV4UNI;
|
||||
import static org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.nebgpcommtype.bgpcommprefixtype.BgpcommPrefixTypeEnum.IPV6UNI;
|
||||
|
||||
/**
|
||||
* Representation of utility for BGP creation and deletion.
|
||||
*/
|
||||
public final class BgpConstructionUtil {
|
||||
|
||||
/**
|
||||
* Error message for unsupported protocol type.
|
||||
*/
|
||||
private static final String UNSUPPORTED_PRO_TYPE = "Unsupported route " +
|
||||
"protocol type is found.";
|
||||
|
||||
// No instantiation.
|
||||
private BgpConstructionUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the created model object data of BGP info of huawei device
|
||||
* from the standard model object data.
|
||||
*
|
||||
* @param bgpInfo device BGP info
|
||||
* @param config BGP driver info
|
||||
* @return driver model object data
|
||||
*/
|
||||
static ModelObjectData getCreateBgp(BgpInfo bgpInfo,
|
||||
BgpDriverInfo config) {
|
||||
String devId = config.devId();
|
||||
BgpModelIdLevel modIdLevel = config.modIdLevel();
|
||||
|
||||
Bgp bgp = new DefaultBgp();
|
||||
Bgpcomm bgpBuilder = new DefaultBgpcomm();
|
||||
BgpVrfs bgpVrfs = new DefaultBgpVrfs();
|
||||
BgpVrf bgpVrf = new DefaultBgpVrf();
|
||||
BgpVrfAfs bgpVrfAfs = new DefaultBgpVrfAfs();
|
||||
List<BgpVrf> bgpVrfList = new LinkedList<>();
|
||||
|
||||
bgpVrf.vrfName(bgpInfo.vpnName());
|
||||
Map<RouteProtocol, ProtocolInfo> proMap = bgpInfo.protocolInfo();
|
||||
addRouteProtocol(proMap, bgpVrfAfs);
|
||||
|
||||
bgpVrf.bgpVrfAfs(bgpVrfAfs);
|
||||
bgpVrfList.add(bgpVrf);
|
||||
bgpVrfs.bgpVrf(bgpVrfList);
|
||||
bgpBuilder.bgpVrfs(bgpVrfs);
|
||||
bgp.bgpcomm(bgpBuilder);
|
||||
return getModObjData(modIdLevel, bgp, devId, bgpVrf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds route protocol from the standard device model to the BGP address
|
||||
* family respectively.
|
||||
*
|
||||
* @param proMap protocol map
|
||||
* @param bgpVrfAfs BGP address family
|
||||
*/
|
||||
private static void addRouteProtocol(Map<RouteProtocol, ProtocolInfo> proMap,
|
||||
BgpVrfAfs bgpVrfAfs) {
|
||||
BgpVrfAf ipv4 = new DefaultBgpVrfAf();
|
||||
ImportRoutes ipv4Routes = new DefaultImportRoutes();
|
||||
ipv4.afType(of(IPV4UNI));
|
||||
|
||||
BgpVrfAf ipv6 = new DefaultBgpVrfAf();
|
||||
ImportRoutes ipv6Routes = new DefaultImportRoutes();
|
||||
ipv6.afType(of(IPV6UNI));
|
||||
for (Map.Entry<RouteProtocol, ProtocolInfo> info : proMap.entrySet()) {
|
||||
RouteProtocol protocol = info.getKey();
|
||||
ProtocolInfo proInfo = info.getValue();
|
||||
if (proInfo.isIpv4Af()) {
|
||||
addImportRoute(ipv4Routes, proInfo, protocol);
|
||||
}
|
||||
if (proInfo.isIpv6Af()) {
|
||||
addImportRoute(ipv6Routes, proInfo, protocol);
|
||||
}
|
||||
}
|
||||
if (ipv4Routes.importRoute() != null &&
|
||||
!ipv4Routes.importRoute().isEmpty()) {
|
||||
addToBgpVrf(ipv4Routes, ipv4, bgpVrfAfs);
|
||||
}
|
||||
if (ipv6Routes.importRoute() != null &&
|
||||
!ipv6Routes.importRoute().isEmpty()) {
|
||||
addToBgpVrf(ipv6Routes, ipv6, bgpVrfAfs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the routes to BGP VRF in driver model.
|
||||
*
|
||||
* @param routes routes
|
||||
* @param vrfAf VRF address family
|
||||
* @param bgpVrfAfs BGP address family
|
||||
*/
|
||||
private static void addToBgpVrf(ImportRoutes routes, BgpVrfAf vrfAf,
|
||||
BgpVrfAfs bgpVrfAfs) {
|
||||
List<BgpVrfAf> ipList = new LinkedList<>();
|
||||
vrfAf.importRoutes(routes);
|
||||
ipList.add(vrfAf);
|
||||
bgpVrfAfs.bgpVrfAf(ipList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the import route to the routes, according to the protocol info
|
||||
* from the standard device model.
|
||||
*
|
||||
* @param routes routes object
|
||||
* @param proInfo protocol info
|
||||
* @param protocol route protocol
|
||||
*/
|
||||
private static void addImportRoute(ImportRoutes routes, ProtocolInfo proInfo,
|
||||
RouteProtocol protocol) {
|
||||
List<ImportRoute> routeList = new LinkedList<>();
|
||||
ImportRoute route = buildAfBgp(proInfo, protocol);
|
||||
routeList.add(route);
|
||||
routes.importRoute(routeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the import route details from the route protocol and the
|
||||
* process id.
|
||||
*
|
||||
* @param proInfo protocol info
|
||||
* @param protocol route protocol
|
||||
* @return import route object
|
||||
*/
|
||||
private static ImportRoute buildAfBgp(ProtocolInfo proInfo,
|
||||
RouteProtocol protocol) {
|
||||
BgpcommImRouteProtocolEnum rpEnum = getProtocolType(protocol);
|
||||
ImportRoute impRoute = new DefaultImportRoute();
|
||||
impRoute.importProcessId(proInfo.processId());
|
||||
impRoute.importProtocol(BgpcommImRouteProtocol.of(rpEnum));
|
||||
return impRoute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the huawei route protocol corresponding to standard device
|
||||
* route protocol.
|
||||
*
|
||||
* @param protocol device route protocol
|
||||
* @return driver route protocol
|
||||
*/
|
||||
private static BgpcommImRouteProtocolEnum getProtocolType(RouteProtocol protocol) {
|
||||
switch (protocol) {
|
||||
case DIRECT:
|
||||
return DIRECT;
|
||||
|
||||
case OSPF:
|
||||
return OSPF;
|
||||
|
||||
case RIP:
|
||||
return RIP;
|
||||
|
||||
case RIP_NG:
|
||||
return RIPNG;
|
||||
|
||||
case STATIC:
|
||||
return STATIC;
|
||||
|
||||
case BGP:
|
||||
case VRRP:
|
||||
default:
|
||||
throw new IllegalArgumentException(UNSUPPORTED_PRO_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver model object data, according to the levels it has
|
||||
* to be constructed.
|
||||
*
|
||||
* @param modIdLevel model id level
|
||||
* @param bgp driver BGP object
|
||||
* @param devId device id
|
||||
* @param bgpVrf driver BGP VRF object
|
||||
* @return model object data
|
||||
*/
|
||||
public static ModelObjectData getModObjData(BgpModelIdLevel modIdLevel,
|
||||
Bgp bgp, String devId,
|
||||
BgpVrf bgpVrf) {
|
||||
switch (modIdLevel) {
|
||||
case ROOT:
|
||||
return getRootModObj(bgp, devId);
|
||||
|
||||
case DEVICES:
|
||||
return getDevicesModObj(bgp, devId);
|
||||
|
||||
case DEVICE:
|
||||
return getDevModObj(bgpVrf, devId);
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver model object data with device in model object id,
|
||||
* till BGP VRF.
|
||||
*
|
||||
* @param bgpVrf BGP VRF object
|
||||
* @param devId device id
|
||||
* @return model object data
|
||||
*/
|
||||
private static ModelObjectData getDevModObj(BgpVrf bgpVrf, String devId) {
|
||||
DeviceKeys key = new DeviceKeys();
|
||||
key.deviceid(devId);
|
||||
ModelObjectId id = ModelObjectId.builder()
|
||||
.addChild(DefaultDevices.class)
|
||||
.addChild(DefaultDevice.class, key)
|
||||
.addChild(DefaultBgp.class)
|
||||
.addChild(DefaultBgpcomm.class)
|
||||
.addChild(DefaultBgpVrfs.class).build();
|
||||
return getData(id, (InnerModelObject) bgpVrf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver model object data with devices in model object id.
|
||||
*
|
||||
* @param bgp BGP object
|
||||
* @param devId device id
|
||||
* @return model object data
|
||||
*/
|
||||
private static ModelObjectData getDevicesModObj(Bgp bgp, String devId) {
|
||||
ModelObjectId modelId = ModelObjectId.builder()
|
||||
.addChild(DefaultDevices.class).build();
|
||||
Device device = getDevInfo(bgp, devId);
|
||||
return getData(modelId, (InnerModelObject) device);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver root model object without model object id.
|
||||
*
|
||||
* @param bgp driver BGP
|
||||
* @param devId device id
|
||||
* @return model object data
|
||||
*/
|
||||
private static ModelObjectData getRootModObj(Bgp bgp, String devId) {
|
||||
Devices devices = new DefaultDevices();
|
||||
List<Device> devList = new LinkedList<>();
|
||||
Device device = getDevInfo(bgp, devId);
|
||||
devList.add(device);
|
||||
devices.device(devList);
|
||||
return getData(null, (InnerModelObject) devices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver BGP from the device object.
|
||||
*
|
||||
* @param bgp BGP object
|
||||
* @param devId device id
|
||||
* @return device object
|
||||
*/
|
||||
private static Device getDevInfo(Bgp bgp, String devId) {
|
||||
Device device = new DefaultDevice();
|
||||
device.deviceid(devId);
|
||||
device.bgp(bgp);
|
||||
return device;
|
||||
}
|
||||
}
|
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.DefaultDevices;
|
||||
import org.onosproject.yang.model.AtomicPath;
|
||||
import org.onosproject.yang.model.DefaultModelObjectData;
|
||||
import org.onosproject.yang.model.InnerModelObject;
|
||||
import org.onosproject.yang.model.ModelObject;
|
||||
import org.onosproject.yang.model.ModelObjectData;
|
||||
import org.onosproject.yang.model.ModelObjectId;
|
||||
import org.onosproject.yang.model.MultiInstanceNode;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Representation of utility for huawei driver.
|
||||
*/
|
||||
public final class DriverUtil {
|
||||
|
||||
/**
|
||||
* Static constant value for devices.
|
||||
*/
|
||||
static final String CONS_DEVICES = "Devices";
|
||||
|
||||
/**
|
||||
* Error message for YANG model registry service not found.
|
||||
*/
|
||||
static final String SERVICE_NOT_FOUND = "Service required for huawei " +
|
||||
"driver is not found.";
|
||||
|
||||
/**
|
||||
* Error message for object from the standard device model being null.
|
||||
*/
|
||||
static final String OBJECT_NULL = "Object from device model cannot be null";
|
||||
|
||||
/**
|
||||
* Error message for device object under devices from the standard model
|
||||
* being null.
|
||||
*/
|
||||
static final String DEVICE_NULL = "Device object from the devices of " +
|
||||
"standard device model cannot be null";
|
||||
|
||||
/**
|
||||
* Error message for device object under devices from the standard model
|
||||
* being null.
|
||||
*/
|
||||
static final String INS_NULL = "Instance object from the instances of " +
|
||||
"standard device model cannot be null";
|
||||
|
||||
/**
|
||||
* Error message for unsupported model id level.
|
||||
*/
|
||||
static final String UNSUPPORTED_MODEL_LVL = "The model id level is not " +
|
||||
"supported";
|
||||
|
||||
/**
|
||||
* Error message for failure of device info retrieval.
|
||||
*/
|
||||
static final String DEV_INFO_FAILURE = "Failed to retrieve device info.";
|
||||
|
||||
/**
|
||||
* Error message for failure of interface info retrieval.
|
||||
*/
|
||||
static final String INT_INFO_FAILURE = "Failed to retrieve Interfaces";
|
||||
|
||||
/**
|
||||
* RPC message header.
|
||||
*/
|
||||
static final String RPC_MSG = "<rpc message-id=\"101\" xmlns=\"urn:ietf:" +
|
||||
"params:xml:ns:netconf:base:1.0\">";
|
||||
|
||||
/**
|
||||
* RPC get message.
|
||||
*/
|
||||
static final String RPC_GET = "<get>";
|
||||
|
||||
/**
|
||||
* RPC subtree filter message.
|
||||
*/
|
||||
static final String RPC_FILTER = "<filter type=\"subtree\">";
|
||||
|
||||
/**
|
||||
* RPC system message with namespace.
|
||||
*/
|
||||
static final String RPC_SYS = "<system xmlns=\"http://www.huawei.com/" +
|
||||
"netconf/vrp\" format-version=\"1.0\" content-version=\"1.0\"/>";
|
||||
|
||||
/**
|
||||
* RPC ifm message with namespace.
|
||||
*/
|
||||
static final String RPC_IFM = "<ifm xmlns=\"http://www.huawei.com" +
|
||||
"/netconf/vrp\" format-version=\"1.0\" content-version=\"1.0\">";
|
||||
|
||||
/**
|
||||
* RPC interfaces message.
|
||||
*/
|
||||
static final String RPC_IFS = "<interfaces/>";
|
||||
|
||||
/**
|
||||
* RPC ifm message.
|
||||
*/
|
||||
static final String RPC_CLOSE_IFM = "</ifm>";
|
||||
|
||||
/**
|
||||
* RPC filter close message.
|
||||
*/
|
||||
static final String RPC_CLOSE_FILTER = "</filter>";
|
||||
|
||||
/**
|
||||
* RPC close message.
|
||||
*/
|
||||
static final String RPC_CLOSE = "</rpc>";
|
||||
|
||||
/**
|
||||
* RPC get close message.
|
||||
*/
|
||||
static final String RPC_CLOSE_GET = "</get>";
|
||||
|
||||
/**
|
||||
* Static constant for slash.
|
||||
*/
|
||||
static final String SLASH = "/";
|
||||
|
||||
/**
|
||||
* Static constant for devices name.
|
||||
*/
|
||||
static final String DEVICES = "devices";
|
||||
|
||||
/**
|
||||
* Static constant for devices namespace.
|
||||
*/
|
||||
static final String NAMESPACE = "ne-l3vpn-api";
|
||||
|
||||
/**
|
||||
* Error message for model object id having more than two objects.
|
||||
*/
|
||||
private static final String MODEL_OBJ_ID_LIMIT = "The model object id " +
|
||||
"must not have more than two objects.";
|
||||
|
||||
// No instantiation.
|
||||
private DriverUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the device id from the model object id. If model object id is
|
||||
* not present then null is returned. If only one path is available in
|
||||
* the list then devices value is returned.
|
||||
*
|
||||
* @param id model object data
|
||||
* @return device id
|
||||
*/
|
||||
static String getIdFromModId(ModelObjectId id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<AtomicPath> paths = id.atomicPaths();
|
||||
int size = paths.size();
|
||||
if (size == 1) {
|
||||
return CONS_DEVICES;
|
||||
} else if (size == 2) {
|
||||
return ((MultiInstanceNode) paths.get(1)).key().toString();
|
||||
} else {
|
||||
throw new IllegalArgumentException(MODEL_OBJ_ID_LIMIT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first object from the model object data. If no objects are
|
||||
* present then it returns null.
|
||||
*
|
||||
* @param modData model object data
|
||||
* @return object
|
||||
*/
|
||||
static Object getObjFromModData(ModelObjectData modData) {
|
||||
List<ModelObject> obj = modData.modelObjects();
|
||||
Iterator<ModelObject> it = obj.iterator();
|
||||
if (it.hasNext()) {
|
||||
return it.next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the model object id for with the devices object added to it.
|
||||
*
|
||||
* @return model object id
|
||||
*/
|
||||
static ModelObjectId getModObjIdDriDevices() {
|
||||
return ModelObjectId.builder().addChild(DefaultDevices.class).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns model object data built from the object that has to be added
|
||||
* and the model object id.
|
||||
*
|
||||
* @param id model object id
|
||||
* @param obj object
|
||||
* @return model object data
|
||||
*/
|
||||
static ModelObjectData getData(ModelObjectId id, InnerModelObject obj) {
|
||||
return DefaultModelObjectData.builder().addModelObject(obj)
|
||||
.identifier(id).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.onosproject.net.Device;
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.device.DefaultDeviceDescription;
|
||||
import org.onosproject.net.device.DeviceDescription;
|
||||
import org.onosproject.net.device.DeviceDescriptionDiscovery;
|
||||
import org.onosproject.net.device.DeviceService;
|
||||
import org.onosproject.net.device.PortDescription;
|
||||
import org.onosproject.net.driver.AbstractHandlerBehaviour;
|
||||
import org.onosproject.netconf.NetconfController;
|
||||
import org.onosproject.netconf.NetconfException;
|
||||
import org.onosproject.netconf.NetconfSession;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.DEV_INFO_FAILURE;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.INT_INFO_FAILURE;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE_IFM;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_IFS;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE_FILTER;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE_GET;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_FILTER;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_GET;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_IFM;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_MSG;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.RPC_SYS;
|
||||
import static org.onosproject.net.Device.Type.ROUTER;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
/**
|
||||
* Representation of device information and ports via NETCONF for huawei
|
||||
* routers.
|
||||
*/
|
||||
public class HuaweiDeviceDescription extends AbstractHandlerBehaviour
|
||||
implements DeviceDescriptionDiscovery {
|
||||
|
||||
private final Logger log = getLogger(getClass());
|
||||
|
||||
/**
|
||||
* Constructs huawei device description.
|
||||
*/
|
||||
public HuaweiDeviceDescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Discovers device details, for huawei device by getting the system
|
||||
* information.
|
||||
*
|
||||
* @return device description
|
||||
*/
|
||||
@Override
|
||||
public DeviceDescription discoverDeviceDetails() {
|
||||
NetconfSession session = getNetconfSession();
|
||||
String sysInfo;
|
||||
try {
|
||||
sysInfo = session.get(getVersionReq());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(
|
||||
new NetconfException(DEV_INFO_FAILURE));
|
||||
}
|
||||
|
||||
String[] details = parseSysInfoXml(sysInfo);
|
||||
DeviceService devSvc = checkNotNull(handler().get(DeviceService.class));
|
||||
DeviceId devId = handler().data().deviceId();
|
||||
Device dev = devSvc.getDevice(devId);
|
||||
return new DefaultDeviceDescription(dev.id().uri(), ROUTER,
|
||||
details[0], details[1],
|
||||
details[2], details[3],
|
||||
dev.chassisId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Discovers interface details, for huawei device.
|
||||
*
|
||||
* @return port list
|
||||
*/
|
||||
@Override
|
||||
public List<PortDescription> discoverPortDetails() {
|
||||
NetconfSession session = getNetconfSession();
|
||||
String interfaces;
|
||||
try {
|
||||
interfaces = session.get(getInterfacesReq());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(
|
||||
new NetconfException(INT_INFO_FAILURE));
|
||||
}
|
||||
return ImmutableList.copyOf(parseInterfaceXml(interfaces));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the NETCONF session of the device.
|
||||
*
|
||||
* @return session
|
||||
*/
|
||||
private NetconfSession getNetconfSession() {
|
||||
NetconfController controller = checkNotNull(
|
||||
handler().get(NetconfController.class));
|
||||
return controller.getDevicesMap().get(handler().data().deviceId())
|
||||
.getSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rpc request message for fetching system details in huawei
|
||||
* device.
|
||||
*
|
||||
* @return rpc request message
|
||||
*/
|
||||
private String getVersionReq() {
|
||||
StringBuilder rpc = new StringBuilder(RPC_MSG);
|
||||
rpc.append(RPC_GET);
|
||||
rpc.append(RPC_FILTER);
|
||||
rpc.append(RPC_SYS);
|
||||
rpc.append(RPC_CLOSE_FILTER);
|
||||
rpc.append(RPC_CLOSE_GET);
|
||||
rpc.append(RPC_CLOSE);
|
||||
return rpc.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses system info received from huawei device.
|
||||
*
|
||||
* @param sysInfo system info
|
||||
* @return parsed values
|
||||
*/
|
||||
private String[] parseSysInfoXml(String sysInfo) {
|
||||
HuaweiXmlParser parser = new HuaweiXmlParser(sysInfo);
|
||||
parser.parseSysInfo();
|
||||
return parser.getInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rpc request message for fetching interface details in
|
||||
* huawei device.
|
||||
*
|
||||
* @return rpc request message
|
||||
*/
|
||||
private String getInterfacesReq() {
|
||||
StringBuilder rpc = new StringBuilder(RPC_MSG);
|
||||
rpc.append(RPC_GET);
|
||||
rpc.append(RPC_FILTER);
|
||||
rpc.append(RPC_IFM);
|
||||
rpc.append(RPC_IFS);
|
||||
rpc.append(RPC_CLOSE_IFM);
|
||||
rpc.append(RPC_CLOSE_FILTER);
|
||||
rpc.append(RPC_CLOSE_GET);
|
||||
rpc.append(RPC_CLOSE);
|
||||
return rpc.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses interfaces received from huawei device.
|
||||
*
|
||||
* @param interfaces interfaces
|
||||
* @return port list
|
||||
*/
|
||||
private List<PortDescription> parseInterfaceXml(String interfaces) {
|
||||
HuaweiXmlParser parser = new HuaweiXmlParser(interfaces);
|
||||
parser.parseInterfaces();
|
||||
return parser.getPorts();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import org.apache.felix.scr.annotations.Component;
|
||||
import org.onosproject.net.driver.AbstractDriverLoader;
|
||||
|
||||
/**
|
||||
* Loader for Huawei device drivers.
|
||||
*/
|
||||
@Component(immediate = true)
|
||||
public class HuaweiDriversLoader extends AbstractDriverLoader {
|
||||
public HuaweiDriversLoader() {
|
||||
super("/huawei-drivers.xml");
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import org.onlab.osgi.ServiceNotFoundException;
|
||||
import org.onosproject.config.DynamicConfigService;
|
||||
import org.onosproject.config.FailedException;
|
||||
import org.onosproject.l3vpn.netl3vpn.BgpDriverInfo;
|
||||
import org.onosproject.l3vpn.netl3vpn.BgpInfo;
|
||||
import org.onosproject.net.behaviour.L3vpnConfig;
|
||||
import org.onosproject.net.driver.AbstractHandlerBehaviour;
|
||||
import org.onosproject.yang.gen.v1.l3vpn.comm.type.rev20141225.NeL3VpncommType;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.rev20141225.NeBgpcomm;
|
||||
import org.onosproject.yang.gen.v1.ne.bgpcomm.type.rev20141225.NeBgpcommType;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.NeL3VpnApi;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.comm.rev20141225.NeL3Vpncomm;
|
||||
import org.onosproject.yang.model.DataNode;
|
||||
import org.onosproject.yang.model.ModelObjectData;
|
||||
import org.onosproject.yang.model.ResourceId;
|
||||
import org.onosproject.yang.model.YangModel;
|
||||
import org.onosproject.yang.model.YangModuleId;
|
||||
import org.onosproject.yang.runtime.DefaultAppModuleInfo;
|
||||
import org.onosproject.yang.runtime.ModelRegistrationParam;
|
||||
import org.onosproject.yang.runtime.YangModelRegistry;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.onosproject.drivers.huawei.BgpConstructionUtil.getCreateBgp;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.DEVICES;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.NAMESPACE;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.SERVICE_NOT_FOUND;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.SLASH;
|
||||
import static org.onosproject.drivers.huawei.InsConstructionUtil.getCreateVpnIns;
|
||||
import static org.onosproject.drivers.huawei.IntConstructionUtil.getCreateInt;
|
||||
import static org.onosproject.yang.runtime.DefaultModelRegistrationParam.builder;
|
||||
import static org.onosproject.yang.runtime.helperutils.YangApacheUtils.getYangModel;
|
||||
|
||||
/**
|
||||
* Configures l3vpn on Huawei devices.
|
||||
*/
|
||||
public class HuaweiL3vpnConfig extends AbstractHandlerBehaviour
|
||||
implements L3vpnConfig {
|
||||
|
||||
/**
|
||||
* YANG model registry.
|
||||
*/
|
||||
protected YangModelRegistry modelRegistry;
|
||||
|
||||
/**
|
||||
* Dynamic config service.
|
||||
*/
|
||||
protected DynamicConfigService configService;
|
||||
|
||||
/**
|
||||
* Constructs huawei L3VPN config.
|
||||
*/
|
||||
public HuaweiL3vpnConfig() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the YANG model registry service and registers the driver YANG.
|
||||
* If service is not available it throws exception.
|
||||
*/
|
||||
private void init() {
|
||||
try {
|
||||
modelRegistry = handler().get(YangModelRegistry.class);
|
||||
configService = handler().get(DynamicConfigService.class);
|
||||
registerModel();
|
||||
} catch (ServiceNotFoundException e) {
|
||||
throw new ServiceNotFoundException(SERVICE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the huawei generated classes to the YANG model.
|
||||
*/
|
||||
private void registerModel() {
|
||||
YangModel model = getYangModel(NeBgpcomm.class);
|
||||
Iterator<YangModuleId> it = model.getYangModulesId().iterator();
|
||||
|
||||
//Create model registration param.
|
||||
ModelRegistrationParam.Builder b = builder().setYangModel(model);
|
||||
YangModuleId id;
|
||||
while (it.hasNext()) {
|
||||
id = it.next();
|
||||
switch (id.moduleName()) {
|
||||
case "ne-bgpcomm":
|
||||
b.addAppModuleInfo(id, new DefaultAppModuleInfo(
|
||||
NeBgpcomm.class, null));
|
||||
break;
|
||||
case "ne-bgpcomm-type":
|
||||
b.addAppModuleInfo(id, new DefaultAppModuleInfo(
|
||||
NeBgpcommType.class, null));
|
||||
break;
|
||||
case "ne-l3vpn-api":
|
||||
b.addAppModuleInfo(id, new DefaultAppModuleInfo(
|
||||
NeL3VpnApi.class, null));
|
||||
break;
|
||||
case "ne-l3vpncomm":
|
||||
b.addAppModuleInfo(id, new DefaultAppModuleInfo(
|
||||
NeL3Vpncomm.class, null));
|
||||
break;
|
||||
case "ne-l3vpncomm-type":
|
||||
b.addAppModuleInfo(id, new DefaultAppModuleInfo(
|
||||
NeL3VpncommType.class, null));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
ModelRegistrationParam regParam = b.build();
|
||||
modelRegistry.registerModel(regParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createInstance(Object objectData) {
|
||||
if (modelRegistry == null) {
|
||||
init();
|
||||
}
|
||||
return getCreateVpnIns((ModelObjectData) objectData,
|
||||
isDevicesPresent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object bindInterface(Object objectData) {
|
||||
return getCreateInt((ModelObjectData) objectData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createBgpInfo(Object bgpInfo, Object bgpConfig) {
|
||||
return getCreateBgp((BgpInfo) bgpInfo, (BgpDriverInfo) bgpConfig);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object deleteInstance(Object objectData) {
|
||||
return InsConstructionUtil.getDeleteVpnIns((ModelObjectData) objectData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object unbindInterface(Object objectData) {
|
||||
//TODO:To be committed.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deleteBgpInfo(Object bgpInfo, Object bgpConfig) {
|
||||
//TODO:To be committed.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if devices, which is the root node present in store;
|
||||
* false otherwise.
|
||||
*
|
||||
* @return true if devices available; false otherwise
|
||||
*/
|
||||
private boolean isDevicesPresent() {
|
||||
ResourceId resId = ResourceId.builder()
|
||||
.addBranchPointSchema(SLASH, null)
|
||||
.addBranchPointSchema(DEVICES, NAMESPACE).build();
|
||||
try {
|
||||
DataNode node = configService.readNode(resId, null);
|
||||
if (node != null) {
|
||||
return true;
|
||||
}
|
||||
} catch (FailedException e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.onosproject.net.DefaultAnnotations;
|
||||
import org.onosproject.net.device.DefaultPortDescription;
|
||||
import org.onosproject.net.device.PortDescription;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
|
||||
import static org.onosproject.net.Port.Type.COPPER;
|
||||
import static org.onosproject.net.PortNumber.portNumber;
|
||||
|
||||
/**
|
||||
* Created by root1 on 27/3/17.
|
||||
*/
|
||||
public class HuaweiXmlParser {
|
||||
|
||||
private static final String DATA = "data";
|
||||
private static final String IFM = "ifm";
|
||||
private static final String IFS = "interfaces";
|
||||
private static final String IF = "interface";
|
||||
private static final String IF_TYPE = "ifPhyType";
|
||||
private static final String IF_STAT = "ifPhyStatus";
|
||||
private static final String IF_NUM = "ifNumber";
|
||||
private static final String IF_SPEED = "ifOperSpeed";
|
||||
private static final String IF_NAME = "ifName";
|
||||
private static final String UP = "up";
|
||||
private static final String DYN_INFO = "ifDynamicInfo";
|
||||
private static final String DELIMITER = "/";
|
||||
private static final String SYS = "system";
|
||||
private static final String SYS_INFO = "systemInfo";
|
||||
private static final String SYS_NAME = "sysName";
|
||||
private static final String PDT_VER = "productVer";
|
||||
private static final String PLATFORM_VER = "platformVer";
|
||||
private static final String SYS_ID = "sysObjectId";
|
||||
|
||||
private static final String DEV_PARSE_ERR = "Unable to parse the received" +
|
||||
" xml reply for system details from the huawei device";
|
||||
private static final String INT_PARSE_ERR = "Unable to parse the received" +
|
||||
" xml reply for interface details from the huawei device";
|
||||
private static final String P_NAME_INVALID = "Invalid port name.";
|
||||
|
||||
//TODO: All type of interfaces has to be added.
|
||||
private static final List INTERFACES = Arrays.asList(
|
||||
"MEth", "LoopBack", "Ethernet", "POS", "GigabitEthernet");
|
||||
|
||||
private List<PortDescription> ports = new ArrayList<>();
|
||||
private String xml;
|
||||
private int portInc;
|
||||
private String[] info = new String[4];
|
||||
|
||||
/**
|
||||
* Constructs huawei XML parser with xml reply.
|
||||
*
|
||||
* @param xml xml reply
|
||||
*/
|
||||
public HuaweiXmlParser(String xml) {
|
||||
this.xml = xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the system info.
|
||||
*
|
||||
* @return system info
|
||||
*/
|
||||
String[] getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port list.
|
||||
*
|
||||
* @return port list
|
||||
*/
|
||||
List<PortDescription> getPorts() {
|
||||
return ports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses system info xml reply.
|
||||
*/
|
||||
void parseSysInfo() {
|
||||
Document doc;
|
||||
try {
|
||||
doc = DocumentHelper.parseText(xml);
|
||||
} catch (DocumentException e) {
|
||||
throw new IllegalArgumentException(DEV_PARSE_ERR);
|
||||
}
|
||||
|
||||
Element root = doc.getRootElement();
|
||||
Element parent = root.element(DATA).element(SYS).element(SYS_INFO);
|
||||
info[0] = parent.element(SYS_NAME).getText();
|
||||
info[1] = parent.element(PDT_VER).getText();
|
||||
info[2] = parent.element(PLATFORM_VER).getText();
|
||||
info[3] = parent.element(SYS_ID).getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses interface xml reply and creates ports to be updated.
|
||||
*/
|
||||
void parseInterfaces() {
|
||||
Document doc;
|
||||
try {
|
||||
doc = DocumentHelper.parseText(xml);
|
||||
} catch (DocumentException e) {
|
||||
throw new IllegalArgumentException(INT_PARSE_ERR);
|
||||
}
|
||||
Element root = doc.getRootElement();
|
||||
Element parent = root.element(DATA).element(IFM).element(IFS);
|
||||
Iterator itr = parent.elementIterator(IF);
|
||||
|
||||
while (itr.hasNext()) {
|
||||
Element ifElement = (Element) itr.next();
|
||||
addPorts(ifElement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds port information to the port list from the xml reply.
|
||||
*
|
||||
* @param ifElement interface element
|
||||
*/
|
||||
private void addPorts(Element ifElement) {
|
||||
String ifType = ifElement.element(IF_TYPE).getText();
|
||||
|
||||
if (INTERFACES.contains(ifType)) {
|
||||
Element info = ifElement.element(DYN_INFO);
|
||||
String status = info.element(IF_STAT).getText();
|
||||
String port = getPortNum(ifElement.element(IF_NUM).getText());
|
||||
String speed = info.element(IF_SPEED).getText();
|
||||
String ifName = ifElement.element(IF_NAME).getText();
|
||||
|
||||
boolean isEnabled = false;
|
||||
if (status.equals(UP)) {
|
||||
isEnabled = true;
|
||||
}
|
||||
|
||||
Long portSpeed = 0L;
|
||||
if (!speed.isEmpty()) {
|
||||
portSpeed = Long.valueOf(speed);
|
||||
}
|
||||
|
||||
DefaultAnnotations annotations = DefaultAnnotations.builder()
|
||||
.set(PORT_NAME, ifName).build();
|
||||
ports.add(new DefaultPortDescription(portNumber(port), isEnabled,
|
||||
COPPER, portSpeed,
|
||||
annotations));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns port number from the port name. As many type of port can have
|
||||
* same port number, each port number will be prepended with a incrementing
|
||||
* number to make it unique in the list.
|
||||
*
|
||||
* @param portName port name
|
||||
* @return port number
|
||||
*/
|
||||
private String getPortNum(String portName) {
|
||||
String port;
|
||||
if (!portName.contains(DELIMITER)) {
|
||||
portInc++;
|
||||
port = String.valueOf(portInc) + portName;
|
||||
} else if (portName.indexOf(DELIMITER) > 0) {
|
||||
try {
|
||||
port = portName.substring(
|
||||
portName.lastIndexOf(DELIMITER) + 1);
|
||||
portInc++;
|
||||
port = String.valueOf(portInc) + port;
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
throw new IllegalArgumentException(P_NAME_INVALID);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException(P_NAME_INVALID);
|
||||
}
|
||||
return port;
|
||||
}
|
||||
}
|
@ -0,0 +1,481 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.DefaultDevice;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.DeviceKeys;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.DefaultL3Vpn;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.L3Vpn;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.DefaultL3Vpncomm;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.L3Vpncomm;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.DefaultL3VpnInstances;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.L3VpnInstances;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.DefaultL3VpnInstance;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.L3VpnInstance;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.L3VpnInstanceKeys;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.DefaultVpnInstAfs;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.VpnInstAfs;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.DefaultVpnInstAf;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.VpnInstAf;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.DefaultVpnTargets;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.VpnTargets;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.vpntargets.DefaultVpnTarget;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.vpntargets.VpnTarget;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.bgp.l3vpn.rev20160909.ietfbgpl3vpn.devices.device.networkinstances.networkinstance.DefaultAugmentedNiNetworkInstance;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.bgp.l3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.ipv4.Unicast;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.bgp.l3vpn.rev20160909.ietfbgpl3vpn.routetargetset.Rts;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.bgp.l3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.instance.rev20160623.ietfnetworkinstance.DefaultDevices;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.instance.rev20160623.ietfnetworkinstance.devices.Device;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.instance.rev20160623.ietfnetworkinstance.devices.device.NetworkInstances;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.instance.rev20160623.ietfnetworkinstance.devices.device.networkinstances.DefaultNetworkInstance;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.instance.rev20160623.ietfnetworkinstance.devices.device.networkinstances.NetworkInstance;
|
||||
import org.onosproject.yang.model.InnerModelObject;
|
||||
import org.onosproject.yang.model.ModelObjectData;
|
||||
import org.onosproject.yang.model.ModelObjectId;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.CONS_DEVICES;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.DEVICE_NULL;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.INS_NULL;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.OBJECT_NULL;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.UNSUPPORTED_MODEL_LVL;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getData;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getIdFromModId;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getModObjIdDriDevices;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getObjFromModData;
|
||||
import static org.onosproject.drivers.huawei.ModelIdLevel.DEVICE;
|
||||
import static org.onosproject.drivers.huawei.ModelIdLevel.DEVICES;
|
||||
import static org.onosproject.drivers.huawei.ModelIdLevel.ROOT;
|
||||
import static org.onosproject.yang.gen.v1.l3vpn.comm.type.rev20141225.nel3vpncommtype.L3VpncommonL3VpnPrefixType.of;
|
||||
import static org.onosproject.yang.gen.v1.l3vpn.comm.type.rev20141225.nel3vpncommtype.L3VpncommonVrfRtType.fromString;
|
||||
import static org.onosproject.yang.gen.v1.l3vpn.comm.type.rev20141225.nel3vpncommtype.l3vpncommonl3vpnprefixtype.L3VpncommonL3VpnPrefixTypeEnum.IPV4UNI;
|
||||
import static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.bgp.l3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum.BOTH;
|
||||
|
||||
/**
|
||||
* Representation of utility for instance creation and deletion.
|
||||
*/
|
||||
public final class InsConstructionUtil {
|
||||
|
||||
/**
|
||||
* Static constant for route target export.
|
||||
*/
|
||||
private static final String EXP_COMM = "export_extcommunity";
|
||||
|
||||
/**
|
||||
* Static constant for route target import.
|
||||
*/
|
||||
private static final String IMP_COMM = "import_extcommunity";
|
||||
|
||||
/**
|
||||
* Error message for unsupported RT type.
|
||||
*/
|
||||
private static final String UNSUPPORTED_RT_TYPE = "The RT type is not " +
|
||||
"supported";
|
||||
|
||||
// No instantiation.
|
||||
private InsConstructionUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the created model object data of VPN instance of huawei device
|
||||
* from the standard model object data.
|
||||
*
|
||||
* @param modObj model object data
|
||||
* @param isDevAvail if devices available
|
||||
* @return driver model object data
|
||||
*/
|
||||
static ModelObjectData getCreateVpnIns(ModelObjectData modObj,
|
||||
boolean isDevAvail) {
|
||||
ModelIdLevel modIdLvl = DEVICE;
|
||||
String id = getIdFromModId(modObj.identifier());
|
||||
Object obj = getObjFromModData(modObj);
|
||||
|
||||
if (obj == null) {
|
||||
throw new IllegalArgumentException(OBJECT_NULL);
|
||||
}
|
||||
|
||||
if (id == null) {
|
||||
id = getDevIdFromRootObj(obj);
|
||||
obj = getObjFromRootObj(obj);
|
||||
if (isDevAvail) {
|
||||
modIdLvl = DEVICES;
|
||||
} else {
|
||||
modIdLvl = ROOT;
|
||||
}
|
||||
} else if (id.equals(CONS_DEVICES)) {
|
||||
modIdLvl = DEVICES;
|
||||
id = ((Device) obj).deviceid();
|
||||
obj = ((Device) obj).networkInstances();
|
||||
}
|
||||
org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi
|
||||
.DefaultDevices devices = getDriverDevices(
|
||||
id, (NetworkInstances) obj);
|
||||
return getCreateModObjData(modIdLvl, id, devices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver model object data, according to the levels it has
|
||||
* to be constructed.
|
||||
*
|
||||
* @param modIdLvl model id level
|
||||
* @param devId device id
|
||||
* @param devices devices object
|
||||
* @return model object data
|
||||
*/
|
||||
private static ModelObjectData getCreateModObjData(ModelIdLevel modIdLvl,
|
||||
String devId,
|
||||
org.onosproject.yang.gen
|
||||
.v1.ne.l3vpn.api
|
||||
.rev20141225
|
||||
.nel3vpnapi
|
||||
.DefaultDevices
|
||||
devices) {
|
||||
ModelObjectId id;
|
||||
List<org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi
|
||||
.devices.Device> devList = devices.device();
|
||||
Iterator<org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi
|
||||
.devices.Device> it = devList.iterator();
|
||||
org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi
|
||||
.devices.Device device = it.next();
|
||||
Iterator<L3VpnInstance> instIt = device.l3Vpn().l3Vpncomm()
|
||||
.l3VpnInstances().l3VpnInstance().iterator();
|
||||
L3VpnInstance ins = instIt.next();
|
||||
|
||||
switch (modIdLvl) {
|
||||
|
||||
case ROOT:
|
||||
return getData(null, devices);
|
||||
|
||||
case DEVICES:
|
||||
id = getModObjIdDriDevices();
|
||||
return getData(id, (InnerModelObject) device);
|
||||
|
||||
case DEVICE:
|
||||
id = getModelObjIdForIns(devId).build();
|
||||
return getData(id, (InnerModelObject) ins);
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the devices object of the huawei VPN instance model. This
|
||||
* constructs all the required information in the device for L3VPN
|
||||
* instance creation.
|
||||
*
|
||||
* @param id device id
|
||||
* @param obj network instances object
|
||||
* @return driver VPN instance's devices
|
||||
*/
|
||||
private static org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225
|
||||
.nel3vpnapi.DefaultDevices getDriverDevices(String id,
|
||||
NetworkInstances obj) {
|
||||
|
||||
org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.
|
||||
DefaultDevices devices = new org.onosproject.yang.gen.v1.ne
|
||||
.l3vpn.api.rev20141225.nel3vpnapi.DefaultDevices();
|
||||
org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices
|
||||
.Device device = new org.onosproject.yang.gen.v1.ne.l3vpn.api
|
||||
.rev20141225.nel3vpnapi.devices.DefaultDevice();
|
||||
|
||||
L3Vpn l3Vpn = new DefaultL3Vpn();
|
||||
L3Vpncomm l3VpnComm = new DefaultL3Vpncomm();
|
||||
L3VpnInstances instances = new DefaultL3VpnInstances();
|
||||
L3VpnInstance ins = new DefaultL3VpnInstance();
|
||||
List<L3VpnInstance> insList = new LinkedList<>();
|
||||
List<org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi
|
||||
.devices.Device> devList = new LinkedList<>();
|
||||
|
||||
createDriIns(obj, ins);
|
||||
insList.add(ins);
|
||||
instances.l3VpnInstance(insList);
|
||||
l3VpnComm.l3VpnInstances(instances);
|
||||
l3Vpn.l3Vpncomm(l3VpnComm);
|
||||
|
||||
device.deviceid(id);
|
||||
device.l3Vpn(l3Vpn);
|
||||
devList.add(device);
|
||||
devices.device(devList);
|
||||
return devices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates driver instance value from standard device instance.
|
||||
*
|
||||
* @param ins standard device instance
|
||||
* @param driIns driver instance
|
||||
*/
|
||||
private static void createDriIns(NetworkInstances ins,
|
||||
L3VpnInstance driIns) {
|
||||
NetworkInstance networkInstance = ins.networkInstance().iterator()
|
||||
.next();
|
||||
driIns.vrfName(networkInstance.name());
|
||||
DefaultAugmentedNiNetworkInstance augIns =
|
||||
((DefaultNetworkInstance) networkInstance).augmentation(
|
||||
DefaultAugmentedNiNetworkInstance.class);
|
||||
VpnInstAfs vpnInstAfs = processL3VpnAf(augIns.l3Vpn());
|
||||
driIns.vpnInstAfs(vpnInstAfs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the device id from the root object.
|
||||
*
|
||||
* @param obj root object
|
||||
* @return device id
|
||||
*/
|
||||
private static String getDevIdFromRootObj(Object obj) {
|
||||
Device dev = getDevFromRootObj(obj);
|
||||
return dev.deviceid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first device from the root object. If no device is
|
||||
* present, it returns null.
|
||||
*
|
||||
* @param obj root object
|
||||
* @return device object
|
||||
*/
|
||||
private static Device getDevFromRootObj(Object obj) {
|
||||
List<Device> deviceList = ((DefaultDevices) obj).device();
|
||||
Iterator<Device> it = deviceList.iterator();
|
||||
if (it.hasNext()) {
|
||||
return it.next();
|
||||
}
|
||||
throw new IllegalArgumentException(DEVICE_NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the network instances object from the root object.
|
||||
*
|
||||
* @param obj root object
|
||||
* @return network instances
|
||||
*/
|
||||
private static NetworkInstances getObjFromRootObj(Object obj) {
|
||||
Device dev = getDevFromRootObj(obj);
|
||||
return dev.networkInstances();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns model object id builder that has to be constructed for driver
|
||||
* instance level addition, with the device id.
|
||||
*
|
||||
* @param id device id
|
||||
* @return model object id
|
||||
*/
|
||||
private static ModelObjectId.Builder getModelObjIdForIns(String id) {
|
||||
ModelObjectId.Builder device = getModObjIdDriDevice(id);
|
||||
return device.addChild(DefaultL3Vpn.class)
|
||||
.addChild(DefaultL3Vpncomm.class)
|
||||
.addChild(DefaultL3VpnInstances.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes standard device model L3VPN address family and returns the
|
||||
* driver L3VPN address family.
|
||||
*
|
||||
* @param l3Vpn standard device L3VPN
|
||||
* @return driver address family
|
||||
*/
|
||||
private static VpnInstAfs processL3VpnAf(org.onosproject.yang.gen.v1.urn
|
||||
.ietf.params.xml.ns.yang
|
||||
.ietf.bgp.l3vpn.rev20160909
|
||||
.ietfbgpl3vpn.devices
|
||||
.device.networkinstances
|
||||
.networkinstance
|
||||
.augmentedninetworkinstance
|
||||
.L3Vpn l3Vpn) {
|
||||
// TODO: Need to handle the ipv6 case
|
||||
Unicast ipv4Unicast = l3Vpn.ipv4().unicast();
|
||||
VpnInstAfs vpnInstAfs = new DefaultVpnInstAfs();
|
||||
VpnInstAf vpnInstAf = new DefaultVpnInstAf();
|
||||
VpnTargets vpnTargets = new DefaultVpnTargets();
|
||||
List<VpnInstAf> afList = new LinkedList<>();
|
||||
|
||||
vpnInstAf.vrfRd(l3Vpn.routeDistinguisher().config().rd());
|
||||
vpnInstAf.afType(of(IPV4UNI));
|
||||
|
||||
List<Rts> rts = ipv4Unicast.routeTargets().config().rts();
|
||||
addVpnTarget(vpnTargets, rts);
|
||||
|
||||
vpnInstAf.vpnTargets(vpnTargets);
|
||||
afList.add(vpnInstAf);
|
||||
vpnInstAfs.vpnInstAf(afList);
|
||||
return vpnInstAfs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds VPN target to the target list from the list of RTs available in
|
||||
* the standard device model.
|
||||
*
|
||||
* @param vpnTgts VPN targets
|
||||
* @param rts rts
|
||||
*/
|
||||
private static void addVpnTarget(VpnTargets vpnTgts, List<Rts> rts) {
|
||||
List<VpnTarget> tgtList = new LinkedList<>();
|
||||
for (Rts rt : rts) {
|
||||
if (rt == null) {
|
||||
continue;
|
||||
}
|
||||
if (rt.rtType() == BOTH) {
|
||||
VpnTarget expTgt = addRt(rt.rt(), EXP_COMM);
|
||||
VpnTarget impTgt = addRt(rt.rt(), IMP_COMM);
|
||||
tgtList.add(expTgt);
|
||||
tgtList.add(impTgt);
|
||||
} else {
|
||||
String rtType = getRtVal(rt.rtType());
|
||||
VpnTarget tgt = addRt(rt.rt(), rtType);
|
||||
tgtList.add(tgt);
|
||||
}
|
||||
}
|
||||
vpnTgts.vpnTarget(tgtList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RT value according to the RT type available.
|
||||
*
|
||||
* @param type RT type
|
||||
* @return RT value
|
||||
*/
|
||||
private static String getRtVal(RtTypeEnum type) {
|
||||
switch (type) {
|
||||
|
||||
case EXPORT:
|
||||
return EXP_COMM;
|
||||
|
||||
case IMPORT:
|
||||
return IMP_COMM;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(UNSUPPORTED_RT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds RT to the VPN target with the RT value and RT type.
|
||||
*
|
||||
* @param rt RT value
|
||||
* @param rtType RT type
|
||||
* @return VPN target
|
||||
*/
|
||||
private static VpnTarget addRt(String rt, String rtType) {
|
||||
VpnTarget vpnTarget = new DefaultVpnTarget();
|
||||
vpnTarget.vrfRtvalue(rt);
|
||||
vpnTarget.vrfRttype(fromString(rtType));
|
||||
return vpnTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deletable model object data of VPN instance of huawei device
|
||||
* from the standard model object data.
|
||||
*
|
||||
* @param modObj model object data
|
||||
* @return driver model object data
|
||||
*/
|
||||
static Object getDeleteVpnIns(ModelObjectData modObj) {
|
||||
ModelIdLevel modIdLvl = DEVICE;
|
||||
String id = getIdFromModId(modObj.identifier());
|
||||
Object obj = getObjFromModData(modObj);
|
||||
|
||||
if (obj == null) {
|
||||
throw new IllegalArgumentException(OBJECT_NULL);
|
||||
}
|
||||
|
||||
if (id == null) {
|
||||
modIdLvl = ROOT;
|
||||
id = getDevIdFromRootObj(obj);
|
||||
obj = getObjFromRootObj(obj);
|
||||
} else if (id.equals(CONS_DEVICES)) {
|
||||
modIdLvl = DEVICES;
|
||||
id = ((Device) obj).deviceid();
|
||||
obj = ((Device) obj).networkInstances();
|
||||
}
|
||||
List<NetworkInstance> ins = ((NetworkInstances) obj).networkInstance();
|
||||
Iterator<NetworkInstance> it = ins.iterator();
|
||||
NetworkInstance instance;
|
||||
if (it.hasNext()) {
|
||||
instance = it.next();
|
||||
} else {
|
||||
throw new IllegalArgumentException(INS_NULL);
|
||||
}
|
||||
return getDelModObjData(modIdLvl, id, instance.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver model object data for delete, according to the
|
||||
* levels it has to be constructed.
|
||||
*
|
||||
* @param modIdLvl model id level
|
||||
* @param id device id
|
||||
* @param name VPN name
|
||||
* @return driver model object data
|
||||
*/
|
||||
private static ModelObjectData getDelModObjData(ModelIdLevel modIdLvl,
|
||||
String id, String name) {
|
||||
ModelObjectId modId;
|
||||
switch (modIdLvl) {
|
||||
case ROOT:
|
||||
modId = getModObjIdDriDevices();
|
||||
break;
|
||||
|
||||
case DEVICES:
|
||||
modId = getModObjIdDriDevice(id).build();
|
||||
break;
|
||||
|
||||
case DEVICE:
|
||||
modId = getModObjIdDriVpn(id, name);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
|
||||
}
|
||||
return getData(modId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the model object id, with device id and VPN name.
|
||||
*
|
||||
* @param id device id
|
||||
* @param name VPN name
|
||||
* @return model object id
|
||||
*/
|
||||
private static ModelObjectId getModObjIdDriVpn(String id, String name) {
|
||||
ModelObjectId.Builder ins = getModelObjIdForIns(id);
|
||||
L3VpnInstanceKeys key = new L3VpnInstanceKeys();
|
||||
key.vrfName(name);
|
||||
return ins.addChild(DefaultL3VpnInstance.class, key).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the model object id builder of the driver with respect to device.
|
||||
*
|
||||
* @param id device id
|
||||
* @return model object id builder
|
||||
*/
|
||||
private static ModelObjectId.Builder getModObjIdDriDevice(String id) {
|
||||
DeviceKeys key = new DeviceKeys();
|
||||
key.deviceid(id);
|
||||
return ModelObjectId.builder()
|
||||
.addChild(org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225
|
||||
.nel3vpnapi.DefaultDevices.class)
|
||||
.addChild(DefaultDevice.class, key);
|
||||
}
|
||||
}
|
@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
import org.onosproject.yang.gen.v1.l3vpn.comm.type.rev20141225.nel3vpncommtype.Ipv4Address;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.DeviceKeys;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.DefaultL3Vpn;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.DefaultL3Vpncomm;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.DefaultL3VpnInstances;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.DefaultL3VpnInstance;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.L3VpnInstanceKeys;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.comm.rev20141225.nel3vpncomm.l3vpnifs.DefaultL3VpnIfs;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.comm.rev20141225.nel3vpncomm.l3vpnifs.L3VpnIfs;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.comm.rev20141225.nel3vpncomm.l3vpnifs.l3vpnifs.DefaultL3VpnIf;
|
||||
import org.onosproject.yang.gen.v1.ne.l3vpn.comm.rev20141225.nel3vpncomm.l3vpnifs.l3vpnifs.L3VpnIf;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20140508.ietfinterfaces.DefaultDevices;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20140508.ietfinterfaces.devices.Device;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20140508.ietfinterfaces.devices.device.Interfaces;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20140508.ietfinterfaces.devices.device.interfaces.DefaultYangAutoPrefixInterface;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20140508.ietfinterfaces.devices.device.interfaces.YangAutoPrefixInterface;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.Ipv4;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.Address;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.address.subnet.PrefixLength;
|
||||
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.instance.rev20160623.ietfnetworkinstance.devices.device.interfaces.yangautoprefixinterface.DefaultAugmentedIfInterface;
|
||||
import org.onosproject.yang.model.InnerModelObject;
|
||||
import org.onosproject.yang.model.ModelObjectData;
|
||||
import org.onosproject.yang.model.ModelObjectId;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.DEVICE_NULL;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.OBJECT_NULL;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getData;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getIdFromModId;
|
||||
import static org.onosproject.drivers.huawei.DriverUtil.getObjFromModData;
|
||||
import static org.onosproject.yang.gen.v1.l3vpn.comm.type.rev20141225.nel3vpncommtype.Ipv4Address.fromString;
|
||||
|
||||
/**
|
||||
* Representation of utility for interface creation and deletion.
|
||||
*/
|
||||
public final class IntConstructionUtil {
|
||||
|
||||
/**
|
||||
* Error message for illegal length of mask.
|
||||
*/
|
||||
private static final String ILLEGAL_MASK_LENGTH = "Illegal length of mask" +
|
||||
" is not allowed.";
|
||||
|
||||
// No instantiation.
|
||||
private IntConstructionUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the created model object data of VPN bounded interface of huawei
|
||||
* device from the standard model object data.
|
||||
*
|
||||
* @param modObj model object data
|
||||
* @return driver interface model object data
|
||||
*/
|
||||
static ModelObjectData getCreateInt(ModelObjectData modObj) {
|
||||
boolean isModIdAvail = true;
|
||||
String id = getIdFromModId(modObj.identifier());
|
||||
Object obj = getObjFromModData(modObj);
|
||||
if (id == null) {
|
||||
isModIdAvail = false;
|
||||
id = getIdFromRootObj(obj);
|
||||
obj = getObjFromDevObj(obj);
|
||||
}
|
||||
if (obj == null) {
|
||||
throw new IllegalArgumentException(OBJECT_NULL);
|
||||
}
|
||||
List<YangAutoPrefixInterface> intList = ((Interfaces) obj)
|
||||
.yangAutoPrefixInterface();
|
||||
YangAutoPrefixInterface l3Int = intList.get(0);
|
||||
DefaultAugmentedIfInterface ifInt =
|
||||
((DefaultYangAutoPrefixInterface) l3Int).augmentation(
|
||||
DefaultAugmentedIfInterface.class);
|
||||
String insName = ifInt.bindNetworkInstanceName();
|
||||
L3VpnIfs l3VpnIfs = getDriverInterfaces(l3Int);
|
||||
return getDriModObj(id, insName, l3VpnIfs, isModIdAvail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver model object data, according to the levels it has
|
||||
* to be constructed.
|
||||
*
|
||||
* @param id device id
|
||||
* @param insName VPN name
|
||||
* @param l3VpnIfs driver VPN if object
|
||||
* @param isModIdAvail model id availability
|
||||
* @return driver model object data
|
||||
*/
|
||||
private static ModelObjectData getDriModObj(String id, String insName,
|
||||
L3VpnIfs l3VpnIfs,
|
||||
boolean isModIdAvail) {
|
||||
List<L3VpnIf> intList = l3VpnIfs.l3VpnIf();
|
||||
Iterator<L3VpnIf> it = intList.iterator();
|
||||
L3VpnIf l3VpnIf = it.next();
|
||||
ModelObjectData data;
|
||||
ModelObjectId.Builder objId = getModIdBuilder(id, insName);
|
||||
if (isModIdAvail) {
|
||||
objId.addChild(DefaultL3VpnIfs.class);
|
||||
data = getData(objId.build(), (InnerModelObject) l3VpnIf);
|
||||
} else {
|
||||
data = getData(objId.build(), (InnerModelObject) l3VpnIfs);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static ModelObjectId.Builder getModIdBuilder(String id,
|
||||
String vpnName) {
|
||||
DeviceKeys key = new DeviceKeys();
|
||||
key.deviceid(id);
|
||||
L3VpnInstanceKeys insKey = new L3VpnInstanceKeys();
|
||||
insKey.vrfName(vpnName);
|
||||
return ModelObjectId.builder()
|
||||
.addChild(org.onosproject.yang.gen.v1.ne.l3vpn.api.rev20141225
|
||||
.nel3vpnapi.DefaultDevices.class)
|
||||
.addChild(org.onosproject.yang.gen.v1.ne.l3vpn.api
|
||||
.rev20141225.nel3vpnapi.devices
|
||||
.DefaultDevice.class, key)
|
||||
.addChild(DefaultL3Vpn.class)
|
||||
.addChild(DefaultL3Vpncomm.class)
|
||||
.addChild(DefaultL3VpnInstances.class)
|
||||
.addChild(DefaultL3VpnInstance.class, insKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver interfaces from the standard device model interfaces.
|
||||
*
|
||||
* @param ifs standard device model interfaces
|
||||
* @return driver interfaces
|
||||
*/
|
||||
private static L3VpnIfs getDriverInterfaces(YangAutoPrefixInterface ifs) {
|
||||
L3VpnIfs l3VpnIfs = new DefaultL3VpnIfs();
|
||||
L3VpnIf l3VpnIf = new DefaultL3VpnIf();
|
||||
List<L3VpnIf> l3VpnIfList = new LinkedList<>();
|
||||
l3VpnIf.ifName(ifs.name());
|
||||
org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip
|
||||
.rev20140616.ietfip.devices.device.interfaces
|
||||
.yangautoprefixinterface.DefaultAugmentedIfInterface ipAug =
|
||||
((DefaultYangAutoPrefixInterface) ifs).augmentation(
|
||||
org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang
|
||||
.ietf.ip.rev20140616.ietfip.devices.device
|
||||
.interfaces.yangautoprefixinterface
|
||||
.DefaultAugmentedIfInterface.class);
|
||||
|
||||
if (ipAug != null && ipAug.ipv4() != null) {
|
||||
Ipv4 ipAddress = ipAug.ipv4();
|
||||
for (Address add : ipAddress.address()) {
|
||||
Ipv4Address v4Add = fromString(add.ip().ipv4Address()
|
||||
.toString());
|
||||
Ipv4Address subnet = fromString(getSubnet(
|
||||
((PrefixLength) add.subnet()).prefixLength()));
|
||||
l3VpnIf.ipv4Addr(v4Add);
|
||||
l3VpnIf.subnetMask(subnet);
|
||||
}
|
||||
}
|
||||
l3VpnIfList.add(l3VpnIf);
|
||||
l3VpnIfs.l3VpnIf(l3VpnIfList);
|
||||
return l3VpnIfs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the device id from the root object.
|
||||
*
|
||||
* @param obj root object
|
||||
* @return device id
|
||||
*/
|
||||
private static String getIdFromRootObj(Object obj) {
|
||||
Device dev = getDevFromRootObj(obj);
|
||||
return dev.deviceid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the device from the root object.
|
||||
*
|
||||
* @param obj root object
|
||||
* @return device object
|
||||
*/
|
||||
private static Device getDevFromRootObj(Object obj) {
|
||||
List<Device> deviceList = ((DefaultDevices) obj).device();
|
||||
Iterator<Device> it = deviceList.iterator();
|
||||
if (it.hasNext()) {
|
||||
return it.next();
|
||||
}
|
||||
throw new IllegalArgumentException(DEVICE_NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the interfaces object from the root object.
|
||||
*
|
||||
* @param obj root object
|
||||
* @return interfaces object
|
||||
*/
|
||||
private static Interfaces getObjFromDevObj(Object obj) {
|
||||
Device dev = getDevFromRootObj(obj);
|
||||
return dev.interfaces();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subnet address from the mask value.
|
||||
*
|
||||
* @param mask mask value
|
||||
* @return subnet address
|
||||
*/
|
||||
private static String getSubnet(short mask) {
|
||||
int value = 0xffffffff << (32 - mask);
|
||||
byte[] bytes = new byte[]{
|
||||
(byte) (value >>> 24), (byte) (value >> 16 & 0xff),
|
||||
(byte) (value >> 8 & 0xff), (byte) (value & 0xff)};
|
||||
InetAddress netAdd;
|
||||
try {
|
||||
netAdd = InetAddress.getByAddress(bytes);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new IllegalArgumentException(ILLEGAL_MASK_LENGTH);
|
||||
}
|
||||
return netAdd.getHostAddress();
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.drivers.huawei;
|
||||
|
||||
/**
|
||||
* Represents the model id level of the VPN instance.
|
||||
*/
|
||||
public enum ModelIdLevel {
|
||||
|
||||
/**
|
||||
* Requested model id level is not present, representing top node.
|
||||
*/
|
||||
ROOT,
|
||||
|
||||
/**
|
||||
* Requested model id level is devices container.
|
||||
*/
|
||||
DEVICE,
|
||||
|
||||
/**
|
||||
* Requested model id level is device list.
|
||||
*/
|
||||
DEVICES
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package for Huawei device drivers.
|
||||
*/
|
||||
package org.onosproject.drivers.huawei;
|
25
drivers/huawei/driver/src/main/resources/huawei-drivers.xml
Normal file
25
drivers/huawei/driver/src/main/resources/huawei-drivers.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2017-present Open Networking Laboratory
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<drivers>
|
||||
<driver name="huawei" extends="" manufacturer="Huawei"
|
||||
hwVersion="" swVersion="">
|
||||
<behaviour api="org.onosproject.net.behaviour.L3vpnConfig"
|
||||
impl="org.onosproject.drivers.huawei.HuaweiL3vpnConfig"/>
|
||||
<behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
|
||||
impl="org.onosproject.drivers.huawei.HuaweiDeviceDescription"/>
|
||||
</driver>
|
||||
</drivers>
|
39
drivers/huawei/pom.xml
Normal file
39
drivers/huawei/pom.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2017-present Open Networking Laboratory
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-drivers-general</artifactId>
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>onos-drivers-huawei</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>driver</module>
|
||||
<module>yangmodel</module>
|
||||
</modules>
|
||||
|
||||
<description>L3VPN YANG Application</description>
|
||||
</project>
|
13
drivers/huawei/yangmodel/BUCK
Normal file
13
drivers/huawei/yangmodel/BUCK
Normal file
@ -0,0 +1,13 @@
|
||||
COMPILE_DEPS = [
|
||||
'//lib:CORE_DEPS',
|
||||
'//lib:onos-yang-model',
|
||||
]
|
||||
|
||||
yang_osgi_jar(
|
||||
deps = COMPILE_DEPS,
|
||||
name = 'onos-drivers-huawei-yangmodel',
|
||||
srcs = glob(['src/main/**/*.yang']),
|
||||
visibility = [
|
||||
'PUBLIC'
|
||||
],
|
||||
)
|
66
drivers/huawei/yangmodel/pom.xml
Normal file
66
drivers/huawei/yangmodel/pom.xml
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2017-present Open Networking Laboratory
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-yang-model</artifactId>
|
||||
<version>1.12.0-b7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<parent>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-drivers-huawei</artifactId>
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>onos-drivers-huawei-yangmodel</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<description>Huawei L3VPN YANG model</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-yang-compiler-maven-plugin</artifactId>
|
||||
<version>1.12.0-b7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>yang2java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
115
drivers/huawei/yangmodel/src/main/yang/ne-bgpcomm-type.yang
Normal file
115
drivers/huawei/yangmodel/src/main/yang/ne-bgpcomm-type.yang
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
WARNING:
|
||||
This yang model is just for fuction ONOS opensource project demo purpose only,
|
||||
And is subject to change in future, Huawei does not commit provide compatibilty
|
||||
in commercial product.
|
||||
*/
|
||||
module ne-bgpcomm-type {
|
||||
namespace "ne-bgpcomm-type";
|
||||
prefix bgpcomm-type;
|
||||
organization "Huawei Technologies Co., Ltd";
|
||||
contact "Huawei Industrial Base
|
||||
Bantian, Longgang
|
||||
Shenzhen 518129
|
||||
People's Republic of China
|
||||
Website: http://www.huawei.com
|
||||
Email: support@huawei.com";
|
||||
description "ne-bgpcomm-type yang";
|
||||
revision "2014-12-25" {
|
||||
description "Initial version";
|
||||
}
|
||||
typedef bgpcommImRouteProtocol {
|
||||
type enumeration {
|
||||
enum "direct" {
|
||||
value 0;
|
||||
description "direct:";
|
||||
}
|
||||
enum "ospf" {
|
||||
value 1;
|
||||
description "ospf:";
|
||||
}
|
||||
enum "isis" {
|
||||
value 2;
|
||||
description "isis:";
|
||||
}
|
||||
enum "static" {
|
||||
value 3;
|
||||
description "static:";
|
||||
}
|
||||
enum "rip" {
|
||||
value 4;
|
||||
description "rip:";
|
||||
}
|
||||
enum "ospfv3" {
|
||||
value 5;
|
||||
description "ospfv3:";
|
||||
}
|
||||
enum "ripng" {
|
||||
value 6;
|
||||
description "ripng:";
|
||||
}
|
||||
enum "unr" {
|
||||
value 7;
|
||||
description "unr:";
|
||||
}
|
||||
enum "op-route" {
|
||||
value 8;
|
||||
description "op-route:";
|
||||
}
|
||||
}
|
||||
description "";
|
||||
}
|
||||
typedef bgpcommPrefixType {
|
||||
type enumeration {
|
||||
enum "ipv4uni" {
|
||||
value 0;
|
||||
description "ipv4uni:";
|
||||
}
|
||||
enum "ipv4multi" {
|
||||
value 1;
|
||||
description "ipv4multi:";
|
||||
}
|
||||
enum "ipv4vpn" {
|
||||
value 2;
|
||||
description "ipv4vpn:";
|
||||
}
|
||||
enum "ipv6uni" {
|
||||
value 3;
|
||||
description "ipv6uni:";
|
||||
}
|
||||
enum "ipv6vpn" {
|
||||
value 4;
|
||||
description "ipv6vpn:";
|
||||
}
|
||||
enum "ipv4flow" {
|
||||
value 5;
|
||||
description "ipv4flow:";
|
||||
}
|
||||
enum "l2vpnad" {
|
||||
value 6;
|
||||
description "l2vpnad:";
|
||||
}
|
||||
enum "mvpn" {
|
||||
value 7;
|
||||
description "mvpn:";
|
||||
}
|
||||
enum "evpn" {
|
||||
value 8;
|
||||
description "evpn:";
|
||||
}
|
||||
enum "ipv4vpnmcast" {
|
||||
value 9;
|
||||
description "ipv4vpnmcast:";
|
||||
}
|
||||
enum "ls" {
|
||||
value 10;
|
||||
description "ls:";
|
||||
}
|
||||
enum "mdt" {
|
||||
value 11;
|
||||
description "mdt:";
|
||||
}
|
||||
}
|
||||
description "";
|
||||
}
|
||||
}
|
77
drivers/huawei/yangmodel/src/main/yang/ne-bgpcomm.yang
Normal file
77
drivers/huawei/yangmodel/src/main/yang/ne-bgpcomm.yang
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
WARNING:
|
||||
This yang model is just for fuction ONOS opensource project demo purpose only,
|
||||
And is subject to change in future, Huawei does not commit provide compatibilty
|
||||
in commercial product.
|
||||
*/
|
||||
module ne-bgpcomm {
|
||||
namespace "ne-bgpcomm";
|
||||
prefix bgpcomm;
|
||||
import ne-bgpcomm-type {
|
||||
prefix bgpcomm-type;
|
||||
}
|
||||
organization "Huawei Technologies Co., Ltd";
|
||||
contact "Huawei Industrial Base
|
||||
Bantian, Longgang
|
||||
Shenzhen 518129
|
||||
People's Republic of China
|
||||
Website: http://www.huawei.com
|
||||
Email: support@huawei.com";
|
||||
description "ne-bgpcomm yang";
|
||||
revision "2014-12-25" {
|
||||
description "Initial version";
|
||||
}
|
||||
|
||||
container devices {
|
||||
list device {
|
||||
key deviceid;
|
||||
leaf deviceid {
|
||||
type string;
|
||||
}
|
||||
container bgp {
|
||||
container bgpcomm {
|
||||
description "";
|
||||
container bgpVrfs {
|
||||
description "";
|
||||
list bgpVrf {
|
||||
key "vrfName";
|
||||
description "BGP instance class";
|
||||
leaf vrfName {
|
||||
description "Specifies the name of the VPN in stance.
|
||||
It is a string of 1 to 31 case-sensitive characters.";
|
||||
type string;
|
||||
}
|
||||
container bgpVrfAFs {
|
||||
description "";
|
||||
list bgpVrfAF {
|
||||
key "afType";
|
||||
description "IPv4 unicast Address family class for
|
||||
BGP instance";
|
||||
leaf afType {
|
||||
type "bgpcomm-type:bgpcommPrefixType";
|
||||
description "Address family";
|
||||
}
|
||||
container importRoutes {
|
||||
description "";
|
||||
list importRoute {
|
||||
key "importProtocol importProcessId";
|
||||
description "Import route class";
|
||||
leaf importProtocol {
|
||||
type "bgpcomm-type:bgpcommImRouteProtocol";
|
||||
description "Specifies the protocol from
|
||||
which routes are imported.";
|
||||
}
|
||||
leaf importProcessId {
|
||||
type "string";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
82
drivers/huawei/yangmodel/src/main/yang/ne-l3vpn-api.yang
Normal file
82
drivers/huawei/yangmodel/src/main/yang/ne-l3vpn-api.yang
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
WARNING:
|
||||
This yang model is just for fuction ONOS opensource project demo purpose only,
|
||||
And is subject to change in future, Huawei does not commit provide compatibilty
|
||||
in commercial product.
|
||||
*/
|
||||
module ne-l3vpn-api {
|
||||
namespace "ne-l3vpn-api";
|
||||
prefix l3vpn-api;
|
||||
import ne-l3vpncomm-type {
|
||||
prefix l3vpncomm-type;
|
||||
}
|
||||
import ne-l3vpncomm {
|
||||
prefix l3vpncomm;
|
||||
}
|
||||
organization "Huawei Technologies Co., Ltd";
|
||||
contact "Huawei Industrial Base
|
||||
Bantian, Longgang
|
||||
Shenzhen 518129
|
||||
People's Republic of China
|
||||
Website: http://www.huawei.com
|
||||
Email: support@huawei.com";
|
||||
description "VRP V800R010 Schema";
|
||||
revision "2014-12-25" {
|
||||
reference "Huawei VRPV8 Schema";
|
||||
}
|
||||
container devices {
|
||||
list device {
|
||||
key deviceid;
|
||||
leaf deviceid {
|
||||
type string;
|
||||
}
|
||||
container l3vpn {
|
||||
container l3vpncomm {
|
||||
container l3vpnInstances {
|
||||
description "";
|
||||
list l3vpnInstance {
|
||||
key "vrfName";
|
||||
leaf vrfName {
|
||||
type string;
|
||||
}
|
||||
leaf vrfDescription {
|
||||
type string;
|
||||
}
|
||||
uses l3vpncomm:l3vpnIfs;
|
||||
container vpnInstAFs {
|
||||
description "";
|
||||
list vpnInstAF {
|
||||
key "afType";
|
||||
description "Address family";
|
||||
leaf afType {
|
||||
type "l3vpncomm-type:l3vpncommonL3vpnPrefixType";
|
||||
description "Address family";
|
||||
}
|
||||
leaf vrfRD {
|
||||
when "vrfName != '_public_'";
|
||||
type "string";
|
||||
description "route-distinguisher.";
|
||||
}
|
||||
container vpnTargets {
|
||||
description "";
|
||||
list vpnTarget {
|
||||
must "vrfName != '_public_' and vpnTarget = '0'";
|
||||
key "vrfRTValue vrfRTType";
|
||||
description "L3vpn vpntarget configure class";
|
||||
leaf vrfRTValue {
|
||||
type "string";
|
||||
}
|
||||
leaf vrfRTType {
|
||||
type "l3vpncomm-type:l3vpncommonVrfRtType";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
WARNING:
|
||||
This yang model is just for fuction ONOS opensource project demo purpose only,
|
||||
And is subject to change in future, Huawei does not commit provide compatibilty
|
||||
in commercial product.
|
||||
*/
|
||||
module ne-l3vpncomm-type {
|
||||
namespace "l3vpn-comm-type";
|
||||
prefix l3vpncomm-type;
|
||||
organization "Huawei Technologies Co., Ltd";
|
||||
contact "Huawei Industrial Base
|
||||
Bantian, Longgang
|
||||
Shenzhen 518129
|
||||
People's Republic of China
|
||||
Website: http://www.huawei.com
|
||||
Email: support@huawei.com";
|
||||
description "";
|
||||
revision "2014-12-25" {
|
||||
description "Initial version";
|
||||
}
|
||||
typedef l3vpncommonL3vpnPrefixType {
|
||||
type enumeration {
|
||||
enum "ipv4uni" {
|
||||
value 0;
|
||||
description "ipv4uni:";
|
||||
}
|
||||
enum "ipv6uni" {
|
||||
value 1;
|
||||
description "ipv6uni:";
|
||||
}
|
||||
}
|
||||
description "";
|
||||
}
|
||||
typedef l3vpncommonVrfRtType {
|
||||
type enumeration {
|
||||
enum "export_extcommunity" {
|
||||
value 0;
|
||||
description "export-extcommunity:";
|
||||
}
|
||||
enum "import_extcommunity" {
|
||||
value 1;
|
||||
description "import-extcommunity:";
|
||||
}
|
||||
}
|
||||
description "";
|
||||
}
|
||||
typedef ipv4Address {
|
||||
type string {
|
||||
length "0..255";
|
||||
pattern "((([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}
|
||||
([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))";
|
||||
}
|
||||
}
|
||||
}
|
49
drivers/huawei/yangmodel/src/main/yang/ne-l3vpncomm.yang
Normal file
49
drivers/huawei/yangmodel/src/main/yang/ne-l3vpncomm.yang
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
WARNING:
|
||||
This yang model is just for fuction ONOS opensource project demo purpose only,
|
||||
And is subject to change in future, Huawei does not commit provide compatibilty
|
||||
in commercial product.
|
||||
*/
|
||||
module ne-l3vpncomm {
|
||||
namespace "ne-l3vpn-comm";
|
||||
prefix "l3vpncomm";
|
||||
import ne-l3vpncomm-type {
|
||||
prefix l3vpncomm-type;
|
||||
}
|
||||
organization "Huawei Technologies Co., Ltd";
|
||||
contact "Huawei Industrial Base
|
||||
Bantian, Longgang
|
||||
Shenzhen 518129
|
||||
People's Republic of China
|
||||
Website: http://www.huawei.com
|
||||
Email: support@huawei.com";
|
||||
description "";
|
||||
revision "2014-12-25" {
|
||||
description "Initial version";
|
||||
}
|
||||
grouping l3vpnIfs {
|
||||
container l3vpnIfs {
|
||||
description "";
|
||||
list l3vpnIf {
|
||||
key "ifName";
|
||||
description "interface Name.";
|
||||
leaf ifName {
|
||||
type string;
|
||||
description "interface Name";
|
||||
}
|
||||
leaf ipv4Addr {
|
||||
when "subnetMask != null";
|
||||
mandatory "true";
|
||||
type "l3vpncomm-type:ipv4Address";
|
||||
description "Interface Address.";
|
||||
}
|
||||
leaf subnetMask {
|
||||
when "ipv4Addr != null";
|
||||
mandatory "true";
|
||||
type "l3vpncomm-type:ipv4Address";
|
||||
description "Interface address mask.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -48,6 +48,7 @@
|
||||
<module>juniper</module>
|
||||
<module>lisp</module>
|
||||
<module>flowspec</module>
|
||||
<module>huawei</module>
|
||||
</modules>
|
||||
|
||||
<!--<properties>
|
||||
|
@ -95,6 +95,7 @@ ONOS_DRIVERS = [
|
||||
'//drivers/juniper:onos-drivers-juniper-oar',
|
||||
'//drivers/lisp:onos-drivers-lisp-oar',
|
||||
'//drivers/flowspec:onos-drivers-flowspec-oar',
|
||||
'//drivers/huawei:onos-drivers-huawei-oar',
|
||||
]
|
||||
|
||||
ONOS_PROVIDERS = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user