Updating Microsemi Driver to onos-yang-tools 2.x

Change-Id: I80e3348087518a8f9a742c813b6238371a3f8f97
This commit is contained in:
Sean Condon 2017-06-09 15:14:01 +01:00
parent ce25649ff6
commit 06613e9e35
110 changed files with 2442 additions and 3276 deletions

View File

@ -3,29 +3,31 @@ COMPILE_DEPS = [
'//drivers/utilities:onos-drivers-utilities',
'//protocols/netconf/api:onos-protocols-netconf-api',
'//protocols/netconf/ctl:onos-protocols-netconf-ctl',
'//drivers/microsemi/ea1000yang:onos-drivers-microsemi-ea1000yang',
'//drivers/microsemi/ea1000yang:onos-drivers-microsemi-ea1000yang-gen',
'//models/microsemi:onos-models-microsemi',
'//lib:org.apache.karaf.shell.console',
'//cli:onos-cli',
'//incubator/api:onos-incubator-api',
]
] + YANG_TOOLS
TEST_DEPS = [
'//lib:TEST_ADAPTERS',
'//core/api:onos-api-tests',
'//drivers/netconf:onos-drivers-netconf-tests',
'//drivers/microsemi/ea1000yang:onos-drivers-microsemi-ea1000yang-tests',
'//utils/osgi:onlab-osgi-tests'
]
BUNDLES = [
'//drivers/utilities:onos-drivers-utilities',
'//drivers/microsemi/ea1000yang:onos-drivers-microsemi-ea1000yang',
APPS = [
'org.onosproject.yang',
# 'org.onosproject.yang-gui',
'org.onosproject.config',
'org.onosproject.netconf',
'org.onosproject.netconfsb',
'org.onosproject.drivers.netconf',
'org.onosproject.models.microsemi'
]
osgi_jar_with_tests (
deps = COMPILE_DEPS,
test_deps = TEST_DEPS,
srcs = glob(['src/main/java/**/*.java']),
resources_root = 'src/main/resources',
resources = glob(['src/main/resources/**']),
)
@ -36,6 +38,5 @@ onos_app (
category = 'Drivers',
url = 'http://onosproject.org',
description = 'ONOS Microsemi device drivers application.',
included_bundles = BUNDLES,
required_apps = [ 'org.onosproject.netconf', 'org.onosproject.yms' ],
required_apps = APPS,
)

View File

@ -7,60 +7,45 @@ The User Guide for this product is available on request from Microsemi, and give
Currently only a subset of it's functionality is supported through ONOS, but this will expand to full functionality in future releases.
#Compile and Installation
Currently this driver is **not** built using BUCK (because it depends on an older version of onos-yang-tools, while BUCK points to the newer version of the onos-yang-tools)<br/>
Currently this driver is built using BUCK and uses version 2.1 of onos-yang-tools<br/>
Before this driver can work successfully one problem with the Yang Management System (YMS) App has to be taken in to account. This is that the Yang Codec Handler (YCH) part needs to be built in Maven (when compiled in Buck something is not configured properly).<br/>
To build YMS with Maven:
1. Change directory to onos/apps/yms/app
2. Run the command "mvn clean install" (or use the shortcut 'mci')
3. With onos running, **reinstall** the generated OAR file for YMS on the target machine (could be localhost - replace {bracketed} values with real values)
* onos-app {onos-server} reinstall! target/onos-app-yms-{version}.oar
Then this Microsemi driver has to be built using Maven and installed. To build it:
1. Change directory to onos/drivers/microsemi
2. Run the command "mvn clean install" (or use the shortcut 'mci')
3. With onos running, install the 2 generated OAR files on the target machine (could be localhost - replace {bracketed} values with real values)
* onos-app {onos-server} install ea1000yang/target/onos-drivers-microsemi-ea1000yang-{version}.oar
* onos-app {onos-server} install ea1000driver/target/onos-drivers-microsemi-ea1000-{version}.oar
4. Verify that they are installed by calling **apps -s | grep microsemi** at the onos> prompt
5. Activate the modules at the onos prompt
* onos:app activate org.onosproject.drivers.netconf org.onosproject.drivers.microsemi.yang org.onosproject.drivers.microsemi
All that is required to activate the driver is to run the following at the ONOS CLI<br/>
**`onos:app activate org.onosproject.drivers.microsemi`**<br/>
This will load any dependent apps also. To verify the driver has been loaded run the command<br/>
**onos:apps -a -s**
#Change NETCONF default connection timeout
Connection timeouts need to be increased from default values when using EA1000. At ONOS command line run
`onos:cfg set org.onosproject.netconf.ctl.NetconfControllerImpl netconfConnectTimeout 150`<br/>
`onos:cfg set org.onosproject.netconf.ctl.NetconfControllerImpl netconfReplyTimeout 150`<br/>
`onos:cfg set org.onosproject.netconf.ctl.impl.NetconfControllerImpl netconfConnectTimeout 50`<br/>
`onos:cfg set org.onosproject.netconf.ctl.impl.NetconfControllerImpl netconfReplyTimeout 50`<br/>
#Creating Devices
EA1000 Devices will not be automatically discovered at present in ONOS. They have to be created through the network/configuration REST interface in ONOS.
* The name must follow the format **netconf:<ipaddr>:<port>**
* The name must follow the format **netconf:ipaddr:port**
* The **ip** and **port** must correspond to the ip and port in the name (above).
`{`<br/>
`&nbsp;"devices": {`<br/>
`&nbsp;&nbsp;"netconf:192.168.56.10:830": {`<br/>
`&nbsp;&nbsp;&nbsp;"netconf": {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"username": "admin",`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"password": "admin",`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ip": "192.168.56.10",`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"port": "830"`<br/>
`&nbsp;&nbsp;&nbsp;},`<br/>
`&nbsp;&nbsp;&nbsp;"basic": {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;"driver": "microsemi-netconf",`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;"type": "SWITCH",`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;"manufacturer": "Microsemi",`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;"hwVersion": "EA1000"`<br/>
`&nbsp;&nbsp;&nbsp;}`<br/>
`&nbsp;&nbsp;}`<br/>
`&nbsp;}`<br/>
&nbsp;`"devices": {`<br/>
&nbsp;&nbsp;`"netconf:192.168.56.10:830": {`<br/>
&nbsp;&nbsp;&nbsp;`"netconf": {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"username": "admin",`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"password": "admin",`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"ip": "192.168.56.10",`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"port": "830"`<br/>
&nbsp;&nbsp;&nbsp;`},`<br/>
&nbsp;&nbsp;&nbsp;`"basic": {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`"driver": "microsemi-netconf",`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`"type": "SWITCH",`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`"manufacturer": "Microsemi",`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`"hwVersion": "EA1000"`<br/>
&nbsp;&nbsp;&nbsp;`}`<br/>
&nbsp;&nbsp;`}`<br/>
&nbsp;`}`<br/>
`}`<br/>
#Connected Device
When the EA1000 is configured and connected is should be visible in ONOS through the **devices** command.
@ -94,22 +79,22 @@ A feature of the EA1000 that may be configured through Flow Rules is IP Source A
`POST /onos/v1/flows/ HTTP/1.1`<br/>
`{`<br/>
`&nbsp;"flows": [`<br/>
`&nbsp;&nbsp;{`<br/>
`&nbsp;&nbsp;&nbsp;"priority": 40000,`<br/>
`&nbsp;&nbsp;&nbsp;"timeout": 0,`<br/>
`&nbsp;&nbsp;&nbsp;"isPermanent": true,`<br/>
`&nbsp;&nbsp;&nbsp;"deviceId": "netconf:192.168.56.10:830",`<br/>
`&nbsp;&nbsp;&nbsp;"tableId": 8,`<br/>
`&nbsp;&nbsp;&nbsp;"treatment": {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;"instructions": [ {"type": "NOACTION"} ],`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;"deferred": []`<br/>
`&nbsp;&nbsp;&nbsp;},`<br/>
`&nbsp;&nbsp;&nbsp;"selector": {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;"criteria": [ {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "IPV4_SRC", "ip": "192.168.8.0/24"`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;},{`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "IN_PORT", "port": "0"`<br/>
&nbsp;`"flows": [`<br/>
&nbsp;&nbsp;`{`<br/>
&nbsp;&nbsp;&nbsp;`"priority": 50000,`<br/>
&nbsp;&nbsp;&nbsp;`"timeout": 0,`<br/>
&nbsp;&nbsp;&nbsp;`"isPermanent": true,`<br/>
&nbsp;&nbsp;&nbsp;`"deviceId": "netconf:192.168.56.10:830",`<br/>
&nbsp;&nbsp;&nbsp;`"tableId": 8,`<br/>
&nbsp;&nbsp;&nbsp;`"treatment": {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`"instructions": [ {"type": "NOACTION"} ],`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`"deferred": []`<br/>
&nbsp;&nbsp;&nbsp;`},`<br/>
&nbsp;&nbsp;&nbsp;`"selector": {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`"criteria": [ {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"type": "IPV4_SRC", "ip": "192.168.8.0/24"`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`},{`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"type": "IN_PORT", "port": "0"`<br/>
`} ] } } ] }`<br/>
## Vlan Tag Manipulation
@ -306,34 +291,34 @@ On the actual EA1000 itself using a NETCONF CLI Client like yangcli-pro, the res
`admin@192.168.56.10> sget-config /mef-services/uni source=running`<br/>
`rpc-reply {`<br/>
`&nbsp;data {`<br/>
`&nbsp;&nbsp;mef-services {`<br/>
`&nbsp;&nbsp;&nbsp;uni {` -- There is only one UNI on the EA1000<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;name Uni-on-192.168.56.10:830` -- Automatically assigned<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;evc 1 {` -- From the VLAN 1 from CE app<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evc-index 1`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name EVC-1` -- Automatically assigned<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evc-per-uni {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evc-per-uni-c {` -- The UNI-C side<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ce-vlan-map 101` -- Could be a range of values<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flow-mapping {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ce-vlan-id 101`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flow-id 31243725464268887` -- For tracking with ONOS<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ingress-bwp-group-index 0` -- No meters<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tag-push {` -- Push on an a VLAN<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;push-tag-type pushStag` -- Push type is S-TAG<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outer-tag-vlan 1` -- Push value is 1<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evc-per-uni-n {` -- For the UNI-N side<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ce-vlan-map 1` -- The VLAN to match for egress on this side<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flow-mapping {`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ce-vlan-id 1`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flow-id 31243723770830293`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ingress-bwp-group-index 0`<br/>
`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tag-pop {` -- Pop off the S-TAG<br/>
&nbsp;data `{`<br/>
&nbsp;&nbsp;`mef-services {`<br/>
&nbsp;&nbsp;&nbsp;`uni {` -- There is only one UNI on the EA1000<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`name Uni-on-192.168.56.10:830` -- Automatically assigned<br/>
&nbsp;&nbsp;&nbsp;&nbsp;`evc 1 {` -- From the VLAN 1 from CE app<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`evc-index 1`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`name EVC-1` -- Automatically assigned<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`evc-per-uni {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`evc-per-uni-c {` -- The UNI-C side<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`ce-vlan-map 101` -- Could be a range of values<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`flow-mapping {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`ce-vlan-id 101`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`flow-id 31243725464268887` -- For tracking with ONOS<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`}`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`ingress-bwp-group-index 0` -- No meters<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`tag-push {` -- Push on an a VLAN<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`push-tag-type pushStag` -- Push type is S-TAG<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`outer-tag-vlan 1` -- Push value is 1<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`}`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`}`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`evc-per-uni-n {` -- For the UNI-N side<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`ce-vlan-map 1` -- The VLAN to match for egress on this side<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`flow-mapping {`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`ce-vlan-id 1`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`flow-id 31243723770830293`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`}`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`ingress-bwp-group-index 0`<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`tag-pop {` -- Pop off the S-TAG<br/>
`} } } } } } } }`<br/>
`admin@192.168.56.10>`<br/>

View File

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Copyright 2016 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>
<artifactId>onos-drivers-microsemi</artifactId>
<groupId>org.onosproject</groupId>
<version>1.11.0-SNAPSHOT</version>
</parent>
<artifactId>onos-drivers-microsemi-ea1000</artifactId>
<packaging>bundle</packaging>
<description>Microsemi EA1000 device drivers for ONOS</description>
<url>http://www.microsemi.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<onos.version>${project.version}</onos.version>
<onos.app.name>org.onosproject.drivers.microsemi</onos.app.name>
<onos.app.title>Microsemi Device Drivers</onos.app.title>
<onos.app.origin>Microsemi, Inc.</onos.app.origin>
<onos.app.category>Drivers</onos.app.category>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.readme>For various Microsemi Devices including EdgeAssure
1000 SFP-NID</onos.app.readme>
<onos.app.requires>org.onosproject.netconf</onos.app.requires>
<onos.app.requires>org.onosproject.drivers.netconf</onos.app.requires>
<onos.app.requires>org.onosproject.yms</onos.app.requires>
<onos.app.requires>org.onosproject.drivers.microsemi.yang</onos.app.requires>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-netconf-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-drivers-microsemi-ea1000yang</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-drivers-microsemi-ea1000yang</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-yms-api</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-yms</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-drivers-netconf</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,36 +0,0 @@
YANG_DEPS = [
'//lib:CORE_DEPS',
'//lib:onos-yang-datamodel',
'//lib:onos-yang-utils-generator',
]
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//apps/yms/api:onos-apps-yms-api',
'//protocols/netconf/api:onos-protocols-netconf-api',
'//lib:onos-yang-datamodel',
'//lib:onos-yang-utils-generator',
'//lib:org.apache.servicemix.bundles.dom4j',
'//drivers/microsemi/ea1000yang:onos-drivers-microsemi-ea1000yang-gen',
]
TEST_DEPS = [
'//lib:TEST_ADAPTERS',
'//apps/yms/app:onos-apps-yms-app',
'//drivers/netconf:onos-drivers-netconf-tests',
'//protocols/netconf/ctl:onos-protocols-netconf-ctl',
]
yang_osgi_jar(
deps = YANG_DEPS,
name = 'onos-drivers-microsemi-ea1000yang-gen',
srcs = glob(['src/main/yang/**/*.yang']),
visibility = [ 'PUBLIC' ],
)
osgi_jar_with_tests(
deps = COMPILE_DEPS,
test_deps = TEST_DEPS,
visibility = [ 'PUBLIC' ],
srcs = glob(['src/main/**/*.java'])
)

View File

@ -1,144 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Copyright 2016 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>
<artifactId>onos-drivers-microsemi</artifactId>
<groupId>org.onosproject</groupId>
<version>1.11.0-SNAPSHOT</version>
</parent>
<artifactId>onos-drivers-microsemi-ea1000yang</artifactId>
<packaging>bundle</packaging>
<description>Microsemi YANG model for EA1000</description>
<url>http://www.microsemi.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<onos.version>${project.version}</onos.version>
<onos.app.name>org.onosproject.drivers.microsemi.yang</onos.app.name>
<onos.app.title>Microsemi Device Drivers YANG</onos.app.title>
<onos.app.origin>Microsemi, Inc.</onos.app.origin>
<onos.app.category>Drivers</onos.app.category>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.readme>For various Microsemi Devices including EdgeAssure
1000 SFP-NID</onos.app.readme>
<onos.yang.version>1.11</onos.yang.version>
</properties>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-netconf-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-yang-utils-generator</artifactId>
<version>${onos.yang.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-yang-datamodel</artifactId>
<version>${onos.yang.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-yms-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-yms</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-drivers-netconf</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.onosproject</groupId>
<artifactId>onos-yang-maven-plugin</artifactId>
<version>${onos.yang.version}</version>
<executions>
<execution>
<configuration>
<classFileDir>target/generated-sources</classFileDir>
</configuration>
<goals>
<goal>yang2java</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>yang/resources/YangMetaData.ser=target/classes/yang/resources/YangMetaData.ser</Include-Resource>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>onos-yang-plugin-workaround</id>
<!-- yang plugin cannot handle non-clean compilation -->
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>target/generated-sources</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/delaymeasurement/*</exclude>
<exclude>**/lossmeasurement/*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,185 +0,0 @@
/*
* 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.microsemi.yang.impl;
import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REPLY;
import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
import java.util.List;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yms.ych.YangCodecHandler;
import org.onosproject.yms.ych.YangCompositeEncoding;
import org.onosproject.yms.ymsm.YmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Abstract class that implements some of the core functions of a YANG model service.
*
*/
@Component(immediate = true)
@Service
public abstract class AbstractYangServiceImpl {
protected final Logger log = LoggerFactory.getLogger(getClass());
protected boolean alreadyLoaded = false;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected YmsService ymsService;
protected ApplicationId appId;
// YCH is not a service and is a class variable. Can be lost on deactivate.
// Must be recreated on activate
protected YangCodecHandler ych;
@Activate
public abstract void activate();
@Deactivate
public void deactivate() {
alreadyLoaded = false;
}
/**
* Internal method to generically make a NETCONF get query from YANG objects.
* @param yangObjectOpParamFilter A YANG object model
* @param session A NETCONF session
* @return YangObjectModel
* @throws NetconfException if the session has any error
*/
protected final Object getNetconfObject(
Object yangObjectOpParamFilter, NetconfSession session)
throws NetconfException {
if (session == null) {
throw new NetconfException("Session is null when calling getNetconfObject()");
}
if (yangObjectOpParamFilter == null) {
throw new NetconfException("Query object cannot be null");
}
//Convert the param to XML to use as a filter
YangCompositeEncoding xmlQuery =
ych.encodeCompositeOperation(null, null,
yangObjectOpParamFilter, XML, QUERY_REQUEST);
String xmlQueryStr = xmlQuery.getResourceInformation().replace("<>", "").replace("</>", "").trim();
log.debug("Sending <get> query on NETCONF session " + session.getSessionId() +
":\n" + xmlQueryStr);
String xmlResult = session.get(xmlQueryStr, null);
List<Object> objectList = ych.decode(xmlResult, XML, QUERY_REPLY);
if (objectList != null && objectList.size() > 0) {
Object systemObject = objectList.get(0);
return systemObject;
} else {
return null;
}
}
/**
* Internal method to generically make a NETCONF get-config query from YANG objects.
*
* @param yangObjectOpParamFilter A YANG object model
* @param session A NETCONF session
* @param targetDs - running,candidate or startup
* @return YangObjectModel
* @throws NetconfException if the session has any error
*/
protected final Object getConfigNetconfObject(
Object yangObjectOpParamFilter, NetconfSession session, TargetConfig targetDs)
throws NetconfException {
if (session == null) {
throw new NetconfException("Session is null when calling getConfigNetconfObject()");
}
if (yangObjectOpParamFilter == null) {
throw new NetconfException("Query object cannot be null");
}
//Convert the param to XML to use as a filter
YangCompositeEncoding xmlQuery =
ych.encodeCompositeOperation(null, null,
yangObjectOpParamFilter, XML, QUERY_REQUEST);
String xmlQueryStr = xmlQuery.getResourceInformation().replace("<>", "").replace("</>", "").trim();
log.debug("Sending <get-config> for " + targetDs +
" query on NETCONF session " + session.getSessionId() +
":\n" + xmlQueryStr);
String xmlResult = session.getConfig(targetDs, xmlQueryStr);
List<Object> objectList = ych.decode(xmlResult, XML, QUERY_REPLY);
if (objectList != null && objectList.size() > 0) {
Object systemObject = objectList.get(0);
return systemObject;
} else {
return null;
}
}
/**
* Internal method to generically make a NETCONF edit-config call from a set of YANG objects.
*
* @param yangObjectOpParamFilter A YANG object model
* @param session A NETCONF session
* @param targetDs - running,candidate or startup
* @throws NetconfException if the session has any error
*/
protected final void setNetconfObject(
Object yangObjectOpParamFilter, NetconfSession session, TargetConfig targetDs)
throws NetconfException {
if (yangObjectOpParamFilter == null) {
throw new NetconfException("Query object cannot be null");
} else if (session == null) {
throw new NetconfException("Session is null when calling getMseaSaFiltering()");
}
//Convert the param to XML to use as a filter
YangCompositeEncoding xmlContent =
ych.encodeCompositeOperation(null, null,
yangObjectOpParamFilter, XML, EDIT_CONFIG_REQUEST);
String xmlContentStr = xmlContent.getResourceInformation()
.replace("<>", "").replace("</>", "")
//FIXME: Necessary for MEP ccmInterval
.replaceAll("yangAutoPrefix", "")
.trim();
log.debug("Sending XML <edit-config> on NETCONF session " + session.getSessionId() +
":\n" + xmlContentStr);
boolean succeeded = session.editConfig(targetDs, null, xmlContentStr);
if (succeeded) {
log.debug("<edit-config> succeeded through NETCONF");
} else {
throw new NetconfException("Failed to run edit-config through NETCONF");
}
}
}

View File

@ -1,76 +0,0 @@
/*
* 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.microsemi.yang.impl;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.drivers.microsemi.yang.MseaSaFilteringNetconfService;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFilteringService;
/**
* Implementation of the MseaSaFiltering YANG model service.
*/
@Component(immediate = true, inherit = true)
@Service
public class MseaSaFilteringManager extends AbstractYangServiceImpl
implements MseaSaFilteringNetconfService {
public static final String MSEA_SA_FILTERING = "org.onosproject.drivers.microsemi.yang.mseasafiltering";
@Activate
public void activate() {
appId = coreService.registerApplication(MSEA_SA_FILTERING);
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(MseaSaFilteringService.class);
log.info("MseaSaFilteringManager Started");
}
@Deactivate
public void deactivate() {
super.deactivate();
ymsService.unRegisterService(this, MseaSaFilteringService.class);
ych = null;
log.info("MseaSaFilteringManager Stopped");
}
/**
* Get a filtered subset of the model.
* This is meant to filter the current live model
* against the attribute(s) given in the argument
* and return the filtered model.
*/
@Override
public MseaSaFiltering getMseaSaFiltering(MseaSaFilteringOpParam mseaSaFilteringFilter, NetconfSession session)
throws NetconfException {
return (MseaSaFiltering) getNetconfObject(mseaSaFilteringFilter, session);
}
/**
* Call NETCONF edit-config with a configuration.
*/
@Override
public void setMseaSaFiltering(
MseaSaFilteringOpParam mseaSaFiltering, NetconfSession session, TargetConfig ncDs)
throws NetconfException {
setNetconfObject(mseaSaFiltering, session, ncDs);
}
}

View File

@ -1,107 +0,0 @@
/*
* 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.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni;
import org.onosproject.drivers.microsemi.yang.UniSide;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types
.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.FlowMapping;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc.CustomEvcPerUni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnin;
/**
* A custom implementation of the DefaultEvc - especially its Builder.
*
* This allows the Evc to be modified after creation. These additions to the
* builder are necessary because in the EA1000 YANG model many different Open Flow
* flows can be associated with one EVC - each one has its own Ce-Vlan-Id and
* Flow Reference
*/
public class CustomEvc extends DefaultEvc {
public static EvcBuilder builder(Evc evc) {
return new EvcBuilder(evc);
}
public static class EvcBuilder extends DefaultEvc.EvcBuilder {
/**
* Allow a builder to be constructed from an existing EVC
* @param evc An existing EVC
*/
public EvcBuilder(Evc evc) {
this.evcPerUni = evc.evcPerUni();
this.evcStatus = evc.evcStatus();
this.evcIndex = evc.evcIndex();
this.mtuSize = evc.mtuSize();
this.cevlanCosPreservation = evc.cevlanCosPreservation();
this.cevlanIdPreservation = evc.cevlanIdPreservation();
this.name = evc.name();
this.yangEvcOpType = evc.yangEvcOpType();
this.yangAugmentedInfoMap = evc.yangAugmentedInfoMap();
this.name = evc.name();
this.serviceType = evc.serviceType();
this.selectLeafFlags = evc.selectLeafFlags();
this.uniEvcId = evc.uniEvcId();
this.valueLeafFlags = evc.valueLeafFlags();
}
/**
* Method to allow ceVlanMap to be modified.
* @param additionalCeVlanMap An addition to the existing ceVlanMap
* @param side The Uni Side - Customer or Network
* @return The updated builder
*/
public EvcBuilder addToCeVlanMap(ServiceListType additionalCeVlanMap, UniSide side) {
evcPerUni = CustomEvcPerUni.builder(evcPerUni).addToCeVlanMap(additionalCeVlanMap, side).build();
return this;
}
/**
* Method to allow the Flow Mapping list to be modified.
* @param fm the flow mapping
* @param side The Uni Side - Customer or Network
* @return The updated builder
*/
public EvcBuilder addToFlowMapping(FlowMapping fm, UniSide side) {
evcPerUni = CustomEvcPerUni.builder(evcPerUni).addToFlowMapping(fm, side).build();
return this;
}
/**
* Method to allow an EVC side to be added.
* @param evcUniN An EVCPerUni object
* @return The updated builder
*/
public EvcBuilder addUniN(EvcPerUnin evcUniN) {
evcPerUni = CustomEvcPerUni.builder(evcPerUni).addUniN(evcUniN).build();
return this;
}
/**
* Method to allow an EVC side to be added.
* @param evcUniC An EVCPerUni object
* @return The updated builder
*/
public EvcBuilder addUniC(EvcPerUnic evcUniC) {
evcPerUni = CustomEvcPerUni.builder(evcPerUni).addUniC(evcUniC).build();
return this;
}
}
}

View File

@ -1,110 +0,0 @@
/*
* 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.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc;
import org.onosproject.drivers.microsemi.yang.UniSide;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types
.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.FlowMapping;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.CustomEvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.CustomEvcPerUnin;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnin;
/**
* A custom implementation of the DefaultEvcPerUni - especially its Builder.
*
* This allows the EvcPerUni to be modified after creation. These additions to the
* builder are necessary because in the EA1000 YANG model the EvcPerUni side can
* be added at separate stages
*/
public class CustomEvcPerUni extends DefaultEvcPerUni {
public static EvcPerUniBuilder builder(EvcPerUni evcPerUni) {
return new EvcPerUniBuilder(evcPerUni);
}
public static class EvcPerUniBuilder extends DefaultEvcPerUni.EvcPerUniBuilder {
/**
* Allow a builder to be constructed from an existing EvcPerUni
* @param evcPerUni An existing EvcPerUni
*/
public EvcPerUniBuilder(EvcPerUni evcPerUni) {
this.evcPerUnic = evcPerUni.evcPerUnic();
this.evcPerUnin = evcPerUni.evcPerUnin();
this.evcUniType = evcPerUni.evcUniType();
this.yangEvcPerUniOpType = evcPerUni.yangEvcPerUniOpType();
this.valueLeafFlags = evcPerUni.valueLeafFlags();
this.selectLeafFlags = evcPerUni.selectLeafFlags();
this.yangAugmentedInfoMap = evcPerUni.yangAugmentedInfoMap();
}
/**
* Method to allow ceVlanMap to be modified.
* @param additionalCeVlanMap An addition to the existing ceVlanMap
* @param side The Uni Side - Customer or Network
* @return The updated builder
*/
public EvcPerUniBuilder addToCeVlanMap(ServiceListType additionalCeVlanMap, UniSide side) {
if (side == UniSide.NETWORK) {
evcPerUnin = CustomEvcPerUnin.builder(evcPerUnin).addToCeVlanMap(additionalCeVlanMap).build();
} else {
evcPerUnic = CustomEvcPerUnic.builder(evcPerUnic).addToCeVlanMap(additionalCeVlanMap).build();
}
return this;
}
/**
* Method to allow the Flow Mapping list to be modified.
* @param fm the flow mapping
* @param side The Uni Side - Customer or Network
* @return The updated builder
*/
public EvcPerUniBuilder addToFlowMapping(FlowMapping fm, UniSide side) {
if (side == UniSide.NETWORK) {
evcPerUnin = CustomEvcPerUnin.builder(evcPerUnin).addToFlowMapping(fm).build();
} else {
evcPerUnic = CustomEvcPerUnic.builder(evcPerUnic).addToFlowMapping(fm).build();
}
return this;
}
/**
* Method to allow an EVC side to be added.
* @param evcUniN An EVCPerUni object
* @return The updated builder
*/
public EvcPerUniBuilder addUniN(EvcPerUnin evcUniN) {
this.evcPerUnin = evcUniN;
return this;
}
/**
* Method to allow an EVC side to be added.
* @param evcUniC An EVCPerUni object
* @return The updated builder
*/
public EvcPerUniBuilder addUniC(EvcPerUnic evcUniC) {
this.evcPerUnic = evcUniC;
return this;
}
}
}

View File

@ -1,82 +0,0 @@
/*
* 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.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni;
import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types
.rev20160229.mseatypes.ServiceListType;
/**
* A custom implementation of the DefaultEvcPerUnic - especially its Builder.
*
* This allows the EvcPerUniC to be modified after creation. These additions to the
* builder are necessary because in the EA1000 YANG model the EvcPerUniC can
* be added at separate stages
*/
public class CustomEvcPerUnic extends DefaultEvcPerUnic {
public static EvcPerUnicBuilder builder(EvcPerUnic evcPerUnic) {
return new EvcPerUnicBuilder(evcPerUnic);
}
public static EvcPerUnicBuilder builder() {
return new EvcPerUnicBuilder();
}
public static class EvcPerUnicBuilder extends DefaultEvcPerUnic.EvcPerUnicBuilder {
/**
* Allow a new builder to be constructed
*/
public EvcPerUnicBuilder() {
valueLeafFlags.set(LeafIdentifier.CEVLANMAP.getLeafIndex());
this.ceVlanMap = new ServiceListType("0");
valueLeafFlags.set(LeafIdentifier.INGRESSBWPGROUPINDEX.getLeafIndex());
this.ingressBwpGroupIndex = 0;
}
/**
* Allow a builder to be constructed from an existing EvcPerUnic
* @param evcPerUnic An existing EvcPerUnic
*/
public EvcPerUnicBuilder(EvcPerUnic evcPerUnic) {
this.ceVlanMap = evcPerUnic.ceVlanMap();
this.evcPerUniServiceType = evcPerUnic.evcPerUniServiceType();
this.ingressBwpGroupIndex = evcPerUnic.ingressBwpGroupIndex();
this.tagManipulation = evcPerUnic.tagManipulation();
this.flowMapping = evcPerUnic.flowMapping();
this.yangEvcPerUnicOpType = evcPerUnic.yangEvcPerUnicOpType();
this.yangAugmentedInfoMap = evcPerUnic.yangAugmentedInfoMap();
this.selectLeafFlags = evcPerUnic.selectLeafFlags();
this.valueLeafFlags = evcPerUnic.valueLeafFlags();
}
/**
* Method to allow ceVlanMap to be modified.
* @param additionalCeVlanMap An addition to the existing ceVlanMap
* @return The updated builder
*/
public EvcPerUnicBuilder addToCeVlanMap(ServiceListType additionalCeVlanMap) {
String combinedCeVlanMap =
CeVlanMapUtils.combineVlanSets(ceVlanMap.string(), additionalCeVlanMap.string());
//If it contains 0 we should remove it
ceVlanMap = new ServiceListType(
CeVlanMapUtils.removeZeroIfPossible(combinedCeVlanMap));
return this;
}
}
}

View File

@ -1,81 +0,0 @@
/*
* 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.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni;
import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types
.rev20160229.mseatypes.ServiceListType;
/**
* A custom implementation of the DefaultEvcPerUnin - especially its Builder.
*
* This allows the EvcPerUniN to be modified after creation. These additions to the
* builder are necessary because in the EA1000 YANG model the EvcPerUniN can
* be added at separate stages
*/
public class CustomEvcPerUnin extends DefaultEvcPerUnin {
public static EvcPerUninBuilder builder(EvcPerUnin evcPerUnin) {
return new EvcPerUninBuilder(evcPerUnin);
}
public static EvcPerUninBuilder builder() {
return new EvcPerUninBuilder();
}
public static class EvcPerUninBuilder extends DefaultEvcPerUnin.EvcPerUninBuilder {
/**
* Allow a new builder to be constructed
*/
public EvcPerUninBuilder() {
valueLeafFlags.set(LeafIdentifier.CEVLANMAP.getLeafIndex());
this.ceVlanMap = new ServiceListType("0");
valueLeafFlags.set(LeafIdentifier.INGRESSBWPGROUPINDEX.getLeafIndex());
this.ingressBwpGroupIndex = 0;
}
/**
* Allow a builder to be constructed from an existing EvcPerUnin
* @param evcPerUnin An existing EvcPerUnin
*/
public EvcPerUninBuilder(EvcPerUnin evcPerUnin) {
this.ceVlanMap = evcPerUnin.ceVlanMap();
this.evcPerUniServiceType = evcPerUnin.evcPerUniServiceType();
this.ingressBwpGroupIndex = evcPerUnin.ingressBwpGroupIndex();
this.tagManipulation = evcPerUnin.tagManipulation();
this.flowMapping = evcPerUnin.flowMapping();
this.yangEvcPerUninOpType = evcPerUnin.yangEvcPerUninOpType();
this.yangAugmentedInfoMap = evcPerUnin.yangAugmentedInfoMap();
this.selectLeafFlags = evcPerUnin.selectLeafFlags();
this.valueLeafFlags = evcPerUnin.valueLeafFlags();
}
/**
* Method to allow ceVlanMap to be modified.
* @param additionalCeVlanMap An addition to the existing ceVlanMap
* @return The updated builder
*/
public EvcPerUninBuilder addToCeVlanMap(ServiceListType additionalCeVlanMap) {
String combinedCeVlanMap =
CeVlanMapUtils.combineVlanSets(ceVlanMap.string(), additionalCeVlanMap.string());
//If it contains 0 we should remove it
ceVlanMap = new ServiceListType(
CeVlanMapUtils.removeZeroIfPossible(combinedCeVlanMap));
return this;
}
}
}

View File

@ -1,21 +0,0 @@
/*
* 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 Microsemi device drivers support for NETCONF for EA1000.
*/
package org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni;

View File

@ -1,21 +0,0 @@
/*
* 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 Microsemi device drivers support for NETCONF for EA1000.
*/
package org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni.evc;

View File

@ -1,21 +0,0 @@
/*
* 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 Microsemi device drivers support for NETCONF for EA1000.
*/
package org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
.rev20160317.mseaunievcservice.mefservices.uni;

View File

@ -1,43 +0,0 @@
/*
* 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.microsemi.yang;
import java.io.IOException;
import java.io.UncheckedIOException;
import org.onosproject.drivers.microsemi.yang.impl.IetfSystemManager;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.IetfSystemMicrosemiService;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystemService;
import org.onosproject.yms.app.yab.MockYmsManager;
public class MockIetfSystemManager extends IetfSystemManager {
@Override
public void activate() {
try {
ymsService = new MockYmsManager();
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(IetfSystemService.class);
ych.addDeviceSchema(IetfSystemMicrosemiService.class);
} catch (InstantiationException | IllegalAccessException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
throw new UncheckedIOException(e);
}
}
}

View File

@ -1,45 +0,0 @@
/*
* 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.microsemi.yang;
import java.io.IOException;
import java.io.UncheckedIOException;
import org.onosproject.drivers.microsemi.yang.impl.MseaCfmManager;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfmService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.soam.fm.rev20160229.MseaSoamFmService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.soam.pm.rev20160229.MseaSoamPmService;
import org.onosproject.yms.app.yab.MockYmsManager;
public class MockMseaCfmManager extends MseaCfmManager {
@Override
public void activate() {
try {
ymsService = new MockYmsManager();
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(MseaCfmService.class);
ych.addDeviceSchema(MseaSoamFmService.class);
ych.addDeviceSchema(MseaSoamPmService.class);
} catch (InstantiationException | IllegalAccessException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
throw new UncheckedIOException(e);
}
}
}

View File

@ -1,456 +0,0 @@
/*
* 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.microsemi.yang;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.Ip4Address;
import org.onosproject.drivers.microsemi.yang.impl.MseaUniEvcServiceManager;
import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.Identifier45;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.VlanIdType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.DefaultMefServices;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.MefServices;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.EvcPerUniServiceTypeEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagPush;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.tagpush.tagpush.PushTagTypeEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagPush;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.Profiles;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.DefaultProfiles;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.DefaultUni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.Uni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.Cos;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.DefaultBwpGroup;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.DefaultCos;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.Bwp;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.DefaultBwp;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.bwp.ColorModeEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.CustomEvc;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.DefaultEvc;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.Evc;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.DefaultEvcPerUni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.EvcPerUni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.CustomEvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.CustomEvcPerUnin;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.DefaultEvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.DefaultEvcPerUnin;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnin;
import org.onosproject.yms.ymsm.YmsService;
public class MseaUniEvcServiceManagerTest {
MseaUniEvcServiceManager mseaUniEvcServiceSvc;
YmsService ymsService;
NetconfSession session;
@Before
public void setUp() throws Exception {
try {
mseaUniEvcServiceSvc = new MockMseaUniEvcServiceManager();
mseaUniEvcServiceSvc.activate();
} catch (UncheckedIOException e) {
fail(e.getMessage());
}
NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo("netconf", "netconf", Ip4Address.valueOf("1.2.3.4"), 830);
session = new MockNetconfSessionEa1000(deviceInfo);
}
@After
public void tearDown() throws Exception {
}
@Test
public void testGetMseaUniEvcServiceMseaUniEvcServiceOpParamNetconfSession() {
Uni.UniBuilder uniBuilder = new DefaultUni.UniBuilder();
MefServices.MefServicesBuilder mefBuilder = new DefaultMefServices.MefServicesBuilder();
MefServices mefServices = mefBuilder.uni(uniBuilder.build()).build();
MseaUniEvcService.MseaUniEvcServiceBuilder evcUniBuilder =
new MseaUniEvcServiceOpParam.MseaUniEvcServiceBuilder();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter =
(MseaUniEvcServiceOpParam) evcUniBuilder.mefServices(mefServices).build();
MseaUniEvcService result = null;
try {
result =
mseaUniEvcServiceSvc.getConfigMseaUniEvcService(
mseaUniEvcServiceFilter, session, TargetConfig.RUNNING);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
assertNotNull(result);
}
@Test
public void testSetMseaUniEvcServiceMseaUniEvcServiceOpParamEvcs() {
TagPush.TagPushBuilder tpBuilder1 = new DefaultTagPush.TagPushBuilder();
org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc
.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation
.tagpush.TagPush.TagPushBuilder tpInnerBuilder1 =
new org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea
.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagpush.DefaultTagPush.TagPushBuilder();
TagPush tp1 = tpBuilder1
.tagPush(tpInnerBuilder1
.outerTagVlan(new VlanIdType(3))
.pushTagType(PushTagTypeEnum.PUSHSTAG)
.build())
.build();
EvcPerUnin.EvcPerUninBuilder epunBuilder1 = new DefaultEvcPerUnin.EvcPerUninBuilder();
EvcPerUnin epun1 = epunBuilder1
.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL)
.ceVlanMap(ServiceListType.fromString("10"))
.ingressBwpGroupIndex("0")
.tagManipulation(tp1)
.build();
EvcPerUnic.EvcPerUnicBuilder epucBuilder1 = new DefaultEvcPerUnic.EvcPerUnicBuilder();
EvcPerUnic epuc1 = epucBuilder1
.ceVlanMap(new ServiceListType("11"))
.ingressBwpGroupIndex("0")
.build();
EvcPerUni.EvcPerUniBuilder epuBuilder = new DefaultEvcPerUni.EvcPerUniBuilder();
List<Evc> evcList = new ArrayList<Evc>();
Evc.EvcBuilder evcBuilder1 = new DefaultEvc.EvcBuilder();
evcList.add(evcBuilder1
.evcIndex(1)
.name(new Identifier45("evc-1"))
.evcPerUni(epuBuilder.evcPerUnin(epun1).evcPerUnic(epuc1).build())
.build());
EvcPerUnin.EvcPerUninBuilder epunBuilder2 = new DefaultEvcPerUnin.EvcPerUninBuilder();
EvcPerUnin epun2 = epunBuilder2
.ceVlanMap(ServiceListType.fromString("13"))
.ingressBwpGroupIndex("0")
.build();
EvcPerUnic.EvcPerUnicBuilder epucBuilder2 = new DefaultEvcPerUnic.EvcPerUnicBuilder();
EvcPerUnic epuc2 = epucBuilder2
.ceVlanMap(new ServiceListType("12"))
.ingressBwpGroupIndex("0")
.build();
Evc.EvcBuilder evcBuilder2 = new DefaultEvc.EvcBuilder();
evcList.add(evcBuilder2
.evcIndex(2)
.name(new Identifier45("evc-2"))
.evcPerUni(epuBuilder.evcPerUnin(epun2).evcPerUnic(epuc2).build())
.build());
Uni.UniBuilder uniBuilder = new DefaultUni.UniBuilder();
Uni uni = uniBuilder.name(new Identifier45("testUni")).evc(evcList).build();
MefServices.MefServicesBuilder mefBuilder = new DefaultMefServices.MefServicesBuilder();
MefServices mefServices = mefBuilder.uni(uni).build();
MseaUniEvcService.MseaUniEvcServiceBuilder evcUniBuilder =
new MseaUniEvcServiceOpParam.MseaUniEvcServiceBuilder();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter =
(MseaUniEvcServiceOpParam) evcUniBuilder.mefServices(mefServices).build();
try {
mseaUniEvcServiceSvc.setMseaUniEvcService(mseaUniEvcServiceFilter, session, TargetConfig.RUNNING);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testSetMseaUniEvcServiceMseaUniEvcServiceOpParamProfiles() {
List<Cos> cosList = new ArrayList<Cos>();
Cos.CosBuilder cosBuilder0 = new DefaultCos.CosBuilder();
cosList.add(cosBuilder0.cosIndex(0).name("cos0").build());
Cos.CosBuilder cosBuilder1 = new DefaultCos.CosBuilder();
cosList.add(cosBuilder1.cosIndex(1).name("cos1").build());
List<BwpGroup> bwpGroupList = new ArrayList<BwpGroup>();
BwpGroup.BwpGroupBuilder bwpGrpBuilder = new DefaultBwpGroup.BwpGroupBuilder();
bwpGroupList.add(bwpGrpBuilder.groupIndex((short) 0).build());
List<Bwp> bwpList = new ArrayList<Bwp>();
Bwp.BwpBuilder bwpBuilder1 = new DefaultBwp.BwpBuilder();
bwpList.add(bwpBuilder1.cosIndex(0).colorMode(ColorModeEnum.COLORAWARE).build());
Bwp.BwpBuilder bwpBuilder2 = new DefaultBwp.BwpBuilder();
bwpList.add(bwpBuilder2.cosIndex(1).colorMode(ColorModeEnum.COLORBLIND).build());
BwpGroup.BwpGroupBuilder bwpGrpBuilder1 = new DefaultBwpGroup.BwpGroupBuilder();
bwpGroupList.add(bwpGrpBuilder1.groupIndex((short) 1).bwp(bwpList).build());
Profiles.ProfilesBuilder profilesBuilder = new DefaultProfiles.ProfilesBuilder();
Profiles profiles = profilesBuilder.bwpGroup(bwpGroupList).build();
MefServices.MefServicesBuilder mefBuilder = new DefaultMefServices.MefServicesBuilder();
MefServices mefServices = mefBuilder.profiles(profiles).build();
MseaUniEvcService.MseaUniEvcServiceBuilder evcUniBuilder =
new MseaUniEvcServiceOpParam.MseaUniEvcServiceBuilder();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter =
(MseaUniEvcServiceOpParam) evcUniBuilder.mefServices(mefServices).build();
try {
mseaUniEvcServiceSvc.setMseaUniEvcService(mseaUniEvcServiceFilter, session, TargetConfig.RUNNING);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testGetMseaUniEvcCeVlanMaps() {
try {
MseaUniEvcService ceVlanMapsResult7 =
mseaUniEvcServiceSvc.getmseaUniEvcCeVlanMaps(session, TargetConfig.RUNNING);
assertNotNull(ceVlanMapsResult7.mefServices().uni().evc());
List<Evc> evcList = ceVlanMapsResult7.mefServices().uni().evc();
assertEquals(3, evcList.size());
for (Evc evc : evcList) {
assertNotNull(evc.evcPerUni().evcPerUnic().ceVlanMap());
assertNotNull(evc.evcPerUni().evcPerUnin().ceVlanMap());
if (evc.evcIndex() == 7) {
assertEquals("700,710,720", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
assertEquals("701:703", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
}
}
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testChangeEvcCeVlanMap() {
EvcPerUnin.EvcPerUninBuilder epunBuilder1 = new DefaultEvcPerUnin.EvcPerUninBuilder();
EvcPerUnin epun1 = epunBuilder1
.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL)
.ceVlanMap(ServiceListType.fromString("10"))
.ingressBwpGroupIndex("0")
.build();
EvcPerUnic.EvcPerUnicBuilder epucBuilder1 = new DefaultEvcPerUnic.EvcPerUnicBuilder();
EvcPerUnic epuc1 = epucBuilder1
.ceVlanMap(new ServiceListType("11"))
.ingressBwpGroupIndex("0")
.build();
EvcPerUni.EvcPerUniBuilder epuBuilder = DefaultEvcPerUni.builder().evcPerUnic(epuc1).evcPerUnin(epun1);
Evc evc = CustomEvc.builder().evcPerUni(epuBuilder.build()).build();
assertEquals("10", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
assertEquals("11", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
evc = CustomEvc.builder(evc).addToCeVlanMap(new ServiceListType("12,13"), UniSide.NETWORK).build();
assertEquals("10,12:13", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
assertEquals("11", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
}
@Test
public void testChangeEvcCeVlanMapNoValues() {
EvcPerUnin.EvcPerUninBuilder epunBuilder1 = CustomEvcPerUnin.builder();
EvcPerUnin epun1 = epunBuilder1
.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL)
.ingressBwpGroupIndex("0")
.build();
EvcPerUnic.EvcPerUnicBuilder epucBuilder1 = CustomEvcPerUnic.builder();
EvcPerUnic epuc1 = epucBuilder1
.ingressBwpGroupIndex("0")
.build();
EvcPerUni.EvcPerUniBuilder epuBuilder = DefaultEvcPerUni.builder().evcPerUnic(epuc1).evcPerUnin(epun1);
Evc evc = CustomEvc.builder().evcPerUni(epuBuilder.build()).build();
assertEquals("0", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
assertEquals("0", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
}
@Test
public void testRemoveEvcUniFlowEntries() {
Map<Integer, String> ceVlanUpdates = new TreeMap<>();
ceVlanUpdates.put((1 << 2), "");
ceVlanUpdates.put((1 << 2) + 1, "");
ceVlanUpdates.put((2 << 2), "");
ceVlanUpdates.put((2 << 2) + 1, "");
ceVlanUpdates.put((7 << 2), "700,710,720");
ceVlanUpdates.put((7 << 2) + 1, "701:703");
ceVlanUpdates.put((8 << 2), "800,810,820");
ceVlanUpdates.put((8 << 2) + 1, "801,802,803");
Map<Integer, List<Short>> flowVlanIdMap = new HashMap<>();
//These should get ignored because whole EVC is being deleted
flowVlanIdMap.put(1 << 2, new ArrayList<Short>());
flowVlanIdMap.get(1 << 2).add((short) 11);
flowVlanIdMap.put((1 << 2) + 1, new ArrayList<Short>());
flowVlanIdMap.get((1 << 2) + 1).add((short) 12L);
//These are the EVCs being removed
flowVlanIdMap.put(7 << 2, new ArrayList<Short>());
flowVlanIdMap.get(7 << 2).add((short) 730L);
flowVlanIdMap.get(7 << 2).add((short) 740L);
flowVlanIdMap.put((7 << 2) + 1, new ArrayList<Short>());
flowVlanIdMap.get((7 << 2) + 1).add((short) 705L);
flowVlanIdMap.get((7 << 2) + 1).add((short) 706L);
flowVlanIdMap.put(8 << 2, new ArrayList<Short>());
flowVlanIdMap.get(8 << 2).add((short) 830L);
flowVlanIdMap.get(8 << 2).add((short) 840L);
flowVlanIdMap.put((8 << 2) + 1, new ArrayList<Short>());
flowVlanIdMap.get((8 << 2) + 1).add((short) 805L);
flowVlanIdMap.get((8 << 2) + 1).add((short) 806L);
try {
mseaUniEvcServiceSvc.removeEvcUniFlowEntries(
ceVlanUpdates, flowVlanIdMap, session, TargetConfig.RUNNING,
UniSideInterfaceAssignmentEnum.UNI_C_ON_OPTICS);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testGetVlanSet1() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10");
assertEquals(1, vlanIds.length);
}
@Test
public void testGetVlanSet2() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10:20");
assertEquals(11, vlanIds.length);
assertEquals(10, vlanIds[0].shortValue());
assertEquals(20, vlanIds[10].shortValue());
}
@Test
public void testGetVlanSet3() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10:20,30:40");
assertEquals(22, vlanIds.length);
assertEquals(10, vlanIds[0].shortValue());
assertEquals(40, vlanIds[21].shortValue());
}
@Test
public void testGetVlanSet4() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10,20,30");
assertEquals(3, vlanIds.length);
assertEquals(10, vlanIds[0].shortValue());
assertEquals(30, vlanIds[2].shortValue());
}
@Test
public void testVlanListAsString() {
assertEquals("20:22", CeVlanMapUtils.vlanListAsString(new Short[]{20, 21, 22}));
assertEquals("20:22,24:25",
CeVlanMapUtils.vlanListAsString(new Short[]{20, 21, 22, 24, 25}));
assertEquals("30,33,36:40",
CeVlanMapUtils.vlanListAsString(new Short[]{30, 33, 36, 37, 38, 39, 40}));
assertEquals("20", CeVlanMapUtils.vlanListAsString(new Short[]{20}));
assertEquals("20,22,24,26,28",
CeVlanMapUtils.vlanListAsString(new Short[]{20, 22, 24, 26, 28}));
}
@Test
public void testAddtoCeVlanMap() {
assertEquals("20,22:24,26,28",
CeVlanMapUtils.addtoCeVlanMap("20,22,24,26,28", (short) 23));
assertEquals("20:26,28",
CeVlanMapUtils.addtoCeVlanMap("20,21,22,24,25,26,28", (short) 23));
assertEquals("20,23",
CeVlanMapUtils.addtoCeVlanMap("20", (short) 23));
assertEquals("20,22:23",
CeVlanMapUtils.addtoCeVlanMap("20,22", (short) 23));
}
@Test
public void testCombineVlanSets() {
assertEquals("10:11,13:14", CeVlanMapUtils.combineVlanSets("10:11", "13:14"));
assertEquals("10:14", CeVlanMapUtils.combineVlanSets("10:11", "12:14"));
assertEquals("10:11,14", CeVlanMapUtils.combineVlanSets("10:11", "14"));
assertEquals("10:12", CeVlanMapUtils.combineVlanSets("10:11", "11:12"));
}
@Test
public void testRemoveZeroIfPossible() {
assertEquals("0", CeVlanMapUtils.removeZeroIfPossible(""));
assertEquals("0", CeVlanMapUtils.removeZeroIfPossible("0"));
assertEquals("1,3", CeVlanMapUtils.removeZeroIfPossible("0:1,3"));
assertEquals("1:2", CeVlanMapUtils.removeZeroIfPossible("0:2"));
assertEquals("10:12", CeVlanMapUtils.removeZeroIfPossible("0,10:12"));
}
}

View File

@ -1,152 +0,0 @@
/*
* Copyright 2016-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.yms.app.yab;
import static java.lang.String.valueOf;
import java.io.IOException;
import java.util.List;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.core.CoreService;
import org.onosproject.core.IdGenerator;
import org.onosproject.drivers.netconf.MockCoreService;
import org.onosproject.yms.app.ych.DefaultYangCodecHandler;
import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
import org.onosproject.yms.app.ydt.YangRequestWorkBench;
import org.onosproject.yms.app.ysr.DefaultYangModuleLibrary;
import org.onosproject.yms.app.ysr.MockYangSchemaRegistry;
import org.onosproject.yms.app.ysr.YangSchemaRegistry;
import org.onosproject.yms.ych.YangCodecHandler;
import org.onosproject.yms.ych.YangDataTreeCodec;
import org.onosproject.yms.ych.YangProtocolEncodingFormat;
import org.onosproject.yms.ydt.YdtBuilder;
import org.onosproject.yms.ydt.YdtResponse;
import org.onosproject.yms.ydt.YdtWalker;
import org.onosproject.yms.ydt.YmsOperationType;
import org.onosproject.yms.ymsm.YmsService;
import org.onosproject.yms.ynh.YangNotificationService;
import org.onosproject.yms.ysr.YangModuleIdentifier;
import org.onosproject.yms.ysr.YangModuleLibrary;
/**
* Represents implementation of YANG application management system manager.
*/
public class MockYmsManager
implements YmsService {
private static final String MODULE_ID = "module-id";
YangSchemaRegistry schemaRegistry;
private YangModuleLibrary library;
private IdGenerator moduleIdGenerator;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
public MockYmsManager()
throws InstantiationException, IllegalAccessException, IOException {
coreService = new MockCoreService();
moduleIdGenerator = coreService.getIdGenerator(MODULE_ID);
library = new DefaultYangModuleLibrary(getNewModuleId());
YangCodecRegistry.initializeDefaultCodec();
}
@Override
public YdtBuilder getYdtBuilder(String logicalRootName,
String rootNamespace,
YmsOperationType operationType) {
return new YangRequestWorkBench(logicalRootName, rootNamespace,
operationType, schemaRegistry, false);
}
@Override
public YdtBuilder getYdtBuilder(String logicalRootName,
String rootNamespace,
YmsOperationType operationType,
Object schemaRegistryForYdt) {
return null;
}
@Override
public YdtWalker getYdtWalker() {
return null;
}
@Override
public YdtResponse executeOperation(YdtBuilder operationRequest) {
YangApplicationBroker requestBroker =
new YangApplicationBroker(schemaRegistry);
switch (operationRequest.getYmsOperationType()) {
case EDIT_CONFIG_REQUEST:
try {
return requestBroker.processEdit(operationRequest);
} catch (CloneNotSupportedException e) {
}
break;
case QUERY_CONFIG_REQUEST:
case QUERY_REQUEST:
return requestBroker.processQuery(operationRequest);
case RPC_REQUEST:
return requestBroker.processOperation(operationRequest);
default:
}
return null;
}
@Override
public YangNotificationService getYangNotificationService() {
return null;
}
@Override
public void registerService(Object appManager, Class<?> yangService,
List<String> supportedFeatureList) {
}
@Override
public void unRegisterService(Object appManager, Class<?> yangService) {
}
@Override
public YangModuleLibrary getYangModuleLibrary() {
return library;
}
@Override
public String getYangFile(YangModuleIdentifier moduleIdentifier) {
return null;
}
@Override
public void registerDefaultCodec(YangDataTreeCodec defaultCodec,
YangProtocolEncodingFormat dataFormat) {
}
@Override
public YangCodecHandler getYangCodecHandler() {
YangSchemaRegistry registry = new MockYangSchemaRegistry();
DefaultYangCodecHandler handler = new DefaultYangCodecHandler(registry);
handler.setLibrary(new DefaultYangModuleLibrary(getNewModuleId()));
return handler;
}
private String getNewModuleId() {
return valueOf(moduleIdGenerator.getNewId());
}
}

View File

@ -1,767 +0,0 @@
/*
* Copyright 2016-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.yms.app.ysr;
import org.onosproject.yangutils.datamodel.YangInclude;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangSchemaNode;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yms.ysr.YangModuleIdentifier;
import org.onosproject.yms.ysr.YangModuleInformation;
import org.onosproject.yms.ysr.YangModuleLibrary;
import org.slf4j.Logger;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
import static java.util.Collections.sort;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.deSerializeDataModel;
import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Representation of default YANG schema registry. Yang schema registry
* provides interface to an application to register its YANG schema
* with YMS. It provides YANG schema nodes to YDT, YNB and YSB.
*/
public class MockYangSchemaRegistry implements YangSchemaRegistry {
private static final String SYSTEM = SLASH + "system" + SLASH;
private static final String MAVEN = "mvn:";
private static final String JAR = ".jar";
private static final String USER_DIRECTORY = "user.dir";
private static final String AT = "@";
private static final String DATE_FORMAT = "yyyy-mm-dd";
private static final String ONOS = "org.onosproject";
private static final Logger log = getLogger(MockYangSchemaRegistry.class);
private static final String FS = File.separator;
private static final String USER_DIR = System.getProperty("user.dir").replaceAll("ea1000driver", "ea1000yang");
// private static final String BUCK_OUT_DIR = "/buck-out/gen/drivers/microsemi/ea1000yang/";
private static final String BUCK_OUT_BIN_LOC =
"/buck-out/bin/drivers/microsemi/ea1000yang/"
+ "lib__onos-drivers-microsemi-ea1000yang__classes/YangMetaData.ser";
private static final String PATH = FS + "target" + FS + "classes" + FS;
private static final String SER_FILE_PATH = "yang" + FS + "resources" +
FS + "YangMetaData.ser";
private static final String RESOURCE = "src/test/resources";
/*
* Map for storing app objects.
*/
private final ConcurrentMap<String, Object> appObjectStore;
/*
* Map for storing YANG schema nodes.
*/
private final ConcurrentMap<String, ConcurrentMap<String, YangSchemaNode>>
yangSchemaStore;
/*
* Map for storing YANG schema nodes with respect to root's generated
* interface file name.
*/
private final ConcurrentMap<String, YangSchemaNode> interfaceNameKeyStore;
/*
* Map for storing YANG schema nodes root's generated op param file name.
*/
private final ConcurrentMap<String, YangSchemaNode> opParamNameKeyStore;
/*
* Map for storing YANG schema nodes with respect to notifications.
*/
private final ConcurrentMap<String, YangSchemaNode> eventNameKeyStore;
/*
* Map for storing YANG schema nodes with respect to app name.
*/
private final ConcurrentMap<String, YangSchemaNode> appNameKeyStore;
/*
* Map for storing registered classes.
*/
private final ConcurrentMap<String, Class<?>> registerClassStore;
/*
* Map for storing YANG file details.
*/
private final ConcurrentMap<YangModuleIdentifier, String> yangFileStore;
/**
* Map for storing schema nodes with respect to namespace.
*/
private final ConcurrentMap<String, YangSchemaNode> nameSpaceSchemaStore;
private final ConcurrentMap<Object, Boolean> ynhRegistrationStore;
private final ConcurrentMap<String, String> jarPathStore;
/**
* Creates an instance of default YANG schema registry.
*/
public MockYangSchemaRegistry() {
appObjectStore = new ConcurrentHashMap<>();
yangSchemaStore = new ConcurrentHashMap<>();
interfaceNameKeyStore = new ConcurrentHashMap<>();
opParamNameKeyStore = new ConcurrentHashMap<>();
eventNameKeyStore = new ConcurrentHashMap<>();
registerClassStore = new ConcurrentHashMap<>();
yangFileStore = new ConcurrentHashMap<>();
appNameKeyStore = new ConcurrentHashMap<>();
ynhRegistrationStore = new ConcurrentHashMap<>();
jarPathStore = new ConcurrentHashMap<>();
nameSpaceSchemaStore = new ConcurrentHashMap<>();
}
/**
* This is overridden for Maven and Buck.
*
* Because they don't have a Bundle Context, and the JAR file doesn't exist
* when this is called, we have to work with the .ser file
*/
@Override
public void registerApplication(Object appObject, Class<?> serviceClass) {
synchronized (MockYangSchemaRegistry.class) {
doPreProcessing(serviceClass, appObject);
if (!verifyIfApplicationAlreadyRegistered(serviceClass)) {
List<YangNode> curNodes = new ArrayList<>();
Path serFile = Paths.get(USER_DIR, PATH, SER_FILE_PATH);
if (USER_DIR.contains("ea1000yang")) {
serFile = Paths.get(USER_DIR, PATH, SER_FILE_PATH);
} else {
serFile = Paths.get(USER_DIR, BUCK_OUT_BIN_LOC);
}
if (Files.notExists(serFile)) {
throw new UncheckedIOException(
new IOException("File " + serFile.toString() + " does not exist!"));
}
try {
curNodes.addAll(deSerializeDataModel(serFile.toString()));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
// process application registration.
if (curNodes != null && !curNodes.isEmpty()) {
jarPathStore.put(serviceClass.getName(), serFile.toString());
processRegistration(serviceClass, serFile.toString(),
curNodes, appObject, false);
} else {
throw new UncheckedIOException(
new IOException("Unable to find Yang Nodes in serFile: " + serFile.toString()));
}
}
}
}
@Override
public void unRegisterApplication(Object managerObject,
Class<?> serviceClass) {
synchronized (MockYangSchemaRegistry.class) {
YangSchemaNode curNode;
String serviceName = serviceClass.getName();
//Check if service should be unregistered?
if (managerObject != null) {
verifyApplicationRegistration(managerObject, serviceClass);
}
//Remove registered class from store.
registerClassStore.remove(serviceName);
//check if service is in app store.
curNode = appNameKeyStore.get(serviceName);
if (curNode == null) {
curNode = interfaceNameKeyStore.get(serviceName);
}
if (curNode != null) {
removeSchemaNode(curNode);
eventNameKeyStore.remove(getEventClassName(curNode));
appObjectStore.remove(serviceName);
interfaceNameKeyStore.remove(getInterfaceClassName(curNode));
opParamNameKeyStore.remove(getOpParamClassName(curNode));
yangFileStore.remove(getModuleIdentifier(curNode));
appNameKeyStore.remove(serviceName);
nameSpaceSchemaStore.remove(curNode.getNameSpace()
.getModuleNamespace());
removeYsrGeneratedTemporaryResources(jarPathStore.get(serviceName),
serviceName);
log.info(" service {} is unregistered.",
serviceClass.getSimpleName());
} else {
throw new RuntimeException(serviceClass.getSimpleName() +
" service was not registered.");
}
}
}
@Override
public Object getRegisteredApplication(YangSchemaNode schemaNode) {
Object obj = null;
if (schemaNode != null) {
String name = getServiceName(schemaNode);
obj = appObjectStore.get(name);
if (obj == null) {
log.error("{} not found.", name);
}
}
return obj;
}
@Override
public YangSchemaNode getYangSchemaNodeUsingSchemaName(String schemaName) {
return getSchemaNodeUsingSchemaNameWithRev(schemaName);
}
@Override
public YangSchemaNode getYangSchemaNodeUsingAppName(String appName) {
YangSchemaNode node = appNameKeyStore.get(appName);
if (node == null) {
log.error("{} not found.", appName);
}
return node;
}
@Override
public YangSchemaNode
getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(String name) {
YangSchemaNode node = interfaceNameKeyStore.get(name);
if (node == null) {
log.error("{} not found.", name);
}
return node;
}
@Override
public YangSchemaNode getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
String name) {
YangSchemaNode node = opParamNameKeyStore.get(name);
if (node == null) {
log.error("{} not found.", name);
}
return node;
}
@Override
public YangSchemaNode getRootYangSchemaNodeForNotification(String name) {
YangSchemaNode node = eventNameKeyStore.get(name);
if (node == null) {
log.error("{} not found.", name);
}
return node;
}
@Override
public Class<?> getRegisteredClass(YangSchemaNode schemaNode) {
String interfaceName = getInterfaceClassName(schemaNode);
String serviceName = getServiceName(schemaNode);
Class<?> regClass = registerClassStore.get(serviceName);
if (regClass == null) {
regClass = registerClassStore.get(interfaceName);
}
return regClass;
}
@Override
public YangSchemaNode getSchemaWrtNameSpace(String nameSpace) {
YangSchemaNode node = nameSpaceSchemaStore.get(nameSpace);
if (node == null) {
log.error("node with {} namespace not found.", nameSpace);
}
return node;
}
@Override
public String getYangFile(YangModuleIdentifier moduleIdentifier) {
String file = yangFileStore.get(moduleIdentifier);
if (file == null) {
log.error("YANG files for corresponding module identifier {} not " +
"found", moduleIdentifier);
}
return file;
}
@Override
public boolean verifyNotificationObject(Object appObj, Class<?> service) {
synchronized (MockYangSchemaRegistry.class) {
YangSchemaNode node = appNameKeyStore.get(service.getName());
if (node == null) {
log.error("application is not registered with YMS {}",
service.getName());
return false;
}
try {
if (node.isNotificationPresent()) {
if (appObj != null) {
Boolean ifPresent = ynhRegistrationStore.get(appObj);
if (ifPresent == null) {
ynhRegistrationStore.put(appObj, true);
return true;
}
}
}
} catch (DataModelException e) {
log.error("notification registration error: {} {}", e
.getLocalizedMessage(), e);
}
return false;
}
}
@Override
public void flushYsrData() {
appObjectStore.clear();
yangSchemaStore.clear();
eventNameKeyStore.clear();
opParamNameKeyStore.clear();
interfaceNameKeyStore.clear();
registerClassStore.clear();
yangFileStore.clear();
nameSpaceSchemaStore.clear();
}
@Override
public void processModuleLibrary(String serviceName,
YangModuleLibrary library) {
synchronized (MockYangSchemaRegistry.class) {
YangSchemaNode node = appNameKeyStore.get(serviceName);
if (node != null) {
YangModuleInformation moduleInformation =
new DefaultYangModuleInformation(getModuleIdentifier(node),
node.getNameSpace());
addSubModuleIdentifier(node, (
DefaultYangModuleInformation) moduleInformation);
//TODO: add feature list to module information.
((DefaultYangModuleLibrary) library)
.addModuleInformation(moduleInformation);
}
}
}
/**
* Process service class.
*
* @param serviceClass service class
* @param appObject application object
*/
void doPreProcessing(Class<?> serviceClass, Object appObject) {
//Check if service should be registered?
if (appObject != null) {
verifyApplicationRegistration(appObject, serviceClass);
}
String name = serviceClass.getName();
//Add app class to registered service store.
if (!registerClassStore.containsKey(name)) {
registerClassStore.put(name, serviceClass);
}
}
void updateServiceClass(Class<?> service) {
registerClassStore.put(service.getName(), service);
}
/**
* Process application registration.
*
* @param service service class
* @param jarPath jar path
* @param nodes YANG nodes
* @param appObj application object
* @param isFromUt if registration is being called form unit test
*/
void processRegistration(Class<?> service, String jarPath,
List<YangNode> nodes,
Object appObj, boolean isFromUt) {
// process storing operations.
YangNode schemaNode = findNodeWhichShouldBeReg(service.getName(), nodes);
if (schemaNode != null) {
if (appObj != null) {
appObjectStore.put(service.getName(), appObj);
}
//Process application context for registrations.
processApplicationContext(schemaNode, service.getName(), isFromUt);
//Update YANG file store.
updateYangFileStore(schemaNode, jarPath);
}
}
/**
* Returns the node for which corresponding class is generated.
*
* @param name generated class name
* @param nodes list of yang nodes
* @return node for which corresponding class is generated
*/
private YangNode findNodeWhichShouldBeReg(String name, List<YangNode> nodes) {
for (YangNode node : nodes) {
if (name.equals(getServiceName(node)) ||
name.equals(getInterfaceClassName(node))) {
return node;
}
}
return null;
}
/**
* Verifies if service class should be registered or not.
*
* @param appObject application object
* @param appClass application class
*/
private void verifyApplicationRegistration(Object appObject,
Class<?> appClass) {
Class<?> managerClass = appObject.getClass();
Class<?>[] services = managerClass.getInterfaces();
List<Class<?>> classes = new ArrayList<>();
Collections.addAll(classes, services);
if (!classes.contains(appClass)) {
throw new RuntimeException("service class " + appClass.getName() +
"is not being implemented by " +
managerClass.getName());
}
}
/**
* Verifies if application is already registered with YMS.
*
* @param appClass application class
* @return true if application already registered
*/
private boolean verifyIfApplicationAlreadyRegistered(Class<?> appClass) {
String appName = appClass.getName();
return appObjectStore.containsKey(appName) ||
interfaceNameKeyStore.containsKey(appName);
}
/**
* Updates yang file store for YANG node.
*
* @param node YANG node
* @param jarPath jar file path
*/
private void updateYangFileStore(YangNode node, String jarPath) {
yangFileStore.put(getModuleIdentifier(node),
getYangFilePath(jarPath, node.getFileName()));
}
/**
* Returns yang file path.
*
* @param jarPath jar path
* @param metaDataFileName name of yang file from metadata
* @return yang file path
*/
private String getYangFilePath(String jarPath, String metaDataFileName) {
String[] metaData = metaDataFileName.split(SLASH);
return jarPath + SLASH + metaData[metaData.length - 1];
}
/**
* Process an application an updates the maps for YANG schema registry.
*
* @param appNode application YANG schema nodes
* @param name class name
* @param isFormUt if method is being called from unit tests
*/
private void processApplicationContext(YangSchemaNode appNode, String name,
boolean isFormUt) {
//Update map for which registrations is being called.
appNameKeyStore.put(name, appNode);
// Updates schema store.
addToSchemaStore(appNode);
// update interface store.
interfaceNameKeyStore.put(getInterfaceClassName(appNode), appNode);
//update op param store.
opParamNameKeyStore.put(getOpParamClassName(appNode), appNode);
//update namespaceSchema store.
nameSpaceSchemaStore.put(appNode.getNameSpace().getModuleNamespace(), appNode);
//Checks if notification is present then update notification store map.
String eventSubject = null;
try {
if (appNode.isNotificationPresent()) {
eventSubject = getEventClassName(appNode);
}
} catch (DataModelException e) {
log.error("failed to search notification from schema map : {}",
e.getLocalizedMessage());
}
if (eventSubject != null) {
eventNameKeyStore.put(eventSubject, appNode);
}
if (!isFormUt) {
log.info("successfully registered this application {}", name);
}
}
/**
* Returns jar path from bundle mvnLocationPath.
*
* @param mvnLocationPath mvnLocationPath of bundle
* @return path of jar
*/
private String getJarPathFromBundleLocation(String mvnLocationPath,
String currentDirectory) {
String path = currentDirectory + SYSTEM;
if (mvnLocationPath.contains(MAVEN)) {
String[] strArray = mvnLocationPath.split(MAVEN);
if (strArray[1].contains(File.separator)) {
String[] split = strArray[1].split(File.separator);
if (split[0].contains(PERIOD)) {
String[] groupId = split[0].split(Pattern.quote(PERIOD));
return path + groupId[0] + SLASH + groupId[1] + SLASH + split[1] +
SLASH + split[2] + SLASH + split[1] + HYPHEN + split[2];
}
}
}
return null;
}
/**
* Returns schema node based on the revision.
*
* @param name name of the schema node
* @return schema node based on the revision
*/
private YangSchemaNode getSchemaNodeUsingSchemaNameWithRev(String name) {
ConcurrentMap<String, YangSchemaNode> revMap;
YangSchemaNode schemaNode;
if (name.contains(AT)) {
String[] revArray = name.split(AT);
revMap = yangSchemaStore.get(revArray[0]);
schemaNode = revMap.get(name);
if (schemaNode == null) {
log.error("{} not found.", name);
}
return schemaNode;
}
if (yangSchemaStore.containsKey(name)) {
revMap = yangSchemaStore.get(name);
if (revMap != null && !revMap.isEmpty()) {
YangSchemaNode node = revMap.get(name);
if (node != null) {
return node;
}
String revName = getLatestVersion(revMap);
return revMap.get(revName);
}
}
log.error("{} not found.", name);
return null;
}
private String getLatestVersion(ConcurrentMap<String, YangSchemaNode> revMap) {
List<String> keys = new ArrayList<>();
for (Map.Entry<String, YangSchemaNode> entry : revMap.entrySet()) {
keys.add(entry.getKey());
}
sort(keys);
return keys.get(keys.size() - 1);
}
/**
* Adds schema node when different revision of node has received.
*
* @param schemaNode schema node
*/
private void addToSchemaStore(YangSchemaNode schemaNode) {
String date = getDateInStringFormat(schemaNode);
String name = schemaNode.getName();
String revName = name;
if (date != null) {
revName = name + AT + date;
}
//check if already present.
if (!yangSchemaStore.containsKey(name)) {
ConcurrentMap<String, YangSchemaNode> revStore =
new ConcurrentHashMap<>();
revStore.put(revName, schemaNode);
yangSchemaStore.put(name, revStore);
} else {
yangSchemaStore.get(name).put(revName, schemaNode);
}
}
/**
* Returns date in string format.
*
* @param schemaNode schema node
* @return date in string format
*/
String getDateInStringFormat(YangSchemaNode schemaNode) {
if (schemaNode != null) {
if (((YangNode) schemaNode).getRevision() != null) {
return new SimpleDateFormat(DATE_FORMAT)
.format(((YangNode) schemaNode).getRevision()
.getRevDate());
}
}
return null;
}
/**
* Removes schema node from schema map.
*
* @param removableNode schema node which needs to be removed
*/
private void removeSchemaNode(YangSchemaNode removableNode) {
String name = removableNode.getName();
String revName = name;
String date = getDateInStringFormat(removableNode);
if (date != null) {
revName = name + AT + date;
}
ConcurrentMap<String, YangSchemaNode> revMap = yangSchemaStore.get(name);
if (revMap != null && !revMap.isEmpty() && revMap.size() != 1) {
revMap.remove(revName);
} else {
yangSchemaStore.remove(removableNode.getName());
}
}
/**
* Adds sub module identifier.
*
* @param node schema node
* @param information module information
*/
private void addSubModuleIdentifier(
YangSchemaNode node, DefaultYangModuleInformation information) {
List<YangInclude> includeList = new ArrayList<>();
if (node instanceof YangModule) {
includeList = ((YangModule) node).getIncludeList();
} else if (node instanceof YangSubModule) {
includeList = ((YangSubModule) node).getIncludeList();
}
for (YangInclude include : includeList) {
information.addSubModuleIdentifiers(getModuleIdentifier(
include.getIncludedNode()));
}
}
/**
* Returns module identifier for schema node.
*
* @param schemaNode schema node
* @return module identifier for schema node
*/
private YangModuleIdentifier getModuleIdentifier(
YangSchemaNode schemaNode) {
return new DefaultYangModuleIdentifier(
schemaNode.getName(), getDateInStringFormat(schemaNode));
}
/**
* Returns schema node's generated interface class name.
*
* @param schemaNode schema node
* @return schema node's generated interface class name
*/
String getInterfaceClassName(YangSchemaNode schemaNode) {
return schemaNode.getJavaPackage() + PERIOD +
getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType());
}
/**
* Returns schema node's generated op param class name.
*
* @param schemaNode schema node
* @return schema node's generated op param class name
*/
private String getOpParamClassName(YangSchemaNode schemaNode) {
return getInterfaceClassName(schemaNode) + OP_PARAM;
}
/**
* Returns schema node's generated event class name.
*
* @param schemaNode schema node
* @return schema node's generated event class name
*/
private String getEventClassName(YangSchemaNode schemaNode) {
return getInterfaceClassName(schemaNode).toLowerCase() + PERIOD +
getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType()) +
EVENT_STRING;
}
/**
* Returns schema node's generated service class name.
*
* @param schemaNode schema node
* @return schema node's generated service class name
*/
String getServiceName(YangSchemaNode schemaNode) {
return getInterfaceClassName(schemaNode) + SERVICE;
}
/**
* Removes YSR generated temporary resources.
*
* @param rscPath resource path
* @param appName application name
*/
private void removeYsrGeneratedTemporaryResources(String rscPath,
String appName) {
if (rscPath != null) {
File jarPath = new File(rscPath);
if (jarPath.exists()) {
try {
deleteDirectory(jarPath);
} catch (IOException e) {
log.error("failed to delete ysr resources for {} : {}",
appName, e.getLocalizedMessage());
}
}
}
}
}

View File

@ -1,20 +0,0 @@
/*
* Copyright 2016-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 Microsemi device drivers support for NETCONF for EA1000.
*/
package org.onosproject.yms.app.ysr;

View File

@ -1,49 +0,0 @@
<!-- ~ Copyright 2016-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.11.0-SNAPSHOT</version>
</parent>
<artifactId>onos-drivers-microsemi</artifactId>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>ea1000yang</module>
<module>ea1000driver</module>
</modules>
<!-- FIXME this can be removed if/when buck-api is released -->
<repositories>
<repository>
<id>snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -27,6 +27,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import org.onlab.packet.EthType;
@ -38,6 +39,8 @@ import org.onosproject.core.CoreService;
import org.onosproject.drivers.microsemi.yang.MseaSaFilteringNetconfService;
import org.onosproject.drivers.microsemi.yang.MseaUniEvcServiceNetconfService;
import org.onosproject.drivers.microsemi.yang.UniSide;
import org.onosproject.drivers.microsemi.yang.custom.CustomEvcPerUnic;
import org.onosproject.drivers.microsemi.yang.custom.CustomEvcPerUnin;
import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
import org.onosproject.net.PortNumber;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
@ -61,54 +64,50 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanHeaderInstruction;
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
import org.onosproject.net.meter.MeterId;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfController;
import org.onosproject.netconf.NetconfDevice;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.DefaultSourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.SourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.DefaultInterfaceEth0;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.InterfaceEth0;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.DefaultSourceAddressRange;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.FilterAdminStateEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.SourceAddressRange;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.Identifier45;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.VlanIdType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.DefaultMefServices;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.MefServices;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.DefaultFlowMapping;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.FlowMapping;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.TagManipulation;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagOverwrite;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagPop;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagPush;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagOverwrite;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagPop;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagPush;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.tagpush.tagpush.PushTagTypeEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.DefaultProfiles;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.DefaultUni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.Profiles;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.Uni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.DefaultBwpGroup;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.CustomEvc;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.DefaultEvc;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.Evc;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.DefaultEvcPerUni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.EvcPerUni;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.CustomEvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.CustomEvcPerUnin;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.DefaultEvcPerUnic.EvcPerUnicBuilder;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.DefaultEvcPerUnin.EvcPerUninBuilder;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnic;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnin;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.DefaultSourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.SourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.DefaultInterfaceEth0;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.InterfaceEth0;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.DefaultSourceAddressRange;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.FilterAdminStateEnum;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.SourceAddressRange;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.Identifier45;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.VlanIdType;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.DefaultMefServices;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.MefServices;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.DefaultFlowMapping;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.FlowMapping;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.TagManipulation;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagOverwrite;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagPop;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagPush;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagOverwrite;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagPop;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagPush;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.tagpush.tagpush.PushTagTypeEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.DefaultProfiles;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.DefaultUni;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.Profiles;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.Uni;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.DefaultBwpGroup;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.DefaultEvc;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.Evc;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.DefaultEvcPerUni;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.EvcPerUni;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnic;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnin;
import org.slf4j.Logger;
/**
@ -146,7 +145,14 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
UniSideInterfaceAssignmentEnum portAssignment = UniSideInterfaceAssignmentEnum.UNI_C_ON_HOST;
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
NetconfDevice ncDevice = controller.getDevicesMap().get(handler().data().deviceId());
if (ncDevice == null) {
log.error("Internal ONOS Error. Device has been marked as reachable, " +
"but deviceID {} is not in Devices Map. Continuing with empty description",
handler().data().deviceId());
return flowEntryCollection;
}
NetconfSession session = ncDevice.getSession();
CoreService coreService = checkNotNull(handler().get(CoreService.class));
ApplicationId appId = coreService.getAppId(MICROSEMI_DRIVERS);
MseaSaFilteringNetconfService mseaSaFilteringService =
@ -156,50 +162,57 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
log.debug("getFlowEntries() called on EA1000FlowRuleProgrammable");
//First get the MseaSaFiltering rules
SourceIpaddressFiltering.SourceIpaddressFilteringBuilder sipBuilder =
new DefaultSourceIpaddressFiltering.SourceIpaddressFilteringBuilder();
SourceIpaddressFiltering sip =
new DefaultSourceIpaddressFiltering();
MseaSaFilteringOpParam op =
new MseaSaFilteringOpParam();
op.sourceIpaddressFiltering(sip);
MseaSaFilteringOpParam.MseaSaFilteringBuilder opBuilder =
new MseaSaFilteringOpParam.MseaSaFilteringBuilder();
MseaSaFilteringOpParam mseaSaFilteringFilter =
(MseaSaFilteringOpParam) opBuilder
.sourceIpaddressFiltering(sipBuilder.build())
.build();
try {
MseaSaFiltering saFilteringCurrent =
mseaSaFilteringService.getMseaSaFiltering(mseaSaFilteringFilter, session);
if (saFilteringCurrent != null) {
mseaSaFilteringService.getMseaSaFiltering(op, session);
if (saFilteringCurrent != null &&
saFilteringCurrent.sourceIpaddressFiltering() != null) {
flowEntryCollection.addAll(
convertSaFilteringToFlowRules(saFilteringCurrent, appId));
}
} catch (NetconfException e) {
log.warn("Unexpected error on getFlowEntries", e);
if (e.getCause() instanceof TimeoutException) {
log.warn("Timeout exception getting SA Filt Flow Entries from {}",
handler().data().deviceId());
return flowEntryCollection;
} else {
log.error("Unexpected error on SA Filt getFlowEntries on {}",
handler().data().deviceId(), e);
}
}
//Then get the EVCs - there will be a flow entry per EVC
Uni.UniBuilder uniBuilder = new DefaultUni.UniBuilder();
MefServices mefServices = new DefaultMefServices();
mefServices.uni(new DefaultUni());
MefServices.MefServicesBuilder mefBuilder = new DefaultMefServices.MefServicesBuilder();
MefServices mefServices = mefBuilder.uni(uniBuilder.build()).build();
MseaUniEvcService.MseaUniEvcServiceBuilder evcUniBuilder =
new MseaUniEvcServiceOpParam.MseaUniEvcServiceBuilder();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter =
(MseaUniEvcServiceOpParam) evcUniBuilder.mefServices(mefServices).build();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter = new MseaUniEvcServiceOpParam();
mseaUniEvcServiceFilter.mefServices(mefServices);
try {
MseaUniEvcService uniEvcCurrent =
mseaUniEvcServiceSvc.getConfigMseaUniEvcService(mseaUniEvcServiceFilter,
session, TargetConfig.RUNNING);
session, DatastoreId.RUNNING);
flowEntryCollection.addAll(
convertEvcUniToFlowRules(uniEvcCurrent, portAssignment));
} catch (NetconfException e) {
log.warn("Unexpected error on getFlowEntries", e);
if (e.getCause() instanceof TimeoutException) {
log.warn("Timeout exception getting EVC Flow Entries from {}",
handler().data().deviceId());
return flowEntryCollection;
} else {
log.error("Unexpected error on EVC getFlowEntries on {}",
handler().data().deviceId(), e);
}
}
return flowEntryCollection;
}
@ -238,7 +251,7 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
try {
sessionMutex.acquire();
MseaUniEvcService evcResponse =
mseaUniEvcServiceSvc.getmseaUniEvcCeVlanMaps(session, TargetConfig.RUNNING);
mseaUniEvcServiceSvc.getmseaUniEvcCeVlanMaps(session, DatastoreId.RUNNING);
//There could be zero or more EVCs
if (evcResponse != null && evcResponse.mefServices() != null && evcResponse.mefServices().uni() != null) {
activeEvcs.addAll(evcResponse.mefServices().uni().evc());
@ -271,7 +284,7 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
if (saRangeList.size() > 0) {
try {
mseaSaFilteringService.setMseaSaFiltering(
buildSaFilteringObject(saRangeList), session, TargetConfig.RUNNING);
buildSaFilteringObject(saRangeList), session, DatastoreId.RUNNING);
} catch (NetconfException e) {
log.error("Error applying Flow Rules to SA Filtering - will try again: " + e.getMessage());
sessionMutex.release();
@ -283,26 +296,27 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
List<Evc> evcList = evcMap.entrySet().stream()
.map(x -> x.getValue())
.collect(Collectors.toList());
Uni.UniBuilder uniBuilder = new DefaultUni.UniBuilder();
Uni uni = new DefaultUni();
URI deviceName = handler().data().deviceId().uri();
Uni uni = uniBuilder.name(new Identifier45("Uni-on-"
+ deviceName.getSchemeSpecificPart())).evc(evcList).build();
uni.name(new Identifier45("Uni-on-"
+ deviceName.getSchemeSpecificPart()));
uni.evc(evcList);
List<BwpGroup> bwpGroupList = new ArrayList<BwpGroup>();
BwpGroup.BwpGroupBuilder bwpGrpBuilder = new DefaultBwpGroup.BwpGroupBuilder();
bwpGroupList.add(bwpGrpBuilder.groupIndex((short) 0).build());
Profiles profiles = (new DefaultProfiles.ProfilesBuilder()).bwpGroup(bwpGroupList).build();
BwpGroup bwpGrp = new DefaultBwpGroup();
bwpGrp.groupIndex((short) 0);
bwpGroupList.add(bwpGrp);
Profiles profiles = new DefaultProfiles();
profiles.bwpGroup(bwpGroupList);
MefServices.MefServicesBuilder mefBuilder = new DefaultMefServices.MefServicesBuilder();
MefServices mefServices = mefBuilder.uni(uni).profiles(profiles).build();
MefServices mefServices = new DefaultMefServices();
mefServices.uni(uni);
mefServices.profiles(profiles);
MseaUniEvcService.MseaUniEvcServiceBuilder evcUniBuilder =
new MseaUniEvcServiceOpParam.MseaUniEvcServiceBuilder();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter =
(MseaUniEvcServiceOpParam) evcUniBuilder.mefServices(mefServices).build();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter = new MseaUniEvcServiceOpParam();
mseaUniEvcServiceFilter.mefServices(mefServices);
try {
mseaUniEvcServiceSvc.setMseaUniEvcService(mseaUniEvcServiceFilter, session, TargetConfig.RUNNING);
mseaUniEvcServiceSvc.setMseaUniEvcService(mseaUniEvcServiceFilter, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
log.error("Error applying Flow Rules to EVC - will try again: " + e.getMessage());
sessionMutex.release();
@ -338,14 +352,18 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
//Retrieve the list of actual EVCs and the CeVlanMaps from device
List<Evc> activeEvcs = new ArrayList<>();
List<Short> acvtiveFiltRanges = new ArrayList<>();
try {
sessionMutex.acquire();
MseaUniEvcService evcResponse =
mseaUniEvcServiceSvc.getmseaUniEvcCeVlanMaps(session, TargetConfig.RUNNING);
mseaUniEvcServiceSvc.getmseaUniEvcCeVlanMaps(session, DatastoreId.RUNNING);
//There could be zero or more EVCs
if (evcResponse != null && evcResponse.mefServices() != null && evcResponse.mefServices().uni() != null) {
activeEvcs.addAll(evcResponse.mefServices().uni().evc());
}
mseaSaFilteringService.getConfigMseaSaFilterIds(session).forEach(
r -> acvtiveFiltRanges.add(r.rangeId()));
} catch (NetconfException | InterruptedException e1) {
log.warn("Error on removeFlowRules.", e1);
}
@ -360,14 +378,9 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
if (ruleToRemove.selector().getCriterion(Type.IPV4_SRC) != null &&
ruleToRemove.selector().getCriterion(Type.IN_PORT) != null &&
((PortCriterion) ruleToRemove.selector().getCriterion(Type.IN_PORT)).port().toLong() == 0) {
SourceAddressRange.SourceAddressRangeBuilder saBuilder =
new DefaultSourceAddressRange.SourceAddressRangeBuilder();
SourceAddressRange sar = saBuilder
.rangeId((short) ruleToRemove.tableId())
.yangSourceAddressRangeOpType(org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.
edge.assure.msea.sa.filtering.rev20160412.MseaSaFiltering.OnosYangOpType.DELETE)
.build();
SourceAddressRange sar = new DefaultSourceAddressRange();
sar.rangeId((short) ruleToRemove.tableId());
acvtiveFiltRanges.remove(Short.valueOf((short) ruleToRemove.tableId()));
rulesRemoved.add(ruleToRemove);
saRangeList.add(sar);
@ -408,10 +421,23 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
//If there are IPv4 Flow Rules created commit them now through the
//MseaSaFiltering service
if (saRangeList.size() > 0) {
if (saRangeList.size() > 0 && acvtiveFiltRanges.size() == 0) {
try {
mseaSaFilteringService.setMseaSaFiltering(
buildSaFilteringObject(saRangeList), session, TargetConfig.RUNNING);
SourceIpaddressFiltering saFilter =
new DefaultSourceIpaddressFiltering();
MseaSaFilteringOpParam mseaSaFiltering = new MseaSaFilteringOpParam();
mseaSaFiltering.sourceIpaddressFiltering(saFilter);
mseaSaFilteringService.deleteMseaSaFilteringRange(
mseaSaFiltering, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
log.warn("Remove FlowRule on MseaSaFilteringService could not delete all SARules - "
+ "they may already have been deleted: " + e.getMessage());
}
} else if (saRangeList.size() > 0) {
try {
mseaSaFilteringService.deleteMseaSaFilteringRange(
buildSaFilteringObject(saRangeList), session, DatastoreId.RUNNING);
} catch (NetconfException e) {
log.warn("Remove FlowRule on MseaSaFilteringService could not delete SARule - "
+ "it may already have been deleted: " + e.getMessage());
@ -421,7 +447,7 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
if (ceVlanMapMap.size() > 0) {
try {
mseaUniEvcServiceSvc.removeEvcUniFlowEntries(ceVlanMapMap, flowIdMap,
session, TargetConfig.RUNNING, portAssignment);
session, DatastoreId.RUNNING, portAssignment);
} catch (NetconfException e) {
log.warn("Remove FlowRule on MseaUniEvcService could not delete EVC - "
+ "it may already have been deleted: " + e.getMessage());
@ -472,14 +498,12 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
log.debug("Applying IP address to " + ipAddrStr
+ " (on Port 0) to IP SA Filtering on EA1000 through NETCONF");
SourceAddressRange.SourceAddressRangeBuilder saBuilder =
new DefaultSourceAddressRange.SourceAddressRangeBuilder();
SourceAddressRange sar =
new DefaultSourceAddressRange();
SourceAddressRange sar = saBuilder
.rangeId((short) fr.tableId())
.name("Flow:" + fr.id().toString())
.ipv4AddressPrefix(ipAddrStr)
.build();
sar.rangeId((short) fr.tableId());
sar.name("Flow:" + fr.id().toString());
sar.ipv4AddressPrefix(ipAddrStr);
frList.add(fr);
saRangeList.add(sar);
@ -493,40 +517,52 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
((PortCriterion) fr.selector().getCriterion(Type.IN_PORT)).port().toLong());
Integer evcKey = (fr.tableId() << 2) + port.portNum();
VlanId sourceVid = ((VlanIdCriterion) fr.selector().getCriterion(Type.VLAN_VID)).vlanId();
FlowMapping.FlowMappingBuilder fmBuilder =
DefaultFlowMapping.builder()
.ceVlanId(VlanIdType.of(sourceVid.id()))
.flowId(BigInteger.valueOf(fr.id().value()));
FlowMapping fm = new DefaultFlowMapping();
fm.ceVlanId(VlanIdType.of(sourceVid.id()));
fm.flowId(BigInteger.valueOf(fr.id().value()));
if (evcMap.containsKey(evcKey)) { //Is there an entry already for this EVC and port?
//Replace ceVlanMap
evcMap.put(evcKey, CustomEvc.builder(evcMap.get(evcKey))
.addToCeVlanMap(new ServiceListType(sourceVid.toString()), port.nOrC(portAssignment))
.addToFlowMapping(fmBuilder.build(), port.nOrC(portAssignment))
.build());
if (port.nOrC(portAssignment) == UniSide.CUSTOMER) {
evcMap.get(evcKey).evcPerUni().evcPerUnic().addToFlowMapping(fm);
ServiceListType newCeVlanMap = new ServiceListType(
CeVlanMapUtils.addtoCeVlanMap(
evcMap.get(evcKey).evcPerUni().evcPerUnic().ceVlanMap().toString(),
sourceVid.toShort()));
evcMap.get(evcKey).evcPerUni().evcPerUnic().ceVlanMap(newCeVlanMap);
} else {
evcMap.get(evcKey).evcPerUni().evcPerUnin().addToFlowMapping(fm);
ServiceListType newCeVlanMap = new ServiceListType(
CeVlanMapUtils.addtoCeVlanMap(
evcMap.get(evcKey).evcPerUni().evcPerUnin().ceVlanMap().toString(),
sourceVid.toShort()));
evcMap.get(evcKey).evcPerUni().evcPerUnin().ceVlanMap(newCeVlanMap);
}
} else if (evcMap.containsKey((evcKey ^ 1))) { //Is there an entry for this EVC but the opposite port?
TagManipulation tm = getTagManipulation(fr);
if (port.nOrC(portAssignment) == UniSide.NETWORK) {
EvcPerUnin epun = CustomEvcPerUnin.builder(evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnin())
.addToCeVlanMap(new ServiceListType(sourceVid.toString()))
.tagManipulation(tm)
.addToFlowMapping(fmBuilder.build())
.ingressBwpGroupIndex(getMeterId(fr.treatment()))
.build();
evcMap.put((evcKey ^ 1), CustomEvc.builder(evcMap.get((evcKey ^ 1))).addUniN(epun).build());
ServiceListType newCeVlanMap = new ServiceListType(
CeVlanMapUtils.addtoCeVlanMap(
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnin().ceVlanMap().toString(),
sourceVid.toShort()));
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnin().ceVlanMap(newCeVlanMap);
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnin().tagManipulation(tm);
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnin().addToFlowMapping(fm);
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnin().ingressBwpGroupIndex(getMeterId(fr.treatment()));
} else {
EvcPerUnic epuc = CustomEvcPerUnic.builder(evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnic())
.addToCeVlanMap(new ServiceListType(sourceVid.toString()))
.tagManipulation(tm)
.addToFlowMapping(fmBuilder.build())
.ingressBwpGroupIndex(getMeterId(fr.treatment()))
.build();
evcMap.put((evcKey ^ 1), CustomEvc.builder(evcMap.get((evcKey ^ 1))).addUniC(epuc).build());
ServiceListType newCeVlanMap = new ServiceListType(
CeVlanMapUtils.addtoCeVlanMap(
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnic().ceVlanMap().toString(),
sourceVid.toShort()));
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnic().ceVlanMap(newCeVlanMap);
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnic().tagManipulation(tm);
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnic().addToFlowMapping(fm);
evcMap.get(evcKey ^ 1).evcPerUni().evcPerUnic().ingressBwpGroupIndex(getMeterId(fr.treatment()));
}
} else {
Evc.EvcBuilder evcBuilder = new DefaultEvc.EvcBuilder();
EvcPerUninBuilder epunBuilder = new CustomEvcPerUnin.EvcPerUninBuilder();
EvcPerUnicBuilder epucBuilder = new CustomEvcPerUnic.EvcPerUnicBuilder();
Evc evc = new DefaultEvc();
EvcPerUnin epun = new CustomEvcPerUnin();
EvcPerUnic epuc = new CustomEvcPerUnic();
TagManipulation tm = getTagManipulation(fr);
UniSide side = port.nOrC(portAssignment);
@ -538,31 +574,32 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
port.opposite().nOrC(portAssignment));
oppositeCeVlanMap = oppositeCeVlanMap.isEmpty() ? "0" : oppositeCeVlanMap;
if (side == UniSide.NETWORK) {
epunBuilder
.ceVlanMap(new ServiceListType(newCeVlanMap))
.tagManipulation(tm)
.addToFlowMapping(fmBuilder.build())
.ingressBwpGroupIndex(getMeterId(fr.treatment()));
epun.ceVlanMap(new ServiceListType(newCeVlanMap));
epun.tagManipulation(tm);
epun.addToFlowMapping(fm);
epun.ingressBwpGroupIndex(getMeterId(fr.treatment()));
epucBuilder.ceVlanMap(new ServiceListType(oppositeCeVlanMap));
epuc.ceVlanMap(new ServiceListType(oppositeCeVlanMap));
epuc.ingressBwpGroupIndex(new Long(0));
} else {
epucBuilder
.ceVlanMap(new ServiceListType(newCeVlanMap))
.tagManipulation(tm)
.addToFlowMapping(fmBuilder.build())
.ingressBwpGroupIndex(getMeterId(fr.treatment()));
epuc.ceVlanMap(new ServiceListType(newCeVlanMap));
epuc.tagManipulation(tm);
epuc.addToFlowMapping(fm);
epuc.ingressBwpGroupIndex(getMeterId(fr.treatment()));
epunBuilder.ceVlanMap(new ServiceListType(oppositeCeVlanMap));
epun.ceVlanMap(new ServiceListType(oppositeCeVlanMap));
epun.ingressBwpGroupIndex(new Long(0));
}
evcBuilder
.evcIndex(fr.tableId())
.name(new Identifier45("EVC-" + String.valueOf(fr.tableId())))
.evcPerUni(new DefaultEvcPerUni.EvcPerUniBuilder()
.evcPerUnin(epunBuilder.build())
.evcPerUnic(epucBuilder.build())
.build());
evcMap.put(evcKey, evcBuilder.build());
evc.evcIndex(fr.tableId());
evc.name(new Identifier45("EVC-" + String.valueOf(fr.tableId())));
DefaultEvcPerUni epu = new DefaultEvcPerUni();
epu.evcPerUnin(epun);
epu.evcPerUnic(epuc);
evc.evcPerUni(epu);
evcMap.put(evcKey, evc);
}
frList.add(fr);
@ -570,20 +607,18 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
private MseaSaFilteringOpParam buildSaFilteringObject(List<SourceAddressRange> saRangeList) {
InterfaceEth0.InterfaceEth0Builder ifBuilder = new DefaultInterfaceEth0.InterfaceEth0Builder();
InterfaceEth0 saIf = new DefaultInterfaceEth0();
for (SourceAddressRange sa:saRangeList) {
ifBuilder = ifBuilder.addToSourceAddressRange(sa);
saIf.addToSourceAddressRange(sa);
}
InterfaceEth0 saIf = ifBuilder.filterAdminState(FilterAdminStateEnum.BLACKLIST).build();
saIf.filterAdminState(FilterAdminStateEnum.BLACKLIST);
SourceIpaddressFiltering.SourceIpaddressFilteringBuilder saFilterBuilder =
new DefaultSourceIpaddressFiltering.SourceIpaddressFilteringBuilder();
SourceIpaddressFiltering saFilter = saFilterBuilder.interfaceEth0(saIf).build();
SourceIpaddressFiltering saFilter =
new DefaultSourceIpaddressFiltering();
saFilter.interfaceEth0(saIf);
MseaSaFilteringOpParam.MseaSaFilteringBuilder opBuilder =
new MseaSaFilteringOpParam.MseaSaFilteringBuilder();
MseaSaFilteringOpParam mseaSaFiltering =
(MseaSaFilteringOpParam) opBuilder.sourceIpaddressFiltering(saFilter).build();
MseaSaFilteringOpParam mseaSaFiltering = new MseaSaFilteringOpParam();
mseaSaFiltering.sourceIpaddressFiltering(saFilter);
return mseaSaFiltering;
}
@ -597,7 +632,8 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
Criterion matchInPort = Criteria.matchInPort(PortNumber.portNumber(0));
TrafficSelector.Builder tsBuilder = DefaultTrafficSelector.builder();
for (SourceAddressRange sa:saRangelist) {
if (saRangelist != null) {
for (SourceAddressRange sa : saRangelist) {
Criterion matchIpSrc = Criteria.matchIPSrc(IpPrefix.valueOf(sa.ipv4AddressPrefix()));
TrafficSelector selector = tsBuilder.add(matchIpSrc).add(matchInPort).build();
@ -623,9 +659,10 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
.withPriority(PRIORITY_DEFAULT)
.build();
flowEntryCollection.add(new DefaultFlowEntry(fr, FlowEntryState.ADDED, 0, 0, 0));
flowEntryCollection.add(
new DefaultFlowEntry(fr, FlowEntryState.ADDED, 0, 0, 0));
}
}
return flowEntryCollection;
}
@ -801,46 +838,41 @@ public class EA1000FlowRuleProgrammable extends AbstractHandlerBehaviour impleme
if (isPop) {
//The should be no vlanId in this case
TagPop.TagPopBuilder popBuilder = new DefaultTagPop.TagPopBuilder();
org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc
.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation
.tagpop.TagPop.TagPopBuilder popInnerBuilder =
new org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea
.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagpop.DefaultTagPop.TagPopBuilder();
return popBuilder
.tagPop(popInnerBuilder.build())
.build();
TagPop pop = new DefaultTagPop();
org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice
.evcperuniextensionattributes.tagmanipulation
.tagpop.TagPop popInner =
new org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317
.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagpop.DefaultTagPop();
pop.tagPop(popInner);
return pop;
} else if (isPush && vlanId != null) {
TagPush.TagPushBuilder pushBuilder = new DefaultTagPush.TagPushBuilder();
org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc
.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation
.tagpush.TagPush.TagPushBuilder pushInnerBuilder =
new org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea
.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagpush.DefaultTagPush.TagPushBuilder();
return pushBuilder
.tagPush(pushInnerBuilder
.outerTagVlan(new VlanIdType(vlanId.id()))
.pushTagType(ethType.equals(EtherType.VLAN.ethType()) ?
PushTagTypeEnum.PUSHCTAG : PushTagTypeEnum.PUSHSTAG)
.build())
.build();
TagPush push = new DefaultTagPush();
org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice
.evcperuniextensionattributes.tagmanipulation
.tagpush.TagPush pushInner =
new org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317
.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagpush.DefaultTagPush();
pushInner.outerTagVlan(new VlanIdType(vlanId.id()));
pushInner.pushTagType(ethType.equals(EtherType.VLAN.ethType()) ?
PushTagTypeEnum.PUSHCTAG : PushTagTypeEnum.PUSHSTAG);
push.tagPush(pushInner);
return push;
} else if (vlanId != null) { //This is overwrite, as it has vlanId, but not push or pop
TagOverwrite.TagOverwriteBuilder ovrBuilder = new DefaultTagOverwrite.TagOverwriteBuilder();
org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc
.service.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation
.tagoverwrite.TagOverwrite.TagOverwriteBuilder ovrInnerBuilder =
new org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea
.uni.evc.service.rev20160317.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagoverwrite.DefaultTagOverwrite.TagOverwriteBuilder();
return ovrBuilder.
tagOverwrite(ovrInnerBuilder
.outerTagVlan(new VlanIdType(vlanId.id()))
.build())
.build();
TagOverwrite ovr = new DefaultTagOverwrite();
org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice
.evcperuniextensionattributes.tagmanipulation
.tagoverwrite.TagOverwrite ovrInner =
new org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317
.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagoverwrite.DefaultTagOverwrite();
ovrInner.outerTagVlan(new VlanIdType(vlanId.id()));
ovr.tagOverwrite(ovrInner);
return ovr;
}
return null;

View File

@ -38,33 +38,35 @@ import org.onosproject.net.meter.MeterProviderRegistry;
import org.onosproject.net.meter.MeterProviderService;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfController;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.CosColorType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.PriorityType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.coscolortype.CosColorTypeEnum;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcService.OnosYangOpType;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.DefaultMefServices;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.MefServices;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.DefaultProfiles;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.DefaultProfiles.ProfilesBuilder;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.Cos;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.DefaultBwpGroup;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.DefaultCos;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.Bwp;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.DefaultBwp;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.cos.costypechoice.DefaultEvcCosTypeEvcColorId;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.cos.costypechoice.evccostypeevccolorid.DefaultEvcCosTypeAll8PrioTo1EvcColor;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.profiles.cos.costypechoice.evccostypeevccolorid.EvcCosTypeAll8PrioTo1EvcColor;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.CosColorType;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.PriorityType;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.coscolortype.CosColorTypeEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.DefaultMefServices;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.MefServices;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.DefaultProfiles;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.Profiles;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.Cos;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.DefaultBwpGroup;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.DefaultCos;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.Bwp;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.DefaultBwp;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.cos.costypechoice.DefaultEvcCosTypeEvcColorId;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.cos.costypechoice.EvcCosTypeEvcColorId;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.cos.costypechoice.evccostypeevccolorid.DefaultEvcCosTypeAll8PrioTo1EvcColor;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.cos.costypechoice.evccostypeevccolorid.EvcCosTypeAll8PrioTo1EvcColor;
import org.slf4j.Logger;
/**
* Provider which uses an NETCONF controller to handle meters.
*
* TODO: move this to an architecture similar to FlowRuleDriverProvider in order
* to use a behavior to discover meters.
*/
@Component(immediate = true, enabled = true)
public class EA1000MeterProvider extends AbstractProvider implements MeterProvider {
@ -125,11 +127,11 @@ public class EA1000MeterProvider extends AbstractProvider implements MeterProvid
String deviceName = deviceId.uri().getSchemeSpecificPart();
Unit unit = meterOp.meter().unit();
ProfilesBuilder profilesBuilder = DefaultProfiles.builder();
Profiles profiles = new DefaultProfiles();
if (meterOp.type() == MeterOperation.Type.ADD || meterOp.type() == MeterOperation.Type.MODIFY) {
Bwp.BwpBuilder bwpBuilder = DefaultBwp.builder()
.cosIndex(COS_INDEX_1)
.name("BWP-" + String.valueOf(meterId) + "-" + deviceName);
Bwp bwp = new DefaultBwp();
bwp.cosIndex(COS_INDEX_1);
bwp.name("BWP-" + String.valueOf(meterId) + "-" + deviceName);
long cirRateKbps = 0L;
long cbsRateKbps = 0L;
@ -146,51 +148,56 @@ public class EA1000MeterProvider extends AbstractProvider implements MeterProvid
ebsRateKbps = band.burst(); //Already in kbps
}
}
bwpBuilder.committedInformationRate(cirRateKbps).excessInformationRate(eirRateKbps - cirRateKbps);
bwp.committedInformationRate(cirRateKbps);
bwp.excessInformationRate(eirRateKbps - cirRateKbps);
if (meterOp.meter().isBurst()) {
bwpBuilder.committedBurstSize(cbsRateKbps).excessBurstSize(ebsRateKbps - cbsRateKbps);
bwp.committedBurstSize(cbsRateKbps);
bwp.excessBurstSize(ebsRateKbps - cbsRateKbps);
}
BwpGroup.BwpGroupBuilder bwpgBuilder =
DefaultBwpGroup.builder()
.groupIndex((short) meterId)
.addToBwp(bwpBuilder.build());
BwpGroup bwpg = new DefaultBwpGroup();
bwpg.groupIndex((short) meterId);
bwpg.addToBwp(bwp);
//Create cos-1 as referenced above - we only support 1 at the moment
Cos.CosBuilder cosBuilder = DefaultCos.builder()
.cosIndex(COS_INDEX_1)
.name("COS-1")
.outgoingCosValue(PriorityType.of(DEFAULT_OUTGOING_PRIO))
.colorAware(true)
.colorForward(true);
EvcCosTypeAll8PrioTo1EvcColor ect =
DefaultEvcCosTypeAll8PrioTo1EvcColor.builder()
.evcAll8ColorTo(CosColorType.of(CosColorTypeEnum.GREEN)).build();
profilesBuilder
.addToBwpGroup(bwpgBuilder.build())
.addToCos(cosBuilder.cosTypeChoice(
DefaultEvcCosTypeEvcColorId.builder()
.evcCosTypeAll8PrioTo1EvcColor(ect).build()).build())
.build();
} else if (meterOp.type() == MeterOperation.Type.REMOVE) {
BwpGroup.BwpGroupBuilder bwpgBuilder =
DefaultBwpGroup.builder()
.groupIndex((short) meterId)
.yangBwpGroupOpType(OnosYangOpType.DELETE);
Cos cos = new DefaultCos();
cos.cosIndex(COS_INDEX_1);
cos.name("COS-1");
cos.outgoingCosValue(PriorityType.of(DEFAULT_OUTGOING_PRIO));
cos.colorAware(true);
cos.colorForward(true);
profilesBuilder.addToBwpGroup(bwpgBuilder.build()).build();
EvcCosTypeAll8PrioTo1EvcColor ect =
new DefaultEvcCosTypeAll8PrioTo1EvcColor();
ect.evcAll8ColorTo(CosColorType.of(CosColorTypeEnum.GREEN));
profiles.addToBwpGroup(bwpg);
EvcCosTypeEvcColorId cid = new DefaultEvcCosTypeEvcColorId();
cid.evcCosTypeAll8PrioTo1EvcColor(ect);
cos.cosTypeChoice(cid);
profiles.addToCos(cos);
} else if (meterOp.type() == MeterOperation.Type.REMOVE) {
BwpGroup bwpg = new DefaultBwpGroup();
bwpg.groupIndex((short) meterId);
profiles.addToBwpGroup(bwpg);
}
MefServices mefServices = DefaultMefServices.builder().profiles(profilesBuilder.build()).build();
MefServices mefServices = new DefaultMefServices();
mefServices.profiles(profiles);
MseaUniEvcService.MseaUniEvcServiceBuilder evcUniBuilder =
new MseaUniEvcServiceOpParam.MseaUniEvcServiceBuilder();
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter = new MseaUniEvcServiceOpParam();
mseaUniEvcServiceFilter.mefServices(mefServices);
MseaUniEvcServiceOpParam mseaUniEvcServiceFilter =
(MseaUniEvcServiceOpParam) evcUniBuilder.mefServices(mefServices).build();
NetconfSession session = controller.getDevicesMap().get(deviceId).getSession();
try {
mseaUniEvcServiceSvc.setMseaUniEvcService(mseaUniEvcServiceFilter, session, TargetConfig.RUNNING);
if (meterOp.type() == MeterOperation.Type.REMOVE) {
mseaUniEvcServiceSvc.deleteMseaUniEvcService(mseaUniEvcServiceFilter,
session, DatastoreId.RUNNING);
} else {
mseaUniEvcServiceSvc.setMseaUniEvcService(mseaUniEvcServiceFilter,
session, DatastoreId.RUNNING);
}
} catch (NetconfException e) {
//This can fail if the BWP Group is deleted before the EVC that is dependent on it
//The delete of the EVC will be called on a separate thread to that should proceed
@ -201,24 +208,25 @@ public class EA1000MeterProvider extends AbstractProvider implements MeterProvid
while (retry.getAndDecrement() > 0) {
try {
Thread.sleep(1000L);
log.debug("Retrying deletion of Bandwith Profile Group {}", String.valueOf(meterId));
log.debug("Retrying deletion of Bandwith Profile Group {}",
String.valueOf(meterId));
mseaUniEvcServiceSvc.setMseaUniEvcService(mseaUniEvcServiceFilter,
session, TargetConfig.RUNNING);
session, DatastoreId.RUNNING);
return; //If it did not throw an exception
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
log.debug("Error when deleting BWP profile on EA1000" +
" - trying again in 1 sec", e1);
} catch (NetconfException e1) {
log.debug("NETCONF failed to delete profile - trying again in 1 sec");
e1.printStackTrace();
log.debug("NETCONF failed to delete profile - trying again in 1 sec", e1);
}
}
log.error("Error deleting BWPGroup {} from {} after 4 tries: {}", meterId, deviceId, e.getMessage());
log.error("Error deleting BWPGroup {} from {} after 4 tries: {}",
meterId, deviceId, e.getMessage());
} else {
log.error("Error adding BWPGroup {} from {}: {}", meterId, deviceId, e.getMessage());
log.error("Error adding BWPGroup {} from {}: {}",
meterId, deviceId, e.getMessage());
throw new UnsupportedOperationException(e);
}
e.printStackTrace();
}
}

View File

@ -40,12 +40,15 @@ 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.NetconfDevice;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.system.AugmentedSysSystem;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.systemstate.platform.AugmentedSysPlatform;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20130715.ietfyangtypes.DateAndTime;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.system.AugmentedSysSystem;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.system.DefaultAugmentedSysSystem;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.systemstate.platform.AugmentedSysPlatform;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.systemstate.platform.DefaultAugmentedSysPlatform;
import org.onosproject.yang.gen.v1.ietfyangtypes.rev20130715.ietfyangtypes.DateAndTime;
import org.slf4j.Logger;
public class Ea1000DeviceDescription extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
@ -65,7 +68,14 @@ public class Ea1000DeviceDescription extends AbstractHandlerBehaviour implements
log.info("Adding description for EA1000 device");
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
NetconfDevice ncDevice = controller.getDevicesMap().get(handler().data().deviceId());
if (ncDevice == null) {
log.error("Internal ONOS Error. Device has been marked as reachable, " +
"but deviceID {} is not in Devices Map. Continuing with empty description",
handler().data().deviceId());
return null;
}
NetconfSession session = ncDevice.getSession();
IetfSystemNetconfService ietfSystemService =
(IetfSystemNetconfService) checkNotNull(handler().get(IetfSystemNetconfService.class));
@ -75,7 +85,7 @@ public class Ea1000DeviceDescription extends AbstractHandlerBehaviour implements
swVersion = system.systemState().platform().osRelease();
AugmentedSysPlatform augmentedSysPlatform =
(AugmentedSysPlatform) system.systemState()
.platform().yangAugmentedInfo(AugmentedSysPlatform.class);
.platform().augmentation(DefaultAugmentedSysPlatform.class);
serialNumber = augmentedSysPlatform.deviceIdentification().serialNumber();
DateAndTime deviceDateAndTime = system.systemState().clock().currentDatetime();
OffsetDateTime odt =
@ -89,7 +99,7 @@ public class Ea1000DeviceDescription extends AbstractHandlerBehaviour implements
if (system != null && system.system() != null) {
AugmentedSysSystem augmentedSystem =
(AugmentedSysSystem) system.system().yangAugmentedInfo(AugmentedSysSystem.class);
(AugmentedSysSystem) system.system().augmentation(DefaultAugmentedSysSystem.class);
longitudeStr = augmentedSystem.longitude().toPlainString();
latitudeStr = augmentedSystem.latitude().toPlainString();
}

View File

@ -17,17 +17,17 @@ package org.onosproject.drivers.microsemi.yang;
import java.time.OffsetDateTime;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootOutput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.pullupdatetarfromtftp.PullUpdateTarFromTftpInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogOutput;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystemOpParam;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.ietfsystem.systemrestart.SystemRestartInput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootInput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootOutput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.pullupdatetarfromtftp.PullUpdateTarFromTftpInput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogInput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogOutput;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystemOpParam;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.systemrestart.SystemRestartInput;
/**
* Extension of ietfSystemService to include NETCONF sessions.
@ -60,10 +60,11 @@ public interface IetfSystemNetconfService {
* @param ietfSystem value of ietfSystem
* @param session An active NETCONF session
* @param ncDs datastore type running, startup or candidate
* @return Boolean to indicate success or failure
* @throws NetconfException if the session has any error
*/
void setIetfSystem(IetfSystemOpParam ietfSystem, NetconfSession session, TargetConfig ncDs)
throws NetconfException;
boolean setIetfSystem(IetfSystemOpParam ietfSystem, NetconfSession session,
DatastoreId ncDs) throws NetconfException;
/**
* Service interface of setCurrentDatetime.

View File

@ -0,0 +1,135 @@
/*
* 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.microsemi.yang;
import com.google.common.collect.ImmutableMap;
import org.apache.felix.scr.annotations.Component;
import org.onosproject.yang.AbstractYangModelRegistrator;
import org.onosproject.yang.gen.v1.entitystatetcmib.rev20051122.EntityStateTcMib;
import org.onosproject.yang.gen.v1.fpgainternal.rev20151130.FpgaInternal;
import org.onosproject.yang.gen.v1.ianacrypthash.rev20140806.IanaCryptHash;
import org.onosproject.yang.gen.v1.ianaiftype.rev20140508.IanaIfType;
import org.onosproject.yang.gen.v1.ieeetypes.rev20080522.IeeeTypes;
import org.onosproject.yang.gen.v1.ietfinettypes.rev20130715.IetfInetTypes;
import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.IetfInterfaces;
import org.onosproject.yang.gen.v1.ietfnetconf.rev20110601.IetfNetconf;
import org.onosproject.yang.gen.v1.ietfnetconfacm.rev20120222.IetfNetconfAcm;
import org.onosproject.yang.gen.v1.ietfnetconfmonitoring.rev20101004.IetfNetconfMonitoring;
import org.onosproject.yang.gen.v1.ietfnetconfnotifications.rev20120206.IetfNetconfNotifications;
import org.onosproject.yang.gen.v1.ietfnetconfwithdefaults.rev20100609.IetfNetconfWithDefaults;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.IetfSystemMicrosemi;
import org.onosproject.yang.gen.v1.ietfsystemtlsauth.rev20140524.IetfSystemTlsAuth;
import org.onosproject.yang.gen.v1.ietfx509certtoname.rev20130326.IetfX509CertToName;
import org.onosproject.yang.gen.v1.ietfyangtypes.rev20130715.IetfYangTypes;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.MseaCfm;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.mseasoamfm.rev20160229.MseaSoamFm;
import org.onosproject.yang.gen.v1.mseasoampm.rev20160229.MseaSoamPm;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.MseaTypes;
import org.onosproject.yang.gen.v1.mseaunievcinterface.rev20160317.MseaUniEvcInterface;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.ncnotifications.rev20080714.NcNotifications;
import org.onosproject.yang.gen.v1.netopeercfgnetopeer.rev20130214.NetopeerCfgnetopeer;
import org.onosproject.yang.gen.v1.notifications.rev20080714.Notifications;
import org.onosproject.yang.gen.v1.rfc2544.rev20151020.Rfc2544;
import org.onosproject.yang.gen.v1.svcactivationtypes.rev20151027.SvcActivationTypes;
import org.onosproject.yang.gen.v1.y1564.rev20151029.Y1564;
import org.onosproject.yang.model.DefaultYangModuleId;
import org.onosproject.yang.model.YangModuleId;
import org.onosproject.yang.runtime.AppModuleInfo;
import org.onosproject.yang.runtime.DefaultAppModuleInfo;
import java.util.HashMap;
import java.util.Map;
/**
* Representation of Microsemi model registrator which registers Microsemi device
* models.
*/
@Component(immediate = true)
public class MicrosemiModelRegistrator extends AbstractYangModelRegistrator {
public MicrosemiModelRegistrator() {
super(IetfSystem.class, getAppInfo());
}
private static Map<YangModuleId, AppModuleInfo> getAppInfo() {
Map<YangModuleId, AppModuleInfo> appInfo = new HashMap<>();
appInfo.put(new DefaultYangModuleId("fpga-internal", "2015-11-30"),
new DefaultAppModuleInfo(FpgaInternal.class, null));
appInfo.put(new DefaultYangModuleId("iana-if-type", "2014-05-08"),
new DefaultAppModuleInfo(IanaIfType.class, null));
appInfo.put(new DefaultYangModuleId("ietf-yang-types", "2013-07-15"),
new DefaultAppModuleInfo(IetfYangTypes.class, null));
appInfo.put(new DefaultYangModuleId("msea-sa-filtering", "2016-04-12"),
new DefaultAppModuleInfo(MseaSaFiltering.class, null));
appInfo.put(new DefaultYangModuleId("ietf-x509-cert-to-name", "2013-03-26"),
new DefaultAppModuleInfo(IetfX509CertToName.class, null));
appInfo.put(new DefaultYangModuleId("ietf-system", "2014-08-06"),
new DefaultAppModuleInfo(IetfSystem.class, null));
appInfo.put(new DefaultYangModuleId("msea-types", "2016-02-29"),
new DefaultAppModuleInfo(MseaTypes.class, null));
appInfo.put(new DefaultYangModuleId("ietf-inet-types", "2013-07-15"),
new DefaultAppModuleInfo(IetfInetTypes.class, null));
appInfo.put(new DefaultYangModuleId("ietf-netconf-with-defaults", "2010-06-09"),
new DefaultAppModuleInfo(IetfNetconfWithDefaults.class, null));
appInfo.put(new DefaultYangModuleId("msea-uni-evc-service", "2016-03-17"),
new DefaultAppModuleInfo(MseaUniEvcService.class, null));
appInfo.put(new DefaultYangModuleId("ietf-netconf-monitoring", "2010-10-04"),
new DefaultAppModuleInfo(IetfNetconfMonitoring.class, null));
appInfo.put(new DefaultYangModuleId("ietf-netconf-acm", "2012-02-22"),
new DefaultAppModuleInfo(IetfNetconfAcm.class, null));
appInfo.put(new DefaultYangModuleId("ietf-system-tls-auth", "2014-05-24"),
new DefaultAppModuleInfo(IetfSystemTlsAuth.class, null));
appInfo.put(new DefaultYangModuleId("rfc-2544", "2015-10-20"),
new DefaultAppModuleInfo(Rfc2544.class, null));
appInfo.put(new DefaultYangModuleId("msea-cfm", "2016-02-29"),
new DefaultAppModuleInfo(MseaCfm.class, null));
appInfo.put(new DefaultYangModuleId("netopeer-cfgnetopeer", "2013-02-14"),
new DefaultAppModuleInfo(NetopeerCfgnetopeer.class, null));
appInfo.put(new DefaultYangModuleId("ENTITY-STATE-TC-MIB", "2005-11-22"),
new DefaultAppModuleInfo(EntityStateTcMib.class, null));
appInfo.put(new DefaultYangModuleId("msea-soam-fm", "2016-02-29"),
new DefaultAppModuleInfo(MseaSoamFm.class, null));
appInfo.put(new DefaultYangModuleId("ietf-netconf-notifications", "2012-02-06"),
new DefaultAppModuleInfo(IetfNetconfNotifications.class, null));
appInfo.put(new DefaultYangModuleId("nc-notifications", "2008-07-14"),
new DefaultAppModuleInfo(NcNotifications.class, null));
appInfo.put(new DefaultYangModuleId("iana-crypt-hash", "2014-08-06"),
new DefaultAppModuleInfo(IanaCryptHash.class, null));
appInfo.put(new DefaultYangModuleId("msea-uni-evc-interface", "2016-03-17"),
new DefaultAppModuleInfo(MseaUniEvcInterface.class, null));
appInfo.put(new DefaultYangModuleId("msea-soam-pm", "2016-02-29"),
new DefaultAppModuleInfo(MseaSoamPm.class, null));
appInfo.put(new DefaultYangModuleId("ieee-types", "2008-05-22"),
new DefaultAppModuleInfo(IeeeTypes.class, null));
appInfo.put(new DefaultYangModuleId("svc-activation-types", "2015-10-27"),
new DefaultAppModuleInfo(SvcActivationTypes.class, null));
appInfo.put(new DefaultYangModuleId("ietf-netconf", "2011-06-01"),
new DefaultAppModuleInfo(IetfNetconf.class, null));
appInfo.put(new DefaultYangModuleId("ietf-system-microsemi", "2016-05-05"),
new DefaultAppModuleInfo(IetfSystemMicrosemi.class, null));
appInfo.put(new DefaultYangModuleId("notifications", "2008-07-14"),
new DefaultAppModuleInfo(Notifications.class, null));
appInfo.put(new DefaultYangModuleId("y-1564", "2015-10-29"),
new DefaultAppModuleInfo(Y1564.class, null));
appInfo.put(new DefaultYangModuleId("ietf-interfaces", "2014-05-08"),
new DefaultAppModuleInfo(IetfInterfaces.class, null));
return ImmutableMap.copyOf(appInfo);
}
}

View File

@ -15,18 +15,15 @@
*/
package org.onosproject.drivers.microsemi.yang;
import org.onosproject.event.ListenerService;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfm;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfmOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.MseaCfmEvent;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.MseaCfmEventListener;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.abortloopback.AbortLoopbackInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceOutput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.transmitloopback.TransmitLoopbackInput;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.MseaCfm;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.MseaCfmOpParam;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.abortloopback.AbortLoopbackInput;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceInput;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceOutput;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.transmitloopback.TransmitLoopbackInput;
/**
* Extension of mseaCfmService to include NETCONF sessions.
@ -34,7 +31,7 @@ import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.
* This is manually extended and should be revised if the msea-cfm.yang,
* msea-soam-pm.yang or msea-soam-fm.yang files change
*/
public interface MseaCfmNetconfService extends ListenerService<MseaCfmEvent, MseaCfmEventListener> {
public interface MseaCfmNetconfService {
/**
* Returns attributes of MEP.
@ -70,9 +67,11 @@ public interface MseaCfmNetconfService extends ListenerService<MseaCfmEvent, Mse
* @param mseaCfm value of mseaCfm
* @param session An active NETCONF session
* @param targetDs one of running, candidate or startup
* @return Boolean to indicate success or failure
* @throws NetconfException if the session has any error
*/
void setMseaCfm(MseaCfmOpParam mseaCfm, NetconfSession session, TargetConfig targetDs) throws NetconfException;
boolean setMseaCfm(MseaCfmOpParam mseaCfm, NetconfSession session,
DatastoreId targetDs) throws NetconfException;
/**
* Service interface of transmitLoopback.
@ -81,7 +80,8 @@ public interface MseaCfmNetconfService extends ListenerService<MseaCfmEvent, Mse
* @param session An active NETCONF session
* @throws NetconfException if the session has any error
*/
void transmitLoopback(TransmitLoopbackInput inputVar, NetconfSession session) throws NetconfException;
void transmitLoopback(TransmitLoopbackInput inputVar,
NetconfSession session) throws NetconfException;
/**
* Service interface of abortLoopback.
@ -90,7 +90,8 @@ public interface MseaCfmNetconfService extends ListenerService<MseaCfmEvent, Mse
* @param session An active NETCONF session
* @throws NetconfException if the session has any error
*/
void abortLoopback(AbortLoopbackInput inputVar, NetconfSession session) throws NetconfException;
void abortLoopback(AbortLoopbackInput inputVar,
NetconfSession session) throws NetconfException;
/**
* Service interface of transmitLinktrace.
@ -100,6 +101,6 @@ public interface MseaCfmNetconfService extends ListenerService<MseaCfmEvent, Mse
* @return transmitLinktraceOutput output of service interface transmitLinktrace
* @throws NetconfException if the session has any error
*/
TransmitLinktraceOutput transmitLinktrace(TransmitLinktraceInput inputVar, NetconfSession session)
throws NetconfException;
TransmitLinktraceOutput transmitLinktrace(TransmitLinktraceInput inputVar,
NetconfSession session) throws NetconfException;
}

View File

@ -16,11 +16,14 @@
package org.onosproject.drivers.microsemi.yang;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.SourceAddressRange;
import java.util.List;
/**
* Extension of mseaSaFilteringService to include NETCONF sessions.
@ -40,15 +43,38 @@ public interface MseaSaFilteringNetconfService {
MseaSaFilteringOpParam mseaSaFiltering, final NetconfSession session)
throws NetconfException;
/**
* Get a filtered subset of the config model.
*
* @param session An active NETCONF session
* @return mseaSaFiltering
* @throws NetconfException if the session has any error
*/
public List<SourceAddressRange> getConfigMseaSaFilterIds(NetconfSession session)
throws NetconfException;
/**
* Sets the value to attribute mseaSaFiltering.
*
* @param mseaSaFiltering value of mseaSaFiltering
* @param session An active NETCONF session
* @param targetDs The NETCONF datastore to edit
* @return Boolean to indicate success or failure
* @throws NetconfException if the session has any error
*/
void setMseaSaFiltering(MseaSaFilteringOpParam mseaSaFiltering, NetconfSession session, TargetConfig targetDs)
throws NetconfException;
boolean setMseaSaFiltering(MseaSaFilteringOpParam mseaSaFiltering,
NetconfSession session, DatastoreId targetDs) throws NetconfException;
/**
* Deletes the value to attribute mseaSaFiltering.
*
* @param mseaSaFiltering value of mseaSaFiltering
* @param session An active NETCONF session
* @param targetDs The NETCONF datastore to edit
* @return Boolean to indicate success or failure
* @throws NetconfException if the session has any error
*/
boolean deleteMseaSaFilteringRange(MseaSaFilteringOpParam mseaSaFiltering,
NetconfSession session, DatastoreId targetDs) throws NetconfException;
}

View File

@ -19,12 +19,12 @@ package org.onosproject.drivers.microsemi.yang;
import java.util.List;
import java.util.Map;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
/**
* Extension of mseaUniEvcServiceService to include NETCONF sessions.
@ -55,8 +55,8 @@ public interface MseaUniEvcServiceNetconfService {
* @throws NetconfException if the session has any error
*/
MseaUniEvcService getConfigMseaUniEvcService(
MseaUniEvcServiceOpParam mseaUniEvcService, NetconfSession session, TargetConfig targetDs)
throws NetconfException;
MseaUniEvcServiceOpParam mseaUniEvcService, NetconfSession session,
DatastoreId targetDs) throws NetconfException;
/**
* Sets the value to attribute mseaUniEvcService.
@ -64,12 +64,25 @@ public interface MseaUniEvcServiceNetconfService {
* @param mseaUniEvcService value of mseaUniEvcService
* @param session The NETCONF session
* @param targetDs one of running, candidate or startup
* @return Boolean to indicate success or failure
* @throws NetconfException if the session has any error
*/
void setMseaUniEvcService(MseaUniEvcServiceOpParam mseaUniEvcService,
NetconfSession session, TargetConfig targetDs)
boolean setMseaUniEvcService(MseaUniEvcServiceOpParam mseaUniEvcService,
NetconfSession session, DatastoreId targetDs)
throws NetconfException;
/**
* Deletes the objects in mseaUniEvcService.
*
* @param mseaUniEvcService value of mseaUniEvcService
* @param session The NETCONF session
* @param targetDs one of running, candidate or startup
* @return Boolean to indicate success or failure
* @throws NetconfException if the session has any error
*/
boolean deleteMseaUniEvcService(MseaUniEvcServiceOpParam mseaUniEvcService,
NetconfSession session, DatastoreId targetDs) throws NetconfException;
/**
* Returns a list of the CeVlanMaps on both sides of the EVC.
*
@ -79,7 +92,7 @@ public interface MseaUniEvcServiceNetconfService {
* @throws NetconfException if the session has any error
*/
MseaUniEvcService getmseaUniEvcCeVlanMaps(
NetconfSession session, TargetConfig ncDs)
NetconfSession session, DatastoreId ncDs)
throws NetconfException;
/**
@ -100,7 +113,7 @@ public interface MseaUniEvcServiceNetconfService {
Map<Integer, String> ceVlanUpdates,
Map<Integer, List<Short>> flowVlanIds,
NetconfSession session,
TargetConfig targetDs,
DatastoreId targetDs,
UniSideInterfaceAssignmentEnum portAssign)
throws NetconfException;

View File

@ -0,0 +1,56 @@
/*
* 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.microsemi.yang.custom;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.EvcPerUniServiceTypeEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.FlowMapping;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.TagManipulation;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.DefaultEvcPerUnic;
import java.util.List;
/**
* Extend the DefaultEvcPerUnic so that the ceVlanMap can always be initialized at 0.
*/
public class CustomEvcPerUnic extends DefaultEvcPerUnic {
@Override
public ServiceListType ceVlanMap() {
if (ceVlanMap == null) {
return new ServiceListType("0");
}
return ceVlanMap;
}
@Override
public Object ingressBwpGroupIndex() {
return ingressBwpGroupIndex;
}
@Override
public EvcPerUniServiceTypeEnum evcPerUniServiceType() {
return evcPerUniServiceType;
}
@Override
public TagManipulation tagManipulation() {
return tagManipulation;
}
@Override
public List<FlowMapping> flowMapping() {
return flowMapping;
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.microsemi.yang.custom;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.EvcPerUniServiceTypeEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.FlowMapping;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.TagManipulation;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.DefaultEvcPerUnin;
import java.util.List;
/**
* Extend the DefaultEvcPerUnin so that the ceVlanMap can always be initialized at 0.
*/
public class CustomEvcPerUnin extends DefaultEvcPerUnin {
@Override
public ServiceListType ceVlanMap() {
if (ceVlanMap == null) {
return new ServiceListType("0");
}
return ceVlanMap;
}
@Override
public Object ingressBwpGroupIndex() {
return ingressBwpGroupIndex;
}
@Override
public EvcPerUniServiceTypeEnum evcPerUniServiceType() {
return evcPerUniServiceType;
}
@Override
public TagManipulation tagManipulation() {
return tagManipulation;
}
@Override
public List<FlowMapping> flowMapping() {
return flowMapping;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-present Open Networking Laboratory
* 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.
@ -17,4 +17,4 @@
/**
* Package for Microsemi device drivers support for NETCONF for EA1000.
*/
package org.onosproject.yms.app.yab;
package org.onosproject.drivers.microsemi.yang.custom;

View File

@ -0,0 +1,245 @@
/*
* 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.microsemi.yang.impl;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import com.google.common.base.Charsets;
import com.google.common.io.ByteSource;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.yang.model.ModelConverter;
import org.onosproject.yang.model.ModelObjectData;
import org.onosproject.yang.model.ResourceData;
import org.onosproject.yang.model.ResourceId;
import org.onosproject.yang.model.SchemaContext;
import org.onosproject.yang.model.SchemaContextProvider;
import org.onosproject.yang.runtime.AnnotatedNodeInfo;
import org.onosproject.yang.runtime.CompositeData;
import org.onosproject.yang.runtime.CompositeStream;
import org.onosproject.yang.runtime.DefaultCompositeData;
import org.onosproject.yang.runtime.DefaultCompositeStream;
import org.onosproject.yang.runtime.DefaultYangSerializerContext;
import org.onosproject.yang.runtime.YangModelRegistry;
import org.onosproject.yang.runtime.YangSerializer;
import org.onosproject.yang.runtime.YangSerializerContext;
import org.onosproject.yang.runtime.YangSerializerRegistry;
import org.onosproject.yang.serializers.xml.XmlSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Abstract class that implements some of the core functions of a YANG model service.
*
*/
@Component(immediate = true)
@Service
public abstract class AbstractYangServiceImpl {
public static final String NC_OPERATION = "nc:operation";
public static final String OP_DELETE = "delete";
protected final Logger log = LoggerFactory.getLogger(getClass());
protected boolean alreadyLoaded = false;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected YangModelRegistry yangModelRegistry;
// @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
// protected SchemaContextProvider schemaContextProvider;
protected ApplicationId appId;
// xSer is not a service and is a class variable. Can be lost on deactivate.
// Must be recreated on activate
protected XmlSerializer xSer;
protected YangSerializerContext yCtx;
protected static final Pattern REGEX_XML_HEADER =
Pattern.compile("(<\\?xml).*(\\?>)", Pattern.DOTALL);
protected static final Pattern REGEX_RPC_REPLY =
Pattern.compile("(<rpc-reply)[ ]*" +
"(xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\")[ ]*" +
"(message-id=\")[0-9]*(\">)", Pattern.DOTALL);
protected static final Pattern REGEX_RPC_REPLY_DATA_NS =
Pattern.compile("(<data)[ ]*(xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)");
protected static final Pattern REGEX_RPC_REPLY_DATA =
Pattern.compile("(<data>)");
protected static final Pattern REGEX_RPC_REPLY_DATA_CLOSE =
Pattern.compile("(</data>)");
protected static final Pattern REGEX_RPC_REPLY_DATA_EMPTY =
Pattern.compile("(<data/>)");
protected static final Pattern REGEX_RPC_REPLY_CLOSE =
Pattern.compile("(</rpc-reply>)");
@Activate
public void activate() {
Set<YangSerializer> yangSer = ((YangSerializerRegistry) yangModelRegistry).getSerializers();
yangSer.forEach(ser -> {
if (ser instanceof XmlSerializer) {
xSer = (XmlSerializer) ser;
}
});
SchemaContext context = ((SchemaContextProvider) yangModelRegistry)
.getSchemaContext(ResourceId.builder().addBranchPointSchema("/", null).build());
yCtx = new DefaultYangSerializerContext(context, null);
};
@Deactivate
public void deactivate() {
alreadyLoaded = false;
}
/**
* Internal method to generically make a NETCONF get query from YANG objects.
* @param moFilter A YANG object model
* @param session A NETCONF session
* @return YangObjectModel
* @throws NetconfException if the session has any error
*/
protected final ModelObjectData getNetconfObject(
ModelObjectData moFilter, NetconfSession session)
throws NetconfException {
return getConfigNetconfObject(moFilter, session, null);
}
/**
* Internal method to generically make a NETCONF get-config query from YANG objects.
*
* @param moFilter A YANG object model
* @param session A NETCONF session
* @param targetDs - running,candidate or startup
* @return YangObjectModel
* @throws NetconfException if the session has any error
*/
protected final ModelObjectData getConfigNetconfObject(
ModelObjectData moFilter, NetconfSession session, DatastoreId targetDs)
throws NetconfException {
if (session == null) {
throw new NetconfException("Session is null when calling getConfigNetconfObject()");
}
if (moFilter == null) {
throw new NetconfException("Query object cannot be null");
}
String xmlQueryStr = encodeMoToXmlStr(moFilter, null);
log.debug("Sending <get-(config)> query on NETCONF session " + session.getSessionId() +
":\n" + xmlQueryStr);
String xmlResult;
if (targetDs == null) {
xmlResult = session.get(xmlQueryStr, null);
} else {
xmlResult = session.getConfig(targetDs, xmlQueryStr);
}
xmlResult = removeRpcReplyData(xmlResult);
DefaultCompositeStream resultDcs = new DefaultCompositeStream(
null, new ByteArrayInputStream(xmlResult.getBytes()));
CompositeData compositeData = xSer.decode(resultDcs, yCtx);
return ((ModelConverter) yangModelRegistry).createModel(compositeData.resourceData());
}
/**
* Internal method to generically make a NETCONF edit-config call from a set of YANG objects.
*
* @param moConfig A YANG object model
* @param session A NETCONF session
* @param targetDs - running,candidate or startup
* @param annotations A list of AnnotatedNodeInfos to be added to the DataNodes
* @return Boolean value indicating success or failure of command
* @throws NetconfException if the session has any error
*/
protected final boolean setNetconfObject(
ModelObjectData moConfig, NetconfSession session, DatastoreId targetDs,
List<AnnotatedNodeInfo> annotations) throws NetconfException {
if (moConfig == null) {
throw new NetconfException("Query object cannot be null");
} else if (session == null) {
throw new NetconfException("Session is null when calling getMseaSaFiltering()");
} else if (targetDs == null) {
throw new NetconfException("TargetDs is null when calling getMseaSaFiltering()");
}
String xmlQueryStr = encodeMoToXmlStr(moConfig, annotations);
log.debug("Sending <edit-config> query on NETCONF session " + session.getSessionId() +
":\n" + xmlQueryStr);
return session.editConfig(targetDs, null, xmlQueryStr);
}
protected final String encodeMoToXmlStr(ModelObjectData yangObjectOpParamFilter,
List<AnnotatedNodeInfo> annotations)
throws NetconfException {
//Convert the param to XML to use as a filter
ResourceData rd = ((ModelConverter) yangModelRegistry).createDataNode(yangObjectOpParamFilter);
DefaultCompositeData.Builder cdBuilder =
DefaultCompositeData.builder().resourceData(rd);
if (annotations != null) {
for (AnnotatedNodeInfo ani : annotations) {
cdBuilder.addAnnotatedNodeInfo(ani);
}
}
CompositeStream cs = xSer.encode(cdBuilder.build(), yCtx);
//Convert the param to XML to use as a filter
try {
ByteSource byteSource = new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return cs.resourceData();
}
};
return byteSource.asCharSource(Charsets.UTF_8).read();
} catch (IOException e) {
throw new NetconfException("Error decoding CompositeStream to String", e);
}
}
protected static final String removeRpcReplyData(String rpcReplyXml) {
rpcReplyXml = REGEX_XML_HEADER.matcher(rpcReplyXml).replaceFirst("");
rpcReplyXml = REGEX_RPC_REPLY.matcher(rpcReplyXml).replaceFirst("");
rpcReplyXml = REGEX_RPC_REPLY_DATA_NS.matcher(rpcReplyXml).replaceFirst("");
rpcReplyXml = REGEX_RPC_REPLY_DATA.matcher(rpcReplyXml).replaceFirst("");
rpcReplyXml = REGEX_RPC_REPLY_DATA_CLOSE.matcher(rpcReplyXml).replaceFirst("");
rpcReplyXml = REGEX_RPC_REPLY_DATA_EMPTY.matcher(rpcReplyXml).replaceFirst("");
rpcReplyXml = REGEX_RPC_REPLY_CLOSE.matcher(rpcReplyXml).replaceFirst("");
rpcReplyXml = rpcReplyXml.replace("\t", "");
return rpcReplyXml;
}
}

View File

@ -15,32 +15,34 @@
*/
package org.onosproject.drivers.microsemi.yang.impl;
import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REPLY;
import java.io.ByteArrayInputStream;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.drivers.microsemi.yang.IetfSystemNetconfService;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.IetfSystemMicrosemiService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootOutput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.pullupdatetarfromtftp.PullUpdateTarFromTftpInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogOutput;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystemOpParam;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystemService;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.ietfsystem.systemrestart.SystemRestartInput;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.DefaultSystem;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.DefaultSystemState;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootInput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.doupgradeandreboot.DoUpgradeAndRebootOutput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.pullupdatetarfromtftp.PullUpdateTarFromTftpInput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogInput;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.readfromsyslog.ReadFromSyslogOutput;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystemOpParam;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.systemrestart.SystemRestartInput;
import org.onosproject.yang.model.DefaultModelObjectData;
import org.onosproject.yang.model.ModelConverter;
import org.onosproject.yang.model.ModelObject;
import org.onosproject.yang.model.ModelObjectData;
import org.onosproject.yang.runtime.CompositeData;
import org.onosproject.yang.runtime.DefaultCompositeStream;
/**
* Implementation of the IetfService YANG model service.
@ -50,28 +52,18 @@ import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20
public class IetfSystemManager extends AbstractYangServiceImpl
implements IetfSystemNetconfService {
protected final Pattern regexRemoveSystem =
Pattern.compile("(<system).*(</system>)", Pattern.DOTALL);
protected final Pattern regexRemoveSystemState =
Pattern.compile("(<system-state).*(</system-state>)", Pattern.DOTALL);
protected static final String IETF_SYSTEM = "org.onosproject.drivers.microsemi.yang.ietfsystem";
@Activate
public void activate() {
super.activate();
appId = coreService.registerApplication(IETF_SYSTEM);
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(IetfSystemService.class);
ych.addDeviceSchema(IetfSystemMicrosemiService.class);
log.info("IetfSystemManager Started");
}
@Deactivate
public void deactivate() {
super.deactivate();
ymsService.unRegisterService(this, IetfSystemService.class);
ymsService.unRegisterService(this, IetfSystemMicrosemiService.class);
ych = null;
log.info("IetfSystemManager Stopped");
}
@ -85,7 +77,23 @@ public class IetfSystemManager extends AbstractYangServiceImpl
@Override
public IetfSystem getIetfSystem(IetfSystemOpParam ietfSystemFilter, NetconfSession session)
throws NetconfException {
return (IetfSystem) getNetconfObject(ietfSystemFilter, session);
ModelObjectData moQuery = DefaultModelObjectData.builder()
.addModelObject((ModelObject) ietfSystemFilter.system())
.build();
ModelObjectData moReply = getNetconfObject(moQuery, session);
IetfSystemOpParam ietfSystem = new IetfSystemOpParam();
for (ModelObject mo:moReply.modelObjects()) {
if (mo instanceof DefaultSystem) {
ietfSystem.system((DefaultSystem) mo);
} else if (mo instanceof DefaultSystemState) {
ietfSystem.systemState((DefaultSystemState) mo);
}
}
return ietfSystem;
}
@Override
@ -96,34 +104,34 @@ public class IetfSystemManager extends AbstractYangServiceImpl
String xmlResult = session.get(getInitRequestBuilder(), null);
//The result will be a <system> followed by <system-state>
//YCH can decode only one at a time - split it and send half each time
IetfSystem.IetfSystemBuilder iBuilder = new IetfSystemOpParam.IetfSystemBuilder();
xmlResult = removeRpcReplyData(xmlResult);
DefaultCompositeStream resultDcs = new DefaultCompositeStream(
null, new ByteArrayInputStream(xmlResult.getBytes()));
CompositeData compositeData = xSer.decode(resultDcs, yCtx);
String xmlResultSystem = regexRemoveSystemState.matcher(xmlResult).replaceFirst("");
List<Object> objectListState = ych.decode(xmlResultSystem, XML, QUERY_REPLY);
if (objectListState != null && objectListState.size() > 0) {
IetfSystem system = (IetfSystem) objectListState.get(0);
iBuilder.system(system.system());
ModelObjectData mod = ((ModelConverter) yangModelRegistry).createModel(compositeData.resourceData());
IetfSystemOpParam ietfSystem = new IetfSystemOpParam();
for (ModelObject mo:mod.modelObjects()) {
if (mo instanceof DefaultSystem) {
ietfSystem.system((DefaultSystem) mo);
} else if (mo instanceof DefaultSystemState) {
ietfSystem.systemState((DefaultSystemState) mo);
}
}
String xmlResultSystemState = regexRemoveSystem.matcher(xmlResult).replaceFirst("");
List<Object> objectListSystemState = ych.decode(xmlResultSystemState, XML, QUERY_REPLY);
if (objectListSystemState != null && objectListSystemState.size() > 0) {
IetfSystem system = (IetfSystem) objectListSystemState.get(0);
iBuilder.systemState(system.systemState());
}
return iBuilder.build();
return ietfSystem;
}
/**
* Call NETCONF edit-config with a configuration.
*/
@Override
public void setIetfSystem(IetfSystemOpParam ietfSystem, NetconfSession session, TargetConfig ncDs)
throws NetconfException {
setNetconfObject(ietfSystem, session, ncDs);
public boolean setIetfSystem(IetfSystemOpParam ietfSystem, NetconfSession session,
DatastoreId ncDs) throws NetconfException {
ModelObjectData mo = DefaultModelObjectData.builder()
.addModelObject(ietfSystem).build();
return setNetconfObject(mo, session, ncDs, null);
}
@Override

View File

@ -15,29 +15,29 @@
*/
package org.onosproject.drivers.microsemi.yang.impl;
import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REPLY;
import java.util.List;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.drivers.microsemi.yang.MseaCfmNetconfService;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfm;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfmOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfmService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.MseaCfmEventListener;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.abortloopback.AbortLoopbackInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceOutput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.transmitloopback.TransmitLoopbackInput;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.soam.fm.rev20160229.MseaSoamFmService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.soam.pm.rev20160229.MseaSoamPmService;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.MseaCfm;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.MseaCfmOpParam;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.DefaultMefCfm;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.abortloopback.AbortLoopbackInput;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceInput;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.transmitlinktrace.TransmitLinktraceOutput;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.transmitloopback.TransmitLoopbackInput;
import org.onosproject.yang.model.DefaultModelObjectData;
import org.onosproject.yang.model.ModelConverter;
import org.onosproject.yang.model.ModelObject;
import org.onosproject.yang.model.ModelObjectData;
import org.onosproject.yang.runtime.CompositeData;
import org.onosproject.yang.runtime.DefaultCompositeStream;
import java.io.ByteArrayInputStream;
/**
* Implementation of the MseaCfmServiceNetconf YANG model service.
@ -51,21 +51,14 @@ public class MseaCfmManager extends AbstractYangServiceImpl
@Activate
public void activate() {
super.activate();
appId = coreService.registerApplication(MSEA_CFM);
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(MseaCfmService.class);
ych.addDeviceSchema(MseaSoamFmService.class);
ych.addDeviceSchema(MseaSoamPmService.class);
log.info("MseaCfmService Started");
}
@Deactivate
public void deactivate() {
super.deactivate();
ymsService.unRegisterService(this, MseaCfmService.class);
ymsService.unRegisterService(this, MseaSoamFmService.class);
ymsService.unRegisterService(this, MseaSoamPmService.class);
ych = null;
log.info("MseaCfmService Stopped");
}
@ -82,42 +75,38 @@ public class MseaCfmManager extends AbstractYangServiceImpl
":\n" + xmlQueryStr);
String xmlResult = session.get(xmlQueryStr, null);
//FIXME Line is removed because YCH decode does not know how to handle it
xmlResult = xmlResult.replaceAll("(<ccm-interval>)(3.3ms|10ms|100ms|1s)(</ccm-interval>)", "");
xmlResult = xmlResult.replaceAll("(<active-defects/>)", "");
List<Object> objectList = ych.decode(xmlResult, XML, QUERY_REPLY);
if (objectList != null && objectList.size() > 0) {
Object systemObject = objectList.get(0);
return (MseaCfm) systemObject;
} else {
throw new NetconfException("Failure of YCH decode - could not parse as MseaCfm: " + xmlResult);
xmlResult = removeRpcReplyData(xmlResult);
DefaultCompositeStream resultDcs = new DefaultCompositeStream(
null, new ByteArrayInputStream(xmlResult.getBytes()));
CompositeData compositeData = xSer.decode(resultDcs, yCtx);
ModelObjectData mod = ((ModelConverter) yangModelRegistry).createModel(compositeData.resourceData());
MseaCfmOpParam mseaCfm = new MseaCfmOpParam();
for (ModelObject mo:mod.modelObjects()) {
if (mo instanceof DefaultMefCfm) {
mseaCfm.mefCfm((DefaultMefCfm) mo);
}
}
return mseaCfm;
}
@Override
public MseaCfm getSoamDm(String mdName, String maName, int mepId,
int dmId, NetconfSession session) throws NetconfException {
String xmlQueryStr = buildDmQueryString(mdName, maName, mepId, dmId);
log.debug("Sending <get> for " +
" query on NETCONF session " + session.getSessionId() +
":\n" + xmlQueryStr);
String xmlResult = session.get(xmlQueryStr, null);
List<Object> objectList = ych.decode(xmlResult, XML, QUERY_REPLY);
if (objectList != null && objectList.size() > 0) {
Object systemObject = objectList.get(0);
return (MseaCfm) systemObject;
} else {
throw new NetconfException("Failure of YCH decode - could not parse as MseaCfm: " + xmlResult);
}
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void setMseaCfm(MseaCfmOpParam mseaCfm, NetconfSession session, TargetConfig targetDs)
throws NetconfException {
setNetconfObject(mseaCfm, session, targetDs);
public boolean setMseaCfm(MseaCfmOpParam mseaCfm, NetconfSession session,
DatastoreId targetDs) throws NetconfException {
ModelObjectData moEdit = DefaultModelObjectData.builder()
.addModelObject(mseaCfm).build();
return setNetconfObject(moEdit, session, targetDs, null);
}
/**
@ -139,16 +128,6 @@ public class MseaCfmManager extends AbstractYangServiceImpl
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void addListener(MseaCfmEventListener listener) {
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void removeListener(MseaCfmEventListener listener) {
throw new UnsupportedOperationException("Not yet implemented");
}
private String buildMepQueryString(String mdName, String maName, int mepId) {
StringBuilder rpc = new StringBuilder();
@ -162,7 +141,7 @@ public class MseaCfmManager extends AbstractYangServiceImpl
rpc.append("<maintenance-association>\n");
rpc.append("<id/>\n");
rpc.append("<name>" + maName + "</name>\n");
// rpc.append("<ccm-interval>10ms</ccm-interval>\n"); //Have to omit for the moment - YMS problem
rpc.append("<ccm-interval>10ms</ccm-interval>\n");
rpc.append("<remote-meps/>\n");
rpc.append("<component-list/>\n");
rpc.append("<maintenance-association-end-point>\n");
@ -175,7 +154,7 @@ public class MseaCfmManager extends AbstractYangServiceImpl
rpc.append("<mac-address/>\n");
rpc.append("<msea-soam-fm:port-status/>\n");
rpc.append("<msea-soam-fm:interface-status/>\n");
// rpc.append("<msea-soam-fm:last-defect-sent/>\n");//Have to omit for the moment - YMS problem
rpc.append("<msea-soam-fm:last-defect-sent/>\n");
rpc.append("<msea-soam-fm:rdi-transmit-status/>\n");
rpc.append("<loopback/>\n");
rpc.append("<remote-mep-database/>\n");
@ -202,7 +181,7 @@ public class MseaCfmManager extends AbstractYangServiceImpl
rpc.append("<maintenance-association>\n");
rpc.append("<id/>\n");
rpc.append("<name>" + maName + "</name>\n");
// rpc.append("<ccm-interval>10ms</ccm-interval>\n"); //Have to omit for the moment - YMS problem
rpc.append("<ccm-interval>10ms</ccm-interval>\n");
rpc.append("<maintenance-association-end-point>\n");
rpc.append("<mep-identifier>" + mepId + "</mep-identifier>\n");
rpc.append("<msea-soam-pm:delay-measurements>");

View File

@ -0,0 +1,202 @@
/*
* 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.microsemi.yang.impl;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.drivers.microsemi.yang.MseaSaFilteringNetconfService;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.SourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.SourceAddressRange;
import org.onosproject.yang.model.DefaultModelObjectData;
import org.onosproject.yang.model.ModelConverter;
import org.onosproject.yang.model.ModelObject;
import org.onosproject.yang.model.ModelObjectData;
import org.onosproject.yang.model.ResourceId;
import org.onosproject.yang.runtime.AnnotatedNodeInfo;
import org.onosproject.yang.runtime.CompositeData;
import org.onosproject.yang.runtime.DefaultAnnotatedNodeInfo;
import org.onosproject.yang.runtime.DefaultAnnotation;
import org.onosproject.yang.runtime.DefaultCompositeStream;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.List;
/**
* Implementation of the MseaSaFiltering YANG model service.
*/
@Component(immediate = true, inherit = true)
@Service
public class MseaSaFilteringManager extends AbstractYangServiceImpl
implements MseaSaFilteringNetconfService {
public static final String MSEA_SA_FILTERING =
"org.onosproject.drivers.microsemi.yang.mseasafiltering";
public static final String MSEA_SA_FILTERING_NS =
"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering";
@Activate
public void activate() {
super.activate();
appId = coreService.registerApplication(MSEA_SA_FILTERING);
log.info("MseaSaFilteringManager Started");
}
@Deactivate
public void deactivate() {
super.deactivate();
log.info("MseaSaFilteringManager Stopped");
}
/**
* Get a filtered subset of the model.
* This is meant to filter the current live model
* against the attribute(s) given in the argument
* and return the filtered model.
*/
@Override
public MseaSaFiltering getMseaSaFiltering(
MseaSaFilteringOpParam mseaSaFilteringFilter, NetconfSession session)
throws NetconfException {
ModelObjectData moQuery = DefaultModelObjectData.builder()
.addModelObject((ModelObject) mseaSaFilteringFilter
.sourceIpaddressFiltering())
.build();
ModelObjectData moReply = getNetconfObject(moQuery, session);
MseaSaFiltering reply = new MseaSaFilteringOpParam();
for (ModelObject mo:moReply.modelObjects()) {
if (mo instanceof SourceIpaddressFiltering) {
reply.sourceIpaddressFiltering((SourceIpaddressFiltering) mo);
}
}
return reply;
}
/**
* Get a filtered subset of the config model (from running)
* This is meant to filter the current live model
* against the attribute(s) given in the argument
* and return the filtered model.
*/
@Override
public List<SourceAddressRange> getConfigMseaSaFilterIds(NetconfSession session)
throws NetconfException {
String xmlResult = session.getConfig(DatastoreId.RUNNING, saFilterQuery());
xmlResult = removeRpcReplyData(xmlResult);
DefaultCompositeStream resultDcs = new DefaultCompositeStream(
null, new ByteArrayInputStream(xmlResult.getBytes()));
CompositeData compositeData = xSer.decode(resultDcs, yCtx);
ModelObjectData moReply = ((ModelConverter) yangModelRegistry).createModel(compositeData.resourceData());
MseaSaFiltering reply = new MseaSaFilteringOpParam();
for (ModelObject mo:moReply.modelObjects()) {
if (mo instanceof SourceIpaddressFiltering) {
reply.sourceIpaddressFiltering((SourceIpaddressFiltering) mo);
}
}
if (reply != null && reply.sourceIpaddressFiltering() != null &&
reply.sourceIpaddressFiltering().interfaceEth0() != null) {
return reply.sourceIpaddressFiltering().interfaceEth0().sourceAddressRange();
} else {
return new ArrayList<SourceAddressRange>();
}
}
/**
* Call NETCONF edit-config with a configuration.
*/
@Override
public boolean setMseaSaFiltering(MseaSaFilteringOpParam mseaSaFiltering,
NetconfSession session, DatastoreId ncDs) throws NetconfException {
ModelObjectData moQuery = DefaultModelObjectData.builder()
.addModelObject((ModelObject) mseaSaFiltering
.sourceIpaddressFiltering()).build();
return setNetconfObject(moQuery, session, ncDs, null);
}
@Override
public boolean deleteMseaSaFilteringRange(MseaSaFilteringOpParam mseaSaFiltering,
NetconfSession session, DatastoreId ncDs) throws NetconfException {
ModelObjectData moQuery = DefaultModelObjectData.builder()
.addModelObject((ModelObject) mseaSaFiltering
.sourceIpaddressFiltering()).build();
ArrayList anis = new ArrayList<AnnotatedNodeInfo>();
if (mseaSaFiltering.sourceIpaddressFiltering().interfaceEth0() != null &&
mseaSaFiltering.sourceIpaddressFiltering().interfaceEth0().sourceAddressRange() != null) {
for (SourceAddressRange sar:mseaSaFiltering.sourceIpaddressFiltering()
.interfaceEth0().sourceAddressRange()) {
String sarRangeIdStr = String.valueOf(sar.rangeId());
ResourceId.Builder ridBuilder = ResourceId.builder()
.addBranchPointSchema("/", null)
.addBranchPointSchema("source-ipaddress-filtering", MSEA_SA_FILTERING_NS)
.addBranchPointSchema("interface-eth0", MSEA_SA_FILTERING_NS)
.addBranchPointSchema("source-address-range", MSEA_SA_FILTERING_NS)
.addKeyLeaf("range-id", MSEA_SA_FILTERING_NS, sarRangeIdStr);
AnnotatedNodeInfo ani = DefaultAnnotatedNodeInfo.builder()
.resourceId(ridBuilder.build())
.addAnnotation(new DefaultAnnotation(NC_OPERATION, OP_DELETE))
.build();
anis.add(ani);
}
} else {
//Delete all
ResourceId.Builder ridBuilder = ResourceId.builder()
.addBranchPointSchema("/", null)
.addBranchPointSchema("source-ipaddress-filtering", MSEA_SA_FILTERING_NS);
AnnotatedNodeInfo ani = DefaultAnnotatedNodeInfo.builder()
.resourceId(ridBuilder.build())
.addAnnotation(new DefaultAnnotation(NC_OPERATION, OP_DELETE))
.build();
anis.add(ani);
}
return setNetconfObject(moQuery, session, ncDs, anis);
}
private static String saFilterQuery() {
StringBuilder sb = new StringBuilder("<source-ipaddress-filtering " +
"xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">");
sb.append("<interface-eth0>");
sb.append("<filter-admin-state>blacklist</filter-admin-state>");
sb.append("<source-address-range>");
sb.append("<range-id/>");
sb.append("</source-address-range>");
sb.append("</interface-eth0>");
sb.append("</source-ipaddress-filtering>");
return sb.toString();
}
}

View File

@ -15,9 +15,7 @@
*/
package org.onosproject.drivers.microsemi.yang.impl;
import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REPLY;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -27,13 +25,24 @@ import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.drivers.microsemi.yang.MseaUniEvcServiceNetconfService;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcServiceService;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.MefServices;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
import org.onosproject.yang.model.DefaultModelObjectData;
import org.onosproject.yang.model.ModelConverter;
import org.onosproject.yang.model.ModelObject;
import org.onosproject.yang.model.ModelObjectData;
import org.onosproject.yang.model.ResourceId;
import org.onosproject.yang.runtime.AnnotatedNodeInfo;
import org.onosproject.yang.runtime.CompositeData;
import org.onosproject.yang.runtime.DefaultAnnotatedNodeInfo;
import org.onosproject.yang.runtime.DefaultAnnotation;
import org.onosproject.yang.runtime.DefaultCompositeStream;
/**
* Implementation of the MseaUniEvcServiceService YANG model service.
@ -42,70 +51,127 @@ import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.
@Service
public class MseaUniEvcServiceManager extends AbstractYangServiceImpl
implements MseaUniEvcServiceNetconfService {
public static final String MSEA_SA_FILTERING = "org.onosproject.drivers.microsemi.yang.mseaunievcservice";
public static final String MSEA_UNI_EVC_SVC =
"org.onosproject.drivers.microsemi.yang.mseaunievcservice";
public static final String MSEA_UNI_EVC_SVC_NS =
"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service";
@Activate
public void activate() {
appId = coreService.registerApplication(MSEA_SA_FILTERING);
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(MseaUniEvcServiceService.class);
super.activate();
appId = coreService.registerApplication(MSEA_UNI_EVC_SVC);
log.info("MseaUniEvcServiceManager Started");
}
@Deactivate
public void deactivate() {
super.deactivate();
ymsService.unRegisterService(this, MseaUniEvcServiceService.class);
ych = null;
log.info("MseaUniEvcServiceManager Stopped");
}
@Override
public MseaUniEvcService getMseaUniEvcService(
MseaUniEvcServiceOpParam mseaUniEvcService, NetconfSession session) throws NetconfException {
return (MseaUniEvcService) getNetconfObject(mseaUniEvcService, session);
MseaUniEvcServiceOpParam mseaUniEvcService, NetconfSession session)
throws NetconfException {
return getConfigMseaUniEvcService(mseaUniEvcService, session, null);
}
@Override
public MseaUniEvcService getConfigMseaUniEvcService(
MseaUniEvcServiceOpParam mseaUniEvcService, NetconfSession session, TargetConfig targetDs)
throws NetconfException {
return (MseaUniEvcService) getConfigNetconfObject(mseaUniEvcService, session, targetDs);
MseaUniEvcServiceOpParam mseaUniEvcService, NetconfSession session,
DatastoreId targetDs) throws NetconfException {
ModelObjectData moFilter = DefaultModelObjectData.builder()
.addModelObject((ModelObject) mseaUniEvcService.mefServices()).build();
ModelObjectData moReply = getConfigNetconfObject(moFilter, session, targetDs);
MseaUniEvcService reply = new MseaUniEvcServiceOpParam();
for (ModelObject mo:moReply.modelObjects()) {
if (mo instanceof MefServices) {
reply.mefServices((MefServices) mo);
}
}
return reply;
}
/**
* Modify the configuration.
*/
@Override
public void setMseaUniEvcService(
MseaUniEvcServiceOpParam mseaUniEvcService, NetconfSession session, TargetConfig ncDs)
throws NetconfException {
setNetconfObject(mseaUniEvcService, session, ncDs);
public boolean setMseaUniEvcService(MseaUniEvcServiceOpParam mseaUniEvcService,
NetconfSession session, DatastoreId ncDs) throws NetconfException {
ModelObjectData moEdit = DefaultModelObjectData.builder()
.addModelObject((ModelObject) mseaUniEvcService.mefServices()).build();
return setNetconfObject(moEdit, session, ncDs, null);
}
/**
* Delete the configuration.
*/
@Override
public boolean deleteMseaUniEvcService(MseaUniEvcServiceOpParam mseaUniEvcService,
NetconfSession session, DatastoreId ncDs) throws NetconfException {
ModelObjectData moEdit = DefaultModelObjectData.builder()
.addModelObject((ModelObject) mseaUniEvcService.mefServices()).build();
ArrayList anis = new ArrayList<AnnotatedNodeInfo>();
for (BwpGroup bwpGrp:mseaUniEvcService.mefServices().profiles().bwpGroup()) {
String bwpGroupIndex = String.valueOf(bwpGrp.groupIndex());
ResourceId.Builder ridBuilder = ResourceId.builder()
.addBranchPointSchema("/", null)
.addBranchPointSchema("mef-services", MSEA_UNI_EVC_SVC_NS)
.addBranchPointSchema("profiles", MSEA_UNI_EVC_SVC_NS)
.addBranchPointSchema("bwp-group", MSEA_UNI_EVC_SVC_NS)
.addKeyLeaf("group-index", MSEA_UNI_EVC_SVC_NS, bwpGroupIndex);
AnnotatedNodeInfo ani = DefaultAnnotatedNodeInfo.builder()
.resourceId(ridBuilder.build())
.addAnnotation(new DefaultAnnotation(NC_OPERATION, OP_DELETE))
.build();
anis.add(ani);
}
return setNetconfObject(moEdit, session, ncDs, anis);
}
@Override
public MseaUniEvcService getmseaUniEvcCeVlanMaps(
NetconfSession session, TargetConfig ncDs)
NetconfSession session, DatastoreId ncDs)
throws NetconfException {
if (session == null) {
throw new NetconfException("Session is null when calling getMseaSaFiltering()");
}
String xmlResult = session.getConfig(ncDs, evcFilterQuery());
xmlResult = removeRpcReplyData(xmlResult);
List<Object> objectList = ych.decode(xmlResult, XML, QUERY_CONFIG_REPLY);
if (objectList != null && objectList.size() > 0) {
return (MseaUniEvcService) objectList.get(0);
DefaultCompositeStream resultDcs = new DefaultCompositeStream(
null, new ByteArrayInputStream(xmlResult.getBytes()));
CompositeData compositeData = xSer.decode(resultDcs, yCtx);
ModelObjectData moReply = ((ModelConverter) yangModelRegistry).createModel(compositeData.resourceData());
MseaUniEvcService reply = new MseaUniEvcServiceOpParam();
for (ModelObject mo:moReply.modelObjects()) {
if (mo instanceof MefServices) {
reply.mefServices((MefServices) mo);
}
return null;
}
return reply;
}
@Override
public void removeEvcUniFlowEntries(
Map<Integer, String> ceVlanUpdates,
Map<Integer, List<Short>> flowVlanIds,
NetconfSession session, TargetConfig targetDs,
NetconfSession session, DatastoreId targetDs,
UniSideInterfaceAssignmentEnum portAssign) throws NetconfException {
List<Integer> evcAlreadyHandled = new ArrayList<>();

View File

@ -21,7 +21,7 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20130715.ietfyangtypes.DateAndTime;
import org.onosproject.yang.gen.v1.ietfyangtypes.rev20130715.ietfyangtypes.DateAndTime;
/**
* A utility class to change various YANG types to general purpose classes.

View File

@ -31,21 +31,20 @@ import org.onosproject.drivers.microsemi.yang.impl.IetfSystemManager;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.system.AugmentedSysSystem;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.system.rev20160505.ietfsystemmicrosemi.systemstate.platform.AugmentedSysPlatform;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.IetfSystemOpParam;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.ietfsystem.DefaultSystem;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.ietfsystem.System;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.ietfsystem.system.Clock;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.ietfsystem.system.DefaultClock;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev20140806.ietfsystem.system.clock.timezone.DefaultTimezoneName;
import org.onosproject.yms.ymsm.YmsService;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.system.AugmentedSysSystem;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.system.DefaultAugmentedSysSystem;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.systemstate.platform.AugmentedSysPlatform;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystem;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystemOpParam;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.DefaultSystem;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.System;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.system.DefaultClock;
import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.system.clock.timezone.DefaultTimezoneName;
import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.systemstate.platform.DefaultAugmentedSysPlatform;
public class IetfSystemManagerTest {
IetfSystemManager sysSvc = null;
YmsService ymsService;
NetconfSession session;
@Before
@ -67,14 +66,11 @@ public class IetfSystemManagerTest {
@Test
public void testGetIetfSystemSession() throws NetconfException {
Clock.ClockBuilder cBuilder = new DefaultClock.ClockBuilder();
Clock clock = cBuilder.build();
System system = new DefaultSystem();
system.clock(new DefaultClock());
System.SystemBuilder sBuilder = new DefaultSystem.SystemBuilder();
System system = sBuilder.clock(clock).build();
IetfSystemOpParam.IetfSystemBuilder builder = new IetfSystemOpParam.IetfSystemBuilder();
IetfSystemOpParam sampleSystem = (IetfSystemOpParam) builder.system(system).build();
IetfSystemOpParam sampleSystem = new IetfSystemOpParam();
sampleSystem.system(system);
IetfSystem sys = sysSvc.getIetfSystem(sampleSystem, session);
assertNotNull(sys);
@ -91,14 +87,14 @@ public class IetfSystemManagerTest {
assertNotNull(sys);
assertNotNull(sys.system());
AugmentedSysSystem sysSystem = (AugmentedSysSystem) sys.system().yangAugmentedInfo(AugmentedSysSystem.class);
AugmentedSysSystem sysSystem = (AugmentedSysSystem) sys.system().augmentation(DefaultAugmentedSysSystem.class);
assertEquals("-8.4683990", sysSystem.longitude().toPlainString());
assertEquals("51.9036140", sysSystem.latitude().toPlainString());
assertEquals("4.4.0-53-generic", sys.systemState().platform().osRelease());
AugmentedSysPlatform sysSystemState =
(AugmentedSysPlatform) sys.systemState().platform().yangAugmentedInfo(AugmentedSysPlatform.class);
(AugmentedSysPlatform) sys.systemState().platform().augmentation(DefaultAugmentedSysPlatform.class);
assertEquals("Eagle Simulator.", sysSystemState.deviceIdentification().serialNumber());
}

View File

@ -0,0 +1,36 @@
/*
* 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.microsemi.yang;
import org.onosproject.drivers.microsemi.yang.impl.IetfSystemManager;
import org.onosproject.yang.MockYangRuntimeManager;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
import org.onosproject.yang.serializers.xml.XmlSerializer;
public class MockIetfSystemManager extends IetfSystemManager {
@Override
public void activate() {
yCtx = new MockYangSerializerContext();
xSer = new XmlSerializer();
yangModelRegistry = new MockYangRuntimeManager();
((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
(DefaultYangModelRegistry) yCtx.getContext());
((MockYangRuntimeManager) yangModelRegistry).activate();
}
}

View File

@ -0,0 +1,35 @@
/*
* 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.microsemi.yang;
import org.onosproject.drivers.microsemi.yang.impl.MseaCfmManager;
import org.onosproject.yang.MockYangRuntimeManager;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
import org.onosproject.yang.serializers.xml.XmlSerializer;
public class MockMseaCfmManager extends MseaCfmManager {
@Override
public void activate() {
yCtx = new MockYangSerializerContext();
xSer = new XmlSerializer();
yangModelRegistry = new MockYangRuntimeManager();
((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
(DefaultYangModelRegistry) yCtx.getContext());
((MockYangRuntimeManager) yangModelRegistry).activate();
}
}

View File

@ -15,27 +15,21 @@
*/
package org.onosproject.drivers.microsemi.yang;
import java.io.IOException;
import java.io.UncheckedIOException;
import org.onosproject.drivers.microsemi.yang.impl.MseaSaFilteringManager;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFilteringService;
import org.onosproject.yms.app.yab.MockYmsManager;
import org.onosproject.yang.MockYangRuntimeManager;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
import org.onosproject.yang.serializers.xml.XmlSerializer;
public class MockMseaSaFilteringManager extends MseaSaFilteringManager {
@Override
public void activate() {
try {
ymsService = new MockYmsManager();
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(MseaSaFilteringService.class);
} catch (InstantiationException | IllegalAccessException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
throw new UncheckedIOException(e);
}
yCtx = new MockYangSerializerContext();
xSer = new XmlSerializer();
yangModelRegistry = new MockYangRuntimeManager();
((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
(DefaultYangModelRegistry) yCtx.getContext());
((MockYangRuntimeManager) yangModelRegistry).activate();
}
}

View File

@ -15,26 +15,20 @@
*/
package org.onosproject.drivers.microsemi.yang;
import java.io.IOException;
import java.io.UncheckedIOException;
import org.onosproject.drivers.microsemi.yang.impl.MseaUniEvcServiceManager;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev20160317.MseaUniEvcServiceService;
import org.onosproject.yms.app.yab.MockYmsManager;
import org.onosproject.yang.MockYangRuntimeManager;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
import org.onosproject.yang.serializers.xml.XmlSerializer;
public class MockMseaUniEvcServiceManager extends MseaUniEvcServiceManager {
@Override
public void activate() {
try {
ymsService = new MockYmsManager();
ych = ymsService.getYangCodecHandler();
ych.addDeviceSchema(MseaUniEvcServiceService.class);
} catch (InstantiationException | IllegalAccessException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
log.error("Failed to load YMS Manager: " + e.getMessage());
throw new UncheckedIOException(e);
}
yCtx = new MockYangSerializerContext();
xSer = new XmlSerializer();
yangModelRegistry = new MockYangRuntimeManager();
((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
(DefaultYangModelRegistry) yCtx.getContext());
((MockYangRuntimeManager) yangModelRegistry).activate();
}
}

View File

@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfDeviceOutputEventListener;
import org.onosproject.netconf.NetconfException;
@ -88,17 +89,21 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
+ "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
private Pattern sampleXmlRegexEditDeleteSaFilt =
Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
+ "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
+ "(<target><running/></target>)\\R?"
+ "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
+ "(<source-ipaddress-filtering "
+ "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">).*"
+ "(<interface-eth0>).*"
+ "(<source-address-range nc:operation=\"delete\">).*(<range-id>).*(</range-id>).*"
+ "(</source-address-range>).*"
+ "(<source-address-range nc:operation=\"delete\">).*(<range-id>).*(</range-id>).*"
+ "(</source-address-range>).*"
+ "(</interface-eth0>).*(</source-ipaddress-filtering>).*"
+ "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
+ "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">)\\R?"
+ "(<interface-eth0>)\\R?"
+ "((<source-address-range nc:operation=\"delete\">)\\R?"
+ "(<range-id>)[0-9]*(</range-id>)\\R?"
+ "((<name>)[a-zA-Z0-9]*(</name>))?\\R?"
+ "((<ipv4-address-prefix>)[0-9\\\\./]*(</ipv4-address-prefix>))?\\R?"
+ "(</source-address-range>))++\\R?"
+ "(</interface-eth0>)\\R?"
+ "(</source-ipaddress-filtering>)\\R?"
+ "(</config>)\\R?"
+ "(</edit-config>)\\R?(</rpc>).*(]]>){2}", Pattern.DOTALL);
private Pattern sampleXmlRegexUniEvc =
Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?"
@ -126,18 +131,18 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
+ "(<evc>)\\R?(<evc-index>).*(</evc-index>)\\R?(<name>).*(</name>)\\R?"
+ "(<evc-per-uni>)\\R?"
+ "(<evc-per-uni-c>)\\R?"
+ "(<ce-vlan-map>).*(</ce-vlan-map>)\\R?"
+ "(<ingress-bwp-group-index>).*(</ingress-bwp-group-index>)\\R?"
+ "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?(<outer-tag-vlan>).*"
+ "(</outer-tag-vlan>)\\R?(</tag-push>)\\R?"
+ "(<ce-vlan-map>)[0-9]*(</ce-vlan-map>)\\R?"
+ "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?"
+ "(<outer-tag-vlan>)[0-9]*(</outer-tag-vlan>)\\R?(</tag-push>)\\R?"
+ "((<flow-mapping>)\\R?"
+ "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?"
+ "(<flow-id>)[0-9]*(</flow-id>)\\R?"
+ "(</flow-mapping>)\\R?)*"
+ "(</evc-per-uni-c>)\\R?"
+ "(<evc-per-uni-n>)\\R?"
+ "(<ce-vlan-map>).*(</ce-vlan-map>)\\R?"
+ "(<ingress-bwp-group-index>).*(</ingress-bwp-group-index>)\\R?"
+ "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
+ "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ "(<tag-pop).*"
+ "((<flow-mapping>)\\R?"
+ "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?"
@ -146,7 +151,7 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
+ "(</evc-per-uni-n>)\\R?"
+ "(</evc-per-uni>)\\R?"
+ "(</evc>)\\R?"
+ "(</uni>).*"
+ "(</uni>)\\R?"
+ "(</mef-services>)\\R?"
+ "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
@ -300,9 +305,10 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
+ "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
+ "(<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?"
+ "(<profiles>)\\R?"
+ "(<bwp-group nc:operation=\"delete\">)\\R?"
+ "((<bwp-group nc:operation=\"delete\">)\\R?"
+ "(<group-index>)[0-9]*(</group-index>)\\R?"
+ "(</bwp-group>)\\R?"
+ "(<bwp>.*</bwp>)?"
+ "(</bwp-group>))++\\R?"
+ "(</profiles>)\\R?"
+ "(</mef-services>)\\R?"
+ "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
@ -328,7 +334,7 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
+ "(<maintenance-association>)\\R?"
+ "(<id/>)\\R?"
+ "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
// rpc.append("<ccm-interval>10ms</ccm-interval>\n"); //Have to omit for the moment - YMS problem
+ "(<ccm-interval>)[0-9]{1,3}(ms</ccm-interval>)\\R?"
+ "(<remote-meps/>)\\R?"
+ "(<component-list/>)\\R?"
+ "(<maintenance-association-end-point>)\\R?"
@ -341,7 +347,7 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
+ "(<mac-address/>)\\R?"
+ "(<msea-soam-fm:port-status/>)\\R?"
+ "(<msea-soam-fm:interface-status/>)\\R?"
// rpc.append("<msea-soam-fm:last-defect-sent/>\n");//Have to omit for the moment - YMS problem
+ "(<msea-soam-fm:last-defect-sent/>)\\R?"
+ "(<msea-soam-fm:rdi-transmit-status/>)\\R?"
+ "(<loopback/>)\\R?"
+ "(<remote-mep-database/>)\\R?"
@ -816,23 +822,9 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
return reply;
}
@Override
public String getConfig(String targetConfiguration) throws NetconfException {
return getConfig(TargetConfig.valueOf(targetConfiguration), null);
}
@Override
public String getConfig(String targetConfiguration, String configurationSchema) throws NetconfException {
return getConfig(TargetConfig.valueOf(targetConfiguration), null);
}
@Override
public String getConfig(TargetConfig targetConfiguration) throws NetconfException {
return getConfig(targetConfiguration, null);
}
@Override
public String getConfig(TargetConfig targetConfiguration, String configurationSchema) throws NetconfException {
public String getConfig(DatastoreId targetConfiguration, String configurationSchema) throws NetconfException {
StringBuilder rpc = new StringBuilder(XML_HEADER);
rpc.append("<rpc ");
rpc.append(MESSAGE_ID_STRING);
@ -859,16 +851,11 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
@Override
public boolean editConfig(String newConfiguration) throws NetconfException {
return editConfig(TargetConfig.RUNNING, null, newConfiguration);
return editConfig(DatastoreId.RUNNING, null, newConfiguration);
}
@Override
public boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
throws NetconfException {
return editConfig(TargetConfig.valueOf(targetConfiguration), mode, newConfiguration);
}
@Override
public boolean editConfig(TargetConfig targetConfiguration, String mode, String newConfiguration)
public boolean editConfig(DatastoreId targetConfiguration, String mode, String newConfiguration)
throws NetconfException {
newConfiguration = newConfiguration.trim();
StringBuilder rpc = new StringBuilder(XML_HEADER);
@ -904,23 +891,6 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
return copyConfig(TargetConfig.valueOf(targetConfiguration), newConfiguration);
}
@Override
public boolean copyConfig(TargetConfig targetConfiguration, String newConfiguration) throws NetconfException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean deleteConfig(String targetConfiguration) throws NetconfException {
return deleteConfig(TargetConfig.valueOf(targetConfiguration));
}
@Override
public boolean deleteConfig(TargetConfig targetConfiguration) throws NetconfException {
// TODO Auto-generated method stub
return false;
}
@Override
public void startSubscription() throws NetconfException {
// TODO Auto-generated method stub
@ -939,18 +909,6 @@ public class MockNetconfSessionEa1000 implements NetconfSession {
}
@Override
public boolean lock(String configType) throws NetconfException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean unlock(String configType) throws NetconfException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean lock() throws NetconfException {
// TODO Auto-generated method stub

View File

@ -30,20 +30,18 @@ import org.onosproject.drivers.microsemi.yang.impl.MseaCfmManager;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfm;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.DefaultMefCfm;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.MefCfm;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.DefaultMaintenanceDomain;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.MaintenanceDomain;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.DefaultNameCharacterString;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.NameCharacterString;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.Identifier45;
import org.onosproject.yms.ymsm.YmsService;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.MseaCfm;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.DefaultMefCfm;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.MefCfm;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.DefaultMaintenanceDomain;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.MaintenanceDomain;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.DefaultNameCharacterString;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.NameCharacterString;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.Identifier45;
public class MseaCfmManagerTest {
MseaCfmManager mseaCfmService;
YmsService ymsService;
NetconfSession session;
@Before
@ -78,14 +76,15 @@ public class MseaCfmManagerTest {
*/
@Test
public void testSetMseaCfm() throws NetconfException {
NameCharacterString mdName = DefaultNameCharacterString.builder().name(Identifier45.fromString("md-1")).build();
NameCharacterString mdName = new DefaultNameCharacterString();
mdName.name(Identifier45.fromString("md-1"));
MaintenanceDomain yangMd = DefaultMaintenanceDomain.builder()
.id((short) 1)
.mdNameAndTypeCombo(mdName)
.build();
MaintenanceDomain yangMd = new DefaultMaintenanceDomain();
yangMd.id((short) 1);
yangMd.mdNameAndTypeCombo(mdName);
MefCfm mefCfm = DefaultMefCfm.builder().addToMaintenanceDomain(yangMd).build();
MefCfm mefCfm = new DefaultMefCfm();
mefCfm.addToMaintenanceDomain(yangMd);
//FIXME implement this
// MseaCfmOpParam mseaCfmOpParam = (MseaCfmOpParam) MseaCfmOpParam.builder().mefCfm(mefCfm).build();
// mseaCfmService.setMseaCfm(mseaCfmOpParam, session, NcDsType.running);

View File

@ -27,24 +27,22 @@ import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.Ip4Address;
import org.onosproject.drivers.microsemi.yang.impl.MseaSaFilteringManager;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.netconf.TargetConfig;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.DefaultSourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.SourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.DefaultInterfaceEth0;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.InterfaceEth0;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.DefaultSourceAddressRange;
import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.sa.filtering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.SourceAddressRange;
import org.onosproject.yms.ymsm.YmsService;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFilteringOpParam;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.DefaultSourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.SourceIpaddressFiltering;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.DefaultInterfaceEth0;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.InterfaceEth0;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.DefaultSourceAddressRange;
import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.SourceAddressRange;
public class MseaSaFilteringManagerTest {
MseaSaFilteringManager mseaSaSvc;
YmsService ymsService;
NetconfSession session;
@Before
@ -65,17 +63,12 @@ public class MseaSaFilteringManagerTest {
@Test
public void testGetMseaSaFilteringMseaSaFilteringOpParamNetconfSession() throws NetconfException {
SourceIpaddressFiltering.SourceIpaddressFilteringBuilder sipBuilder =
new DefaultSourceIpaddressFiltering.SourceIpaddressFilteringBuilder();
SourceIpaddressFiltering sip = new DefaultSourceIpaddressFiltering();
MseaSaFilteringOpParam.MseaSaFilteringBuilder opBuilder =
new MseaSaFilteringOpParam.MseaSaFilteringBuilder();
MseaSaFilteringOpParam mseaSaFilteringFilter =
(MseaSaFilteringOpParam) opBuilder
.sourceIpaddressFiltering(sipBuilder.build())
.build();
MseaSaFilteringOpParam op = new MseaSaFilteringOpParam();
op.sourceIpaddressFiltering(sip);
MseaSaFiltering result = mseaSaSvc.getMseaSaFiltering(mseaSaFilteringFilter, session);
MseaSaFiltering result = mseaSaSvc.getMseaSaFiltering(op, session);
//Results come from MockNetconfSession SAMPLE_MSEASAFILTERING_REPLY_INIT
assertNotNull(result.sourceIpaddressFiltering().interfaceEth0().sourceAddressRange());
@ -95,11 +88,35 @@ public class MseaSaFilteringManagerTest {
@Test
public void testSetMseaSaFilteringMseaSaFilteringOpParamNetconfSessionNcDsType() {
MseaSaFilteringOpParam mseaSaFilteringConfig = createConfigForEdit("192.168.60.10/27", (short) 3, "Filter3");
MseaSaFilteringOpParam mseaSaFilteringConfig =
createConfigForEdit("192.168.60.10/27", (short) 3, "Filter3");
//Calling on the edit-config just makes the change and hopefully does not throw a Netconf Exception
try {
mseaSaSvc.setMseaSaFiltering(mseaSaFilteringConfig, session, TargetConfig.RUNNING);
mseaSaSvc.setMseaSaFiltering(mseaSaFilteringConfig, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
e.printStackTrace();
fail("NETCONF Exception: " + e.getMessage());
}
}
@Test
public void testDeleteMseaSaFilteringMseaSaFilteringOpParamNetconfSessionNcDsType() {
MseaSaFilteringOpParam mseaSaFilteringConfig =
createConfigForEdit("192.168.60.10/27", (short) 3, "Filter3");
SourceAddressRange sar2 = new DefaultSourceAddressRange();
sar2.ipv4AddressPrefix("10.205.86.10/27");
sar2.rangeId((short) 4);
sar2.name("Filter4");
mseaSaFilteringConfig.sourceIpaddressFiltering().interfaceEth0()
.addToSourceAddressRange(sar2);
//Calling on the edit-config just makes the change and hopefully does not throw a Netconf Exception
try {
mseaSaSvc.deleteMseaSaFilteringRange(mseaSaFilteringConfig, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
e.printStackTrace();
fail("NETCONF Exception: " + e.getMessage());
@ -112,31 +129,20 @@ public class MseaSaFilteringManagerTest {
* @return
*/
public static MseaSaFilteringOpParam createConfigForEdit(String ipAddrPrefix, short rangeId, String rangeName) {
SourceAddressRange.SourceAddressRangeBuilder sarBuilder =
new DefaultSourceAddressRange.SourceAddressRangeBuilder();
SourceAddressRange saRange =
sarBuilder
.ipv4AddressPrefix(ipAddrPrefix)
.rangeId(rangeId)
.name(rangeName)
.build();
SourceAddressRange sar = new DefaultSourceAddressRange();
sar.ipv4AddressPrefix(ipAddrPrefix);
sar.rangeId(rangeId);
sar.name(rangeName);
InterfaceEth0.InterfaceEth0Builder eth0Builder =
new DefaultInterfaceEth0.InterfaceEth0Builder();
InterfaceEth0 eth0 = eth0Builder.addToSourceAddressRange(saRange).build();
InterfaceEth0 eth0 = new DefaultInterfaceEth0();
eth0.addToSourceAddressRange(sar);
SourceIpaddressFiltering.SourceIpaddressFilteringBuilder sipBuilder =
new DefaultSourceIpaddressFiltering.SourceIpaddressFilteringBuilder();
SourceIpaddressFiltering sip = new DefaultSourceIpaddressFiltering();
sip.interfaceEth0(eth0);
SourceIpaddressFiltering sip = sipBuilder.interfaceEth0(eth0).build();
MseaSaFilteringOpParam op = new MseaSaFilteringOpParam();
op.sourceIpaddressFiltering(sip);
MseaSaFilteringOpParam.MseaSaFilteringBuilder opBuilder =
new MseaSaFilteringOpParam.MseaSaFilteringBuilder();
MseaSaFilteringOpParam mseaSaFilteringConfig =
(MseaSaFilteringOpParam) opBuilder
.sourceIpaddressFiltering(sipBuilder.build())
.build();
return mseaSaFilteringConfig;
return op;
}
}

View File

@ -0,0 +1,496 @@
/*
* 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.microsemi.yang;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.Ip4Address;
import org.onosproject.drivers.microsemi.yang.impl.MseaUniEvcServiceManager;
import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfException;
import org.onosproject.netconf.NetconfSession;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.Identifier45;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.ServiceListType;
import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.VlanIdType;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcService;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcServiceOpParam;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.DefaultMefServices;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.MefServices;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.EvcPerUniServiceTypeEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagPush;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.tagpush.tagpush.PushTagTypeEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagPush;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.Profiles;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.DefaultProfiles;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.DefaultUni;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.Uni;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.Cos;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.DefaultBwpGroup;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.DefaultCos;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.Bwp;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.DefaultBwp;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.bwp.ColorModeEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.DefaultEvc;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.Evc;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.DefaultEvcPerUni;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.EvcPerUni;
import org.onosproject.drivers.microsemi.yang.custom.CustomEvcPerUnic;
import org.onosproject.drivers.microsemi.yang.custom.CustomEvcPerUnin;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnic;
import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnin;
public class MseaUniEvcServiceManagerTest {
MseaUniEvcServiceManager mseaUniEvcServiceSvc;
NetconfSession session;
@Before
public void setUp() throws Exception {
try {
mseaUniEvcServiceSvc = new MockMseaUniEvcServiceManager();
mseaUniEvcServiceSvc.activate();
} catch (UncheckedIOException e) {
fail(e.getMessage());
}
NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo("netconf", "netconf", Ip4Address.valueOf("1.2.3.4"), 830);
session = new MockNetconfSessionEa1000(deviceInfo);
}
@After
public void tearDown() throws Exception {
}
@Test
public void testGetMseaUniEvcServiceMseaUniEvcServiceOpParamNetconfSession() {
MefServices mefServices = new DefaultMefServices();
mefServices.uni(new DefaultUni());
MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
evcUni.mefServices(mefServices);
MseaUniEvcService result = null;
try {
result =
mseaUniEvcServiceSvc.getConfigMseaUniEvcService(
evcUni, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
assertNotNull(result);
}
@Test
public void testSetMseaUniEvcServiceMseaUniEvcServiceOpParamEvcs() {
TagPush tp1 = new DefaultTagPush();
org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice
.evcperuniextensionattributes.tagmanipulation
.tagpush.TagPush tpInner1 =
new org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317
.mseaunievcservice.evcperuniextensionattributes
.tagmanipulation.tagpush.DefaultTagPush();
tpInner1.outerTagVlan(new VlanIdType(3));
tpInner1.pushTagType(PushTagTypeEnum.PUSHSTAG);
tp1.tagPush(tpInner1);
EvcPerUnin epun1 = new CustomEvcPerUnin();
epun1.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL);
epun1.ceVlanMap(ServiceListType.fromString("10"));
epun1.ingressBwpGroupIndex("0");
epun1.tagManipulation(tp1);
EvcPerUnic epuc1 = new CustomEvcPerUnic();
epuc1.ceVlanMap(new ServiceListType("11"));
epuc1.ingressBwpGroupIndex("0");
EvcPerUni epu1 = new DefaultEvcPerUni();
epu1.evcPerUnic(epuc1);
epu1.evcPerUnin(epun1);
List<Evc> evcList = new ArrayList<Evc>();
Evc evc1 = new DefaultEvc();
evc1.evcIndex(1);
evc1.name(new Identifier45("evc-1"));
evc1.evcPerUni(epu1);
evcList.add(evc1);
EvcPerUnin epun2 = new CustomEvcPerUnin();
epun2.ceVlanMap(ServiceListType.fromString("13"));
epun2.ingressBwpGroupIndex("0");
EvcPerUnic epuc2 = new CustomEvcPerUnic();
epuc2.ceVlanMap(new ServiceListType("12"));
epuc2.ingressBwpGroupIndex("0");
EvcPerUni epu2 = new DefaultEvcPerUni();
epu2.evcPerUnic(epuc2);
epu2.evcPerUnin(epun2);
Evc evc2 = new DefaultEvc();
evc2.evcIndex(2);
evc2.name(new Identifier45("evc-2"));
evc2.evcPerUni(epu2);
evcList.add(evc2);
Uni uni = new DefaultUni();
uni.name(new Identifier45("testUni"));
uni.evc(evcList);
MefServices mefServices = new DefaultMefServices();
mefServices.uni(uni);
MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
evcUni.mefServices(mefServices);
try {
mseaUniEvcServiceSvc.setMseaUniEvcService(evcUni, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testSetMseaUniEvcServiceMseaUniEvcServiceOpParamProfiles() {
List<Cos> cosList = new ArrayList<Cos>();
Cos cos0 = new DefaultCos();
cos0.cosIndex(0);
cos0.name("cos0");
cosList.add(cos0);
Cos cos1 = new DefaultCos();
cos1.cosIndex(1);
cos1.name("cos1");
cosList.add(cos1);
List<BwpGroup> bwpGroupList = new ArrayList<BwpGroup>();
BwpGroup bwpGrp = new DefaultBwpGroup();
bwpGrp.groupIndex((short) 0);
bwpGroupList.add(bwpGrp);
List<Bwp> bwpList = new ArrayList<Bwp>();
Bwp bwp1 = new DefaultBwp();
bwp1.cosIndex(0);
bwp1.colorMode(ColorModeEnum.COLORAWARE);
bwpList.add(bwp1);
Bwp bwp2 = new DefaultBwp();
bwp2.cosIndex(1);
bwp2.colorMode(ColorModeEnum.COLORBLIND);
bwpList.add(bwp2);
BwpGroup bwpGrp1 = new DefaultBwpGroup();
bwpGrp1.groupIndex((short) 1);
bwpGrp1.bwp(bwpList);
bwpGroupList.add(bwpGrp1);
Profiles profiles = new DefaultProfiles();
profiles.bwpGroup(bwpGroupList);
MefServices mefServices = new DefaultMefServices();
mefServices.profiles(profiles);
MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
evcUni.mefServices(mefServices);
try {
mseaUniEvcServiceSvc.setMseaUniEvcService(evcUni, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testDeleteMseaUniEvcServiceMseaUniEvcServiceOpParamProfiles() {
List<Cos> cosList = new ArrayList<Cos>();
Cos cos0 = new DefaultCos();
cos0.cosIndex(0);
cos0.name("cos0");
cosList.add(cos0);
Cos cos1 = new DefaultCos();
cos1.cosIndex(1);
cos1.name("cos1");
cosList.add(cos1);
List<BwpGroup> bwpGroupList = new ArrayList<BwpGroup>();
BwpGroup bwpGrp = new DefaultBwpGroup();
bwpGrp.groupIndex((short) 0);
bwpGroupList.add(bwpGrp);
List<Bwp> bwpList = new ArrayList<Bwp>();
Bwp bwp1 = new DefaultBwp();
bwp1.cosIndex(0);
bwp1.colorMode(ColorModeEnum.COLORAWARE);
bwpList.add(bwp1);
Bwp bwp2 = new DefaultBwp();
bwp2.cosIndex(1);
bwp2.colorMode(ColorModeEnum.COLORBLIND);
bwpList.add(bwp2);
BwpGroup bwpGrp1 = new DefaultBwpGroup();
bwpGrp1.groupIndex((short) 1);
bwpGrp1.bwp(bwpList);
bwpGroupList.add(bwpGrp1);
Profiles profiles = new DefaultProfiles();
profiles.bwpGroup(bwpGroupList);
MefServices mefServices = new DefaultMefServices();
mefServices.profiles(profiles);
MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
evcUni.mefServices(mefServices);
try {
mseaUniEvcServiceSvc.deleteMseaUniEvcService(evcUni, session, DatastoreId.RUNNING);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testGetMseaUniEvcCeVlanMaps() {
try {
MseaUniEvcService ceVlanMapsResult7 =
mseaUniEvcServiceSvc.getmseaUniEvcCeVlanMaps(session, DatastoreId.RUNNING);
assertNotNull(ceVlanMapsResult7.mefServices().uni().evc());
List<Evc> evcList = ceVlanMapsResult7.mefServices().uni().evc();
assertEquals(3, evcList.size());
for (Evc evc : evcList) {
assertNotNull(evc.evcPerUni().evcPerUnic().ceVlanMap());
assertNotNull(evc.evcPerUni().evcPerUnin().ceVlanMap());
if (evc.evcIndex() == 7) {
assertEquals("700,710,720", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
assertEquals("701:703", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
}
}
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testChangeEvcCeVlanMap() {
EvcPerUnin epun1 = new CustomEvcPerUnin();
epun1.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL);
epun1.ceVlanMap(ServiceListType.fromString("10"));
epun1.ingressBwpGroupIndex("0");
EvcPerUnic epuc1 = new CustomEvcPerUnic();
epuc1.ceVlanMap(new ServiceListType("11"));
epuc1.ingressBwpGroupIndex("0");
EvcPerUni epu = new DefaultEvcPerUni();
epu.evcPerUnic(epuc1);
epu.evcPerUnin(epun1);
Evc evc = new DefaultEvc();
evc.evcPerUni(epu);
assertEquals("10", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
assertEquals("11", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
assertEquals("11", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
}
@Test
public void testChangeEvcCeVlanMapNoValues() {
EvcPerUnin epun1 = new CustomEvcPerUnin();
epun1.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL);
epun1.ingressBwpGroupIndex("0");
EvcPerUnic epuc1 = new CustomEvcPerUnic();
epuc1.ingressBwpGroupIndex("0");
EvcPerUni epu = new DefaultEvcPerUni();
epu.evcPerUnic(epuc1);
epu.evcPerUnin(epun1);
Evc evc = new DefaultEvc();
evc.evcIndex(1);
evc.evcPerUni(epu);
assertEquals("0", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
assertEquals("0", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
}
@Test
public void testRemoveEvcUniFlowEntries() {
Map<Integer, String> ceVlanUpdates = new TreeMap<>();
ceVlanUpdates.put((1 << 2), "");
ceVlanUpdates.put((1 << 2) + 1, "");
ceVlanUpdates.put((2 << 2), "");
ceVlanUpdates.put((2 << 2) + 1, "");
ceVlanUpdates.put((7 << 2), "700,710,720");
ceVlanUpdates.put((7 << 2) + 1, "701:703");
ceVlanUpdates.put((8 << 2), "800,810,820");
ceVlanUpdates.put((8 << 2) + 1, "801,802,803");
Map<Integer, List<Short>> flowVlanIdMap = new HashMap<>();
//These should get ignored because whole EVC is being deleted
flowVlanIdMap.put(1 << 2, new ArrayList<Short>());
flowVlanIdMap.get(1 << 2).add((short) 11);
flowVlanIdMap.put((1 << 2) + 1, new ArrayList<Short>());
flowVlanIdMap.get((1 << 2) + 1).add((short) 12L);
//These are the EVCs being removed
flowVlanIdMap.put(7 << 2, new ArrayList<Short>());
flowVlanIdMap.get(7 << 2).add((short) 730L);
flowVlanIdMap.get(7 << 2).add((short) 740L);
flowVlanIdMap.put((7 << 2) + 1, new ArrayList<Short>());
flowVlanIdMap.get((7 << 2) + 1).add((short) 705L);
flowVlanIdMap.get((7 << 2) + 1).add((short) 706L);
flowVlanIdMap.put(8 << 2, new ArrayList<Short>());
flowVlanIdMap.get(8 << 2).add((short) 830L);
flowVlanIdMap.get(8 << 2).add((short) 840L);
flowVlanIdMap.put((8 << 2) + 1, new ArrayList<Short>());
flowVlanIdMap.get((8 << 2) + 1).add((short) 805L);
flowVlanIdMap.get((8 << 2) + 1).add((short) 806L);
try {
mseaUniEvcServiceSvc.removeEvcUniFlowEntries(
ceVlanUpdates, flowVlanIdMap, session, DatastoreId.RUNNING,
UniSideInterfaceAssignmentEnum.UNI_C_ON_OPTICS);
} catch (NetconfException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Error: " + e.getMessage());
}
}
@Test
public void testGetVlanSet1() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10");
assertEquals(1, vlanIds.length);
}
@Test
public void testGetVlanSet2() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10:20");
assertEquals(11, vlanIds.length);
assertEquals(10, vlanIds[0].shortValue());
assertEquals(20, vlanIds[10].shortValue());
}
@Test
public void testGetVlanSet3() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10:20,30:40");
assertEquals(22, vlanIds.length);
assertEquals(10, vlanIds[0].shortValue());
assertEquals(40, vlanIds[21].shortValue());
}
@Test
public void testGetVlanSet4() {
Short[] vlanIds = CeVlanMapUtils.getVlanSet("10,20,30");
assertEquals(3, vlanIds.length);
assertEquals(10, vlanIds[0].shortValue());
assertEquals(30, vlanIds[2].shortValue());
}
@Test
public void testVlanListAsString() {
assertEquals("20:22", CeVlanMapUtils.vlanListAsString(new Short[]{20, 21, 22}));
assertEquals("20:22,24:25",
CeVlanMapUtils.vlanListAsString(new Short[]{20, 21, 22, 24, 25}));
assertEquals("30,33,36:40",
CeVlanMapUtils.vlanListAsString(new Short[]{30, 33, 36, 37, 38, 39, 40}));
assertEquals("20", CeVlanMapUtils.vlanListAsString(new Short[]{20}));
assertEquals("20,22,24,26,28",
CeVlanMapUtils.vlanListAsString(new Short[]{20, 22, 24, 26, 28}));
}
@Test
public void testAddtoCeVlanMap() {
assertEquals("20,22:24,26,28",
CeVlanMapUtils.addtoCeVlanMap("20,22,24,26,28", (short) 23));
assertEquals("20:26,28",
CeVlanMapUtils.addtoCeVlanMap("20,21,22,24,25,26,28", (short) 23));
assertEquals("20,23",
CeVlanMapUtils.addtoCeVlanMap("20", (short) 23));
assertEquals("20,22:23",
CeVlanMapUtils.addtoCeVlanMap("20,22", (short) 23));
}
@Test
public void testCombineVlanSets() {
assertEquals("10:11,13:14", CeVlanMapUtils.combineVlanSets("10:11", "13:14"));
assertEquals("10:14", CeVlanMapUtils.combineVlanSets("10:11", "12:14"));
assertEquals("10:11,14", CeVlanMapUtils.combineVlanSets("10:11", "14"));
assertEquals("10:12", CeVlanMapUtils.combineVlanSets("10:11", "11:12"));
}
@Test
public void testRemoveZeroIfPossible() {
assertEquals("0", CeVlanMapUtils.removeZeroIfPossible(""));
assertEquals("0", CeVlanMapUtils.removeZeroIfPossible("0"));
assertEquals("1,3", CeVlanMapUtils.removeZeroIfPossible("0:1,3"));
assertEquals("1:2", CeVlanMapUtils.removeZeroIfPossible("0:2"));
assertEquals("10:12", CeVlanMapUtils.removeZeroIfPossible("0,10:12"));
}
}

View File

@ -26,7 +26,7 @@ import java.time.ZonedDateTime;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20130715.ietfyangtypes.DateAndTime;
import org.onosproject.yang.gen.v1.ietfyangtypes.rev20130715.ietfyangtypes.DateAndTime;
public class IetfYangTypesUtilsTest {

View File

@ -0,0 +1,152 @@
/*
* 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.yang;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.core.CoreService;
import org.onosproject.drivers.netconf.MockCoreService;
import org.onosproject.yang.model.ModelConverter;
import org.onosproject.yang.model.ModelObjectData;
import org.onosproject.yang.model.NodeKey;
import org.onosproject.yang.model.ResourceData;
import org.onosproject.yang.model.ResourceId;
import org.onosproject.yang.model.SchemaContext;
import org.onosproject.yang.model.SchemaContextProvider;
import org.onosproject.yang.model.YangModel;
import org.onosproject.yang.runtime.CompositeData;
import org.onosproject.yang.runtime.CompositeStream;
import org.onosproject.yang.runtime.ModelRegistrationParam;
import org.onosproject.yang.runtime.RuntimeContext;
import org.onosproject.yang.runtime.YangModelRegistry;
import org.onosproject.yang.runtime.YangRuntimeService;
import org.onosproject.yang.runtime.YangSerializer;
import org.onosproject.yang.runtime.YangSerializerRegistry;
import org.onosproject.yang.runtime.impl.DefaultModelConverter;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
import org.onosproject.yang.runtime.impl.DefaultYangRuntimeHandler;
import org.onosproject.yang.runtime.impl.DefaultYangSerializerRegistry;
import org.onosproject.yang.serializers.json.JsonSerializer;
import org.onosproject.yang.serializers.xml.XmlSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
public class MockYangRuntimeManager implements YangModelRegistry,
YangSerializerRegistry, YangRuntimeService, ModelConverter,
SchemaContextProvider {
private static final String APP_ID = "org.onosproject.yang";
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
private DefaultYangModelRegistry modelRegistry;
private DefaultYangSerializerRegistry serializerRegistry;
private DefaultYangRuntimeHandler runtimeService;
private DefaultModelConverter modelConverter;
public void setModelRegistry(DefaultYangModelRegistry yReg) {
this.modelRegistry = yReg;
}
@Activate
public void activate() {
coreService = new MockCoreService();
coreService.registerApplication(APP_ID);
serializerRegistry = new DefaultYangSerializerRegistry();
runtimeService =
new DefaultYangRuntimeHandler(serializerRegistry, modelRegistry);
serializerRegistry.registerSerializer(new JsonSerializer());
serializerRegistry.registerSerializer(new XmlSerializer());
modelConverter = new DefaultModelConverter(modelRegistry);
log.info("Started");
}
@Deactivate
public void deactivate() {
log.info("Stopped");
}
@Override
public void registerModel(ModelRegistrationParam p) {
modelRegistry.registerModel(p);
}
@Override
public void unregisterModel(ModelRegistrationParam p) {
modelRegistry.unregisterModel(p);
}
@Override
public Set<YangModel> getModels() {
return modelRegistry.getModels();
}
@Override
public void registerSerializer(YangSerializer ys) {
serializerRegistry.registerSerializer(ys);
}
@Override
public void unregisterSerializer(YangSerializer ys) {
serializerRegistry.unregisterSerializer(ys);
}
@Override
public Set<YangSerializer> getSerializers() {
return serializerRegistry.getSerializers();
}
@Override
public CompositeData decode(CompositeStream cs, RuntimeContext rc) {
return runtimeService.decode(cs, rc);
}
@Override
public CompositeStream encode(CompositeData cd, RuntimeContext rc) {
return runtimeService.encode(cd, rc);
}
@Override
public ModelObjectData createModel(ResourceData resourceData) {
return modelConverter.createModel(resourceData);
}
@Override
public ResourceData createDataNode(ModelObjectData modelObjectData) {
return modelConverter.createDataNode(modelObjectData);
}
@Override
public SchemaContext getSchemaContext(ResourceId resourceId) {
checkNotNull(resourceId, " resource id can't be null.");
NodeKey key = resourceId.nodeKeys().get(0);
if (resourceId.nodeKeys().size() == 1 &&
"/".equals(key.schemaId().name())) {
return modelRegistry;
}
log.info("To be implemented.");
return null;
}
}

View File

@ -0,0 +1,138 @@
/*
* 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.yang.serializers.xml;
import org.onosproject.yang.compiler.datamodel.YangNode;
import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
import org.onosproject.yang.model.YangModel;
import org.onosproject.yang.runtime.AppModuleInfo;
import org.onosproject.yang.runtime.DefaultAppModuleInfo;
import org.onosproject.yang.runtime.DefaultModelRegistrationParam;
import org.onosproject.yang.runtime.ModelRegistrationParam;
import org.onosproject.yang.runtime.YangModelRegistry;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.onosproject.yang.compiler.datamodel.utils.DataModelUtils;
import org.onosproject.yang.compiler.utils.UtilConstants;
import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
import org.onosproject.yang.runtime.helperutils.YangApacheUtils;
import org.onosproject.yang.runtime.RuntimeHelper;
public class MockYangSchemaNodeProvider {
private static final String FS = File.separator;
private static final String PATH = System.getProperty("user.dir") +
FS + "buck-out" + FS + "gen" +
FS + "models" + FS + "microsemi" + FS + "onos-models-microsemi-schema" + FS;
private static final String SER_FILE_PATH = "yang" + FS + "resources" +
FS + "YangMetaData.ser";
private static final String META_PATH =
PATH.replace("drivers/microsemi", "")
+ SER_FILE_PATH;
private static final String TEMP_FOLDER_PATH = PATH + UtilConstants.TEMP;
private YangModelRegistry reg = new DefaultYangModelRegistry();
private List<YangNode> nodes = new ArrayList<>();
/**
* Creates an instance of mock bundle context.
*/
public MockYangSchemaNodeProvider() {
}
/**
* Process YANG schema node for a application.
*/
public void processSchemaRegistry() {
try {
//Need to deserialize generated meta data file for unit tests.
Set<YangNode> appNode = DataModelUtils.deSerializeDataModel(META_PATH);
RuntimeHelper.addLinkerAndJavaInfo(appNode);
nodes.addAll(appNode);
reg.registerModel(prepareParam(nodes));
YangIoUtils.deleteDirectory(TEMP_FOLDER_PATH);
} catch (IOException e) {
throw new IllegalArgumentException("YangMetaData.ser could not " +
"be loaded from " + META_PATH, e);
}
}
/**
* Unregister given nodes from runtime service.
*
* @param nodes list of nodes
*/
public void unRegister(List<YangNode> nodes) {
reg.unregisterModel(prepareParam(nodes));
}
/**
* Prepares model registration parameter.
*
* @param nodes list of nodes
* @return model registration parameter
*/
private ModelRegistrationParam prepareParam(List<YangNode> nodes) {
//Process loading class file.
String appName;
ClassLoader classLoader = getClass().getClassLoader();
//Create model registration param.
ModelRegistrationParam.Builder b =
DefaultModelRegistrationParam.builder();
//create a new YANG model
YangModel model = YangApacheUtils.processYangModel(META_PATH, nodes);
//set YANG model
b.setYangModel(model);
Iterator<YangNode> it = nodes.iterator();
while (it.hasNext()) {
YangSchemaNode node = it.next();
//If service class is not generated then use
// interface file to load this class.
appName = RuntimeHelper.getInterfaceClassName(node);
Class<?> cls;
try {
cls = classLoader.loadClass(appName);
} catch (ClassNotFoundException e) {
continue;
}
//generate app info.
AppModuleInfo info = new DefaultAppModuleInfo(cls, null);
b.addAppModuleInfo(YangApacheUtils.processModuleId((YangNode) node), info);
}
return b.build();
}
/**
* Returns schema registry.
*
* @return schema registry
*/
public DefaultYangModelRegistry registry() {
return (DefaultYangModelRegistry) reg;
}
}

View File

@ -0,0 +1,50 @@
/*
* 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.yang.serializers.xml;
import org.onosproject.yang.model.SchemaContext;
import org.onosproject.yang.runtime.Annotation;
import org.onosproject.yang.runtime.DefaultAnnotation;
import org.onosproject.yang.runtime.YangSerializerContext;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
import java.util.LinkedList;
import java.util.List;
public class MockYangSerializerContext implements YangSerializerContext {
private static MockYangSchemaNodeProvider schemaProvider =
new MockYangSchemaNodeProvider();
private static final String NETCONF_NS =
"urn:ietf:params:xml:ns:netconf:base:1.0";
private static final String XMNLS_NC = "xmlns:xc";
@Override
public SchemaContext getContext() {
schemaProvider.processSchemaRegistry();
DefaultYangModelRegistry registry = schemaProvider.registry();
return registry;
}
@Override
public List<Annotation> getProtocolAnnotations() {
Annotation annotation = new DefaultAnnotation(XMNLS_NC, NETCONF_NS);
List<Annotation> protocolAnnotation = new LinkedList<>();
protocolAnnotation.add(annotation);
return protocolAnnotation;
}
}

View File

@ -47,7 +47,6 @@
<module>juniper</module>
<module>lisp</module>
<module>flowspec</module>
<module>microsemi</module>
<module>oplink</module>
<!-- <module>bmv2</module> -->
<module>hp</module>

4
models/microsemi/BUCK Normal file
View File

@ -0,0 +1,4 @@
yang_model(
app_name = 'org.onosproject.models.microsemi',
title = 'Microsemi YANG Model',
)

Some files were not shown because too many files have changed in this diff Show More